From 9a27b92a7d775d8fc1e18282bbcf28acb65ba03f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 18 Apr 2024 12:50:20 +0200 Subject: [PATCH 1/2] NP allow_move_functor from tangential_relaxation to isotropic_remeshing this NP exists in tangential_relaxation() and we want to be able to use it in the relaxation step, from the named parameters of isotropic_remeshing() --- .../internal/Isotropic_remeshing/remesh_impl.h | 7 +++++-- .../include/CGAL/Polygon_mesh_processing/remesh.h | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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 30d201d1ef5..f98373a0424 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 @@ -1014,10 +1014,11 @@ namespace internal { // "applies an iterative smoothing filter to the mesh. // The vertex movement has to be constrained to the vertex tangent plane [...] // smoothing algorithm with uniform Laplacian weights" - template + template void tangential_relaxation_impl(const bool relax_constraints/*1d smoothing*/ , const unsigned int nb_iterations - , const SizingFunction& sizing) + , const SizingFunction& sizing + , const AllowMoveFunctor& shall_move) { #ifdef CGAL_PMP_REMESHING_VERBOSE std::cout << "Tangential relaxation (" << nb_iterations << " iter.)..."; @@ -1063,6 +1064,7 @@ namespace internal { .edge_is_constrained_map(constrained_edges_pmap) .vertex_is_constrained_map(constrained_vertices_pmap) .relax_constraints(relax_constraints) + .allow_move_functor(shall_move) ); } else @@ -1081,6 +1083,7 @@ namespace internal { .vertex_is_constrained_map(constrained_vertices_pmap) .relax_constraints(relax_constraints) .sizing_function(sizing) + .allow_move_functor(shall_move) ); } 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 7c5ff9ab261..3022b825d20 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -267,6 +268,9 @@ void isotropic_remeshing(const FaceRange& faces #endif ) ) ); + auto shall_move = choose_parameter(get_parameter(np, internal_np::allow_move_functor), + internal::Allow_all_moves()); + #if !defined(CGAL_NO_PRECONDITIONS) if(protect) { @@ -322,7 +326,7 @@ void isotropic_remeshing(const FaceRange& faces remesher.collapse_short_edges(sizing, collapse_constraints); if(do_flip) remesher.flip_edges_for_valence_and_shape(); - remesher.tangential_relaxation_impl(smoothing_1d, nb_laplacian, sizing); + remesher.tangential_relaxation_impl(smoothing_1d, nb_laplacian, sizing, shall_move); if ( choose_parameter(get_parameter(np, internal_np::do_project), true) ) remesher.project_to_surface(get_parameter(np, internal_np::projection_functor)); #ifdef CGAL_PMP_REMESHING_VERBOSE From 96d8e1a5f69b9b453e9c8ade17798316471c8f46 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 18 Apr 2024 12:55:31 +0200 Subject: [PATCH 2/2] document NP allow_move_functor --- .../include/CGAL/Polygon_mesh_processing/remesh.h | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 3022b825d20..0a0fdfb4504 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -171,6 +171,16 @@ namespace Polygon_mesh_processing { * \cgalParamDefault{`false`} * \cgalParamNEnd * +* \cgalParamNBegin{allow_move_functor} +* \cgalParamDescription{A function object used to determinate if a vertex move should +* be allowed or not during the relaxation step.} +* \cgalParamType{Unary functor that provides `bool operator()(vertex_descriptor v, Point_3 src, Point_3 tgt)` +* returning `true` +* if the vertex `v` can be moved from `src` to `tgt`; +* `%Point_3` being the value type of the vertex point map } +* \cgalParamDefault{If not provided, all moves are allowed.} +* \cgalParamNEnd +* * \cgalParamNBegin{do_project} * \cgalParamDescription{whether vertices should be reprojected on the input surface after creation or displacement} * \cgalParamType{Boolean}