Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMP::isotropic_remeshing() - add NP allow move functor #8150

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class SizingFunction>
template <class SizingFunction, typename AllowMoveFunctor>
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.)...";
Expand Down Expand Up @@ -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
Expand All @@ -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)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h>
#include <CGAL/Polygon_mesh_processing/Uniform_sizing_field.h>
#include <CGAL/Polygon_mesh_processing/tangential_relaxation.h>

#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
Expand Down Expand Up @@ -170,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)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the sentence itself contradicts the word "Unary" (that would take one parameter). That is not a unary functor.

Oops

* 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}
Expand Down Expand Up @@ -267,6 +278,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)
{
Expand Down Expand Up @@ -322,7 +336,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
Expand Down