From c1bc60b067686ad884830bac733012a9fa183379 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 2 Jun 2025 15:41:07 +0200 Subject: [PATCH] rename example and change it to use planar patches instead of patches that are separated by sharp edges (which may be non planar) --- .../Constrained_triangulation_3.txt | 7 +-- .../Constrained_triangulation_3/examples.txt | 2 +- .../CMakeLists.txt | 2 +- ...trained_Delaunay_triangulation_3_fimap.cpp | 32 ++++++----- ...trained_Delaunay_triangulation_3_fpmap.cpp | 54 ------------------- 5 files changed, 24 insertions(+), 73 deletions(-) delete mode 100644 Constrained_triangulation_3/examples/Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fpmap.cpp diff --git a/Constrained_triangulation_3/doc/Constrained_triangulation_3/Constrained_triangulation_3.txt b/Constrained_triangulation_3/doc/Constrained_triangulation_3/Constrained_triangulation_3.txt index 611a60a586b..0d7ef113ef7 100644 --- a/Constrained_triangulation_3/doc/Constrained_triangulation_3/Constrained_triangulation_3.txt +++ b/Constrained_triangulation_3/doc/Constrained_triangulation_3/Constrained_triangulation_3.txt @@ -183,18 +183,19 @@ following example demonstrates how to build such a triangulation. \subsection CT_3_example_ccdt_fpmap Build a Conforming Constrained Delaunay Triangulation with Known Polygon Identifiers -If the user already knows the set of polygon identifiers to associate with each facet, this information can be +If the user already knows the set of polygon identifiers to associate with each PLC facet, this information can be provided and preserved throughout the construction of the conforming constrained Delaunay triangulation. -The following example demonstrates how to detect surface patches separated by sharp edges and use +The following example demonstrates how to detect planar surface patches, remesh them as coarsely +as possible, and use this segmentation during the tetrahedralization process. When the named parameter `plc_facet_id` is specified, each constrained facet in the 3D triangulation is assigned to the corresponding input PLC facet, identified in the provided property map. If this parameter is not specified, each input polygon, or PLC facet, is given a unique facet index. -\cgalExample{Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fpmap.cpp} +\cgalExample{Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fimap.cpp} \cgalFigureRef{CT_3_ccdt_fpmap_fig} shows the input and output of this triangulation construction example. diff --git a/Constrained_triangulation_3/doc/Constrained_triangulation_3/examples.txt b/Constrained_triangulation_3/doc/Constrained_triangulation_3/examples.txt index 1010a05ab7c..f6656faf359 100644 --- a/Constrained_triangulation_3/doc/Constrained_triangulation_3/examples.txt +++ b/Constrained_triangulation_3/doc/Constrained_triangulation_3/examples.txt @@ -32,7 +32,7 @@ constrained Delaunay conforming_constrained_Delaunay_triangulation_3_from_soup. */ /*! -\example Constrained_triangulation_3/ccdt_3_from_soup_fpmap.cpp +\example Constrained_triangulation_3/ccdt_3_from_soup_fimap.cpp @brief From a non-manifold OFF file, construct the constrained Delaunay triangulation. diff --git a/Constrained_triangulation_3/examples/Constrained_triangulation_3/CMakeLists.txt b/Constrained_triangulation_3/examples/Constrained_triangulation_3/CMakeLists.txt index e16d3547b3d..36167f8f346 100644 --- a/Constrained_triangulation_3/examples/Constrained_triangulation_3/CMakeLists.txt +++ b/Constrained_triangulation_3/examples/Constrained_triangulation_3/CMakeLists.txt @@ -9,7 +9,7 @@ include(CGAL_Eigen3_support) add_compile_definitions(QT_NO_KEYWORDS) create_single_source_cgal_program(conforming_constrained_Delaunay_triangulation_3.cpp) -create_single_source_cgal_program(conforming_constrained_Delaunay_triangulation_3_fpmap.cpp) +create_single_source_cgal_program(conforming_constrained_Delaunay_triangulation_3_fimap.cpp) create_single_source_cgal_program(conforming_constrained_Delaunay_triangulation_3_from_soup.cpp) create_single_source_cgal_program(ccdt_3_from_soup_fpmap.cpp) create_single_source_cgal_program(ccdt_3_after_autorefinement.cpp) diff --git a/Constrained_triangulation_3/examples/Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fimap.cpp b/Constrained_triangulation_3/examples/Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fimap.cpp index 923762d3e8f..0d9f3e42199 100644 --- a/Constrained_triangulation_3/examples/Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fimap.cpp +++ b/Constrained_triangulation_3/examples/Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fimap.cpp @@ -1,9 +1,11 @@ #include + +#include +#include +#include + #include #include -#include -#include -#include using K = CGAL::Exact_predicates_inexact_constructions_kernel; @@ -16,28 +18,30 @@ int main(int argc, char* argv[]) { std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cross_quad.off"); - Mesh mesh; - if(!PMP::IO::read_polygon_mesh(filename, mesh)) { + Mesh input; + if(!PMP::IO::read_polygon_mesh(filename, input)) { std::cerr << "Invalid input." << std::endl; return 1; } - std::cout << "Read " << mesh.number_of_vertices() << " vertices and " - << mesh.number_of_faces() << " facets\n"; + std::cout << "Read " << input.number_of_vertices() << " vertices and " + << input.number_of_faces() << " facets\n"; - auto edge_is_feature_map = get(CGAL::edge_is_feature, mesh); - auto face_patch_map = get(CGAL::face_patch_id_t(), mesh); + auto plc_facet_map = get(CGAL::face_patch_id_t(), input); - std::size_t number_of_patches = PMP::sharp_edges_segmentation(mesh, 10, edge_is_feature_map, face_patch_map); - - std::cout << "Number of patches: " << number_of_patches << std::endl; + Mesh mesh; + PMP::remesh_planar_patches(input, mesh, + CGAL::parameters::default_values(), + CGAL::parameters::face_patch_map(plc_facet_map) + .do_not_triangulate_faces(true)); filename = argc > 2 ? argv[2] : "mesh.ply"; - CGAL::IO::write_polygon_mesh(filename, mesh, CGAL::parameters::stream_precision(17)); + CGAL::IO::write_polygon_mesh(filename, mesh, + CGAL::parameters::stream_precision(17)); std::cout << "Wrote segmented mesh to " << filename << "\n"; auto ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(mesh, - CGAL::parameters::plc_facet_id(face_patch_map)); + CGAL::parameters::plc_facet_id(plc_facet_map)); std::cout << "Number of vertices in the CDT: " << ccdt.triangulation().number_of_vertices() << '\n' diff --git a/Constrained_triangulation_3/examples/Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fpmap.cpp b/Constrained_triangulation_3/examples/Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fpmap.cpp deleted file mode 100644 index 923762d3e8f..00000000000 --- a/Constrained_triangulation_3/examples/Constrained_triangulation_3/conforming_constrained_Delaunay_triangulation_3_fpmap.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include -#include -#include - -using K = CGAL::Exact_predicates_inexact_constructions_kernel; - -using Mesh = CGAL::Surface_mesh; -using face_descriptor = boost::graph_traits::face_descriptor; - -namespace PMP = CGAL::Polygon_mesh_processing; - -int main(int argc, char* argv[]) -{ - std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cross_quad.off"); - - Mesh mesh; - if(!PMP::IO::read_polygon_mesh(filename, mesh)) { - std::cerr << "Invalid input." << std::endl; - return 1; - } - - std::cout << "Read " << mesh.number_of_vertices() << " vertices and " - << mesh.number_of_faces() << " facets\n"; - - auto edge_is_feature_map = get(CGAL::edge_is_feature, mesh); - auto face_patch_map = get(CGAL::face_patch_id_t(), mesh); - - std::size_t number_of_patches = PMP::sharp_edges_segmentation(mesh, 10, edge_is_feature_map, face_patch_map); - - std::cout << "Number of patches: " << number_of_patches << std::endl; - - filename = argc > 2 ? argv[2] : "mesh.ply"; - CGAL::IO::write_polygon_mesh(filename, mesh, CGAL::parameters::stream_precision(17)); - std::cout << "Wrote segmented mesh to " << filename << "\n"; - - auto ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(mesh, - CGAL::parameters::plc_facet_id(face_patch_map)); - - std::cout << "Number of vertices in the CDT: " - << ccdt.triangulation().number_of_vertices() << '\n' - << "Number of constrained facets in the CDT: " - << ccdt.number_of_constrained_facets() << '\n'; - - filename = argc > 3 ? argv[3] : "out.mesh"; - std::ofstream out(filename); - out.precision(17); - CGAL::IO::write_MEDIT(out, ccdt, CGAL::parameters::with_plc_facet_id(true)); - std::cout << "Wrote CDT to " << filename << "\n"; - - return EXIT_SUCCESS; -}