Skip to content

Commit

Permalink
Merge branch 'dev' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
larc committed Nov 27, 2023
2 parents 1af6886 + b34005e commit 79dd1e6
Show file tree
Hide file tree
Showing 31 changed files with 308 additions and 305 deletions.
6 changes: 3 additions & 3 deletions include/gproshan/geodesics/geodesics_ptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ index_t run_ptp(const CHE * mesh, const std::vector<index_t> & sources,
index_t * h_clusters = clusters[2];
#endif

for(index_t i = 0; i < sources.size(); ++i)
for(index_t i = 0; i < size(sources); ++i)
{ // !coalescence ?
const index_t & v = sorted ? sources[i] : idx[sources[i]];

Expand Down Expand Up @@ -196,7 +196,7 @@ index_t run_ptp(const CHE * mesh, const std::vector<index_t> & sources,
}
#endif

const int & max_iter = limits.size() << 1;
const int & max_iter = size(limits) << 1;

int iter = -1;
index_t count = 0;
Expand Down Expand Up @@ -247,7 +247,7 @@ index_t run_ptp(const CHE * mesh, const std::vector<index_t> & sources,
#endif

if(n_cond == count) ++i;
if(j < limits.size() - 1) ++j;
if(j < size(limits) - 1) ++j;
}

return !(iter & 1);
Expand Down
44 changes: 22 additions & 22 deletions src/gproshan/app_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ bool app_viewer::process_knn(viewer * p_view)
if(ImGui::Button("Run"))
{
auto query = mesh.selected;
if(!query.size()) query.push_back(0);
if(!size(query)) query.push_back(0);

mesh.selected.clear();

Expand Down Expand Up @@ -191,7 +191,7 @@ bool app_viewer::process_simulate_scanner(viewer * p_view)
static const size_t n_max = 10000;
static vertex cam_pos = {0, 0, 0};

if(view->sphere_points.size() != 1)
if(size(view->sphere_points) != 1)
{
view->sphere_points.clear();
view->sphere_points.push_back(cam_pos);
Expand Down Expand Up @@ -231,7 +231,7 @@ bool app_viewer::process_sampling_4points(viewer * p_view)
if(ImGui::Button("Clean")) points.clear();

ImGui::SameLine();
if(mesh.selected.size() > 3)
if(size(mesh.selected) > 3)
{
if(ImGui::Button("Add Samples"))
{
Expand All @@ -249,9 +249,9 @@ bool app_viewer::process_sampling_4points(viewer * p_view)
}
else ImGui::Text("Select 4 points.");

ImGui::Text("Total added points: %lu", points.size());
ImGui::Text("Total added points: %lu", size(points));
if(ImGui::Button("Create Point Cloud"))
view->add_mesh(new che(points.data(), points.size(), nullptr, 0));
view->add_mesh(new che(points.data(), size(points), nullptr, 0));

return true;
}
Expand Down Expand Up @@ -407,7 +407,7 @@ bool app_viewer::process_delete_vertices(viewer * p_view)
app_viewer * view = (app_viewer *) p_view;
che_viewer & mesh = view->selected_mesh();

if(!mesh.selected.size()) return true;
if(!size(mesh.selected)) return true;

gproshan_debug(removing vertex);
mesh->remove_vertices(mesh.selected);
Expand Down Expand Up @@ -444,7 +444,7 @@ bool app_viewer::process_fairing_spectral(viewer * p_view)

if(ImGui::SliderScalar("n_eigs", ImGuiDataType_U64, &fair.n_eigs, &min_neigs, &max_neigs))
{
if(vertices.size() != mesh->n_vertices)
if(size(vertices) != mesh->n_vertices)
{
vertices.resize(mesh->n_vertices);
memcpy(vertices.data(), &mesh->point(0), mesh->n_vertices * sizeof(vertex));
Expand Down Expand Up @@ -473,7 +473,7 @@ bool app_viewer::process_fairing_taubin(viewer * p_view)

if(ImGui_InputReal("step", &fair.step, 0.001))
{
if(vertices.size() != mesh->n_vertices)
if(size(vertices) != mesh->n_vertices)
{
vertices.resize(mesh->n_vertices);
memcpy(vertices.data(), &mesh->point(0), mesh->n_vertices * sizeof(vertex));
Expand Down Expand Up @@ -510,7 +510,7 @@ bool app_viewer::process_geodesics(viewer * p_view)

if(ImGui::Button("Run"))
{
if(!mesh.selected.size())
if(!size(mesh.selected))
mesh.selected.push_back(0);

params.dist_alloc = &mesh->heatmap(0);
Expand Down Expand Up @@ -571,7 +571,7 @@ bool app_viewer::process_voronoi(viewer * p_view)
for(index_t i = 0; i < mesh->n_vertices; ++i)
{
mesh->heatmap(i) = ptp.clusters[i];
mesh->heatmap(i) /= mesh.selected.size() + 1;
mesh->heatmap(i) /= size(mesh.selected) + 1;
}

mesh.update_vbo_heatmap();
Expand All @@ -584,15 +584,15 @@ bool app_viewer::process_compute_toplesets(viewer * p_view)
app_viewer * view = (app_viewer *) p_view;
che_viewer & mesh = view->selected_mesh();

if(!mesh.selected.size())
if(!size(mesh.selected))
mesh.selected.push_back(0);

index_t * toplesets = new index_t[mesh->n_vertices];
index_t * sorted = new index_t[mesh->n_vertices];
std::vector<index_t> limites;
mesh->compute_toplesets(toplesets, sorted, limites, mesh.selected);

size_t n_toplesets = limites.size() - 1;
size_t n_toplesets = size(limites) - 1;

#pragma omp parallel for
for(index_t v = 0; v < mesh->n_vertices; ++v)
Expand Down Expand Up @@ -680,10 +680,10 @@ bool app_viewer::process_mdict_patch(viewer * p_view)
view->vectors.push_back(mesh->point(v));
view->vectors.push_back(mesh->point(v) + 3 * mean_edge * mesh->normal(v));

avg_nvp += p.vertices.size();
avg_nvp += size(p.vertices);
}

avg_nvp /= mesh.selected.size();
avg_nvp /= size(mesh.selected);
gproshan_log_var(avg_nvp);

delete [] toplevel;
Expand Down Expand Up @@ -723,7 +723,7 @@ bool app_viewer::process_mask(viewer * p_view)
a_vec points_out;
gproshan_debug_var(f_points);
points_out.load(f_points);
gproshan_debug_var(points_out.size());
gproshan_debug_var(size(points_out));

for(index_t i = 0; i < points_out.size(); ++i)
mesh.selected.push_back(points_out(i));
Expand Down Expand Up @@ -950,10 +950,10 @@ bool app_viewer::process_fill_holes(viewer * p_view)
vertices.push_back(mesh->point(v));
center += mesh->point(v);
}
center /= vbounds.size();
center /= size(vbounds);

std::priority_queue<std::pair<real_t, index_t> > front;
std::vector<uvec2> neigs(vertices.size());
std::vector<uvec2> neigs(size(vertices));
/*
auto bprev = [&](const index_t & v) -> index_t &
{
Expand All @@ -972,14 +972,14 @@ bool app_viewer::process_fill_holes(viewer * p_view)
front.push({angle, p.x()});
};

index_t nv = vertices.size();
index_t nv = size(vertices);
push({0, nv - 1, 1});
for(index_t i = 1; i < vertices.size() - 1; ++i)
for(index_t i = 1; i < size(vertices) - 1; ++i)
push({i, i - 1, i + 1});
push({nv - 1, nv - 2, 0});

std::vector<bool> border;
border.assign(true, vertices.size());
border.assign(true, size(vertices));

// real_t angle;
index_t v0 = NIL;
Expand All @@ -998,7 +998,7 @@ bool app_viewer::process_fill_holes(viewer * p_view)
// vertices.push_back(center);

che * old = fill_mesh;
che * hole = new che(vertices.data(), vertices.size(), trigs.data(), trigs.size() / 3);
che * hole = new che(vertices.data(), size(vertices), trigs.data(), size(trigs) / 3);
fill_mesh = old->merge(hole, vbounds);
delete old;
delete hole;
Expand Down Expand Up @@ -1027,7 +1027,7 @@ bool app_viewer::process_fill_holes_biharmonic_splines(viewer * p_view)
if(holes[h])
{
old_n_vertices = n_vertices;
biharmonic_interp_2(mesh, old_n_vertices, n_vertices += holes[h]->n_vertices - border_vertices[h].size(), border_vertices[h], k);
biharmonic_interp_2(mesh, old_n_vertices, n_vertices += holes[h]->n_vertices - size(border_vertices[h]), border_vertices[h], k);
delete holes[h];
}

Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/features/key_points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void key_points::compute_kps_areas(che * mesh, const real_t & percent)
}
}

kps.resize(percent * kps.size());
kps.resize(percent * size(kps));
is_kp.assign(mesh->n_vertices, false);

#pragma omp parallel for
Expand Down
4 changes: 2 additions & 2 deletions src/gproshan/geodesics/geodesics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ geodesics::geodesics(che * mesh, const std::vector<index_t> & sources, const par
for(index_t v = 0; v < n_vertices; ++v)
dist[v] = INFINITY;

assert(sources.size() > 0);
assert(size(sources) > 0);
execute(mesh, sources, p);
}

Expand Down Expand Up @@ -199,7 +199,7 @@ void geodesics::run_parallel_toplesets_propagation_cpu(che * mesh, const std::ve
double time_ptp;

TIC(time_ptp)
parallel_toplesets_propagation_cpu({dist, clusters}, mesh, sources, {limits, sorted_index}, sources.size() == 1);
parallel_toplesets_propagation_cpu({dist, clusters}, mesh, sources, {limits, sorted_index}, size(sources) == 1);
TOC(time_ptp)

gproshan_log_var(time_ptp);
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/geodesics/geodesics_ptp.cu
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ real_t farthest_point_sampling_ptp_gpu(che * mesh, std::vector<index_t> & sample

if(n >= n_vertices) n = n_vertices >> 2;

n -= samples.size();
n -= size(samples);
samples.reserve(n);

int farthest;
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/geodesics/heat_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace gproshan {

double heat_method(real_t * dist, const che * mesh, const std::vector<index_t> & sources, const heat_method_opt & opt)
{
if(!sources.size()) return 0;
if(!size(sources)) return 0;

// build impulse signal
a_vec u0(mesh->n_vertices, arma::fill::zeros);
Expand Down
6 changes: 3 additions & 3 deletions src/gproshan/geodesics/sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool load_sampling(std::vector<index_t> & points, real_t & radio, che * mesh, si
{
const std::string & filename = mesh->filename;

std::string file = filename.substr(filename.find_last_of('/'), filename.size() - filename.find_last_of('/')) + "." + std::to_string(n);
std::string file = filename.substr(filename.find_last_of('/'), size(filename) - filename.find_last_of('/')) + "." + std::to_string(n);

std::ifstream is(tmp_file_path(file));
gproshan_log_var(tmp_file_path(file));
Expand All @@ -60,7 +60,7 @@ bool load_sampling(std::vector<index_t> & points, real_t & radio, che * mesh, si
}
else
{
if(!points.size())
if(!size(points))
points.push_back(0);

#ifdef GPROSHAN_CUDA
Expand All @@ -73,7 +73,7 @@ bool load_sampling(std::vector<index_t> & points, real_t & radio, che * mesh, si

std::ofstream os(tmp_file_path(file));
os << radio << std::endl;
os << points.size() << std::endl;
os << size(points) << std::endl;
for(const index_t & i: points)
os << i << std::endl;

Expand Down
20 changes: 10 additions & 10 deletions src/gproshan/geodesics/test_geodesics_ptp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,20 @@ void main_test_geodesics_ptp(const int & nargs, const char ** args)

// TOPLESETS DISTRIBUTION __________________________________________________________________

index_t * toplesets_dist = new index_t[limits.size() - 1];
index_t * toplesets_dist = new index_t[size(limits) - 1];

os.open(test_path + filename + "_toplesets.dist");
for(index_t i = 1; i < limits.size(); ++i)
for(index_t i = 1; i < size(limits); ++i)
{
toplesets_dist[i - 1] = limits[i] - limits[i - 1];
os << i - 1 << " " << toplesets_dist[i - 1] << std::endl;
}
os.close();

std::sort(toplesets_dist, toplesets_dist + limits.size() - 1);
std::sort(toplesets_dist, toplesets_dist + size(limits) - 1);

os.open(test_path + filename + "_toplesets_sorted.dist");
for(index_t i = 0; i < limits.size() - 1; ++i)
for(index_t i = 0; i < size(limits) - 1; ++i)
os << i << " " << toplesets_dist[i] << std::endl;
os.close();

Expand Down Expand Up @@ -213,7 +213,7 @@ void main_test_geodesics_ptp(const int & nargs, const char ** args)
// FARTHEST POINT SAMPLING _________________________________________________________________

#ifdef GPROSHAN_CUDA // IMPLEMENT: times_farthest_point_sampling_ptp_cpu
size_t i_samples = source.size();
size_t i_samples = size(source);
size_t n_samples = 1001;
double * times_fps = times_farthest_point_sampling_ptp_gpu(mesh, source, n_samples);

Expand Down Expand Up @@ -249,7 +249,7 @@ double test_fast_marching(real_t & error, const real_t * exact, che * mesh, cons

geodesics fm(mesh, source);

error = compute_error(&fm[0], exact, mesh->n_vertices, source.size());
error = compute_error(&fm[0], exact, mesh->n_vertices, size(source));

return seconds;
}
Expand All @@ -265,7 +265,7 @@ double test_ptp_cpu(real_t & error, const real_t * exact, che * mesh, const std:
seconds = std::min(seconds, t);
}

error = compute_error(dist, exact, mesh->n_vertices, source.size());
error = compute_error(dist, exact, mesh->n_vertices, size(source));

delete [] dist;

Expand All @@ -285,7 +285,7 @@ double test_heat_method_cholmod(real_t & error, double & stime, const real_t * e
stime = std::min(st, stime);
}

error = compute_error(dist, exact, mesh->n_vertices, source.size());
error = compute_error(dist, exact, mesh->n_vertices, size(source));

delete [] dist;

Expand All @@ -306,7 +306,7 @@ double test_ptp_gpu(real_t & error, const real_t * exact, che * mesh, const std:
seconds = std::min(seconds, t);
}

error = compute_error(dist, exact, mesh->n_vertices, source.size());
error = compute_error(dist, exact, mesh->n_vertices, size(source));

delete [] dist;

Expand All @@ -328,7 +328,7 @@ double test_heat_method_gpu(real_t & error, double & stime, const real_t * exact
stime = std::min(st, stime);
}

error = compute_error(dist, exact, mesh->n_vertices, source.size());
error = compute_error(dist, exact, mesh->n_vertices, size(source));

delete [] dist;

Expand Down
Loading

0 comments on commit 79dd1e6

Please sign in to comment.