Skip to content

Commit 0f89cac

Browse files
committed
Merge branch 'dev' into alpha
2 parents 6e4e6bf + d474ae4 commit 0f89cac

File tree

12 files changed

+146
-151
lines changed

12 files changed

+146
-151
lines changed

include/gproshan/app_viewer.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ class app_viewer : public viewer
8080

8181
// Features
8282
static bool process_eigenfuntions(viewer * p_view);
83-
static bool process_descriptor_heatmap(viewer * p_view, const descriptor::signature & sig);
84-
static bool process_gps(viewer * p_view);
85-
static bool process_hks(viewer * p_view);
86-
static bool process_wks(viewer * p_view);
83+
static bool process_descriptor_heatmap(viewer * p_view);
8784
static bool process_key_points(viewer * p_view);
8885
static bool process_key_components(viewer * p_view);
8986

include/gproshan/features/key_components.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define KEY_COMPONENTS_H
33

44
#include "mesh/che.h"
5-
#include "features/key_points.h"
65

76
#include <map>
87

@@ -14,21 +13,21 @@ namespace gproshan {
1413
class key_components
1514
{
1615
private:
17-
real_t radio;
18-
size_t n_vertices;
19-
size_t n_comp;
20-
index_t * comp;
21-
size_t * comp_size;
16+
real_t radio = 0;
17+
size_t n_vertices = 0;
18+
size_t n_comp = 0;
19+
index_t * comp = nullptr;
20+
size_t * comp_size = nullptr;
2221
std::map<index_t, index_t> comp_idx;
2322

2423
public:
25-
key_components(che * mesh, const key_points & kps, const real_t & r);
24+
key_components(che * mesh, const std::vector<index_t> & kps, const real_t & r);
2625
~key_components();
2726
index_t operator()(const index_t & i);
2827
operator const size_t & () const;
2928

3029
private:
31-
void compute_kcs(che * mesh, const key_points & kps);
30+
void compute_kcs(che * mesh, const std::vector<index_t> & kps);
3231
index_t find(const index_t & x);
3332
bool join(index_t x, index_t y);
3433
};

include/gproshan/features/key_points.h

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,23 @@
33

44
#include "mesh/che.h"
55

6-
#include <utility>
7-
86

97
// geometry processing and shape analysis framework
108
namespace gproshan {
119

1210

13-
typedef std::pair<real_t, index_t> real_idx_t;
14-
1511
class key_points
1612
{
1713
private:
18-
size_t n_faces;
19-
size_t n_vertices;
20-
real_idx_t * face_areas;
21-
index_t * kps;
22-
bool * is_kp;
23-
size_t n_kps;
14+
std::vector<index_t> kps;
15+
std::vector<bool> is_kp;
2416

2517
public:
2618
key_points(che * mesh, const real_t & percent = 0.10);
27-
~key_points();
28-
const index_t & operator[](const index_t & i) const;
29-
const bool & operator()(const index_t & i) const;
30-
const size_t & size() const;
19+
operator const std::vector<index_t> & () const;
3120

3221
private:
33-
void compute_kps(che * mesh);
22+
void compute_kps_areas(che * mesh, const real_t & percent);
3423
};
3524

3625

include/gproshan/viewer/camera.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "mesh/quaternion.h"
55

6+
#include <glm/glm.hpp>
7+
68

79
// geometry processing and shape analysis framework
810
namespace gproshan {
@@ -11,21 +13,24 @@ namespace gproshan {
1113
class camera
1214
{
1315
private:
14-
quaternion p_click;
15-
quaternion p_drag;
16-
quaternion p_last;
17-
quaternion r_last;
16+
quaternion p_click = 1;
17+
quaternion p_drag = 1;
18+
quaternion p_last = 1;
19+
quaternion r_last = 1;
1820

1921
public:
20-
double zoom;
22+
quaternion eye = vertex(0, 0, 2);
23+
quaternion center = vertex(0, 0, 0);
24+
quaternion up = vertex(0, 1, 0);
25+
double zoom = 2;
2126

2227
public:
23-
camera();
28+
glm::mat4 look_at(const quaternion & r);
29+
quaternion current_rotation() const;
2430
void mouse(const bool & press, const double & x, const double & y, const int & w, const int & h);
2531
void motion(const double & x, const double & y, const int & w, const int & h);
2632
void zoom_in();
2733
void zoom_out();
28-
quaternion current_rotation() const;
2934

3035
private:
3136
quaternion click_to_sphere(const double & x, const double & y, const int & w, const int & h);

include/gproshan/viewer/che_viewer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class che_viewer
4848
void reload();
4949
void update();
5050
void update_vbo();
51+
void update_vbo_geometry();
52+
void update_vbo_normal();
53+
void update_vbo_color();
54+
void update_vbo_heatmap();
5155
void update_instances_translations(const std::vector<vertex> & translations);
5256
void draw(shader & program);
5357
void draw_point_cloud(shader & program);

include/gproshan/viewer/viewer.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ class viewer
6969

7070
camera cam;
7171

72-
quaternion eye;
73-
quaternion center;
74-
quaternion up;
75-
7672
quaternion light;
7773

7874
glm::mat4 view_mat;

src/app_viewer.cpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,16 @@ void app_viewer::init()
8585

8686
sub_menus.push_back("Features");
8787
add_process(GLFW_KEY_2, {"2", "Eigenfunctions", process_eigenfuntions});
88-
add_process(GLFW_KEY_3, {"3", "GPS", process_gps});
89-
add_process(GLFW_KEY_4, {"4", "HKS", process_hks});
90-
add_process(GLFW_KEY_5, {"5", "WKS", process_wks});
91-
add_process(GLFW_KEY_6, {"6", "Key Points", process_key_points});
92-
add_process(GLFW_KEY_7, {"7", "Key Components", process_key_components});
88+
add_process(GLFW_KEY_3, {"3", "Descriptors", process_descriptor_heatmap});
89+
add_process(GLFW_KEY_4, {"4", "Key Points", process_key_points});
90+
add_process(GLFW_KEY_5, {"5", "Key Components", process_key_components});
9391

9492
sub_menus.push_back("Hole Filling");
9593
add_process(GLFW_KEY_X, {"X", "Poisson: Membrane surface", process_poisson_laplacian_1});
9694
add_process(GLFW_KEY_Y, {"Y", "Poisson: Thin-plate surface", process_poisson_laplacian_2});
9795
add_process(GLFW_KEY_Z, {"Z", "Poisson: Minimum variation surface", process_poisson_laplacian_3});
98-
add_process(GLFW_KEY_8, {"8", "Fill hole: planar mesh", process_fill_holes});
99-
add_process(GLFW_KEY_9, {"0", "Fill hole: biharmonic splines", process_fill_holes_biharmonic_splines});
96+
add_process(GLFW_KEY_6, {"6", "Fill hole: planar mesh", process_fill_holes});
97+
add_process(GLFW_KEY_7, {"7", "Fill hole: biharmonic splines", process_fill_holes_biharmonic_splines});
10098

10199
sub_menus.push_back("Others");
102100
add_process(GLFW_KEY_SEMICOLON, {"SEMICOLON", "Select multiple vertices", process_select_multiple});
@@ -269,6 +267,9 @@ bool app_viewer::process_fairing_spectral(viewer * p_view)
269267
mesh->update_normals();
270268
}
271269

270+
mesh.update_vbo_geometry();
271+
mesh.update_vbo_normal();
272+
272273
return true;
273274
}
274275

@@ -296,6 +297,9 @@ bool app_viewer::process_fairing_taubin(viewer * p_view)
296297
mesh->update_normals();
297298
}
298299

300+
mesh.update_vbo_geometry();
301+
mesh.update_vbo_normal();
302+
299303
return true;
300304
}
301305

@@ -335,6 +339,7 @@ bool app_viewer::process_geodesics(viewer * p_view)
335339

336340
params.radio = G.radio();
337341
mesh->update_heatmap(&G[0]);
342+
mesh.update_vbo_heatmap();
338343
}
339344

