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 288c63b + 8fbd63e commit 1af6886
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 124 deletions.
2 changes: 1 addition & 1 deletion include/gproshan/raytracing/embree.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class embree : public raytracing
virtual ~embree();

virtual index_t closest_vertex(const vertex & org, const vertex & dir) const;
virtual eval_hit intersect(const vertex & org, const vertex & dir) const;
virtual eval_hit intersect(const vertex & org, const vertex & dir, const bool & flat = true) const;


protected:
Expand Down
3 changes: 2 additions & 1 deletion include/gproshan/raytracing/raytracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class raytracing
) const;

virtual eval_hit intersect( const vertex &, // org
const vertex & //dir
const vertex &, //dir
[[maybe_unused]] const bool & flat = true
) const { return {}; }

virtual index_t closest_vertex( const vertex &, // org,
Expand Down
9 changes: 6 additions & 3 deletions include/gproshan/viewer/viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class viewer
const char * key = nullptr;
const char * name = nullptr;
function_t function = nullptr;
index_t sub_menu = NIL;
index_t id_menu = NIL;
bool selected = false;
};

Expand Down Expand Up @@ -84,20 +84,22 @@ class viewer
index_t nframes = 0;

std::vector<che_viewer *> meshes;
std::vector<che_viewer *> removed_meshes;
index_t idx_selected_mesh = 0;

frame * frames = nullptr;

float bgc = 0;

std::vector<std::string> menus;
std::vector<std::vector<int> > menu_processes;
std::unordered_map<int, process_t> processes;

che_viewer * sphere = nullptr;
shader shader_sphere;
std::vector<vertex> sphere_points;

std::vector<vertex> vectors;
std::vector<std::string> sub_menus;

char status_message[1024] = {};

Expand All @@ -106,7 +108,8 @@ class viewer
virtual ~viewer();

che_viewer & selected_mesh();
void add_process(const char * name, const function_t & f, const int & key = -1);
void add_menu(const std::string & str, const std::vector<int> & vprocesses);
int add_process(const char * name, const function_t & f, const int & key = -1);
bool add_mesh(che * p_mesh, const bool & reset_normals = true);
bool remove_mesh(const index_t & idx);
bool pop_mesh();
Expand Down
120 changes: 69 additions & 51 deletions src/gproshan/app_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,57 +42,75 @@ int app_viewer::main(int nargs, const char ** args)

