rename example and change it to use planar patches

instead of patches that are separated by sharp edges (which may be non planar)
This commit is contained in:
Jane Tournois 2025-06-02 15:41:07 +02:00
parent fa45ad8943
commit c1bc60b067
5 changed files with 24 additions and 73 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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)

View File

@ -1,9 +1,11 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/remesh_planar_patches.h>
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
#include <CGAL/IO/write_MEDIT.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
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<int>(), mesh);
auto plc_facet_map = get(CGAL::face_patch_id_t<int>(), 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'

View File

@ -1,54 +0,0 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/write_MEDIT.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
using Mesh = CGAL::Surface_mesh<K::Point_3>;
using face_descriptor = boost::graph_traits<Mesh>::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<int>(), 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;
}