From 86bf5305c85e93fc79e31897fb75a90f7ff14adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 25 Apr 2024 20:50:07 +0200 Subject: [PATCH] add a way to collect input coplanar faces after corefinement --- .../Concepts/PMPCorefinementVisitor.h | 3 ++ .../Corefinement/Face_graph_output_builder.h | 28 +++++++++++++++++++ .../internal/Corefinement/face_graph_utils.h | 1 + 3 files changed, 32 insertions(+) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPCorefinementVisitor.h b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPCorefinementVisitor.h index 19e0dd098cf..68f37da7ad8 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPCorefinementVisitor.h +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPCorefinementVisitor.h @@ -119,6 +119,9 @@ public: /// The point has already been put in the vertex point map. void after_vertex_copy(vertex_descriptor v_src, const Triangle_mesh& tm_src, vertex_descriptor v_tgt, const Triangle_mesh& tm_tgt); + /// called for each face `f` in the output mesh `tm` that belongs to the intersection of two coplanar faces of the input meshes. + void input_coplanar_face(face_descriptor f, TriangleMesh& tm); + /// @} /// @name Functions used by corefine() for progress tracking diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index 60e20772372..9740c9cb832 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -2131,6 +2131,34 @@ public: Patches1 patches_of_tm1(tm1, tm1_patch_ids, fids1, intersection_edges1, nb_patches_tm1); Patches2 patches_of_tm2(tm2, tm2_patch_ids, fids2, intersection_edges2, nb_patches_tm2); + // report input coplanar faces + if (coplanar_patches_of_tm1.any()) + { + for (std::size_t i = coplanar_patches_of_tm1.find_first(); + i < coplanar_patches_of_tm1.npos; + i = coplanar_patches_of_tm1.find_next(i)) + { + + for (face_descriptor f : patches_of_tm1[i].faces) + { + user_visitor.input_coplanar_face(f, tm1); + } + } + } + if (coplanar_patches_of_tm2.any()) + { + for (std::size_t i = coplanar_patches_of_tm2.find_first(); + i < coplanar_patches_of_tm2.npos; + i = coplanar_patches_of_tm2.find_next(i)) + { + + for (face_descriptor f : patches_of_tm2[i].faces) + { + user_visitor.input_coplanar_face(f, tm2); + } + } + } + // for each boolean operation, define two bitsets of patches contributing // to the result std::vector< boost::dynamic_bitset<> > patches_of_tm1_used(4); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h index ef7db058587..e30096dfdad 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h @@ -428,6 +428,7 @@ struct Default_visitor{ void before_face_copy(face_descriptor /*f_old*/, const TriangleMesh&, TriangleMesh&){} void after_face_copy(face_descriptor /*f_old*/, const TriangleMesh&, face_descriptor /* f_new */, TriangleMesh&){} + void input_coplanar_face(face_descriptor /*f*/, TriangleMesh&) {} // edge visitor functions void before_edge_split(halfedge_descriptor /* h */, TriangleMesh& /* tm */){} void edge_split(halfedge_descriptor /* hnew */, TriangleMesh& /* tm */){}