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 Dec 7, 2023
2 parents 89f1c68 + f1b79de commit 7a1573a
Show file tree
Hide file tree
Showing 87 changed files with 692 additions and 593 deletions.
4 changes: 2 additions & 2 deletions include/gproshan/app_viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class app_viewer : public viewer
double time;

public:
app_viewer(const char * title = "gproshan", const int & width = 1600, const int & height = 900);
app_viewer(const char * title = "gproshan", const int width = 1600, const int height = 900);
virtual ~app_viewer();

int main(int nargs, const char ** args);
Expand Down Expand Up @@ -98,7 +98,7 @@ class app_viewer : public viewer
static bool process_key_components(viewer * p_view);

// Hole Filling
static bool process_poisson(viewer * p_view, const index_t & k);
static bool process_poisson(viewer * p_view, const index_t k);
static bool process_poisson_laplacian_1(viewer * p_view);
static bool process_poisson_laplacian_2(viewer * p_view);
static bool process_poisson_laplacian_3(viewer * p_view);
Expand Down
4 changes: 2 additions & 2 deletions include/gproshan/features/descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class descriptor
a_mat features;

public:
descriptor(const signature & sig, const che * mesh, const size_t & n_eigs);
descriptor(const signature & sig, const che * mesh, const size_t n_eigs);
size_t n_eigs();

///< return true if the features were computed
operator bool () const;

///< return norm of the descriptor for the vertex v
real_t operator () (const index_t & v) const;
real_t operator () (const index_t v) const;

private:
void compute_gps();
Expand Down
8 changes: 4 additions & 4 deletions include/gproshan/features/key_components.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class key_components
std::map<index_t, index_t> comp_idx;

public:
key_components(che * mesh, const std::vector<index_t> & kps, const real_t & r);
key_components(che * mesh, const std::vector<index_t> & kps, const real_t r);
~key_components();
index_t operator()(const index_t & i);
operator const size_t & () const;
index_t operator()(const index_t i);
operator size_t () const;

private:
void compute_kcs(che * mesh, const std::vector<index_t> & kps);
index_t find(const index_t & x);
index_t find(const index_t x);
bool join(index_t x, index_t y);
};

Expand Down
4 changes: 2 additions & 2 deletions include/gproshan/features/key_points.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class key_points
std::vector<bool> is_kp;

public:
key_points(che * mesh, const real_t & percent = 0.10);
key_points(che * mesh, const real_t percent = 0.10);
operator const std::vector<index_t> & () const;

private:
void compute_kps_areas(che * mesh, const real_t & percent);
void compute_kps_areas(che * mesh, const real_t percent);
};


