From e43221ae8bcc56fa5b94e68d1335a05c25e11fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 16 Jun 2020 15:15:48 +0200 Subject: [PATCH] add an option to not refine one of the two meshes --- .../CGAL/boost/graph/parameters_interface.h | 1 + BGL/test/BGL/test_cgal_bgl_named_params.cpp | 3 +++ .../CGAL/Polygon_mesh_processing/corefinement.h | 15 ++++++++++++++- .../internal/Corefinement/Visitor.h | 7 ++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/parameters_interface.h b/BGL/include/CGAL/boost/graph/parameters_interface.h index 0ca726f6e31..ba367732370 100644 --- a/BGL/include/CGAL/boost/graph/parameters_interface.h +++ b/BGL/include/CGAL/boost/graph/parameters_interface.h @@ -101,6 +101,7 @@ CGAL_add_named_parameter(area_threshold_t, area_threshold, area_threshold) CGAL_add_named_parameter(halfedges_keeper_t, halfedges_keeper, halfedges_keeper) CGAL_add_named_parameter(volume_threshold_t, volume_threshold, volume_threshold) CGAL_add_named_parameter(dry_run_t, dry_run, dry_run) +CGAL_add_named_parameter(do_not_modify_t, do_not_modify, do_not_modify) // List of named parameters that we use in the package 'Surface Mesh Simplification' CGAL_add_named_parameter(get_cost_policy_t, get_cost_policy, get_cost) diff --git a/BGL/test/BGL/test_cgal_bgl_named_params.cpp b/BGL/test/BGL/test_cgal_bgl_named_params.cpp index 1d65c3cd1c2..f2669e50313 100644 --- a/BGL/test/BGL/test_cgal_bgl_named_params.cpp +++ b/BGL/test/BGL/test_cgal_bgl_named_params.cpp @@ -97,6 +97,7 @@ void test(const NamedParameters& np) assert(get_parameter(np, CGAL::internal_np::do_lock_mesh).v == 61); assert(get_parameter(np, CGAL::internal_np::halfedges_keeper).v == 62); assert(get_parameter(np, CGAL::internal_np::do_simplify_border).v == 64); + assert(get_parameter(np, CGAL::internal_np::do_not_modify).v == 65); assert(get_parameter(np, CGAL::internal_np::maximum_number_of_faces).v == 78910); // Named parameters that we use in the package 'Surface Mesh Simplification' @@ -184,6 +185,7 @@ void test(const NamedParameters& np) check_same_type<54>(get_parameter(np, CGAL::internal_np::use_area_smoothing)); check_same_type<55>(get_parameter(np, CGAL::internal_np::use_Delaunay_flips)); check_same_type<56>(get_parameter(np, CGAL::internal_np::use_safety_constraints)); + check_same_type<65>(get_parameter(np, CGAL::internal_np::do_not_modify)); check_same_type<12340>(get_parameter(np, CGAL::internal_np::do_self_intersection_tests)); check_same_type<12341>(get_parameter(np, CGAL::internal_np::do_orientation_tests)); @@ -353,6 +355,7 @@ int main() .halfedges_keeper(A<62>(62)) .use_convex_hull(A<63>(63)) .do_simplify_border(A<64>(64)) + .do_not_modify(A<65>(65)) .point_map(A<9000>(9000)) .query_point_map(A<9001>(9001)) .normal_map(A<9002>(9002)) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h index e0e8c27de2f..85c02424b55 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h @@ -626,6 +626,9 @@ corefine_and_compute_difference( TriangleMesh& tm1, * checked for self-intersection and `CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception` * will be thrown if at least one is found (`np1` only). * \cgalParamEnd + * \cgalParamBegin{do_not_modify} if `true`, the corresponding mesh will not be updated. The default value is `false`. + * Obviously if this parameter is set to `true` for both meshes nothing will be done. + * \cgalParamEnd * \cgalNamedParamsEnd * */ @@ -641,9 +644,19 @@ corefine( TriangleMesh& tm1, using parameters::choose_parameter; using parameters::get_parameter; + if (choose_parameter(get_parameter(np1, internal_np::do_not_modify), false)) + { + if (choose_parameter(get_parameter(np2, internal_np::do_not_modify), false)) + return; + return corefine(tm2,tm1, np2, np1); + } + const bool throw_on_self_intersection = choose_parameter(get_parameter(np1, internal_np::throw_on_self_intersection), false); + const bool modify_tm2 = + !choose_parameter(get_parameter(np2, internal_np::do_not_modify), false); + // Vertex point maps typedef typename GetVertexPointMap::type Vpm; @@ -700,7 +713,7 @@ corefine( TriangleMesh& tm1, Ob ob; Ecm ecm(tm1,tm2,ecm1,ecm2); Corefinement::Intersection_of_triangle_meshes - functor(tm1, tm2, vpm1, vpm2, Algo_visitor(uv,ob,ecm)); + functor(tm1, tm2, vpm1, vpm2, Algo_visitor(uv,ob,ecm,modify_tm2)); functor(CGAL::Emptyset_iterator(), throw_on_self_intersection, true); } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h index d668782b25c..e81be0cfa60 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h @@ -170,6 +170,7 @@ private: OutputBuilder& output_builder; EdgeMarkMapBind marks_on_edges; bool input_with_coplanar_faces; + bool refine_tm2; template void call_put(Ecm_bind& ecm, @@ -200,12 +201,13 @@ private: // visitor public functions public: Surface_intersection_visitor_for_corefinement( - UserVisitor& uv, OutputBuilder& o, const EdgeMarkMapBind& emm) + UserVisitor& uv, OutputBuilder& o, const EdgeMarkMapBind& emm, bool refine_tm2=true) : number_coplanar_vertices(0) , user_visitor(uv) , output_builder(o) , marks_on_edges(emm) , input_with_coplanar_faces(false) + , refine_tm2(refine_tm2) {} template @@ -624,6 +626,7 @@ public: ++it) { TriangleMesh& tm=*it->first; + if (!refine_tm2 && tm2_ptr==&tm) continue; // Face_boundaries& face_boundaries=mesh_to_face_boundaries[&tm]; Node_to_target_of_hedge_map& nodes_to_hedge=it->second; @@ -693,6 +696,7 @@ public: it=on_edge.begin(); it!=on_edge.end(); ++it) { TriangleMesh& tm=*it->first; + if (!refine_tm2 && tm2_ptr==&tm) continue; const VertexPointMap& vpm=vpms[&tm]; On_edge_map& on_edge_map=it->second; On_face_map& on_face_map=on_face[&tm]; @@ -788,6 +792,7 @@ public: it=on_face.begin(); it!=on_face.end(); ++it) { TriangleMesh& tm=*it->first; + if (!refine_tm2 && tm2_ptr==&tm) continue; const VertexPointMap& vpm=vpms[&tm]; On_face_map& on_face_map=it->second; Face_boundaries& face_boundaries=mesh_to_face_boundaries[&tm];