340345
return true;
@@ -388,6 +393,8 @@ bool app_viewer::process_voronoi(viewer * p_view)
388393
mesh->heatmap(i) /= mesh.selected.size() + 1;
389394
}
390395

396+
mesh.update_vbo_heatmap();
397+
391398
return false;
392399
}
393400

@@ -414,6 +421,8 @@ bool app_viewer::process_compute_toplesets(viewer * p_view)
414421
mesh->heatmap(v) = real_t(toplesets[v]) / (n_toplesets);
415422
}
416423

424+
mesh.update_vbo_heatmap();
425+
417426
gproshan_debug_var(n_toplesets);
418427

419428
delete [] toplesets;
@@ -630,13 +639,16 @@ bool app_viewer::process_eigenfuntions(viewer * p_view)
630639
return true;
631640
}
632641

633-
bool app_viewer::process_descriptor_heatmap(viewer * p_view, const descriptor::signature & sig)
642+
bool app_viewer::process_descriptor_heatmap(viewer * p_view)
634643
{
635644
app_viewer * view = (app_viewer *) p_view;
636645
che_viewer & mesh = view->active_mesh();
637646

638647
static int n_eigs = 50;
639648
static bool status = true;
649+
static descriptor::signature sig = descriptor::GPS;
650+
651+
ImGui::Combo("descriptor", (int *) &sig, "GPS\0HKS\0WKS\0\0");
640652
ImGui::InputInt("n_eigs", &n_eigs);
641653
if(!status) ImGui::TextColored({1, 0, 0, 1}, "Error computing features.");
642654

@@ -660,61 +672,49 @@ bool app_viewer::process_descriptor_heatmap(viewer * p_view, const descriptor::s
660672
#pragma omp parallel for
661673
for(index_t v = 0; v < mesh->n_vertices; ++v)
662674
mesh->heatmap(v) /= max_s;
675+
676+
mesh.update_vbo_heatmap();
663677
}
664678
else status = false;
665679
}
666680