Expand Down
19 changes: 10 additions & 9 deletions include/gproshan/geodesics/geodesics.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace gproshan {
*/
class geodesics
{
using fm_function_t = std::function<bool (const index_t &)>;
using fm_function_t = std::function<bool (const index_t)>;

public:
enum algorithm { FM, ///< Execute Fast Marching algorithm
Expand Down Expand Up @@ -50,7 +50,7 @@ class geodesics
size_t n_sorted; ///< Number of vertices sorted by their geodesics distance.
bool free_dist;

const size_t & n_vertices; ///< Number of vertices, const reference
const size_t n_vertices; ///< Number of vertices, const reference

public:
geodesics( che * mesh, ///< input triangular mesh.
Expand All @@ -59,17 +59,18 @@ class geodesics
);

virtual ~geodesics();
const real_t & operator[](const index_t & i) const;
const index_t & operator()(const index_t & i) const;
const real_t & radio() const;
const index_t & farthest() const;
const size_t & n_sorted_index() const;
void copy_sorted_index(index_t * indexes, const size_t & n) const;
operator const real_t * () const;
real_t operator[](const index_t i) const;
index_t operator()(const index_t i) const;
real_t radio() const;
index_t farthest() const;
size_t n_sorted_index() const;
void copy_sorted_index(index_t * indexes, const size_t n) const;
void normalize();

private:
void execute(che * mesh, const std::vector<index_t> & sources, const params & p);
void run_fastmarching(che * mesh, const std::vector<index_t> & sources, const size_t & n_iter, const real_t & radio, const fm_function_t & fun);
void run_fastmarching(che * mesh, const std::vector<index_t> & sources, const size_t n_iter, const real_t radio, const fm_function_t & fun);
void run_parallel_toplesets_propagation_cpu(che * mesh, const std::vector<index_t> & sources);
void run_heat_method(che * mesh, const std::vector<index_t> & sources);

Expand Down
26 changes: 13 additions & 13 deletions include/gproshan/geodesics/geodesics_ptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ struct is_ok
const real_t * error = nullptr;

__host_device__
bool operator()(const real_t & val) const;
bool operator()(const real_t val) const;

__host_device__
bool operator()(const index_t & val) const;
bool operator()(const index_t val) const;
};

#endif // __CUDACC__
Expand All @@ -52,7 +52,7 @@ struct ptp_out_t
real_t * dist;
index_t * clusters;

ptp_out_t(real_t *const & d, index_t *const & c = nullptr);
ptp_out_t(real_t *const d, index_t *const c = nullptr);
};

struct toplesets_t
Expand All @@ -67,7 +67,7 @@ void parallel_toplesets_propagation_cpu(const ptp_out_t & ptp_out, che * mesh, c

real_t farthest_point_sampling_ptp_gpu(che * mesh, std::vector<index_t> & samples, double & time_fps, size_t n, real_t radio = 0);

void normalize_ptp(real_t * dist, const size_t & n);
void normalize_ptp(real_t * dist, const size_t n);


template<class T>
Expand Down Expand Up @@ -131,7 +131,7 @@ template<class T>
__forceinline__
#endif
__host_device__
void relax_ptp(const CHE * mesh, T * new_dist, T * old_dist, index_t * new_clusters, index_t * old_clusters, const index_t & v)
void relax_ptp(const CHE * mesh, T * new_dist, T * old_dist, index_t * new_clusters, index_t * old_clusters, const index_t v)
{
real_t & ndv = new_dist[v] = old_dist[v];
if(new_clusters) new_clusters[v] = old_clusters[v];
Expand Down Expand Up @@ -169,7 +169,7 @@ index_t run_ptp(const CHE * mesh, const std::vector<index_t> & sources,

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

#ifdef __CUDACC__
h_dist[v] = 0;
Expand All @@ -182,7 +182,7 @@ index_t run_ptp(const CHE * mesh, const std::vector<index_t> & sources,
}

#ifdef __CUDACC__
const size_t & n_vertices = limits.back();
const size_t n_vertices = limits.back();
cudaMemcpy(dist[0], h_dist, sizeof(T) * n_vertices, cudaMemcpyHostToDevice);
cudaMemcpy(dist[1], h_dist, sizeof(T) * n_vertices, cudaMemcpyHostToDevice);
if(sorted)
Expand All @@ -196,7 +196,7 @@ index_t run_ptp(const CHE * mesh, const std::vector<index_t> & sources,
}
#endif

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

int iter = -1;
index_t count = 0;
Expand All @@ -206,9 +206,9 @@ index_t run_ptp(const CHE * mesh, const std::vector<index_t> & sources,
{
if(i < (j >> 1)) i = (j >> 1); // K/2 limit band size

const index_t & start = limits[i];
const index_t & end = limits[j];
const index_t & n_cond = limits[i + 1] - start;
const index_t start = limits[i];
const index_t end = limits[j];
const index_t n_cond = limits[i + 1] - start;

T *& new_dist = dist[iter & 1];
T *& old_dist = dist[!(iter & 1)];
Expand All @@ -233,15 +233,15 @@ index_t run_ptp(const CHE * mesh, const std::vector<index_t> & sources,
#pragma omp parallel for
for(index_t k = start; k < start + n_cond; ++k)
{
const index_t & v = sorted ? sorted[k] : k;
const index_t v = sorted ? sorted[k] : k;
error[v] = abs(new_dist[v] - old_dist[v]) / old_dist[v];
}

count = 0;
#pragma omp parallel for reduction(+: count)
for(index_t k = start; k < start + n_cond; ++k)
{
const index_t & v = sorted ? sorted[k] : k;
const index_t v = sorted ? sorted[k] : k;
count += error[v] < PTP_TOL;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/geodesics/test_geodesics_ptp.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace gproshan {

/// Return an array with the error per iteration.
/// Starting to store (position 0) errors after number of toplesets.
std::vector<std::pair<index_t, real_t> > iter_error_run_ptp_gpu(CHE * d_mesh, const index_t & n_vertices, real_t * h_dist, real_t ** d_dist, const std::vector<index_t> & sources, const std::vector<index_t> & limits, const index_t * h_sorted, index_t * d_sorted, const real_t * exact_dist, real_t * d_error);
std::vector<std::pair<index_t, real_t> > iter_error_run_ptp_gpu(CHE * d_mesh, const index_t n_vertices, real_t * h_dist, real_t ** d_dist, const std::vector<index_t> & sources, const std::vector<index_t> & limits, const index_t * h_sorted, index_t * d_sorted, const real_t * exact_dist, real_t * d_error);


} // namespace gproshan
Expand Down
16 changes: 8 additions & 8 deletions include/gproshan/geodesics/test_geodesics_ptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ namespace gproshan {


/// Execute performance and accuracy test for ptp algorithm on cpu and gpu.
void main_test_geodesics_ptp(const int & nargs, const char ** args);
void main_test_geodesics_ptp(const int nargs, const char ** args);

double test_fast_marching(real_t & error, const real_t * exact, che * mesh, const std::vector<index_t> & source, const int & n_test);
double test_fast_marching(real_t & error, const real_t * exact, che * mesh, const std::vector<index_t> & source, const int n_test);

double test_ptp_cpu(real_t & error, const real_t * exact, che * mesh, const std::vector<index_t> & source, const toplesets_t & toplesets, const int & n_test);
double test_ptp_cpu(real_t & error, const real_t * exact, che * mesh, const std::vector<index_t> & source, const toplesets_t & toplesets, const int n_test);

double test_heat_method_cholmod(real_t & error, double & stime, const real_t * exact, che * mesh, const std::vector<index_t> & source, const int & n_test);
double test_heat_method_cholmod(real_t & error, double & stime, const real_t * exact, che * mesh, const std::vector<index_t> & source, const int n_test);


#ifdef GPROSHAN_CUDA

double test_ptp_gpu(real_t & error, const real_t * exact, che * mesh, const std::vector<index_t> & source, const toplesets_t & toplesets, const int & n_test);
double test_ptp_gpu(real_t & error, const real_t * exact, che * mesh, const std::vector<index_t> & source, const toplesets_t & toplesets, const int n_test);

double test_heat_method_gpu(real_t & error, double & stime, const real_t * exact, che * mesh, const std::vector<index_t> & source, const int & n_test);
double test_heat_method_gpu(real_t & error, double & stime, const real_t * exact, che * mesh, const std::vector<index_t> & source, const int n_test);

/// Return an array with the error per iteration.
/// Starting to store (position 0) errors after number of toplesets.
Expand All @@ -44,9 +44,9 @@ double * times_farthest_point_sampling_ptp_coalescence_gpu(che * mesh, std::vect

/// Exact geodesics computed using MeshLP https://github.com/areslp/matlab/tree/master/MeshLP/MeshLP,
/// Geodesics code: http://code.google.com/p/geodesic/
real_t * load_exact_geodesics(const std::string & file, const size_t & n);
real_t * load_exact_geodesics(const std::string & file, const size_t n);

real_t compute_error(const real_t * dist, const real_t * exact, const size_t & n, const size_t & s);
real_t compute_error(const real_t * dist, const real_t * exact, const size_t n, const size_t s);


} // namespace gproshan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace gproshan {

/// Return an array with the error per iteration.
/// Starting to store (position 0) errors after number of toplesets.
std::vector<std::pair<index_t, real_t> > iter_error_run_ptp_coalescence_gpu(CHE * d_mesh, const index_t & n_vertices, real_t * h_dist, real_t ** d_dist, const std::vector<index_t> & sources, const std::vector<index_t> & limits, const index_t * inv, const real_t * exact_dist, real_t * d_error);
std::vector<std::pair<index_t, real_t> > iter_error_run_ptp_coalescence_gpu(CHE * d_mesh, const index_t n_vertices, real_t * h_dist, real_t ** d_dist, const std::vector<index_t> & sources, const std::vector<index_t> & limits, const index_t * inv, const real_t * exact_dist, real_t * d_error);


} // namespace gproshan
Expand Down
4 changes: 2 additions & 2 deletions include/gproshan/geometry/convex_hull.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class convex_hull
std::vector<index_t> CH; ///< convex hull points clockwise

public:
convex_hull(const std::vector<vertex> & points, const real_t & precision = 1000);
convex_hull(const vertex * points, const size_t & n_points, const real_t & precision = 1000);
convex_hull(const std::vector<vertex> & points, const real_t precision = 1000);
convex_hull(const vertex * points, const size_t n_points, const real_t precision = 1000);
operator const std::vector<index_t> & () const;

private:
Expand Down
8 changes: 4 additions & 4 deletions include/gproshan/geometry/mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ class mat
}

__host_device__
T & operator () (const index_t & i, const index_t & j)
T & operator () (const index_t i, const index_t j)
{
return rows[i][j];
}

__host_device__
const T & operator () (const index_t & i, const index_t & j) const
const T & operator () (const index_t i, const index_t j) const
{
return rows[i][j];
}

__host_device__
row<T, N> & operator [] (const index_t & i)
row<T, N> & operator [] (const index_t i)
{
assert(i < N);
return rows[i];
}

__host_device__
const row<T, N> & operator [] (const index_t & i) const
const row<T, N> & operator [] (const index_t i) const
{
assert(i < N);
return rows[i];
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/geometry/points.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace gproshan {


template <class T, size_t N>
std::vector<vec<T, N> > sampling_4points(const size_t & n, const vec<T, N> & a, const vec<T, N> & b, const vec<T, N> & c, const vec<T, N> & d)
std::vector<vec<T, N> > sampling_4points(const size_t n, const vec<T, N> & a, const vec<T, N> & b, const vec<T, N> & c, const vec<T, N> & d)
{
std::vector<vec<T, N> > points;
points.reserve((n + 1) * (n + 1));
Expand Down
4 changes: 2 additions & 2 deletions include/gproshan/geometry/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class vec
}

__host_device__
T & operator [] (const index_t & i)
T & operator [] (const index_t i)
{
assert(i < N);
return values[i];
}

__host_device__
const T & operator [] (const index_t & i) const
const T & operator [] (const index_t i) const
{
assert(i < N);
return values[i];
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/laplacian/fairing_spectral.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class fairing_spectral : public fairing
size_t n_eigs;

public:
fairing_spectral(const size_t & n_eigs_ = 100);
fairing_spectral(const size_t n_eigs_ = 100);
virtual ~fairing_spectral() = default;

private:
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/laplacian/fairing_taubin.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class fairing_taubin : public fairing
real_t step;

public:
fairing_taubin(const real_t & step_ = 0.001);
fairing_taubin(const real_t step_ = 0.001);
virtual ~fairing_taubin() = default;

private:
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/laplacian/laplacian.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace gproshan {

void laplacian(const che * mesh, a_sp_mat & L, a_sp_mat & A);

size_t eigs_laplacian(const che * mesh, a_vec & eigval, a_mat & eigvec, a_sp_mat & L, a_sp_mat & A, const size_t & k);
size_t eigs_laplacian(const che * mesh, a_vec & eigval, a_mat & eigvec, a_sp_mat & L, a_sp_mat & A, const size_t k);


} // namespace gproshan
Expand Down
8 changes: 4 additions & 4 deletions include/gproshan/mdict/basis.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ class basis
size_t _dim;

public:
basis(const real_t & r, const size_t & d);
basis(const real_t r, const size_t d);
virtual ~basis() = default;
virtual void discrete(a_mat & phi, const a_vec & x, const a_vec & y) = 0;
virtual void d_discrete(a_mat & phi, const a_vec & x, const a_vec & y, const bool & b) = 0;
virtual real_t freq(const index_t & idx) = 0;
virtual real_t freq(const index_t idx) = 0;
real_t & radio();
const size_t & dim() const;
size_t dim() const;
void plot_basis();
void plot_atoms(const a_mat & A);
void plot_patch(const a_mat & A, const a_mat & xyz, const index_t & p);
void plot_patch(const a_mat & A, const a_mat & xyz, const index_t p);

private:
virtual void plot_basis(std::ostream & os) = 0;
Expand Down
Loading

0 comments on commit 7a1573a

Please sign in to comment.