From 040b9ab19484010d8a5732b055420faf462a6ac5 Mon Sep 17 00:00:00 2001 From: Ivan Paden Date: Fri, 18 Aug 2023 20:17:38 +0200 Subject: [PATCH] Add precondition that sizing field and remeshing vpmap must be the same --- .../CGAL/Polygon_mesh_processing/Adaptive_sizing_field.h | 4 +++- .../CGAL/Polygon_mesh_processing/Uniform_sizing_field.h | 4 +++- .../internal/Isotropic_remeshing/Sizing_field_base.h | 2 ++ .../include/CGAL/Polygon_mesh_processing/remesh.h | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Adaptive_sizing_field.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Adaptive_sizing_field.h index 60b5e3a8855..36f714dab6e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Adaptive_sizing_field.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Adaptive_sizing_field.h @@ -223,12 +223,14 @@ public: return boost::none; } - virtual Point_3 split_placement(const halfedge_descriptor h, const PolygonMesh& pmesh) const + Point_3 split_placement(const halfedge_descriptor h, const PolygonMesh& pmesh) const { return midpoint(get(m_vpmap, target(h, pmesh)), get(m_vpmap, source(h, pmesh))); } + const DefaultVPMap& get_vpmap() const { return m_vpmap; } + void update_sizing_map(const vertex_descriptor v, const PolygonMesh& pmesh) { // calculating it as the average of two vertices on other ends diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Uniform_sizing_field.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Uniform_sizing_field.h index d22e0079d7f..46ca4c5aced 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Uniform_sizing_field.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Uniform_sizing_field.h @@ -126,12 +126,14 @@ public: return boost::none; } - virtual Point_3 split_placement(const halfedge_descriptor h, const PolygonMesh& pmesh) const + Point_3 split_placement(const halfedge_descriptor h, const PolygonMesh& pmesh) const { return midpoint(get(m_vpmap, target(h, pmesh)), get(m_vpmap, source(h, pmesh))); } + const VPMap& get_vpmap() const { return m_vpmap; } + private: FT m_sq_short; FT m_sq_long; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Sizing_field_base.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Sizing_field_base.h index 81afe3af21f..13661883b2a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Sizing_field_base.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Sizing_field_base.h @@ -53,6 +53,8 @@ public: const PolygonMesh& pmesh) const = 0; virtual Point_3 split_placement(const halfedge_descriptor h, const PolygonMesh& pmesh) const = 0; + virtual const VPMap& get_vpmap() const = 0; + }; }//end namespace CGAL diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index db036a4be6a..a36c3248db1 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -277,6 +277,9 @@ void isotropic_remeshing(const FaceRange& faces } #endif + CGAL_precondition_msg((sizing.get_vpmap()) == vpmap, "Input mesh/vertex point map is not the same as the " + "one used for sizing field. Remeshing aborted."); + #ifdef CGAL_PMP_REMESHING_VERBOSE t.stop(); std::cout << "\rRemeshing parameters done ("<< t.time() <<" sec)" << std::endl;