Skip to content
Open
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 @@ -294,6 +294,7 @@ CGAL_add_named_parameter(cell_selector_t, cell_selector, cell_is_selected_map)
CGAL_add_named_parameter(facet_is_constrained_t, facet_is_constrained, facet_is_constrained_map)
CGAL_add_named_parameter(smooth_constrained_edges_t, smooth_constrained_edges, smooth_constrained_edges)
CGAL_add_named_parameter(nb_flip_smooth_iterations_t, nb_flip_smooth_iterations, nb_flip_smooth_iterations)
CGAL_add_named_parameter(nb_smoothing_iterations_t, nb_smoothing_iterations, nb_smoothing_iterations)

// List of named parameters used in Alpha_wrap_23
CGAL_add_named_parameter(do_enforce_manifoldness_t, do_enforce_manifoldness, do_enforce_manifoldness)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ class Default_remeshing_visitor
void after_flip(CellHandle /* c */) {}
};


struct Remeshing_steps
{
bool do_split = true;
bool do_collapse = true;
bool do_flip = true;
std::size_t nb_smoothing_iterations = 1;
std::size_t nb_flip_smooth_iterations = 3;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now the following code triggers a compilation error:

    CGAL::tetrahedral_isotropic_remeshing(
          cdt,
          3 * bbox_max_span,
          CGAL::parameters::number_of_iterations(1).nb_flip_smooth_iterations(20)
          .remesh_boundaries(false));

include/CGAL/tetrahedral_remeshing.h:585:7: error: non-constant-expression cannot be narrowed from type 'int' to 'std::size_t' (aka 'unsigned long') in initializer list [-Wc++11-narrowing]

   585 |       choose_parameter(get_parameter(np, internal_np::nb_flip_smooth_iterations), std::size_t{3})};
       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A possible fix is to use 20u (of type unsigned int) instead of 20 (type int) as the value passed to nb_flip_smooth_iterations. I am not sure why. And I do not know why the parameter CGAL::parameters::number_of_iterations(1) is fine.

};

template<typename Triangulation
, typename SizingFunction
Expand Down Expand Up @@ -597,7 +604,7 @@ class Adaptive_remesher
}

void remesh(const std::size_t& max_it,
const std::size_t& nb_extra_iterations)
const Remeshing_steps& steps)
{
std::size_t it_nb = 0;
while (it_nb < max_it)
Expand All @@ -608,11 +615,20 @@ class Adaptive_remesher
#endif
if (!resolution_reached())
{
split();
collapse();
if(steps.do_split)
split();
if(steps.do_collapse)
collapse();
}
if(steps.do_flip)
flip();

std::size_t it_smoothing = 0;
while (it_smoothing < steps.nb_smoothing_iterations)
{
smooth();
++it_smoothing;
}
flip();
smooth();

#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE
std::cout << "# Iteration " << it_nb << " done : "
Expand All @@ -634,12 +650,14 @@ class Adaptive_remesher
}

m_vertex_smoother.start_flip_smooth_steps(m_c3t3);
while (it_nb < max_it + nb_extra_iterations)
while (it_nb < max_it + steps.nb_flip_smooth_iterations)
{
++it_nb;

flip();
smooth();
if(steps.do_flip)
flip();
if(steps.nb_smoothing_iterations > 0)
smooth();

#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE
std::cout << "# Iteration " << it_nb << " (flip and smooth only) done : "
Expand Down
22 changes: 14 additions & 8 deletions Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,12 @@ void tetrahedral_isotropic_remeshing(
// Advanced and non documented parameters
auto visitor = choose_parameter<typename Remesher_types::Default_Visitor>(get_parameter(np, internal_np::visitor));

auto nb_extra_iterations
= choose_parameter(get_parameter(np, internal_np::nb_flip_smooth_iterations),
std::size_t{3});
Tetrahedral_remeshing::internal::Remeshing_steps steps{
choose_parameter(get_parameter(np, internal_np::do_split), true),
choose_parameter(get_parameter(np, internal_np::do_collapse), true),
choose_parameter(get_parameter(np, internal_np::do_flip), true),
choose_parameter(get_parameter(np, internal_np::nb_smoothing_iterations), std::size_t{1}),
choose_parameter(get_parameter(np, internal_np::nb_flip_smooth_iterations), std::size_t{3})};

#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE
std::cout << "Tetrahedral remeshing ("
Expand Down Expand Up @@ -255,7 +258,7 @@ void tetrahedral_isotropic_remeshing(
nb_extra_iterations = 0;
#endif

remesher.remesh(max_it, nb_extra_iterations);
remesher.remesh(max_it, steps);

#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG
const double angle_bound = 5.0;
Expand Down Expand Up @@ -475,9 +478,12 @@ void tetrahedral_isotropic_remeshing(
auto visitor
= choose_parameter<typename Remesher_types::Default_Visitor>(get_parameter(np, internal_np::visitor));

auto nb_extra_iterations
= choose_parameter(get_parameter(np, internal_np::nb_flip_smooth_iterations),
std::size_t{3});
Tetrahedral_remeshing::internal::Remeshing_steps steps{
choose_parameter(get_parameter(np, internal_np::do_split), true),
choose_parameter(get_parameter(np, internal_np::do_collapse), true),
choose_parameter(get_parameter(np, internal_np::do_flip), true),
choose_parameter(get_parameter(np, internal_np::nb_smoothing_iterations), std::size_t{1}),
choose_parameter(get_parameter(np, internal_np::nb_flip_smooth_iterations), std::size_t{3})};

#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE
std::cout << "Tetrahedral remeshing ("
Expand Down Expand Up @@ -508,7 +514,7 @@ void tetrahedral_isotropic_remeshing(
nb_extra_iterations = 0;
#endif

remesher.remesh(max_it, nb_extra_iterations);
remesher.remesh(max_it, steps);

#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG
const double angle_bound = 5.0;
Expand Down
Loading