667681
return true;
668682
}
669683

670-
bool app_viewer::process_gps(viewer * p_view)
671-
{
672-
return process_descriptor_heatmap(p_view, descriptor::GPS);
673-
}
674-
675-
bool app_viewer::process_hks(viewer * p_view)
676-
{
677-
return process_descriptor_heatmap(p_view, descriptor::HKS);
678-
}
679-
680-
bool app_viewer::process_wks(viewer * p_view)
681-
{
682-
return process_descriptor_heatmap(p_view, descriptor::WKS);
683-
}
684-
685684
bool app_viewer::process_key_points(viewer * p_view)
686685
{
687-
gproshan_log(APP_VIEWER);
688686
app_viewer * view = (app_viewer *) p_view;
689687
che_viewer & mesh = view->active_mesh();
690688

691-
key_points kps(mesh);
692-
693-
mesh.selected.clear();
694-
mesh.selected.reserve(kps.size());
695-
696-
for(index_t i = 0; i < kps.size(); ++i)
697-
mesh.selected.push_back(kps[i]);
689+
static real_t percent = 0.1;
690+
if(ImGui_InputReal("percent", &percent, 0.01, 0.1, "%.2f"))
691+
{
692+
key_points kps(mesh, percent);
693+
mesh.selected = kps;
694+
}
698695

699-
return false;
696+
return true;
700697
}
701698

702699
bool app_viewer::process_key_components(viewer * p_view)
703700
{
704-
gproshan_log(APP_VIEWER);
705701
app_viewer * view = (app_viewer *) p_view;
706702
che_viewer & mesh = view->active_mesh();
707703

708-
key_points kps(mesh);
709-
key_components kcs(mesh, kps, .25);
704+
static real_t radio = 0.25;
705+
if(ImGui_InputReal("radio", &radio, 0.01, 0.1, "%.2f"))
706+
{
707+
// use the mesh selected points as key points.
708+
key_components kcs(mesh, mesh.selected, radio);
710709

711-
gproshan_debug_var(kcs);
710+
#pragma omp parallel for
711+
for(index_t v = 0; v < mesh->n_vertices; ++v)
712+
mesh->heatmap(v) = (real_t) kcs(v) / kcs;
712713

713-
#pragma omp parallel for
714-
for(index_t v = 0; v < mesh->n_vertices; ++v)
715-
mesh->heatmap(v) = (real_t) kcs(v) / kcs;
714+
mesh.update_vbo_heatmap();
715+
}
716716

717-
return false;
717+
return true;
718718
}
719719

720720

src/features/key_components.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using namespace std;
1111
namespace gproshan {
1212

1313

14-
key_components::key_components(che * mesh, const key_points & kps, const real_t & r): radio(r)
14+
key_components::key_components(che * mesh, const std::vector<index_t> & kps, const real_t & r): radio(r)
1515
{
1616
n_vertices = mesh->n_vertices;
1717

@@ -48,13 +48,14 @@ key_components::operator const size_t & () const
4848
return n_comp;
4949
}
5050

51-
void key_components::compute_kcs(che * mesh, const key_points & kps)
51+
void key_components::compute_kcs(che * mesh, const std::vector<index_t> & kps)
5252
{
53-
geodesics fm(mesh, vector<index_t>(&kps[0], &kps[0] + kps.size()));
53+
geodesics fm(mesh, kps);
5454

5555
radio *= fm.radio();
5656
for(index_t i = 0; i < n_vertices && fm[fm(i)] <= radio; ++i)
57-
for_star(he, mesh, fm(i)) join(fm(i), mesh->vt(next(he)));
57+
for_star(he, mesh, fm(i))
58+
join(fm(i), mesh->vt(next(he)));
5859

5960
for(index_t i = 0; i < n_vertices; ++i)
6061
if(comp[i] == i && comp_size[i] > 1)

0 commit comments

Comments
 (0)