Hide cavity behind a named parameter

This commit is contained in:
Mael Rouxel-Labbé 2023-10-17 13:01:18 +02:00
parent 021d1fe8bd
commit 847795ec00
2 changed files with 30 additions and 15 deletions

View File

@ -278,6 +278,10 @@ public:
// geometrically manifold. // geometrically manifold.
const bool do_enforce_manifoldness = choose_parameter(get_parameter(in_np, internal_np::do_enforce_manifoldness), true); const bool do_enforce_manifoldness = choose_parameter(get_parameter(in_np, internal_np::do_enforce_manifoldness), true);
// Whether to keep pockets of OUTSIDE cells that are not connected to the exterior (or to the
// initial cavities, if used).
const bool keep_inner_ccs = choose_parameter(get_parameter(in_np, internal_np::keep_inner_connected_components), true);
// This parameter enables avoiding recomputing the triangulation from scratch when wrapping // This parameter enables avoiding recomputing the triangulation from scratch when wrapping
// the same input for multiple values of alpha (and typically the same offset values). // the same input for multiple values of alpha (and typically the same offset values).
// /!\ Warning /!\ // /!\ Warning /!\
@ -317,12 +321,6 @@ public:
dump_triangulation_faces("flood_filled_wrap.off", true /*only_boundary_faces*/); dump_triangulation_faces("flood_filled_wrap.off", true /*only_boundary_faces*/);
#endif #endif
purge_inner_islands();
#ifdef CGAL_AW3_DEBUG_DUMP_INTERMEDIATE_WRAPS
dump_triangulation_faces("purged_wrap.off", true /*only_boundary_faces*/);
#endif
#ifdef CGAL_AW3_TIMER #ifdef CGAL_AW3_TIMER
t.stop(); t.stop();
std::cout << "Flood filling took: " << t.time() << " s." << std::endl; std::cout << "Flood filling took: " << t.time() << " s." << std::endl;
@ -338,12 +336,6 @@ public:
dump_triangulation_faces("manifold_wrap.off", true /*only_boundary_faces*/); dump_triangulation_faces("manifold_wrap.off", true /*only_boundary_faces*/);
#endif #endif
purge_inner_islands();
#ifdef CGAL_AW3_DEBUG_DUMP_INTERMEDIATE_WRAPS
dump_triangulation_faces("purged_manifold_wrap.off", true /*only_boundary_faces*/);
#endif
#ifdef CGAL_AW3_TIMER #ifdef CGAL_AW3_TIMER
t.stop(); t.stop();
std::cout << "Manifoldness post-processing took: " << t.time() << " s." << std::endl; std::cout << "Manifoldness post-processing took: " << t.time() << " s." << std::endl;
@ -352,6 +344,17 @@ public:
#endif #endif
} }
if(!keep_inner_ccs)
{
// We could purge *before* manifold enforcement, but making the mesh manifold is
// very cheap in most cases, so it is better to keep the code simpler.
purge_inner_connected_components();
#ifdef CGAL_AW3_DEBUG_DUMP_INTERMEDIATE_WRAPS
dump_triangulation_faces("purged_wrap.off", true /*only_boundary_faces*/);
#endif
}
extract_surface(output_mesh, ovpm, !do_enforce_manifoldness); extract_surface(output_mesh, ovpm, !do_enforce_manifoldness);
#ifdef CGAL_AW3_TIMER #ifdef CGAL_AW3_TIMER
@ -1395,12 +1398,17 @@ private:
return true; return true;
} }
// Any outside cell that isn't reachable from infinity is a cavity that can // Any outside cell that isn't reachable from infinity is a cavity that can be discarded.
// be discarded. This also removes some difficult non-manifoldness onfigurations std::size_t purge_inner_connected_components()
std::size_t purge_inner_islands()
{ {
#ifdef CGAL_AW3_DEBUG #ifdef CGAL_AW3_DEBUG
std::cout << "> Purge inner islands..." << std::endl; std::cout << "> Purge inner islands..." << std::endl;
std::size_t pre_counter = 0;
for(Cell_handle ch : m_tr.all_cell_handles())
if(ch->is_outside())
++pre_counter;
std::cout << pre_counter << " / " << m_tr.all_cell_handles().size() << " (pre purge)" << std::endl;
#endif #endif
std::size_t label_change_counter = 0; std::size_t label_change_counter = 0;
@ -1467,6 +1475,12 @@ private:
ch->tds_data().clear(); ch->tds_data().clear();
#ifdef CGAL_AW3_DEBUG #ifdef CGAL_AW3_DEBUG
std::size_t post_counter = 0;
for(Cell_handle ch : m_tr.all_cell_handles())
if(ch->is_outside())
++post_counter;
std::cout << post_counter << " / " << m_tr.all_cell_handles().size() << " (pre purge)" << std::endl;
std::cout << label_change_counter << " label changes" << std::endl; std::cout << label_change_counter << " label changes" << std::endl;
#endif #endif

View File

@ -238,6 +238,7 @@ CGAL_add_named_parameter(smooth_constrained_edges_t, smooth_constrained_edges, s
CGAL_add_named_parameter(do_enforce_manifoldness_t, do_enforce_manifoldness, do_enforce_manifoldness) CGAL_add_named_parameter(do_enforce_manifoldness_t, do_enforce_manifoldness, do_enforce_manifoldness)
CGAL_add_named_parameter(seed_points_t, seed_points, seed_points) CGAL_add_named_parameter(seed_points_t, seed_points, seed_points)
CGAL_add_named_parameter(refine_triangulation_t, refine_triangulation, refine_triangulation) CGAL_add_named_parameter(refine_triangulation_t, refine_triangulation, refine_triangulation)
CGAL_add_named_parameter(keep_inner_connected_components_t, keep_inner_connected_components, keep_inner_connected_components)
// SMDS_3 parameters // SMDS_3 parameters
CGAL_add_named_parameter(surface_facets_t, surface_facets, surface_facets) CGAL_add_named_parameter(surface_facets_t, surface_facets, surface_facets)