fix the example

This commit is contained in:
Laurent Rineau 2025-05-28 10:21:38 +02:00
parent bdd7988a4a
commit e955df4e28
1 changed files with 8 additions and 5 deletions

View File

@ -26,7 +26,7 @@ int main(int argc, char* argv[])
std::cout << "Read " << mesh.number_of_vertices() << " vertices and " std::cout << "Read " << mesh.number_of_vertices() << " vertices and "
<< mesh.number_of_faces() << " facets\n"; << mesh.number_of_faces() << " facets\n";
auto [face_patch_map, _] =mesh.add_property_map<face_descriptor, int>("f:patch_id", -1); auto [face_patch_map, _] =mesh.add_property_map<face_descriptor, std::size_t>("f:patch_id");
const auto bbox = CGAL::Polygon_mesh_processing::bbox(mesh); const auto bbox = CGAL::Polygon_mesh_processing::bbox(mesh);
const double bbox_max_span = (std::max)({bbox.x_span(), bbox.y_span(), bbox.z_span()}); const double bbox_max_span = (std::max)({bbox.x_span(), bbox.y_span(), bbox.z_span()});
@ -38,7 +38,7 @@ int main(int argc, char* argv[])
CGAL::parameters::maximum_distance(bbox_max_span * 1.e-6).maximum_angle(5.)); CGAL::parameters::maximum_distance(bbox_max_span * 1.e-6).maximum_angle(5.));
for(auto f: faces(mesh)) { for(auto f: faces(mesh)) {
// if region growing did not assign a patch id, assign one // if region growing did not assign a patch id, assign one
if(get(face_patch_map, f) < 0) { if(get(face_patch_map, f) == static_cast<std::size_t>(-1)) {
put(face_patch_map, f, number_of_patches++); put(face_patch_map, f, number_of_patches++);
} }
} }
@ -46,8 +46,11 @@ int main(int argc, char* argv[])
std::cout << "Number of patches: " << number_of_patches << std::endl; std::cout << "Number of patches: " << number_of_patches << std::endl;
filename = argc > 2 ? argv[2] : "mesh.ply"; 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,
std::cout << "Wrote segmented mesh to " << filename << "\n"; CGAL::parameters::stream_precision(17)
.use_binary_mode(false)
.face_patch_map(face_patch_map));
std::cout << "-- Wrote segmented mesh to \"" << filename << "\"\n";
auto ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(mesh, auto ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(mesh,
CGAL::parameters::face_patch_map(face_patch_map)); CGAL::parameters::face_patch_map(face_patch_map));
@ -61,7 +64,7 @@ int main(int argc, char* argv[])
std::ofstream out(filename); std::ofstream out(filename);
out.precision(17); out.precision(17);
CGAL::IO::write_MEDIT(out, ccdt); CGAL::IO::write_MEDIT(out, ccdt);
std::cout << "Wrote CDT to " << filename << "\n"; std::cout << "-- Wrote CDT to \"" << filename << "\"\n";
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }