From cd8d67be5d4c4e855799c0b89426972e426910b2 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 5 Nov 2026 16:35:46 +0100 Subject: [PATCH 01/21] add edges(facet) to T3 for readability --- TDS_3/include/CGAL/Triangulation_data_structure_3.h | 7 +++++++ Triangulation_3/include/CGAL/Triangulation_3.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index 40348035b8f8..f443bb20c2c8 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -1634,6 +1634,13 @@ class Triangulation_data_structure_3 c->vertex(2), c->vertex(3)}; } + static std::array edges(const Facet& f) + { + return std::array{ + Edge(f.first, vertex_triple_index(f.second, 0), vertex_triple_index(f.second, 1)), + Edge(f.first, vertex_triple_index(f.second, 0), vertex_triple_index(f.second, 2)), + Edge(f.first, vertex_triple_index(f.second, 1), vertex_triple_index(f.second, 2))}; + } bool is_small_hole(std::size_t s) { diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index c1edf17efb36..9a1908b29c71 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -1948,6 +1948,12 @@ class Triangulation_3 return Tds::vertices(c); } + /// Edges around a facet + static std::array edges(const Facet& f) + { + return Tds::edges(f); + } + // cells around an edge Cell_circulator incident_cells(const Edge& e) const { From d5f8d91135484400fb92a82497d974dd181fbfe0 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 5 Nov 2026 16:37:10 +0100 Subject: [PATCH 02/21] add new facet criterion to bound approximate normal variation between 2 adjacent complex facets that are not separated by a complex edge --- .../Mesh_3/mesh_standard_facet_criteria.h | 106 ++++++++++++++++++ Mesh_3/include/CGAL/Mesh_facet_criteria_3.h | 19 +++- 2 files changed, 122 insertions(+), 3 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h index 798fc30a2ea2..18d00155fe5a 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h @@ -25,6 +25,7 @@ #include #include +#include #include // for to_double @@ -638,7 +639,112 @@ public Mesh_3::Abstract_criterion }; // end class Facet_on_same_surface_criterion +template +class Facet_normals_variation_criterion +: public Mesh_3::Abstract_criterion +{ + typedef typename C3T3::Triangulation Tr; + typedef typename Tr::Geom_traits::FT FT; + typedef typename Tr::Geom_traits::Vector_3 Vector_3; + + typedef typename Tr::Cell_handle Cell_handle; + typedef typename Tr::Facet Facet; + typedef typename Tr::Edge Edge; + typedef typename Tr::Triangle Triangle; + + typedef Mesh_3::Abstract_criterion Base; + typedef typename Base::Quality Quality; + typedef typename Base::Is_bad Is_bad; + + typedef Facet_normals_variation_criterion Self; + +public: + /// Constructor + Facet_normals_variation_criterion(const FT& bound_degrees) + { + const FT bound_rad = bound_degrees * CGAL_PI / 180.0; + + // theoretical bound for the squared Euclidean distance between two unit normals + // is 2 * sin(theta / 2) + const double sin_half = std::sin(CGAL::to_double(bound_rad) * 0.5); + sq_distance_theoretical_bound_ = CGAL::square( FT(2. * sin_half) ); + } + + /// Destructor + virtual ~Facet_normals_variation_criterion() {} + +protected: + virtual void do_accept(Visitor_& v) const { v.visit(*this); } + + virtual Self* do_clone() const + { + // Call copy ctor on this + return new Self(*this); + } + + virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const + { + const Tr& tr = c3t3.triangulation(); + auto scale = tr.geom_traits().construct_scaled_vector_3_object(); + auto normal = tr.geom_traits().construct_normal_3_object(); + auto diff_vec = tr.geom_traits().construct_difference_of_vectors_3_object(); + + auto unit_normal = [&](const Facet& f) -> Vector_3 + { + auto normal = tr.geom_traits().construct_normal_3_object(); + const auto& t = tr.triangle(f); + + Vector_3 n = normal(t[0], t[1], t[2]); + return scale(n, FT(1) / CGAL::sqrt(n.squared_length())); + }; + + // compute n1 = unit normal to f + const Vector_3 n1 = unit_normal(f); + + // for each of the 3 neighboring facets, compute unit normal n2 and compare with n1 + for(const Edge& e : tr.edges(f)) + { + if(c3t3.is_in_complex(e)) + continue; + + const auto& [vs, vt] = tr.vertices(e); + Cell_handle cell = e.first; + do + { + unsigned int next_index + = CGAL::Triangulation_utils_3::next_around_edge(cell->index(vs), cell->index(vt)); + + if(c3t3.is_in_complex(cell, next_index)) + { + Facet f2(cell, next_index); + Vector_3 n2 = unit_normal(f2); + + // compute squared distance ||n1 - n2||^2 + const Vector_3 diff = diff_vec(n1, n2); + const double sqd = diff.squared_length(); + + if(sqd > sq_distance_theoretical_bound_) + { +#ifdef CGAL_MESH_3_DEBUG_FACET_CRITERIA + std::cerr << "Bad facet (normal variation criterion: " + << sqd << " > " << sq_distance_theoretical_bound_ << ")" << std::endl; +#endif + return Is_bad(Quality(sqd)); + } + } + + cell = cell->neighbor(next_index); + } + while(cell != e.first); + } + + return Is_bad(); + } + +private: + FT sq_distance_theoretical_bound_; +}; // end class Facet_normals_variation_criterion template class Facet_criterion_visitor diff --git a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h index db4dff0610e9..6687fe12fa48 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h @@ -106,6 +106,8 @@ class Mesh_facet_criteria_3 \param min_radius_bound is a uniform lower bound for the radius of the surface Delaunay balls. Only facets with a radius larger than that bound will be refined. + \param normals_variation_bound in degrees, between 2 neighbor + facets of the complex, separated by a non-complex edge @note If one parameter is set to 0, then its corresponding criterion is ignored. @@ -114,11 +116,11 @@ class Mesh_facet_criteria_3 const FT& radius_bound, const FT& distance_bound, const Mesh_facet_topology topology = FACET_VERTICES_ON_SURFACE, - const FT& min_radius_bound = 0.); + const FT& min_radius_bound = 0., + const FT& normals_variation_bound = 50.); #endif - /*! Returns an object to serve as criteria for facets. The types `SizingField` and `DistanceField` must @@ -131,7 +133,8 @@ class Mesh_facet_criteria_3 const SizingField & radius_bound, const DistanceField& distance_bound, const Mesh_facet_topology topology = FACET_VERTICES_ON_SURFACE, - const FT& min_radius_bound = 0.) + const FT& min_radius_bound = 0., + const FT& normals_variation_bound = 50.) : squared_min_radius_bound_(std::nullopt) { if (FT(0) != min_radius_bound) @@ -150,6 +153,8 @@ class Mesh_facet_criteria_3 Mesh_3::Is_mesh_domain_field_3()); init_topo(topology); + + init_normals_variation(normals_variation_bound); } /// @} @@ -255,6 +260,14 @@ class Mesh_facet_criteria_3 } } + void init_normals_variation(const FT& normals_variation_bound) + { + if(FT(0) == normals_variation_bound) + return; + typedef Mesh_3::Facet_normals_variation_criterion Nvar_criterion; + criteria_.add(new Nvar_criterion(normals_variation_bound)); + } + private: Criteria criteria_; Mesh_facet_topology topology_; From bc20a6f0fe45c6ffd0cbbac5d464bbbece2ddae9 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 5 Nov 2026 17:41:32 +0100 Subject: [PATCH 03/21] remove duplicate normal() and add debug code --- .../CGAL/Mesh_3/mesh_standard_facet_criteria.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h index 18d00155fe5a..ebcd34892f42 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h @@ -684,16 +684,18 @@ class Facet_normals_variation_criterion virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { + CGAL_assertion(c3t3.is_in_complex(f)); + CGAL_assertion(sq_distance_theoretical_bound_ > FT(0)); + const Tr& tr = c3t3.triangulation(); - auto scale = tr.geom_traits().construct_scaled_vector_3_object(); - auto normal = tr.geom_traits().construct_normal_3_object(); auto diff_vec = tr.geom_traits().construct_difference_of_vectors_3_object(); auto unit_normal = [&](const Facet& f) -> Vector_3 { auto normal = tr.geom_traits().construct_normal_3_object(); - const auto& t = tr.triangle(f); + auto scale = tr.geom_traits().construct_scaled_vector_3_object(); + const auto& t = tr.triangle(f); Vector_3 n = normal(t[0], t[1], t[2]); return scale(n, FT(1) / CGAL::sqrt(n.squared_length())); }; @@ -725,6 +727,9 @@ class Facet_normals_variation_criterion if(sqd > sq_distance_theoretical_bound_) { + const auto& t = tr.triangle(f); + std::cout << t[0] << " " << t[1] << " " << t[2] << " " << t[0] << std::endl; + #ifdef CGAL_MESH_3_DEBUG_FACET_CRITERIA std::cerr << "Bad facet (normal variation criterion: " << sqd << " > " << sq_distance_theoretical_bound_ << ")" << std::endl; From fd25d10b6772e188527e1962f281fb3dc74b5d4e Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 9 Nov 2026 15:21:17 +0100 Subject: [PATCH 04/21] keep orientation consistent --- TDS_3/include/CGAL/Triangulation_data_structure_3.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index f443bb20c2c8..b24342e34344 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -1636,10 +1636,11 @@ class Triangulation_data_structure_3 } static std::array edges(const Facet& f) { + const int i = f.second; return std::array{ - Edge(f.first, vertex_triple_index(f.second, 0), vertex_triple_index(f.second, 1)), - Edge(f.first, vertex_triple_index(f.second, 0), vertex_triple_index(f.second, 2)), - Edge(f.first, vertex_triple_index(f.second, 1), vertex_triple_index(f.second, 2))}; + Edge(f.first, vertex_triple_index(i, 0), vertex_triple_index(i, 1)), + Edge(f.first, vertex_triple_index(i, 1), vertex_triple_index(i, 2)), + Edge(f.first, vertex_triple_index(i, 2), vertex_triple_index(i, 0))}; } bool is_small_hole(std::size_t s) From 10c9ff04148f85777e3d3b6108a0c2b1eaee3f76 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 9 Nov 2026 15:26:52 +0100 Subject: [PATCH 05/21] add Facet_normals_variation_criterion and a simple implementation checking if 2 neighbor normals have dot product >= 0 --- .../Mesh_3/mesh_standard_facet_criteria.h | 75 ++++++++++++------- Mesh_3/include/CGAL/Mesh_criteria_3.h | 3 +- Mesh_3/include/CGAL/Mesh_facet_criteria_3.h | 4 +- .../internal/parameters_interface.h | 1 + 4 files changed, 51 insertions(+), 32 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h index ebcd34892f42..470ad9457ed4 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h @@ -650,7 +650,6 @@ class Facet_normals_variation_criterion typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Facet Facet; typedef typename Tr::Edge Edge; - typedef typename Tr::Triangle Triangle; typedef Mesh_3::Abstract_criterion Base; typedef typename Base::Quality Quality; @@ -661,14 +660,8 @@ class Facet_normals_variation_criterion public: /// Constructor Facet_normals_variation_criterion(const FT& bound_degrees) - { - const FT bound_rad = bound_degrees * CGAL_PI / 180.0; - - // theoretical bound for the squared Euclidean distance between two unit normals - // is 2 * sin(theta / 2) - const double sin_half = std::sin(CGAL::to_double(bound_rad) * 0.5); - sq_distance_theoretical_bound_ = CGAL::square( FT(2. * sin_half) ); - } + : cosine_bound_(std::cos(bound_degrees * CGAL_PI / 180.0)) + {} /// Destructor virtual ~Facet_normals_variation_criterion() {} @@ -685,10 +678,14 @@ class Facet_normals_variation_criterion virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { CGAL_assertion(c3t3.is_in_complex(f)); - CGAL_assertion(sq_distance_theoretical_bound_ > FT(0)); + CGAL_assertion(cosine_bound_ <= FT(1)); + + using T3_utils = CGAL::Triangulation_utils_3; const Tr& tr = c3t3.triangulation(); - auto diff_vec = tr.geom_traits().construct_difference_of_vectors_3_object(); + auto compare_angle = tr.geom_traits().compare_angle_3_object(); + auto scalar_product = tr.geom_traits().compute_scalar_product_3_object(); + auto opp = tr.geom_traits().construct_opposite_vector_3_object(); auto unit_normal = [&](const Facet& f) -> Vector_3 { @@ -701,53 +698,73 @@ class Facet_normals_variation_criterion }; // compute n1 = unit normal to f - const Vector_3 n1 = unit_normal(f); + const Facet& start_facet = f; + const Vector_3 start_normal = unit_normal(start_facet); - // for each of the 3 neighboring facets, compute unit normal n2 and compare with n1 + // for each of the 3 neighboring facets, compute unit normal n2 and compare with nf for(const Edge& e : tr.edges(f)) { if(c3t3.is_in_complex(e)) continue; const auto& [vs, vt] = tr.vertices(e); - Cell_handle cell = e.first; + + Cell_handle cell = start_facet.first; do { - unsigned int next_index - = CGAL::Triangulation_utils_3::next_around_edge(cell->index(vs), cell->index(vt)); + int next_index = T3_utils::next_around_edge(cell->index(vs), cell->index(vt)); + + if(cell->neighbor(next_index) == f.first) + break; // we have come back to the original facet, stop if(c3t3.is_in_complex(cell, next_index)) { Facet f2(cell, next_index); - Vector_3 n2 = unit_normal(f2); - // compute squared distance ||n1 - n2||^2 - const Vector_3 diff = diff_vec(n1, n2); - const double sqd = diff.squared_length(); + const Vector_3 n2 = unit_normal(f2); - if(sqd > sq_distance_theoretical_bound_) + if(scalar_product(start_normal, n2) < 0.) { - const auto& t = tr.triangle(f); - std::cout << t[0] << " " << t[1] << " " << t[2] << " " << t[0] << std::endl; - #ifdef CGAL_MESH_3_DEBUG_FACET_CRITERIA - std::cerr << "Bad facet (normal variation criterion: " - << sqd << " > " << sq_distance_theoretical_bound_ << ")" << std::endl; + std::cerr << "Bad facet (normals are opposite)" << std::endl; #endif - return Is_bad(Quality(sqd)); + return Is_bad(Quality(1)); } + +// const auto& vf = tr.vertices(f); +// const auto& vf2 = tr.vertices(f2); +// // compare the angle between the two normals, using the 3 points of each facet +// // with the cosine bound +// auto res = compare_angle(vf[0]->point().point(), +// vf[1]->point().point(), +// vf[2]->point().point(), +// vf2[0]->point().point(), +// vf2[1]->point().point(), +// vf2[2]->point().point(), +// cosine_bound_); +// +// // if res == SMALLER, then the angles between the 2 normals is smaller than the bound +// // and the triangulation is "flat enough" +// // otherwise : +// if(res == CGAL::LARGER) +// { +//#ifdef CGAL_MESH_3_DEBUG_FACET_CRITERIA +// std::cerr << "Bad facet (max cos dh variation = " << cosine_bound_ << ")" << std::endl; +//#endif +// return Is_bad(Quality(1)); +// } } cell = cell->neighbor(next_index); } - while(cell != e.first); + while(cell != start_facet.first); } return Is_bad(); } private: - FT sq_distance_theoretical_bound_; + const FT cosine_bound_; }; // end class Facet_normals_variation_criterion diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index 3866b56e89f8..77ecd287dea1 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -93,7 +93,8 @@ class Mesh_criteria_3_impl parameters::choose_parameter(parameters::get_parameter_reference(np, internal_np::facet_size_param), FT(0)), parameters::choose_parameter(parameters::get_parameter_reference(np, internal_np::facet_distance_param), FT(0)), parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_topology_param), CGAL::FACET_VERTICES_ON_SURFACE), - parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_min_size_param), FT(0))), + parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_min_size_param), FT(0)), + parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_normals_variation_param), FT(0))), cell_criteria_(parameters::choose_parameter(parameters::get_parameter(np, internal_np::cell_radius_edge_ratio_param), FT(0)), parameters::choose_parameter(parameters::get_parameter_reference(np, internal_np::cell_size_param), FT(0)), parameters::choose_parameter(parameters::get_parameter(np, internal_np::cell_min_size_param), FT(0))) diff --git a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h index 6687fe12fa48..def60686b4b6 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h @@ -117,7 +117,7 @@ class Mesh_facet_criteria_3 const FT& distance_bound, const Mesh_facet_topology topology = FACET_VERTICES_ON_SURFACE, const FT& min_radius_bound = 0., - const FT& normals_variation_bound = 50.); + const FT& normals_variation_bound = 0.); #endif @@ -134,7 +134,7 @@ class Mesh_facet_criteria_3 const DistanceField& distance_bound, const Mesh_facet_topology topology = FACET_VERTICES_ON_SURFACE, const FT& min_radius_bound = 0., - const FT& normals_variation_bound = 50.) + const FT& normals_variation_bound = 0.) : squared_min_radius_bound_(std::nullopt) { if (FT(0) != min_radius_bound) diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index ba78bc1f4efd..e1a0d7699e30 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -445,6 +445,7 @@ CGAL_add_named_parameter_with_compatibility(facet_angle_param_t, facet_angle_par CGAL_add_named_parameter_with_compatibility(facet_size_param_t, facet_size_param, facet_size) CGAL_add_named_parameter_with_compatibility_cref_only(facet_distance_param_t, facet_distance_param, facet_distance) CGAL_add_named_parameter_with_compatibility(facet_min_size_param_t, facet_min_size_param, facet_min_size) +CGAL_add_named_parameter_with_compatibility(facet_normals_variation_param_t, facet_normals_variation_param, facet_normals_variation) CGAL_add_named_parameter_with_compatibility(facet_topology_param_t, facet_topology_param, facet_topology) CGAL_add_named_parameter_with_compatibility(cell_radius_edge_ratio_param_t, cell_radius_edge_ratio_param, cell_radius_edge_ratio) CGAL_add_named_parameter_with_compatibility(cell_size_param_t, cell_size_param, cell_size) From 49e5b0181412278daff4eca547e708e7b891be96 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 13 Nov 2026 15:45:03 +0100 Subject: [PATCH 06/21] use angle deviation with compare_angle_3_object() to replace scalar product < 0 --- .../Mesh_3/mesh_standard_facet_criteria.h | 60 ++++++------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h index 470ad9457ed4..550adbe8e92b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h @@ -683,23 +683,10 @@ class Facet_normals_variation_criterion using T3_utils = CGAL::Triangulation_utils_3; const Tr& tr = c3t3.triangulation(); + auto cp = tr.geom_traits().construct_point_3_object(); auto compare_angle = tr.geom_traits().compare_angle_3_object(); - auto scalar_product = tr.geom_traits().compute_scalar_product_3_object(); - auto opp = tr.geom_traits().construct_opposite_vector_3_object(); - auto unit_normal = [&](const Facet& f) -> Vector_3 - { - auto normal = tr.geom_traits().construct_normal_3_object(); - auto scale = tr.geom_traits().construct_scaled_vector_3_object(); - - const auto& t = tr.triangle(f); - Vector_3 n = normal(t[0], t[1], t[2]); - return scale(n, FT(1) / CGAL::sqrt(n.squared_length())); - }; - - // compute n1 = unit normal to f const Facet& start_facet = f; - const Vector_3 start_normal = unit_normal(start_facet); // for each of the 3 neighboring facets, compute unit normal n2 and compare with nf for(const Edge& e : tr.edges(f)) @@ -708,7 +695,6 @@ class Facet_normals_variation_criterion continue; const auto& [vs, vt] = tr.vertices(e); - Cell_handle cell = start_facet.first; do { @@ -721,38 +707,28 @@ class Facet_normals_variation_criterion { Facet f2(cell, next_index); - const Vector_3 n2 = unit_normal(f2); - - if(scalar_product(start_normal, n2) < 0.) + const auto& vf = tr.vertices(f); + const auto& vf2 = tr.vertices(f2); + // compare the angle between the two normals, using the 3 points of each facet + // with the cosine bound + auto res = compare_angle(cp(tr.point(vf[0])), + cp(tr.point(vf[1])), + cp(tr.point(vf[2])), + cp(tr.point(vf2[0])), + cp(tr.point(vf2[1])), + cp(tr.point(vf2[2])), + cosine_bound_); + + // if res == SMALLER, then the angles between the 2 normals is smaller than the bound + // and the triangulation is "flat enough" + // otherwise : + if(res == CGAL::LARGER) { #ifdef CGAL_MESH_3_DEBUG_FACET_CRITERIA - std::cerr << "Bad facet (normals are opposite)" << std::endl; + std::cerr << "Bad facet (max cos dh variation = " << cosine_bound_ << ")" << std::endl; #endif return Is_bad(Quality(1)); } - -// const auto& vf = tr.vertices(f); -// const auto& vf2 = tr.vertices(f2); -// // compare the angle between the two normals, using the 3 points of each facet -// // with the cosine bound -// auto res = compare_angle(vf[0]->point().point(), -// vf[1]->point().point(), -// vf[2]->point().point(), -// vf2[0]->point().point(), -// vf2[1]->point().point(), -// vf2[2]->point().point(), -// cosine_bound_); -// -// // if res == SMALLER, then the angles between the 2 normals is smaller than the bound -// // and the triangulation is "flat enough" -// // otherwise : -// if(res == CGAL::LARGER) -// { -//#ifdef CGAL_MESH_3_DEBUG_FACET_CRITERIA -// std::cerr << "Bad facet (max cos dh variation = " << cosine_bound_ << ")" << std::endl; -//#endif -// return Is_bad(Quality(1)); -// } } cell = cell->neighbor(next_index); From 8302efaf07afcac9b356898b6c32fa89d0350b7a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 13 Nov 2026 17:14:48 +0100 Subject: [PATCH 07/21] add facet_normal_deviation to mesh_3_plugin --- Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp | 11 ++ .../Mesh_3/Mesh_3_plugin_cgal_code.cpp | 32 +++-- .../Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h | 4 + Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h | 4 +- Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui | 111 ++++++++++++------ 5 files changed, 120 insertions(+), 42 deletions(-) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp index 85d9d5dfaed0..491aa8f58620 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -73,6 +73,7 @@ class Mesh_3_plugin : Q_PROPERTY(double edges_approx READ get_edges_approx WRITE set_edges_approx) Q_PROPERTY(double facets_sizing READ get_facets_sizing WRITE set_facets_sizing) Q_PROPERTY(double approx READ get_approx WRITE set_approx) + Q_PROPERTY(double facet_normal_deviation READ get_facet_normal_deviation WRITE set_facet_normal_deviation) Q_PROPERTY(double tets_sizing READ get_tets_sizing WRITE set_tets_sizing) Q_PROPERTY(double tets_shape READ get_tets_shape WRITE set_tets_shape) Q_PROPERTY(bool protect_features READ get_protect_features WRITE set_protect_features) @@ -160,6 +161,7 @@ public Q_SLOTS: void set_edges_approx(const double v) { edges_approx = v; }; void set_facets_sizing(const double v) { facets_sizing = v; }; void set_approx(const double v) { approx = v; }; + void set_facet_normal_deviation(const double v) { facet_normal_deviation = v; }; void set_tets_sizing(const double v) { tets_sizing = v; }; void set_tets_shape(const double v) { tets_shape = v; }; void set_manifold_criterion(const bool v) { manifold_criterion = v; } @@ -174,6 +176,7 @@ public Q_SLOTS: double get_edges_approx() { return edges_approx; }; double get_facets_sizing() { return facets_sizing; }; double get_approx() { return approx; }; + double get_facet_normal_deviation() { return facet_normal_deviation; }; double get_tets_sizing() { return tets_sizing; }; double get_tets_shape() { return tets_shape; }; bool get_manifold_criterion() { return manifold_criterion; }; @@ -253,6 +256,7 @@ public Q_SLOTS: int sizing_decimals; double approx; int approx_decimals; + double facet_normal_deviation; double edges_sizing; double edges_min_sizing; double edges_approx; @@ -486,6 +490,7 @@ void Mesh_3_plugin::set_defaults() { facets_sizing = default_sizing; facets_min_sizing = 0.1 * default_sizing; angle = 25.; + facet_normal_deviation = 90.; //tetrahedra parameters tets_sizing = default_sizing; tets_min_sizing = 0.1 * default_sizing; @@ -568,6 +573,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, Setup_ui_row s6(ui.sizingLabel, ui.facetSizing, diag * 10e-6, diag, facets_sizing, {ui.noFacetSizing}); Setup_ui_row s7(ui.sizingMinLabel, ui.facetMinSizing, diag * 10e-6, diag, facets_min_sizing, {ui.noFacetMinSizing}); Setup_ui_row s8(ui.angleLabel, ui.facetAngle, 0.0, 30.0, angle, {ui.noAngle}); +// Setup_ui_row s8b(ui.normalDeviationLabel, ui.normalDeviation, 0.0, 180.0, facet_normal_deviation, {ui.noNormalDeviation}); //tetrahedra parameters Setup_ui_row s9(ui.tetSizingLabel, ui.tetSizing, diag * 10e-6, diag, tets_sizing, {ui.noTetSizing}); @@ -700,6 +706,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing = !ui.noFacetSizing->isChecked() ? 0 : ui.facetSizing->value(); facets_min_sizing = !ui.noFacetMinSizing->isChecked() ? 0 : ui.facetMinSizing->value(); approx = !ui.noApprox->isChecked() ? 0 : ui.approx->value(); + facet_normal_deviation = !ui.noNormalDeviation->isChecked() ? 0 : ui.normalDeviation->value(); tets_shape = !ui.noTetShape->isChecked() ? 0 : ui.tetShape->value(); tets_sizing = !ui.noTetSizing->isChecked() ? 0 : ui.tetSizing->value(); tets_min_sizing = !ui.noTetMinSizing->isChecked() ? 0 : ui.tetMinSizing->value(); @@ -777,6 +784,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing, facets_min_sizing, approx, + facet_normal_deviation, tets_sizing, tets_min_sizing, edges_sizing, @@ -800,6 +808,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing, facets_min_sizing, approx, + facet_normal_deviation, tets_sizing, tets_min_sizing, edges_sizing, @@ -828,6 +837,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing, facets_min_sizing, approx, + facet_normal_deviation, tets_sizing, tets_min_sizing, edges_sizing, @@ -871,6 +881,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing, facets_min_sizing, approx, + facet_normal_deviation, tets_sizing, tets_min_sizing, edges_sizing, diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp index d1e560c5aa7b..d920112bbece 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp @@ -28,6 +28,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, const double facet_sizing, const double facet_min_sizing, const double facet_approx, + const double facet_normal_deviation, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -48,7 +49,8 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, << " edge min size bound: " << edge_min_size << std::endl << " edge distance bound: " << edge_distance << std::endl << " facets size bound: " << facet_sizing << std::endl - << " approximation bound: " << facet_approx << std::endl; + << " approximation bound: " << facet_approx << std::endl + << " normal deviation bound: " << facet_normal_deviation << std::endl; if (!surface_only) std::cerr << " tetrahedra size bound: " << tet_sizing << std::endl; @@ -99,13 +101,15 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, "
  • Edge min size bound: %3
  • " "
  • Edge distance bound: %4
  • " "
  • Facets size bound: %5
  • " - "
  • Approximation bound: %6
  • ") + "
  • Approximation bound: %6
  • " + "
  • Normal deviation bound: %7
  • ") .arg(facet_angle) .arg(edge_size) .arg(edge_min_size) .arg(edge_distance) .arg(facet_sizing) - .arg(facet_approx); + .arg(facet_approx) + .arg(facet_normal_deviation); if (!surface_only) tooltip += QString("
  • Tetrahedra size bound: %1
  • " ) .arg(tet_sizing); @@ -116,6 +120,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, param.facet_angle = facet_angle; param.facet_sizing = facet_sizing; param.facet_approx = facet_approx; + param.facet_normal_deviation = facet_normal_deviation; param.tet_sizing = tet_sizing; param.facet_min_sizing = facet_min_sizing; param.tet_min_sizing = tet_min_sizing; @@ -143,6 +148,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, const double facet_sizing, const double facet_min_sizing, const double facet_approx, + const double facet_normal_deviation, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -163,7 +169,8 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, << " edge min size bound: " << edge_min_size << std::endl << " edge distance bound: " << edge_distance << std::endl << " facets size bound: " << facet_sizing << std::endl - << " approximation bound: " << facet_approx << std::endl; + << " approximation bound: " << facet_approx << std::endl + << " normal deviation bound: " << facet_normal_deviation << std::endl; if (!surface_only) std::cerr << " tetrahedra size bound: " << tet_sizing << std::endl; @@ -209,13 +216,15 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, "
  • Edge min size bound :%3
  • " "
  • Edge distance bound: %4
  • " "
  • Facets size bound: %5
  • " - "
  • Approximation bound: %6
  • ") + "
  • Approximation bound: %6
  • " + "
  • Normal deviation bound: %7
  • ") .arg(facet_angle) .arg(edge_size) .arg(edge_min_size) .arg(edge_distance) .arg(facet_sizing) - .arg(facet_approx); + .arg(facet_approx) + .arg(facet_normal_deviation); if (!surface_only) tooltip += QString("
  • Tetrahedra size bound: %1
  • ") .arg(tet_sizing); @@ -226,6 +235,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, param.facet_angle = facet_angle; param.facet_sizing = facet_sizing; param.facet_approx = facet_approx; + param.facet_normal_deviation = facet_normal_deviation; param.tet_sizing = tet_sizing; param.facet_min_sizing = facet_min_sizing; param.tet_min_sizing = tet_min_sizing; @@ -254,6 +264,7 @@ Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, const double facet_sizing, const double facet_min_sizing, const double facet_approx, + const double facet_normal_deviation, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -286,6 +297,7 @@ Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, param.facet_sizing = facet_sizing; param.facet_min_sizing = facet_min_sizing; param.facet_approx = facet_approx; + param.facet_normal_deviation = facet_normal_deviation; param.tet_sizing = tet_sizing; param.tet_min_sizing = tet_min_sizing; param.tet_shape = tet_shape; @@ -319,6 +331,7 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, const double facet_sizing, const double facet_min_sizing, const double facet_approx, + const double facet_normal_deviation, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -348,6 +361,7 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, param.facet_sizing = facet_sizing; param.facet_min_sizing = facet_min_sizing; param.facet_approx = facet_approx; + param.facet_normal_deviation = facet_normal_deviation; param.tet_sizing = tet_sizing; param.tet_min_sizing = tet_min_sizing; param.facet_min_sizing = facet_min_sizing; @@ -368,13 +382,15 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, "
  • Edge min size bound: %3
  • " "
  • Edge distance bound: %4
  • " "
  • Facets size bound: %5
  • " - "
  • Approximation bound: %6
  • ") + "
  • Approximation bound: %6
  • " + "
  • Normal deviation bound: %7
  • ") .arg(facet_angle) .arg(edge_size) .arg(edge_min_size) .arg(edge_distance) .arg(facet_sizing) - .arg(facet_approx); + .arg(facet_approx) + .arg(facet_normal_deviation); if (!surface_only) tooltip += QString("
  • Tetrahedra size bound: %1
  • ") .arg(tet_sizing); diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h index fbc12778783f..c2a525c285b4 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h @@ -28,6 +28,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, const double facet_sizing, const double facet_min_sizing, const double facet_approx, + const double facet_normal_deviation, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -47,6 +48,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, const double facet_sizing, const double facet_min_sizing, const double facet_approx, + const double facet_normal_deviation, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -65,6 +67,7 @@ Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, const double facet_sizing, const double facet_min_sizing, const double facet_approx, + const double facet_normal_deviation, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -82,6 +85,7 @@ Meshing_thread* cgal_code_mesh_3(const CGAL::Image_3* pImage, const double facet_sizing, const double facet_min_sizing, const double facet_approx, + const double facet_normal_deviation, const double tet_sizing, const double tet_min_sizing, const double edge_size, diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h index 6c3717c6560b..7889743a6994 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h @@ -60,6 +60,7 @@ struct Mesh_parameters double facet_sizing; double facet_min_sizing; double facet_approx; + double facet_normal_deviation; double tet_shape; double tet_sizing; @@ -394,7 +395,8 @@ launch() p_.facet_sizing, p_.facet_approx, CGAL::FACET_VERTICES_ON_SURFACE, - p_.facet_min_sizing), + p_.facet_min_sizing, + p_.facet_normal_deviation), Cell_criteria(p_.tet_shape, p_.tet_sizing, p_.tet_min_sizing)); diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui b/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui index 0b61973d3394..d935bb77420e 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui +++ b/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui @@ -24,7 +24,7 @@ - QLayout::SetFixedSize + QLayout::SizeConstraint::SetFixedSize @@ -55,13 +55,13 @@ - Qt::LeftToRight + Qt::LayoutDirection::LeftToRight &Detect all connected components - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter detectComponents @@ -78,7 +78,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -94,7 +94,7 @@ - Qt::LeftToRight + Qt::LayoutDirection::LeftToRight Sharp features @@ -106,7 +106,7 @@ Edge min size - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter @@ -116,7 +116,7 @@ &Protect sharp edges - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter protect @@ -146,7 +146,7 @@ Edge approximation error - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter @@ -156,7 +156,7 @@ Edge &size - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter edgeSizing @@ -172,7 +172,7 @@ Angle bound for &sharp edges (deg) - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter sharpEdgesAngle @@ -238,10 +238,10 @@ false - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Plain + QFrame::Shadow::Plain @@ -263,7 +263,7 @@ - Qt::RightToLeft + Qt::LayoutDirection::RightToLeft &manifold @@ -283,7 +283,7 @@ - Qt::RightToLeft + Qt::LayoutDirection::RightToLeft force facets vertices on same surface patch @@ -299,7 +299,7 @@ Approximation &error - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter approx @@ -325,7 +325,7 @@ Facet min. &angle (deg) - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter facetAngle @@ -362,7 +362,7 @@ &Facet max. size - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter facetSizing @@ -395,7 +395,7 @@ - + Facet min. size @@ -416,6 +416,51 @@ + + + + Normal max deviation + + + false + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + + 0 + 0 + + + + IBeamCursor + + + + + + Qt::InputMethodHint::ImhNone + + + 180.000000000000000 + + + 90.000000000000000 + + + + + + + + + + @@ -445,7 +490,7 @@ &Tetrahedron max. size - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter tetSizing @@ -484,11 +529,11 @@ Tetrahedron shape (radius-edge ratio) - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter - + Tetrahedron min. size @@ -530,7 +575,7 @@ if unchecked, value inside the domain is greater than isovalue - Qt::LeftToRight + Qt::LayoutDirection::LeftToRight @@ -546,26 +591,26 @@ image value outside the image bounding box - Qt::LeftToRight + Qt::LayoutDirection::LeftToRight Value outside - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter - Qt::LeftToRight + Qt::LayoutDirection::LeftToRight Iso value - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter @@ -575,7 +620,7 @@ Value inside is less than iso value - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter @@ -605,20 +650,20 @@ - Qt::RightToLeft + Qt::LayoutDirection::RightToLeft Use Weighted Image - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter - Qt::LeftToRight + Qt::LayoutDirection::LeftToRight @@ -640,7 +685,7 @@ Sigma - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter @@ -664,10 +709,10 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok From 6074f300f21833c0ddfbff3ba294c22632dc5163 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 17 Nov 2026 15:14:06 +0100 Subject: [PATCH 08/21] allow edges and vertices from the 1D complex to be non-manifold --- .../CGAL/Mesh_3/Refine_facets_manifold_base.h | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h index d650b6bea15e..5122804affcd 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h @@ -132,6 +132,22 @@ class Refine_facets_manifold_base arete.first->vertex(arete.third) ); } + bool is_bad_edge(const Edge& e) const + { + const auto st = this->r_c3t3_.face_status(e); + if(st != C3t3::SINGULAR && (m_with_boundary || st != C3t3::BOUNDARY)) + return false; + return !this->r_c3t3_.is_in_complex(e); // protected feature edge: non-manifold by design + } + + bool is_bad_vertex(const Vertex_handle v) const + { + if(v->in_dimension() <= 1) + return false; // on a protected curve or corner + return this->r_c3t3_.has_incident_facets_in_complex(v) + && this->r_c3t3_.face_status(v) == C3t3::SINGULAR; + } + FT compute_sq_distance_to_facet_center(const Facet& f, const Vertex_handle v) const { @@ -371,9 +387,7 @@ class Refine_facets_manifold_base eit = this->r_tr_.finite_edges_begin(), end = this->r_tr_.finite_edges_end(); eit != end; ++eit) { - if ( (this->r_c3t3_.face_status(*eit) == C3t3::SINGULAR) || - ( (!m_with_boundary) && - (this->r_c3t3_.face_status(*eit) == C3t3::BOUNDARY) ) ) + if (is_bad_edge(*eit)) { const auto [biggest_f, sq_dist] = biggest_incident_facet_in_complex(*eit); if (is_smaller_than_min_size(sq_dist)) @@ -416,7 +430,7 @@ class Refine_facets_manifold_base end = this->r_tr_.finite_vertices_end(); vit != end; ++vit) { - if( this->r_c3t3_.face_status(vit) == C3t3::SINGULAR ) + if( is_bad_vertex(vit)) { const auto [biggest_f, sq_dist] = biggest_incident_facet_in_complex(vit); if (is_smaller_than_min_size(sq_dist)) @@ -588,10 +602,7 @@ class Refine_facets_manifold_base // This test is not efficient because // edges are tried to be inserted several times // TODO one day: test if the edge is still singular - if ( (this->r_c3t3_.face_status(edge) == C3t3::SINGULAR) || - ( (!m_with_boundary) && - (this->r_c3t3_.face_status(edge) == C3t3::BOUNDARY) ) - ) + if(is_bad_edge(edge)) { const auto [biggest_f, sq_dist] = biggest_incident_facet_in_complex(edge); if (is_smaller_than_min_size(sq_dist)) @@ -640,10 +651,7 @@ class Refine_facets_manifold_base vit = vertices.begin(), end = vertices.end(); vit != end; ++vit) { - if ( this->r_c3t3_.has_incident_facets_in_complex(*vit) && - (this->r_c3t3_.face_status(*vit) == C3t3::SINGULAR) - // !this->r_c3t3_.is_regular_or_boundary_for_vertices(*vit) - ) + if (is_bad_vertex(*vit)) { const auto [biggest_f, sq_dist] = biggest_incident_facet_in_complex(*vit); if (is_smaller_than_min_size(sq_dist)) @@ -667,10 +675,7 @@ class Refine_facets_manifold_base } } - if ( this->r_c3t3_.has_incident_facets_in_complex(v) && - (this->r_c3t3_.face_status(v) == C3t3::SINGULAR) - // !this->r_c3t3_.is_regular_or_boundary_for_vertices(v) - ) + if (is_bad_vertex(v)) { const auto [biggest_f, sq_dist] = biggest_incident_facet_in_complex(v); if (is_smaller_than_min_size(sq_dist)) From eb16e00ea08f17a58aed0a601b49aecfcbf12387 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 17 Nov 2026 15:27:37 +0100 Subject: [PATCH 09/21] doc --- Mesh_3/include/CGAL/Mesh_criteria_3.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index 77ecd287dea1..0296dfe66f45 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -307,6 +307,11 @@ typedef Mesh_cell_criteria_3 Cell_criteria; * get all possible values.} * \cgalParamDefault{CGAL::FACET_VERTICES_ON_SURFACE} * \cgalParamNEnd + * \cgalParamNBegin{facet_normals_variation} + * \cgalParamDescription{a lower bound (in degrees) for the angle between the + * normals of two neighbor facets of + * the complex, separated by a non-complex edge.} + * \cgalParamNEnd * \cgalParamNBegin{cell_radius_edge_ratio} * \cgalParamDescription{ an upper bound for the radius-edge ratio of the mesh tetrahedra.} * \cgalParamNEnd From 7322c0fe014b6502c1400b3ac44a8abf20521e4f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 17 Nov 2026 15:39:20 +0100 Subject: [PATCH 10/21] doc --- Mesh_3/include/CGAL/Mesh_criteria_3.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index 0296dfe66f45..708f2663aeee 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -308,9 +308,11 @@ typedef Mesh_cell_criteria_3 Cell_criteria; * \cgalParamDefault{CGAL::FACET_VERTICES_ON_SURFACE} * \cgalParamNEnd * \cgalParamNBegin{facet_normals_variation} - * \cgalParamDescription{a lower bound (in degrees) for the angle between the + * \cgalParamDescription{a higher bound (in degrees) for the angle between the * normals of two neighbor facets of - * the complex, separated by a non-complex edge.} + * the complex, separated by a non-complex edge. + * If the angle is higher than this bound, the facet will be + * refined.} * \cgalParamNEnd * \cgalParamNBegin{cell_radius_edge_ratio} * \cgalParamDescription{ an upper bound for the radius-edge ratio of the mesh tetrahedra.} From 5f643a924bbd8c7d4f537dba4a63c5ce400f8da8 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 17 Nov 2026 17:52:10 +0100 Subject: [PATCH 11/21] doc --- Mesh_3/include/CGAL/Mesh_facet_criteria_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h index def60686b4b6..de2c8163e91c 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h @@ -106,7 +106,7 @@ class Mesh_facet_criteria_3 \param min_radius_bound is a uniform lower bound for the radius of the surface Delaunay balls. Only facets with a radius larger than that bound will be refined. - \param normals_variation_bound in degrees, between 2 neighbor + \param normals_variation_bound in degrees, between two neighbor facets of the complex, separated by a non-complex edge @note If one parameter is set to 0, then its corresponding From a697c22434e27b173a04a20eb0d87b4d7acf250b Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 17 Nov 2026 17:52:58 +0100 Subject: [PATCH 12/21] fix compilation --- Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h index 550adbe8e92b..79c6bef5d1ac 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h @@ -660,7 +660,7 @@ class Facet_normals_variation_criterion public: /// Constructor Facet_normals_variation_criterion(const FT& bound_degrees) - : cosine_bound_(std::cos(bound_degrees * CGAL_PI / 180.0)) + : cosine_bound_(std::cos(CGAL::to_double(bound_degrees * CGAL_PI / 180.0))) {} /// Destructor From 3c4ad5bf1314299115cb55ef1cbcd0bec88b3be5 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 19 Nov 2026 11:53:11 +0100 Subject: [PATCH 13/21] favor readability Co-authored-by: Laurent Rineau --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h index 5122804affcd..bb4a4c230555 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h @@ -134,8 +134,8 @@ class Refine_facets_manifold_base bool is_bad_edge(const Edge& e) const { - const auto st = this->r_c3t3_.face_status(e); - if(st != C3t3::SINGULAR && (m_with_boundary || st != C3t3::BOUNDARY)) + const auto face_status = this->r_c3t3_.face_status(e); + if(face_status != C3t3::SINGULAR && (m_with_boundary || face_status != C3t3::BOUNDARY)) return false; return !this->r_c3t3_.is_in_complex(e); // protected feature edge: non-manifold by design } From eabb8e4ae45f1cb98621a4a25d034f183d414016 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 19 Nov 2026 11:54:07 +0100 Subject: [PATCH 14/21] doc : Apply batched suggestions from review Co-authored-by: Andreas Fabri Co-authored-by: Laurent Rineau --- Mesh_3/include/CGAL/Mesh_criteria_3.h | 6 +++--- Mesh_3/include/CGAL/Mesh_facet_criteria_3.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index 708f2663aeee..9f45eb18dfeb 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -308,10 +308,10 @@ typedef Mesh_cell_criteria_3 Cell_criteria; * \cgalParamDefault{CGAL::FACET_VERTICES_ON_SURFACE} * \cgalParamNEnd * \cgalParamNBegin{facet_normals_variation} - * \cgalParamDescription{a higher bound (in degrees) for the angle between the + * \cgalParamDescription{an upper bound (in degrees) for the angle between the * normals of two neighbor facets of - * the complex, separated by a non-complex edge. - * If the angle is higher than this bound, the facet will be + * the complex, separated by an edge that is not in the 1D complex. + * If the angle is larger than this bound, the facet will be * refined.} * \cgalParamNEnd * \cgalParamNBegin{cell_radius_edge_ratio} diff --git a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h index de2c8163e91c..777f3c680f22 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h @@ -106,8 +106,8 @@ class Mesh_facet_criteria_3 \param min_radius_bound is a uniform lower bound for the radius of the surface Delaunay balls. Only facets with a radius larger than that bound will be refined. - \param normals_variation_bound in degrees, between two neighbor - facets of the complex, separated by a non-complex edge + \param normals_variation_bound is an upper bound, in degrees, between the normal vectors of two neighbor + facets of the complex, separated by a an edge that is not in the 1D complex @note If one parameter is set to 0, then its corresponding criterion is ignored. From 4f4baf239317574baeb016868e68839933fb4df2 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 19 Nov 2026 12:03:46 +0100 Subject: [PATCH 15/21] add c3t3() and tr() accessors to improve readability --- .../CGAL/Mesh_3/Refine_facets_manifold_base.h | 105 +++++++++--------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h index bb4a4c230555..587942e48bd0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_manifold_base.h @@ -100,6 +100,9 @@ class Refine_facets_manifold_base std::optional m_squared_facet_min_size ; private: + const C3t3& c3t3() const { return this->r_c3t3_; } + const Tr& tr() const { return this->r_tr_; } + // computes and return an ordered pair of Vertex EdgeVV make_edgevv(const Vertex_handle vh1, const Vertex_handle vh2) const { @@ -120,7 +123,7 @@ class Refine_facets_manifold_base int index1=0, index2=0; // initialize to avoid g++ 4.8 -Wmaybe-uninitialized CGAL_assume_code(bool is_edge =) - this->r_tr_.is_edge(v1, v2, c, index1, index2); + tr().is_edge(v1, v2, c, index1, index2); CGAL_assume(is_edge); return make_triple( c, index1, index2 ); @@ -134,47 +137,47 @@ class Refine_facets_manifold_base bool is_bad_edge(const Edge& e) const { - const auto face_status = this->r_c3t3_.face_status(e); + const auto face_status = c3t3().face_status(e); if(face_status != C3t3::SINGULAR && (m_with_boundary || face_status != C3t3::BOUNDARY)) return false; - return !this->r_c3t3_.is_in_complex(e); // protected feature edge: non-manifold by design + return !c3t3().is_in_complex(e); // protected feature edge: non-manifold by design } bool is_bad_vertex(const Vertex_handle v) const { if(v->in_dimension() <= 1) return false; // on a protected curve or corner - return this->r_c3t3_.has_incident_facets_in_complex(v) - && this->r_c3t3_.face_status(v) == C3t3::SINGULAR; + return c3t3().has_incident_facets_in_complex(v) + && c3t3().face_status(v) == C3t3::SINGULAR; } FT compute_sq_distance_to_facet_center(const Facet& f, const Vertex_handle v) const { - typename GT::Compute_weight_3 cw = this->r_tr_.geom_traits().compute_weight_3_object(); - typename GT::Construct_point_3 cp = this->r_tr_.geom_traits().construct_point_3_object(); + typename GT::Compute_weight_3 cw = tr().geom_traits().compute_weight_3_object(); + typename GT::Construct_point_3 cp = tr().geom_traits().construct_point_3_object(); - const Bare_point& fcenter = this->r_c3t3_.surface_center(f.first, f.second); - const Weighted_point& wp = this->r_tr_.point(v); + const Bare_point& fcenter = c3t3().surface_center(f.first, f.second); + const Weighted_point& wp = tr().point(v); - return Th().min_squared_distance(this->r_tr_, fcenter, cp(wp)) - cw(wp); + return Th().min_squared_distance(tr(), fcenter, cp(wp)) - cw(wp); } std::pair biggest_incident_facet_in_complex(const Vertex_handle v) const { #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS - std::cerr << "Bad vertex: " << this->r_tr_.point(v) << std::endl; + std::cerr << "Bad vertex: " << tr().point(v) << std::endl; #endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS std::vector facets; facets.reserve(64); - if(this->r_tr_.is_parallel()) - this->r_tr_.incident_facets_threadsafe(v, std::back_inserter(facets)); + if(tr().is_parallel()) + tr().incident_facets_threadsafe(v, std::back_inserter(facets)); else - this->r_tr_.incident_facets(v, std::back_inserter(facets)); + tr().incident_facets(v, std::back_inserter(facets)); typename std::vector::iterator fit = facets.begin(); - while(fit != facets.end() && !this->r_c3t3_.is_in_complex(*fit)) ++fit; + while(fit != facets.end() && !c3t3().is_in_complex(*fit)) ++fit; CGAL_assertion(fit!=facets.end()); CGAL_assertion_code(int facet_counter = 1); @@ -185,7 +188,7 @@ class Refine_facets_manifold_base << " incident faces, with squared sizes:\n"; std::cerr << " " << biggest_sq_dist << "\n"; #endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS - while(fit != facets.end() && !this->r_c3t3_.is_in_complex(*fit)) ++fit; + while(fit != facets.end() && !c3t3().is_in_complex(*fit)) ++fit; for (; fit != facets.end(); ) { @@ -203,10 +206,10 @@ class Refine_facets_manifold_base biggest_sq_dist = current_sq_dist; } ++fit; - while(fit != facets.end() && !this->r_c3t3_.is_in_complex(*fit)) ++fit; + while(fit != facets.end() && !c3t3().is_in_complex(*fit)) ++fit; } CGAL_assertion(v->cached_number_of_incident_facets() == facet_counter); - CGAL_assertion(this->r_c3t3_.is_in_complex(biggest_facet)); + CGAL_assertion(c3t3().is_in_complex(biggest_facet)); #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS std::cerr << "Biggest facet squared radius: " << biggest_sq_dist @@ -224,12 +227,12 @@ class Refine_facets_manifold_base // use the list of incident facets in the complex Vertex_handle fev = edge_to_edgevv(arete).first; #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS - std::cerr << "Bad edge: (" << this->r_tr_.point(fev) - << ", " << this->r_tr_.point(arete.first->vertex(arete.third)) + std::cerr << "Bad edge: (" << tr().point(fev) + << ", " << tr().point(arete.first->vertex(arete.third)) << ")\n incident facets squared sizes:\n"; #endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS - Tr_facet_circulator fcirc = this->r_tr_.incident_facets(arete); - while(!this->r_c3t3_.is_in_complex(*fcirc)) ++fcirc; + Tr_facet_circulator fcirc = tr().incident_facets(arete); + while(!c3t3().is_in_complex(*fcirc)) ++fcirc; Facet first_facet = *fcirc; Facet biggest_facet = *fcirc; FT biggest_sq_dist = compute_sq_distance_to_facet_center(biggest_facet, @@ -241,7 +244,7 @@ class Refine_facets_manifold_base for (++fcirc; *fcirc != first_facet; ++fcirc) { - while(!this->r_c3t3_.is_in_complex(*fcirc)) ++fcirc; + while(!c3t3().is_in_complex(*fcirc)) ++fcirc; if(*fcirc == first_facet) break; const FT current_sq_dist = compute_sq_distance_to_facet_center(*fcirc, fev); @@ -288,14 +291,14 @@ class Refine_facets_manifold_base #endif // CGAL_LINKED_WITH_TBB { //Sequential - if ( this->r_c3t3_.is_in_complex(f) ) { + if ( c3t3().is_in_complex(f) ) { // foreach edge of f const Cell_handle cell = f.first; const int i = f.second; for(int j = 0; j < 3; ++j) { - const int edge_index_va = this->r_tr_.vertex_triple_index(i, j); - const int edge_index_vb = this->r_tr_.vertex_triple_index(i, (j == 2) ? 0 : (j+1)); + const int edge_index_va = tr().vertex_triple_index(i, j); + const int edge_index_vb = tr().vertex_triple_index(i, (j == 2) ? 0 : (j+1)); const Vertex_handle edge_va = cell->vertex(edge_index_va); const Vertex_handle edge_vb = cell->vertex(edge_index_vb); m_bad_edges.left.erase( make_edgevv(edge_va, edge_vb)); @@ -326,7 +329,7 @@ class Refine_facets_manifold_base if(m_bad_vertices.erase(c->vertex(j)) > 0) { #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS std::cerr << "m_bad_vertices.erase(" - << this->r_tr_.point(c, j) << ")\n"; + << tr().point(c, j) << ")\n"; #endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS } } @@ -384,7 +387,7 @@ class Refine_facets_manifold_base int n = 0; #endif for (typename Tr::Finite_edges_iterator - eit = this->r_tr_.finite_edges_begin(), end = this->r_tr_.finite_edges_end(); + eit = tr().finite_edges_begin(), end = tr().finite_edges_end(); eit != end; ++eit) { if (is_bad_edge(*eit)) @@ -402,7 +405,7 @@ class Refine_facets_manifold_base #endif // CGAL_LINKED_WITH_TBB { // Sequential m_bad_edges.insert(Bad_edge(edge_to_edgevv(*eit), - (this->r_c3t3_.face_status(*eit) == + (c3t3().face_status(*eit) == C3t3::SINGULAR ? 0 : 1))); } #ifdef CGAL_MESH_3_VERBOSE @@ -426,8 +429,8 @@ class Refine_facets_manifold_base int n = 0; #endif for (typename Tr::Finite_vertices_iterator - vit = this->r_tr_.finite_vertices_begin(), - end = this->r_tr_.finite_vertices_end(); + vit = tr().finite_vertices_begin(), + end = tr().finite_vertices_end(); vit != end; ++vit) { if( is_bad_vertex(vit)) @@ -438,7 +441,7 @@ class Refine_facets_manifold_base #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS std::cerr << "m_bad_vertices.insert(" - << this->r_tr_.point(vit) << ")\n"; + << tr().point(vit) << ")\n"; #endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS #ifdef CGAL_LINKED_WITH_TBB // Parallel @@ -462,9 +465,9 @@ class Refine_facets_manifold_base std::cerr << "Bad vertices queue:\n"; for(Vertex_handle v2 : m_bad_vertices) { - std::cerr << this->r_tr_.point(v2) << std::endl; + std::cerr << tr().point(v2) << std::endl; } - CGAL::dump_c3t3(this->r_c3t3_, "dump-at-scan-vertices"); + CGAL::dump_c3t3(c3t3(), "dump-at-scan-vertices"); # endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS #endif } @@ -492,7 +495,7 @@ class Refine_facets_manifold_base #endif // not defined CGAL_NO_ATOMIC if(this->m_maximal_number_of_vertices_ !=0 && - this->r_tr_.number_of_vertices() >= + tr().number_of_vertices() >= this->m_maximal_number_of_vertices_) { return true; @@ -523,9 +526,9 @@ class Refine_facets_manifold_base #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS const EdgeVV& edgevv = m_bad_edges.right.begin()->second; std::cerr << "Bad edge " - << this->r_tr_.point(edgevv.first) + << tr().point(edgevv.first) << " - " - << this->r_tr_.point(edgevv.second) + << tr().point(edgevv.second) << "\n"; #endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS return biggest_incident_facet_in_complex(first_bad_edge).first; @@ -536,14 +539,14 @@ class Refine_facets_manifold_base std::cerr << "Bad vertices queue:\n"; for(Vertex_handle v2 : m_bad_vertices) { - std::cerr << this->r_tr_.point(v2) << std::endl; + std::cerr << tr().point(v2) << std::endl; } - std::cerr << "Bad vertex " << this->r_tr_.point(v) << "\n"; + std::cerr << "Bad vertex " << tr().point(v) << "\n"; #endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS - CGAL_assertion(this->r_c3t3_.has_incident_facets_in_complex(v)); - if(this->r_c3t3_.face_status(v) != C3t3::SINGULAR) { - dump_c3t3(this->r_c3t3_, "dump-crash"); - CGAL_error_msg("this->r_c3t3_.face_status(v) != C3t3::SINGULAR"); + CGAL_assertion(c3t3().has_incident_facets_in_complex(v)); + if(c3t3().face_status(v) != C3t3::SINGULAR) { + dump_c3t3(c3t3(), "dump-crash"); + CGAL_error_msg("c3t3().face_status(v) != C3t3::SINGULAR"); } return biggest_incident_facet_in_complex(v).first; } @@ -578,7 +581,7 @@ class Refine_facets_manifold_base typedef std::vector Facets; Facets facets; facets.reserve(64); - this->r_tr_.incident_facets (v, std::back_inserter(facets)); + tr().incident_facets (v, std::back_inserter(facets)); // foreach f in star(v) for (typename Facets::iterator fit = facets.begin(); @@ -590,11 +593,11 @@ class Refine_facets_manifold_base const int i = fit->second; for(int j = 0; j < 3; ++j) { - const int edge_index_va = this->r_tr_.vertex_triple_index(i, j); - const int edge_index_vb = this->r_tr_.vertex_triple_index(i, (j == 2) ? 0 : (j+1)); + const int edge_index_va = tr().vertex_triple_index(i, j); + const int edge_index_vb = tr().vertex_triple_index(i, (j == 2) ? 0 : (j+1)); Edge edge(cell, edge_index_va, edge_index_vb); // test if edge is in Complex - if ( this->r_c3t3_.face_status(edge) != C3t3::NOT_IN_COMPLEX ) { + if ( c3t3().face_status(edge) != C3t3::NOT_IN_COMPLEX ) { // test if edge is not regular to store it as a "bad_edge" // e.g., more than or equal to 3 incident facets (SINGULAR) // or less than or equal to 1 @@ -618,7 +621,7 @@ class Refine_facets_manifold_base #endif // CGAL_LINKED_WITH_TBB { // Sequential m_bad_edges.insert(Bad_edge(edge_to_edgevv(edge), - (this->r_c3t3_.face_status(edge) == + (c3t3().face_status(edge) == C3t3::SINGULAR ? 0 : 1))); } } @@ -640,7 +643,7 @@ class Refine_facets_manifold_base // foreach v' in star of v std::vector vertices; vertices.reserve(64); - this->r_tr_.incident_vertices(v, std::back_inserter(vertices)); + tr().incident_vertices(v, std::back_inserter(vertices)); // is_regular_or_boundary_for_vertices // is used here also incident edges are not known to be @@ -659,7 +662,7 @@ class Refine_facets_manifold_base #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS std::cerr << "m_bad_vertices.insert(" - << this->r_tr_.point(*vit) << ")\n"; + << tr().point(*vit) << ")\n"; #endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS #ifdef CGAL_LINKED_WITH_TBB // Parallel @@ -683,7 +686,7 @@ class Refine_facets_manifold_base #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS std::cerr << "m_bad_vertices.insert(" - << this->r_tr_.point(v) << ")\n"; + << tr().point(v) << ")\n"; #endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS #ifdef CGAL_LINKED_WITH_TBB // Parallel From b7dc152721ed5466b70f75a3a72fbc76ef2561e9 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 19 Nov 2026 12:09:17 +0100 Subject: [PATCH 16/21] keep start_cell instead of start_facet --- Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h index 79c6bef5d1ac..d1ec10f6c0d2 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h @@ -686,7 +686,7 @@ class Facet_normals_variation_criterion auto cp = tr.geom_traits().construct_point_3_object(); auto compare_angle = tr.geom_traits().compare_angle_3_object(); - const Facet& start_facet = f; + const Cell_handle start_cell = f.first; // for each of the 3 neighboring facets, compute unit normal n2 and compare with nf for(const Edge& e : tr.edges(f)) @@ -695,7 +695,7 @@ class Facet_normals_variation_criterion continue; const auto& [vs, vt] = tr.vertices(e); - Cell_handle cell = start_facet.first; + Cell_handle cell = start_cell; do { int next_index = T3_utils::next_around_edge(cell->index(vs), cell->index(vt)); @@ -733,7 +733,7 @@ class Facet_normals_variation_criterion cell = cell->neighbor(next_index); } - while(cell != start_facet.first); + while(cell != start_cell); } return Is_bad(); From cfee3fd9a099749fa09c4c0a37e0f302aa2ada99 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 19 Nov 2026 14:01:43 +0100 Subject: [PATCH 17/21] rename facet_normals_variation to facet_normal_angle --- Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp | 22 ++++++++-------- .../Mesh_3/Mesh_3_plugin_cgal_code.cpp | 26 +++++++++---------- .../Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h | 8 +++--- Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h | 4 +-- .../Mesh_3/mesh_standard_facet_criteria.h | 10 +++---- Mesh_3/include/CGAL/Mesh_criteria_3.h | 4 +-- Mesh_3/include/CGAL/Mesh_facet_criteria_3.h | 16 ++++++------ .../internal/parameters_interface.h | 2 +- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp index 491aa8f58620..7e271904918f 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -73,7 +73,7 @@ class Mesh_3_plugin : Q_PROPERTY(double edges_approx READ get_edges_approx WRITE set_edges_approx) Q_PROPERTY(double facets_sizing READ get_facets_sizing WRITE set_facets_sizing) Q_PROPERTY(double approx READ get_approx WRITE set_approx) - Q_PROPERTY(double facet_normal_deviation READ get_facet_normal_deviation WRITE set_facet_normal_deviation) + Q_PROPERTY(double facet_normal_angle READ get_facet_normal_angle WRITE set_facet_normal_angle) Q_PROPERTY(double tets_sizing READ get_tets_sizing WRITE set_tets_sizing) Q_PROPERTY(double tets_shape READ get_tets_shape WRITE set_tets_shape) Q_PROPERTY(bool protect_features READ get_protect_features WRITE set_protect_features) @@ -161,7 +161,7 @@ public Q_SLOTS: void set_edges_approx(const double v) { edges_approx = v; }; void set_facets_sizing(const double v) { facets_sizing = v; }; void set_approx(const double v) { approx = v; }; - void set_facet_normal_deviation(const double v) { facet_normal_deviation = v; }; + void set_facet_normal_angle(const double v) { facet_normal_angle = v; }; void set_tets_sizing(const double v) { tets_sizing = v; }; void set_tets_shape(const double v) { tets_shape = v; }; void set_manifold_criterion(const bool v) { manifold_criterion = v; } @@ -176,7 +176,7 @@ public Q_SLOTS: double get_edges_approx() { return edges_approx; }; double get_facets_sizing() { return facets_sizing; }; double get_approx() { return approx; }; - double get_facet_normal_deviation() { return facet_normal_deviation; }; + double get_facet_normal_angle() { return facet_normal_angle; }; double get_tets_sizing() { return tets_sizing; }; double get_tets_shape() { return tets_shape; }; bool get_manifold_criterion() { return manifold_criterion; }; @@ -256,7 +256,7 @@ public Q_SLOTS: int sizing_decimals; double approx; int approx_decimals; - double facet_normal_deviation; + double facet_normal_angle; double edges_sizing; double edges_min_sizing; double edges_approx; @@ -490,7 +490,7 @@ void Mesh_3_plugin::set_defaults() { facets_sizing = default_sizing; facets_min_sizing = 0.1 * default_sizing; angle = 25.; - facet_normal_deviation = 90.; + facet_normal_angle = 90.; //tetrahedra parameters tets_sizing = default_sizing; tets_min_sizing = 0.1 * default_sizing; @@ -573,7 +573,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, Setup_ui_row s6(ui.sizingLabel, ui.facetSizing, diag * 10e-6, diag, facets_sizing, {ui.noFacetSizing}); Setup_ui_row s7(ui.sizingMinLabel, ui.facetMinSizing, diag * 10e-6, diag, facets_min_sizing, {ui.noFacetMinSizing}); Setup_ui_row s8(ui.angleLabel, ui.facetAngle, 0.0, 30.0, angle, {ui.noAngle}); -// Setup_ui_row s8b(ui.normalDeviationLabel, ui.normalDeviation, 0.0, 180.0, facet_normal_deviation, {ui.noNormalDeviation}); +// Setup_ui_row s8b(ui.normalDeviationLabel, ui.normalDeviation, 0.0, 180.0, facet_normal_angle, {ui.noNormalDeviation}); //tetrahedra parameters Setup_ui_row s9(ui.tetSizingLabel, ui.tetSizing, diag * 10e-6, diag, tets_sizing, {ui.noTetSizing}); @@ -706,7 +706,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing = !ui.noFacetSizing->isChecked() ? 0 : ui.facetSizing->value(); facets_min_sizing = !ui.noFacetMinSizing->isChecked() ? 0 : ui.facetMinSizing->value(); approx = !ui.noApprox->isChecked() ? 0 : ui.approx->value(); - facet_normal_deviation = !ui.noNormalDeviation->isChecked() ? 0 : ui.normalDeviation->value(); + facet_normal_angle = !ui.noNormalDeviation->isChecked() ? 0 : ui.normalDeviation->value(); tets_shape = !ui.noTetShape->isChecked() ? 0 : ui.tetShape->value(); tets_sizing = !ui.noTetSizing->isChecked() ? 0 : ui.tetSizing->value(); tets_min_sizing = !ui.noTetMinSizing->isChecked() ? 0 : ui.tetMinSizing->value(); @@ -784,7 +784,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing, facets_min_sizing, approx, - facet_normal_deviation, + facet_normal_angle, tets_sizing, tets_min_sizing, edges_sizing, @@ -808,7 +808,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing, facets_min_sizing, approx, - facet_normal_deviation, + facet_normal_angle, tets_sizing, tets_min_sizing, edges_sizing, @@ -837,7 +837,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing, facets_min_sizing, approx, - facet_normal_deviation, + facet_normal_angle, tets_sizing, tets_min_sizing, edges_sizing, @@ -881,7 +881,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing, facets_min_sizing, approx, - facet_normal_deviation, + facet_normal_angle, tets_sizing, tets_min_sizing, edges_sizing, diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp index d920112bbece..67c0d362125e 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp @@ -28,7 +28,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, const double facet_sizing, const double facet_min_sizing, const double facet_approx, - const double facet_normal_deviation, + const double facet_normal_angle, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -50,7 +50,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, << " edge distance bound: " << edge_distance << std::endl << " facets size bound: " << facet_sizing << std::endl << " approximation bound: " << facet_approx << std::endl - << " normal deviation bound: " << facet_normal_deviation << std::endl; + << " normal deviation bound: " << facet_normal_angle << std::endl; if (!surface_only) std::cerr << " tetrahedra size bound: " << tet_sizing << std::endl; @@ -109,7 +109,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, .arg(edge_distance) .arg(facet_sizing) .arg(facet_approx) - .arg(facet_normal_deviation); + .arg(facet_normal_angle); if (!surface_only) tooltip += QString("
  • Tetrahedra size bound: %1
  • " ) .arg(tet_sizing); @@ -120,7 +120,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, param.facet_angle = facet_angle; param.facet_sizing = facet_sizing; param.facet_approx = facet_approx; - param.facet_normal_deviation = facet_normal_deviation; + param.facet_normal_angle = facet_normal_angle; param.tet_sizing = tet_sizing; param.facet_min_sizing = facet_min_sizing; param.tet_min_sizing = tet_min_sizing; @@ -148,7 +148,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, const double facet_sizing, const double facet_min_sizing, const double facet_approx, - const double facet_normal_deviation, + const double facet_normal_angle, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -170,7 +170,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, << " edge distance bound: " << edge_distance << std::endl << " facets size bound: " << facet_sizing << std::endl << " approximation bound: " << facet_approx << std::endl - << " normal deviation bound: " << facet_normal_deviation << std::endl; + << " normal deviation bound: " << facet_normal_angle << std::endl; if (!surface_only) std::cerr << " tetrahedra size bound: " << tet_sizing << std::endl; @@ -224,7 +224,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, .arg(edge_distance) .arg(facet_sizing) .arg(facet_approx) - .arg(facet_normal_deviation); + .arg(facet_normal_angle); if (!surface_only) tooltip += QString("
  • Tetrahedra size bound: %1
  • ") .arg(tet_sizing); @@ -235,7 +235,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, param.facet_angle = facet_angle; param.facet_sizing = facet_sizing; param.facet_approx = facet_approx; - param.facet_normal_deviation = facet_normal_deviation; + param.facet_normal_angle = facet_normal_angle; param.tet_sizing = tet_sizing; param.facet_min_sizing = facet_min_sizing; param.tet_min_sizing = tet_min_sizing; @@ -264,7 +264,7 @@ Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, const double facet_sizing, const double facet_min_sizing, const double facet_approx, - const double facet_normal_deviation, + const double facet_normal_angle, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -297,7 +297,7 @@ Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, param.facet_sizing = facet_sizing; param.facet_min_sizing = facet_min_sizing; param.facet_approx = facet_approx; - param.facet_normal_deviation = facet_normal_deviation; + param.facet_normal_angle = facet_normal_angle; param.tet_sizing = tet_sizing; param.tet_min_sizing = tet_min_sizing; param.tet_shape = tet_shape; @@ -331,7 +331,7 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, const double facet_sizing, const double facet_min_sizing, const double facet_approx, - const double facet_normal_deviation, + const double facet_normal_angle, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -361,7 +361,7 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, param.facet_sizing = facet_sizing; param.facet_min_sizing = facet_min_sizing; param.facet_approx = facet_approx; - param.facet_normal_deviation = facet_normal_deviation; + param.facet_normal_angle = facet_normal_angle; param.tet_sizing = tet_sizing; param.tet_min_sizing = tet_min_sizing; param.facet_min_sizing = facet_min_sizing; @@ -390,7 +390,7 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, .arg(edge_distance) .arg(facet_sizing) .arg(facet_approx) - .arg(facet_normal_deviation); + .arg(facet_normal_angle); if (!surface_only) tooltip += QString("
  • Tetrahedra size bound: %1
  • ") .arg(tet_sizing); diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h index c2a525c285b4..def0a5bd558e 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.h @@ -28,7 +28,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, const double facet_sizing, const double facet_min_sizing, const double facet_approx, - const double facet_normal_deviation, + const double facet_normal_angle, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -48,7 +48,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, const double facet_sizing, const double facet_min_sizing, const double facet_approx, - const double facet_normal_deviation, + const double facet_normal_angle, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -67,7 +67,7 @@ Meshing_thread* cgal_code_mesh_3(const Implicit_function_interface* pfunction, const double facet_sizing, const double facet_min_sizing, const double facet_approx, - const double facet_normal_deviation, + const double facet_normal_angle, const double tet_sizing, const double tet_min_sizing, const double edge_size, @@ -85,7 +85,7 @@ Meshing_thread* cgal_code_mesh_3(const CGAL::Image_3* pImage, const double facet_sizing, const double facet_min_sizing, const double facet_approx, - const double facet_normal_deviation, + const double facet_normal_angle, const double tet_sizing, const double tet_min_sizing, const double edge_size, diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h index 7889743a6994..083e4fb94791 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h @@ -60,7 +60,7 @@ struct Mesh_parameters double facet_sizing; double facet_min_sizing; double facet_approx; - double facet_normal_deviation; + double facet_normal_angle; double tet_shape; double tet_sizing; @@ -396,7 +396,7 @@ launch() p_.facet_approx, CGAL::FACET_VERTICES_ON_SURFACE, p_.facet_min_sizing, - p_.facet_normal_deviation), + p_.facet_normal_angle), Cell_criteria(p_.tet_shape, p_.tet_sizing, p_.tet_min_sizing)); diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h index d1ec10f6c0d2..7915984bb03b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_facet_criteria.h @@ -640,7 +640,7 @@ public Mesh_3::Abstract_criterion }; // end class Facet_on_same_surface_criterion template -class Facet_normals_variation_criterion +class Facet_normal_angle_criterion : public Mesh_3::Abstract_criterion { typedef typename C3T3::Triangulation Tr; @@ -655,16 +655,16 @@ class Facet_normals_variation_criterion typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Facet_normals_variation_criterion Self; + typedef Facet_normal_angle_criterion Self; public: /// Constructor - Facet_normals_variation_criterion(const FT& bound_degrees) + Facet_normal_angle_criterion(const FT& bound_degrees) : cosine_bound_(std::cos(CGAL::to_double(bound_degrees * CGAL_PI / 180.0))) {} /// Destructor - virtual ~Facet_normals_variation_criterion() {} + virtual ~Facet_normal_angle_criterion() {} protected: virtual void do_accept(Visitor_& v) const { v.visit(*this); } @@ -742,7 +742,7 @@ class Facet_normals_variation_criterion private: const FT cosine_bound_; -}; // end class Facet_normals_variation_criterion +}; // end class Facet_normal_angle_criterion template class Facet_criterion_visitor diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index 9f45eb18dfeb..764dd4611c57 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -94,7 +94,7 @@ class Mesh_criteria_3_impl parameters::choose_parameter(parameters::get_parameter_reference(np, internal_np::facet_distance_param), FT(0)), parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_topology_param), CGAL::FACET_VERTICES_ON_SURFACE), parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_min_size_param), FT(0)), - parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_normals_variation_param), FT(0))), + parameters::choose_parameter(parameters::get_parameter(np, internal_np::facet_normal_angle_param), FT(0))), cell_criteria_(parameters::choose_parameter(parameters::get_parameter(np, internal_np::cell_radius_edge_ratio_param), FT(0)), parameters::choose_parameter(parameters::get_parameter_reference(np, internal_np::cell_size_param), FT(0)), parameters::choose_parameter(parameters::get_parameter(np, internal_np::cell_min_size_param), FT(0))) @@ -307,7 +307,7 @@ typedef Mesh_cell_criteria_3 Cell_criteria; * get all possible values.} * \cgalParamDefault{CGAL::FACET_VERTICES_ON_SURFACE} * \cgalParamNEnd - * \cgalParamNBegin{facet_normals_variation} + * \cgalParamNBegin{facet_normal_angle} * \cgalParamDescription{an upper bound (in degrees) for the angle between the * normals of two neighbor facets of * the complex, separated by an edge that is not in the 1D complex. diff --git a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h index 777f3c680f22..7723accab599 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h @@ -106,7 +106,7 @@ class Mesh_facet_criteria_3 \param min_radius_bound is a uniform lower bound for the radius of the surface Delaunay balls. Only facets with a radius larger than that bound will be refined. - \param normals_variation_bound is an upper bound, in degrees, between the normal vectors of two neighbor + \param normal_angle_bound is an upper bound, in degrees, between the normal vectors of two neighbor facets of the complex, separated by a an edge that is not in the 1D complex @note If one parameter is set to 0, then its corresponding @@ -117,7 +117,7 @@ class Mesh_facet_criteria_3 const FT& distance_bound, const Mesh_facet_topology topology = FACET_VERTICES_ON_SURFACE, const FT& min_radius_bound = 0., - const FT& normals_variation_bound = 0.); + const FT& normal_angle_bound = 0.); #endif @@ -134,7 +134,7 @@ class Mesh_facet_criteria_3 const DistanceField& distance_bound, const Mesh_facet_topology topology = FACET_VERTICES_ON_SURFACE, const FT& min_radius_bound = 0., - const FT& normals_variation_bound = 0.) + const FT& normal_angle_bound = 0.) : squared_min_radius_bound_(std::nullopt) { if (FT(0) != min_radius_bound) @@ -154,7 +154,7 @@ class Mesh_facet_criteria_3 init_topo(topology); - init_normals_variation(normals_variation_bound); + init_normal_angle(normal_angle_bound); } /// @} @@ -260,12 +260,12 @@ class Mesh_facet_criteria_3 } } - void init_normals_variation(const FT& normals_variation_bound) + void init_normal_angle(const FT& normal_angle_bound) { - if(FT(0) == normals_variation_bound) + if(FT(0) == normal_angle_bound) return; - typedef Mesh_3::Facet_normals_variation_criterion Nvar_criterion; - criteria_.add(new Nvar_criterion(normals_variation_bound)); + typedef Mesh_3::Facet_normal_angle_criterion Nvar_criterion; + criteria_.add(new Nvar_criterion(normal_angle_bound)); } private: diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index e1a0d7699e30..adfdb3454e58 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -445,7 +445,7 @@ CGAL_add_named_parameter_with_compatibility(facet_angle_param_t, facet_angle_par CGAL_add_named_parameter_with_compatibility(facet_size_param_t, facet_size_param, facet_size) CGAL_add_named_parameter_with_compatibility_cref_only(facet_distance_param_t, facet_distance_param, facet_distance) CGAL_add_named_parameter_with_compatibility(facet_min_size_param_t, facet_min_size_param, facet_min_size) -CGAL_add_named_parameter_with_compatibility(facet_normals_variation_param_t, facet_normals_variation_param, facet_normals_variation) +CGAL_add_named_parameter_with_compatibility(facet_normal_angle_param_t, facet_normal_angle_param, facet_normal_angle) CGAL_add_named_parameter_with_compatibility(facet_topology_param_t, facet_topology_param, facet_topology) CGAL_add_named_parameter_with_compatibility(cell_radius_edge_ratio_param_t, cell_radius_edge_ratio_param, cell_radius_edge_ratio) CGAL_add_named_parameter_with_compatibility(cell_size_param_t, cell_size_param, cell_size) From 7a7fb73e623da37c5c8b2c7f3bde8833f0cfe909 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 19 Nov 2026 16:33:33 +0100 Subject: [PATCH 18/21] strings in the demo (from code review) Co-authored-by: Laurent Rineau --- .../Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp index 67c0d362125e..be5dcc14f124 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin_cgal_code.cpp @@ -50,7 +50,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, << " edge distance bound: " << edge_distance << std::endl << " facets size bound: " << facet_sizing << std::endl << " approximation bound: " << facet_approx << std::endl - << " normal deviation bound: " << facet_normal_angle << std::endl; + << " normal angle bound: " << facet_normal_angle << std::endl; if (!surface_only) std::cerr << " tetrahedra size bound: " << tet_sizing << std::endl; @@ -102,7 +102,7 @@ Meshing_thread* cgal_code_mesh_3(QList pMeshes, "
  • Edge distance bound: %4
  • " "
  • Facets size bound: %5
  • " "
  • Approximation bound: %6
  • " - "
  • Normal deviation bound: %7
  • ") + "
  • Normal angle bound: %7
  • ") .arg(facet_angle) .arg(edge_size) .arg(edge_min_size) @@ -170,7 +170,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, << " edge distance bound: " << edge_distance << std::endl << " facets size bound: " << facet_sizing << std::endl << " approximation bound: " << facet_approx << std::endl - << " normal deviation bound: " << facet_normal_angle << std::endl; + << " normal angle bound: " << facet_normal_angle << std::endl; if (!surface_only) std::cerr << " tetrahedra size bound: " << tet_sizing << std::endl; @@ -217,7 +217,7 @@ Meshing_thread* cgal_code_mesh_3(const QList pMeshes, "
  • Edge distance bound: %4
  • " "
  • Facets size bound: %5
  • " "
  • Approximation bound: %6
  • " - "
  • Normal deviation bound: %7
  • ") + "
  • Normal angle bound: %7
  • ") .arg(facet_angle) .arg(edge_size) .arg(edge_min_size) @@ -383,7 +383,7 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage, "
  • Edge distance bound: %4
  • " "
  • Facets size bound: %5
  • " "
  • Approximation bound: %6
  • " - "
  • Normal deviation bound: %7
  • ") + "
  • Normal angle bound: %7
  • ") .arg(facet_angle) .arg(edge_size) .arg(edge_min_size) From a2f3c262ebae174a1fe2f1b04ddf768e10518331 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 19 Nov 2026 17:10:05 +0100 Subject: [PATCH 19/21] fix naming in demo --- Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp | 4 ++-- Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h | 2 ++ Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp index 7e271904918f..5edb9d3dbf1a 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -573,7 +573,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, Setup_ui_row s6(ui.sizingLabel, ui.facetSizing, diag * 10e-6, diag, facets_sizing, {ui.noFacetSizing}); Setup_ui_row s7(ui.sizingMinLabel, ui.facetMinSizing, diag * 10e-6, diag, facets_min_sizing, {ui.noFacetMinSizing}); Setup_ui_row s8(ui.angleLabel, ui.facetAngle, 0.0, 30.0, angle, {ui.noAngle}); -// Setup_ui_row s8b(ui.normalDeviationLabel, ui.normalDeviation, 0.0, 180.0, facet_normal_angle, {ui.noNormalDeviation}); +// Setup_ui_row s8b(ui.facetNormalAngleLabel, ui.facetNormalAngle, 0.0, 180.0, facet_normal_angle, {ui.nofacetNormalAngle}); //tetrahedra parameters Setup_ui_row s9(ui.tetSizingLabel, ui.tetSizing, diag * 10e-6, diag, tets_sizing, {ui.noTetSizing}); @@ -706,7 +706,7 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, facets_sizing = !ui.noFacetSizing->isChecked() ? 0 : ui.facetSizing->value(); facets_min_sizing = !ui.noFacetMinSizing->isChecked() ? 0 : ui.facetMinSizing->value(); approx = !ui.noApprox->isChecked() ? 0 : ui.approx->value(); - facet_normal_angle = !ui.noNormalDeviation->isChecked() ? 0 : ui.normalDeviation->value(); + facet_normal_angle = !ui.noFacetNormalAngle->isChecked() ? 0 : ui.facetNormalAngle->value(); tets_shape = !ui.noTetShape->isChecked() ? 0 : ui.tetShape->value(); tets_sizing = !ui.noTetSizing->isChecked() ? 0 : ui.tetSizing->value(); tets_min_sizing = !ui.noTetMinSizing->isChecked() ? 0 : ui.tetMinSizing->value(); diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h index 083e4fb94791..425426295ee3 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h @@ -176,6 +176,8 @@ log() const res << QString("facet min size: %1").arg(facet_min_sizing); if(is_valid(facet_approx)) res << QString("facet approx error: %1").arg(facet_approx); + if(is_valid(facet_normal_angle)) + res << QString("facet normal angle: %1").arg(facet_normal_angle); if(is_valid(tet_shape)) res << QString("tet shape (radius-edge): %1").arg(tet_shape); if(is_valid(tet_sizing)) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui b/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui index d935bb77420e..aee3e621fc31 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui +++ b/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui @@ -417,9 +417,9 @@ - + - Normal max deviation + Facet normal angle false @@ -430,7 +430,7 @@ - + 0 @@ -455,7 +455,7 @@ - + From fe72aa9cd0d81af7df9a1baaeed7ce25d405da40 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 19 Nov 2026 17:38:14 +0100 Subject: [PATCH 20/21] add missing edges() function --- .../include/CGAL/Periodic_3_triangulation_3.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h index 81d40783baf0..01f35b40b86e 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h @@ -1971,6 +1971,11 @@ class Periodic_3_triangulation_3 { return Triangulation_data_structure::vertices(c); } + /// Edges around a facet + static std::array edges(const Facet& f) + { + return Triangulation_data_structure::edges(f); + } private: /** @name Checking helpers */ From 92c8817f84d8b26f1caf054c5d71dd489afe85b2 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 20 Nov 2026 14:09:09 +0100 Subject: [PATCH 21/21] use DoubleEdit for facetNormalAngle --- Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp | 10 ++++---- Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui | 24 +++---------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp index 5edb9d3dbf1a..337fc5c933a7 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_3_plugin.cpp @@ -569,11 +569,11 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type, connect(ui.protect, SIGNAL(toggled(bool)), ui.noEdgeApprox, SLOT(setEnabled(bool))); //triangle parameters - Setup_ui_row s5(ui.approxLabel, ui.approx, diag * 10e-7, diag, approx, {ui.noApprox}); - Setup_ui_row s6(ui.sizingLabel, ui.facetSizing, diag * 10e-6, diag, facets_sizing, {ui.noFacetSizing}); - Setup_ui_row s7(ui.sizingMinLabel, ui.facetMinSizing, diag * 10e-6, diag, facets_min_sizing, {ui.noFacetMinSizing}); - Setup_ui_row s8(ui.angleLabel, ui.facetAngle, 0.0, 30.0, angle, {ui.noAngle}); -// Setup_ui_row s8b(ui.facetNormalAngleLabel, ui.facetNormalAngle, 0.0, 180.0, facet_normal_angle, {ui.nofacetNormalAngle}); + Setup_ui_row s5( ui.approxLabel, ui.approx, diag * 10e-7, diag, approx, {ui.noApprox}); + Setup_ui_row s6( ui.sizingLabel, ui.facetSizing, diag * 10e-6, diag, facets_sizing, {ui.noFacetSizing}); + Setup_ui_row s7( ui.sizingMinLabel, ui.facetMinSizing, diag * 10e-6, diag, facets_min_sizing, {ui.noFacetMinSizing}); + Setup_ui_row s8( ui.angleLabel, ui.facetAngle, 0.0, 30.0, angle, {ui.noAngle}); + Setup_ui_row s8b(ui.facetNormalAngleLabel, ui.facetNormalAngle, 0.0, 180., facet_normal_angle,{ui.noFacetNormalAngle}); //tetrahedra parameters Setup_ui_row s9(ui.tetSizingLabel, ui.tetSizing, diag * 10e-6, diag, tets_sizing, {ui.noTetSizing}); diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui b/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui index aee3e621fc31..795182bdef3b 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui +++ b/Lab/demo/Lab/Plugins/Mesh_3/Meshing_dialog.ui @@ -430,27 +430,9 @@ - - - - 0 - 0 - - - - IBeamCursor - - - - - - Qt::InputMethodHint::ImhNone - - - 180.000000000000000 - - - 90.000000000000000 + + + 90.00