Skip to content
Snippets Groups Projects
Commit 5594373f authored by Janis Born's avatar Janis Born
Browse files

add is_collapse_allowed predicate to decimate_config, allowing users to...

add is_collapse_allowed predicate to decimate_config, allowing users to prevent certain halfedge collapses from happening
parent 83e54964
No related branches found
No related tags found
1 merge request!24add is_collapse_allowed predicate to decimate_config
...@@ -26,6 +26,7 @@ namespace polymesh ...@@ -26,6 +26,7 @@ namespace polymesh
* should_stop(pm::Mesh const& m, error_value_t curr_error) -> bool * should_stop(pm::Mesh const& m, error_value_t curr_error) -> bool
* eval(Pos3 const& p, ErrorF const& e) -> error_value_t * eval(Pos3 const& p, ErrorF const& e) -> error_value_t
* merge(ErrorF const& a, ErrorF const& b) -> ErrorF * merge(ErrorF const& a, ErrorF const& b) -> ErrorF
* is_collapse_allowed(pm::halfedge_handle h) -> bool
* collapsed_pos(pm::halfedge_handle h, ErrorF const& e) -> Pos3 * collapsed_pos(pm::halfedge_handle h, ErrorF const& e) -> Pos3
*/ */
template <class Pos3, class ErrorF> template <class Pos3, class ErrorF>
...@@ -56,6 +57,9 @@ struct decimate_config ...@@ -56,6 +57,9 @@ struct decimate_config
/// merges two error functions (can be static or member function) /// merges two error functions (can be static or member function)
static ErrorF merge(ErrorF const& a, ErrorF const& b) { return a + b; } static ErrorF merge(ErrorF const& a, ErrorF const& b) { return a + b; }
/// returns whether
static bool is_collapse_allowed(pm::halfedge_handle /* h */) { return true; }
/// returns the position after collapsing the halfedge (can be static or member function) /// returns the position after collapsing the halfedge (can be static or member function)
static Pos3 collapsed_pos(pm::halfedge_handle /* h */, ErrorF const& e) { return closest_point(e); } static Pos3 collapsed_pos(pm::halfedge_handle /* h */, ErrorF const& e) { return closest_point(e); }
...@@ -145,6 +149,9 @@ void decimate(pm::Mesh& m, // ...@@ -145,6 +149,9 @@ void decimate(pm::Mesh& m, //
auto vreach = m.vertices().make_attribute(-1); auto vreach = m.vertices().make_attribute(-1);
auto const enqueue = [&](pm::halfedge_handle h) { auto const enqueue = [&](pm::halfedge_handle h) {
if (!config.is_collapse_allowed(h))
return;
auto const v_to = h.vertex_to(); auto const v_to = h.vertex_to();
auto const v_from = h.vertex_from(); auto const v_from = h.vertex_from();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment