From 4c462898a8ea6909613b8e01d2433b6f538d5ec2 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 3 Jun 2025 14:06:11 +0200 Subject: [PATCH] fix compilation of PMP::isotropic_remeshing with Epeck and add a test to avoid future regressions --- .../Isotropic_remeshing/remesh_impl.h | 21 +++++++------ .../Polygon_mesh_processing/CMakeLists.txt | 1 + .../remeshing_test_epeck.cpp | 31 +++++++++++++++++++ 3 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_epeck.cpp diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index 776f5654879..6dc9ea082ff 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -271,6 +271,7 @@ namespace internal { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Point_3 Point; typedef typename GeomTraits::Vector_3 Vector_3; typedef typename GeomTraits::Plane_3 Plane_3; @@ -488,7 +489,7 @@ namespace internal { std::cout << "Split long edges..." << std::endl; #endif //collect long edges - typedef std::pair H_and_sql; + typedef std::pair H_and_sql; std::multiset< H_and_sql, std::function > long_edges( [](const H_and_sql& p1, const H_and_sql& p2) @@ -500,7 +501,7 @@ namespace internal { if (!is_split_allowed(e)) continue; const halfedge_descriptor he = halfedge(e, mesh_); - std::optional sqlen = sizing.is_too_long(source(he, mesh_), target(he, mesh_), mesh_); + std::optional sqlen = sizing.is_too_long(source(he, mesh_), target(he, mesh_), mesh_); if(sqlen != std::nullopt) long_edges.emplace(halfedge(e, mesh_), sqlen.value()); } @@ -554,7 +555,7 @@ namespace internal { //check sub-edges //if it was more than twice the "long" threshold, insert them - std::optional sqlen_new = sizing.is_too_long(source(hnew, mesh_), target(hnew, mesh_), mesh_); + std::optional sqlen_new = sizing.is_too_long(source(hnew, mesh_), target(hnew, mesh_), mesh_); if(sqlen_new != std::nullopt) long_edges.emplace(hnew, sqlen_new.value()); @@ -580,7 +581,7 @@ namespace internal { if (snew == PATCH) { - std::optional sql = sizing.is_too_long(source(hnew2, mesh_), target(hnew2, mesh_), mesh_); + std::optional sql = sizing.is_too_long(source(hnew2, mesh_), target(hnew2, mesh_), mesh_); if(sql != std::nullopt) long_edges.emplace(hnew2, sql.value()); } @@ -603,7 +604,7 @@ namespace internal { if (snew == PATCH) { - std::optional sql = sizing.is_too_long(source(hnew2, mesh_), target(hnew2, mesh_), mesh_); + std::optional sql = sizing.is_too_long(source(hnew2, mesh_), target(hnew2, mesh_), mesh_); if (sql != std::nullopt) long_edges.emplace(hnew2, sql.value()); } @@ -633,7 +634,7 @@ namespace internal { { typedef boost::bimap< boost::bimaps::set_of, - boost::bimaps::multiset_of > > Boost_bimap; + boost::bimaps::multiset_of > > Boost_bimap; typedef typename Boost_bimap::value_type short_edge; #ifdef CGAL_PMP_REMESHING_VERBOSE @@ -648,7 +649,7 @@ namespace internal { Boost_bimap short_edges; for(edge_descriptor e : edges(mesh_)) { - std::optional sqlen = sizing.is_too_short(halfedge(e, mesh_), mesh_); + std::optional sqlen = sizing.is_too_short(halfedge(e, mesh_), mesh_); if(sqlen != std::nullopt && is_collapse_allowed(e, collapse_constraints)) short_edges.insert(short_edge(halfedge(e, mesh_), sqlen.value())); @@ -747,7 +748,7 @@ namespace internal { for(halfedge_descriptor ha : halfedges_around_target(va, mesh_)) { vertex_descriptor va_i = source(ha, mesh_); - std::optional sqha = sizing.is_too_long(vb, va_i, mesh_); + std::optional sqha = sizing.is_too_long(vb, va_i, mesh_); if (sqha != std::nullopt) { collapse_ok = false; @@ -813,7 +814,7 @@ namespace internal { //insert new/remaining short edges for (halfedge_descriptor ht : halfedges_around_target(vkept, mesh_)) { - std::optional sqlen = sizing.is_too_short(ht, mesh_); + std::optional sqlen = sizing.is_too_short(ht, mesh_); if (sqlen != std::nullopt && is_collapse_allowed(edge(ht, mesh_), collapse_constraints)) short_edges.insert(short_edge(ht, sqlen.value())); @@ -1795,7 +1796,7 @@ private: //insert new edges in 'short_edges' if (is_collapse_allowed(edge(hf, mesh_), collapse_constraints)) { - std::optional sqlen = sizing.is_too_short(hf, mesh_); + std::optional sqlen = sizing.is_too_short(hf, mesh_); if (sqlen != std::nullopt) short_edges.insert(typename Bimap::value_type(hf, sqlen.value())); } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 30461cd0104..ae022fcd4ea 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -26,6 +26,7 @@ create_single_source_cgal_program("pmp_do_intersect_test.cpp") create_single_source_cgal_program("test_is_polygon_soup_a_polygon_mesh.cpp") create_single_source_cgal_program("test_stitching.cpp") create_single_source_cgal_program("remeshing_test.cpp") +create_single_source_cgal_program("remeshing_test_epeck.cpp") create_single_source_cgal_program("remeshing_with_isolated_constraints_test.cpp" ) create_single_source_cgal_program("measures_test.cpp") create_single_source_cgal_program("triangulate_faces_test.cpp") diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_epeck.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_epeck.cpp new file mode 100644 index 00000000000..f49da0c58ca --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_epeck.cpp @@ -0,0 +1,31 @@ +#include + +#include + +#include + +#include +#include + +namespace PMP = CGAL::Polygon_mesh_processing; + +using Epeck = CGAL::Exact_predicates_exact_constructions_kernel; +using Mesh = CGAL::Surface_mesh; + +int main(int argc, const char* argv[]) +{ + const std::string filename = (argc < 2) ? CGAL::data_file_path("meshes/sphere.off") : argv[1]; + + std::ifstream input(filename); + Mesh mesh; + if (!input || !(input >> mesh)) + { + std::cerr << "Error: cannot read surface mesh : " << filename << "\n"; + assert(false); + } + + double target_edge_length = 1.0; + PMP::isotropic_remeshing(CGAL::faces(mesh), target_edge_length, mesh); + + return 0; +}