void app_viewer::init()
{
sub_menus.push_back("Point Cloud");
add_process("KNN", process_knn);
add_process("Compute Normals", process_compute_normals);

sub_menus.push_back("Scenes");
add_process("Scan Scene", process_simulate_scanner);

sub_menus.push_back("Geometry");
add_process("Sampling 4points", process_sampling_4points);
add_process("2D Convex Hull", process_convex_hull, GLFW_KEY_H);
add_process("Connected Components", process_connected_components, GLFW_KEY_O);
add_process("Gaussian curvature", process_gaussian_curvature, GLFW_KEY_K);
add_process("Edge Collapse", process_edge_collapse, GLFW_KEY_Q);
add_process("Multiplicate", process_multiplicate_vertices, GLFW_KEY_M);
add_process("Delete vertices", process_delete_vertices, GLFW_KEY_SLASH);
add_process("Delete non-manifold vertices", process_delete_non_manifold_vertices, GLFW_KEY_MINUS);

sub_menus.push_back("Fairing");
add_process("Fairing Taubin", process_fairing_taubin, GLFW_KEY_F);
add_process("Fairing Spectral", process_fairing_spectral, GLFW_KEY_E);

sub_menus.push_back("Geodesics");
add_process("Geodesics", process_geodesics, GLFW_KEY_G);
add_process("Geodesic Farthest Point Sampling", process_farthest_point_sampling, GLFW_KEY_S);
add_process("Geodesic Voronoi", process_voronoi, GLFW_KEY_V);
add_process("Toplesets", process_compute_toplesets, GLFW_KEY_T);

sub_menus.push_back("Sparse Coding");
add_process("Mesh Sparse Coding", process_msparse_coding, GLFW_KEY_U);
add_process("MDICT Patch", process_mdict_patch, GLFW_KEY_J);
add_process("MDICT Mask", process_mask, GLFW_KEY_D);
add_process("PC reconstruction", process_pc_reconstruction, GLFW_KEY_L);

sub_menus.push_back("Features");
add_process("Eigenfunctions", process_eigenfuntions, GLFW_KEY_2);
add_process("Descriptors", process_descriptor_heatmap, GLFW_KEY_3);
add_process("Key Points", process_key_points, GLFW_KEY_4);
add_process("Key Components", process_key_components, GLFW_KEY_5);

sub_menus.push_back("Hole Filling");
add_process("Poisson: Membrane surface", process_poisson_laplacian_1, GLFW_KEY_X);
add_process("Poisson: Thin-plate surface", process_poisson_laplacian_2, GLFW_KEY_Y);
add_process("Poisson: Minimum variation surface", process_poisson_laplacian_3, GLFW_KEY_Z);
add_process("Fill hole: planar mesh", process_fill_holes, GLFW_KEY_6);
add_process("Fill hole: biharmonic splines", process_fill_holes_biharmonic_splines, GLFW_KEY_7);

sub_menus.push_back("Others");
add_process("Select multiple vertices", process_select_multiple, GLFW_KEY_SEMICOLON);
add_process("Threshold", process_threshold, GLFW_KEY_BACKSLASH);
add_process("Noise", process_noise, GLFW_KEY_N);
add_process("Black noise", process_black_noise, GLFW_KEY_P);
add_menu("Point Cloud",
{
add_process("KNN", process_knn),
add_process("Compute Normals", process_compute_normals)
});

add_menu("Scenes",
{
add_process("Scan Scene", process_simulate_scanner)
});

add_menu("Geometry",
{
add_process("Sampling 4points", process_sampling_4points),
add_process("2D Convex Hull", process_convex_hull, GLFW_KEY_H),
add_process("Connected Components", process_connected_components, GLFW_KEY_O),
add_process("Gaussian curvature", process_gaussian_curvature, GLFW_KEY_K),
add_process("Edge Collapse", process_edge_collapse, GLFW_KEY_Q),
add_process("Multiplicate", process_multiplicate_vertices, GLFW_KEY_M),
add_process("Delete vertices", process_delete_vertices, GLFW_KEY_SLASH),
add_process("Delete non-manifold vertices", process_delete_non_manifold_vertices, GLFW_KEY_MINUS)
});

add_menu("Fairing",
{
add_process("Fairing Taubin", process_fairing_taubin, GLFW_KEY_F),
add_process("Fairing Spectral", process_fairing_spectral, GLFW_KEY_E)
});

add_menu("Geodesics",
{
add_process("Geodesics", process_geodesics, GLFW_KEY_G),
add_process("Geodesic Farthest Point Sampling", process_farthest_point_sampling, GLFW_KEY_S),
add_process("Geodesic Voronoi", process_voronoi, GLFW_KEY_V),
add_process("Toplesets", process_compute_toplesets, GLFW_KEY_T)
});

add_menu("Sparse Coding",
{
add_process("Mesh Sparse Coding", process_msparse_coding, GLFW_KEY_U),
add_process("MDICT Patch", process_mdict_patch, GLFW_KEY_J),
add_process("MDICT Mask", process_mask, GLFW_KEY_D),
add_process("PC reconstruction", process_pc_reconstruction, GLFW_KEY_L)
});

add_menu("Features",
{
add_process("Eigenfunctions", process_eigenfuntions, GLFW_KEY_2),
add_process("Descriptors", process_descriptor_heatmap, GLFW_KEY_3),
add_process("Key Points", process_key_points, GLFW_KEY_4),
add_process("Key Components", process_key_components, GLFW_KEY_5)
});

add_menu("Hole Filling",
{
add_process("Poisson: Membrane surface", process_poisson_laplacian_1, GLFW_KEY_X),
add_process("Poisson: Thin-plate surface", process_poisson_laplacian_2, GLFW_KEY_Y),
add_process("Poisson: Minimum variation surface", process_poisson_laplacian_3, GLFW_KEY_Z),
add_process("Fill hole: planar mesh", process_fill_holes, GLFW_KEY_6),
add_process("Fill hole: biharmonic splines", process_fill_holes_biharmonic_splines, GLFW_KEY_7)
});

add_menu("Others",
{
add_process("Select multiple vertices", process_select_multiple, GLFW_KEY_SEMICOLON),
add_process("Threshold", process_threshold, GLFW_KEY_BACKSLASH),
add_process("Noise", process_noise, GLFW_KEY_N),
add_process("Black noise", process_black_noise, GLFW_KEY_P)
});
}


Expand Down
5 changes: 3 additions & 2 deletions src/gproshan/raytracing/embree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ vertex embree::ray_hit::dir() const

vertex embree::ray_hit::normal() const
{
return normalize(vec3{hit.Ng_x, hit.Ng_y, hit.Ng_z});
return normalize(vertex{hit.Ng_x, hit.Ng_y, hit.Ng_z});
}

vertex embree::ray_hit::pos() const
Expand Down Expand Up @@ -109,14 +109,15 @@ index_t embree::closest_vertex(const vertex & org, const vertex & dir) const
return mesh->VT[he];
}

eval_hit embree::intersect(const vertex & org, const vertex & dir) const
eval_hit embree::intersect(const vertex & org, const vertex & dir, const bool & flat) const
{
ray_hit r(org, dir);
if(!intersect(r)) return {};

eval_hit hit(*g_meshes[r.hit.geomID], r.hit.primID, r.hit.u, r.hit.v, sc);
hit.dist = r.ray.tfar;
hit.position = r.pos();
hit.normal = flat ? r.normal() : hit.normal;

return hit;
}
Expand Down
Loading

0 comments on commit 1af6886

Please sign in to comment.