From 2cf9156d5861f16f8e5602b4e900407a788ccd2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 13:47:17 +0100 Subject: [PATCH 001/127] Do not duplicate C3T3 in write_MEDIT --- SMDS_3/include/CGAL/IO/File_medit.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/SMDS_3/include/CGAL/IO/File_medit.h b/SMDS_3/include/CGAL/IO/File_medit.h index 943b546e80da..e6ec4f8dab9a 100644 --- a/SMDS_3/include/CGAL/IO/File_medit.h +++ b/SMDS_3/include/CGAL/IO/File_medit.h @@ -858,10 +858,18 @@ template void write_MEDIT(std::ostream& os, - const CGAL::Mesh_complex_3_in_triangulation_3& c3t3, - const NamedParameters& np = parameters::default_values()) + const CGAL::Mesh_complex_3_in_triangulation_3& c3t3, + const NamedParameters& np = parameters::default_values()) { - return write_MEDIT(os, c3t3.triangulation(), np); + using parameters::get_parameter; + using parameters::choose_parameter; + + bool renumber_subdomain_indices = choose_parameter(get_parameter(np, internal_np::rebind_labels), false);; + bool show_patches = choose_parameter(get_parameter(np, internal_np::show_patches), true); + bool all_c = choose_parameter(get_parameter(np, internal_np::all_cells), true); + bool all_v = all_c || choose_parameter(get_parameter(np, internal_np::all_vertices), true); + + output_to_medit(os, c3t3, renumber_subdomain_indices, show_patches, all_v, all_c); } /** From 2e53b28de5993fe881717dba49cebecf6fe8ffc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 13:59:21 +0100 Subject: [PATCH 002/127] Introduce a map that stores surface facet info The point is that in cell bases, we store facet info at great memory cost given that only a small fraction of the facets are surface (i.e., part of the complex / restricted) facets. --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index c209273c9b90..b96948f93039 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -1732,6 +1732,29 @@ class Mesh_complex_3_in_triangulation_3 mutable Edge_facet_counter edge_facet_counter_; + struct Facet_hash + { + std::size_t operator()(const Facet& f) const + { + std::size_t seed = 0; + Hash_handles_with_or_without_timestamps cell_hasher; + boost::hash_combine(seed, cell_hasher(f.first)); + boost::hash_combine(seed, f.second); + return seed; + } + }; + +public: + struct Surface_facet_info + { + Bare_point center_; + Surface_patch_index patch_index_; + Index center_index_; + }; + + mutable std::unordered_map surface_facet_info_; + +private: typename Number_of_elements::type number_of_facets_; typename Number_of_elements::type number_of_cells_; From c6c22fed0c985f02970bd0b6bedab0728b5868d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 14:01:13 +0100 Subject: [PATCH 003/127] Add C3T3 member function to access all surface facet info WIP: available with both cell member API and map API --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 157 +++++++++++++++++- 1 file changed, 153 insertions(+), 4 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index b96948f93039..45f11710d32a 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -484,10 +484,45 @@ class Mesh_complex_3_in_triangulation_3 /** sets the surface index of facet(\p cell, \p i) to \p index */ void set_surface_patch_index(const Cell_handle& cell, - const int i, - const Surface_patch_index& index) const + const int i, + const Surface_patch_index& index) const { +#ifdef CGAL_MESH_3_USE_C3T3_MAPS + // std::cout << "set " << &*(cell) << " " << i << " to " << index << " (new)" << std::endl; + surface_facet_info_[Facet(cell, i)].patch_index_ = index; +#endif + +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL cell->set_surface_patch_index(i, index); +#endif + } + /** sets the surface center of facet(\p cell, \p i) to \p p + */ + void set_surface_center(const Cell_handle& cell, + const int i, + const Bare_point& p) const + { +#ifdef CGAL_MESH_3_USE_C3T3_MAPS + surface_facet_info_[Facet(cell, i)].center_ = p; +#endif + +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL + cell->set_facet_surface_center(i, p); +#endif + } + /** sets the surface center index of facet(\p cell, \p i) to \p index + */ + void set_surface_center_index(const Cell_handle& cell, + const int i, + const Index& index) const + { +#ifdef CGAL_MESH_3_USE_C3T3_MAPS + surface_facet_info_[Facet(cell, i)].center_index_ = index; +#endif + +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL + cell->set_facet_surface_center_index(i, index); +#endif } /** sets the subdomain index of cell \p cell to \p index */ @@ -528,7 +563,94 @@ class Mesh_complex_3_in_triangulation_3 Surface_patch_index surface_patch_index(const Cell_handle& cell, const int i) const { - return cell->surface_patch_index(i); +#ifdef CGAL_MESH_3_USE_C3T3_MAPS + Surface_patch_index res_new = surface_facet_info_[Facet(cell, i)].patch_index_; +#endif + +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL + Surface_patch_index res_old = cell->surface_patch_index(i); + +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + if (res_new != res_old) { + std::cerr << __FILE__ << " " << __LINE__ << std::endl; + std::cerr << "new res = " << res_new << std::endl; + std::cerr << "old res = " << res_old << std::endl; + CGAL_assertion(false); + std::exit(1); + } +# endif + return res_old; +#else +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + return res_new; +# endif +#endif + CGAL_assertion(false); + std::exit(1); + } + /** returns the surface center of facet(\p cell, \p i) + */ + decltype(auto) surface_center(const Cell_handle& cell, + const int i) const + { + CGAL_precondition(is_in_complex(cell, i)); + +#ifdef CGAL_MESH_3_USE_C3T3_MAPS + const auto& res_new = surface_facet_info_[Facet(cell, i)].center_; +#endif + +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL + const auto res_old = cell->get_facet_surface_center(i); + +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + if (res_new != res_old) { + std::cerr << __FILE__ << " " << __LINE__ << std::endl; + std::cerr << "new res = " << res_new << std::endl; + std::cerr << "old res = " << res_old << std::endl; + CGAL_assertion(false); + std::exit(1); + } +# endif + return res_old; +#else +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + return res_new; +# endif +#endif + CGAL_assertion(false); + std::exit(1); + } + /** returns the surface center index of facet(\p cell, \p i) + */ + Index surface_center_index(const Cell_handle& cell, + const int i) const + { + CGAL_precondition(is_in_complex(cell, i)); + +#ifdef CGAL_MESH_3_USE_C3T3_MAPS + const auto& res_new = surface_facet_info_[Facet(cell, i)].center_index_; +#endif + +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL + const auto res_old = cell->get_facet_surface_center_index(i); + +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + if (res_new != res_old) { + std::cerr << __FILE__ << " " << __LINE__ << std::endl; + std::cerr << "new res = " << res_new << std::endl; + std::cerr << "old res = " << res_old << std::endl; + CGAL_assertion(false); + std::exit(1); + } +# endif + return res_old; +#else +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + return res_new; +# endif +#endif + CGAL_assertion(false); + std::exit(1); } /** returns the dimension of the lowest dimensional face of the input 3D * complex that contains the vertex @@ -782,7 +904,34 @@ class Mesh_complex_3_in_triangulation_3 */ bool is_in_complex(const Cell_handle& cell, const int i) const { - return (cell->is_facet_on_surface(i)); +#ifdef CGAL_MESH_3_USE_C3T3_MAPS + auto it = surface_facet_info_.find(Facet(cell, i)); + bool res_new = (it != surface_facet_info_.end() && it->second.patch_index_ != Subdomain_index()); +#endif + +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL + const bool res_old = cell->is_facet_on_surface(i); + +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + if (res_new != res_old) { + std::cerr << __FILE__ << " " << __LINE__ << std::endl; + std::cerr << &*cell << " " << i << std::endl; + std::cerr << "new res = " << res_new << std::endl; + std::cerr << "patch index (new) = " << it->second.patch_index_ << std::endl; + std::cerr << "old res = " << res_old << std::endl; + std::cerr << "patch index (old) = " << cell->surface_patch_index(i) << std::endl; + CGAL_assertion(false); + std::exit(1); + } +# endif + return res_old; +#else +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + return res_new; +# endif +#endif + CGAL_assertion(false); + std::exit(1); } /** * returns true if edge \p e belongs to the 1D complex From 8a062adc210cb81eb6e82185f5624eb00489a800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 14:02:49 +0100 Subject: [PATCH 004/127] TEMP: Fix Refine_cells_3 not unmarking facets about to be destroyed --- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index ad023df618e2..eee8a2dc4e3e 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -961,6 +961,17 @@ Refine_cells_3:: insert_impl(const Weighted_point& point, const Zone& zone) { + // @tmp + // Remove the cell's facets from the complex + // Do *not* call the C3T3's remove_from_complex() because the information + // on the opposite facet should not be cleared for boundary facets + auto cit = zone.cells.begin(); + for ( ; cit != zone.cells.end() ; ++cit ) + { + for (int i = 0 ; i < 4 ; ++i) + r_c3t3_.set_surface_patch_index(*cit, i, Subdomain_index()); + } + // TODO: look at this if( zone.locate_type == Tr::VERTEX ) { From 0484803308a7722616e86fd530375dc5e61a6420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 14:05:12 +0100 Subject: [PATCH 005/127] Optimize Mesh_vertex_base_3's memory footprint: - Get rid of the caches: squat the value -2 - Re-order class member to use as few bytes as possible --- Mesh_3/include/CGAL/Mesh_vertex_base_3.h | 32 +++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h index db43424ec4f4..7595c3f8c733 100644 --- a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h @@ -120,12 +120,9 @@ class Mesh_vertex_3 // Constructor Mesh_vertex_3() : Vb() - , number_of_incident_facets_(0) - , number_of_components_(0) , index_() , meshing_info_(0) , dimension_(-1) - , cache_validity(false) #ifdef CGAL_INTRUSIVE_LIST , next_intrusive_() , previous_intrusive_() @@ -196,19 +193,20 @@ class Mesh_vertex_3 ///@} bool is_c2t3_cache_valid() const { - return cache_validity; + return number_of_incident_facets_ != std::size_t(-2) && + number_of_components_ != std::size_t(-2); } void invalidate_c2t3_cache() { - cache_validity = false; + number_of_incident_facets_ = std::size_t(-2); + number_of_components_ = std::size_t(-2); } void set_c2t3_cache(const std::size_t i, const std::size_t j) { number_of_incident_facets_ = i; number_of_components_ = j; - cache_validity = true; } std::size_t cached_number_of_incident_facets() const @@ -229,30 +227,30 @@ class Mesh_vertex_3 Get_io_signature()() + "+" + Get_io_signature()(); } + private: +#ifdef CGAL_INTRUSIVE_LIST + Vertex_handle next_intrusive_; + Vertex_handle previous_intrusive_; +#endif - std::size_t number_of_incident_facets_; - std::size_t number_of_components_; // number of components in the adjacency + std::size_t time_stamp_ = std::size_t(-2); + std::size_t number_of_incident_facets_ = std::size_t(-2); + std::size_t number_of_components_ = std::size_t(-2); // number of components in the adjacency // graph of incident facets (in complex) + // Stores info needed by optimizers + FT meshing_info_; // Index of the lowest dimensional face of the input 3D complex // that contains me Index index_; - // Stores info needed by optimizers - FT meshing_info_; // Dimension of the lowest dimensional face of the input 3D complex // that contains me. Negative values are a marker for special vertices. short dimension_; - bool cache_validity; -#ifdef CGAL_INTRUSIVE_LIST - Vertex_handle next_intrusive_; - Vertex_handle previous_intrusive_; -#endif - std::size_t time_stamp_ = std::size_t(-2); -public: +public: friend std::istream& operator>>(std::istream &is, Mesh_vertex_3& v) { is >> static_cast(v); From a88a4d9149c199a7a4b90d910ae68f37ff462cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 14:07:49 +0100 Subject: [PATCH 006/127] Use the generic C3T3 member functions to access facet surface info --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 8 ++++---- Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h | 3 +-- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 14 +++++++------- .../CGAL/Mesh_3/Refine_facets_manifold_base.h | 2 +- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 11 +++-------- 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index f920e3e9d4cb..09de0aa33711 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1237,9 +1237,9 @@ class C3T3_helpers #endif // NOT CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 // Update facet surface center - Bare_point surface_center = std::get<0>(intersection); - facet.first->set_facet_surface_center(facet.second, surface_center); - facet_m.first->set_facet_surface_center(facet_m.second, surface_center); + const Bare_point& surface_center = std::get<0>(intersection); + c3t3_.set_surface_center(facet.first, facet.second, surface_center); + c3t3_.set_surface_center(facet_m.first, facet_m.second, surface_center); } } @@ -3480,7 +3480,7 @@ get_least_square_surface_plane(const Vertex_handle& v, Default_diagonalize_traits()); // The surface center of a facet might have an offset in periodic triangulations - const Bare_point& ref_facet_scp = ref_facet.first->get_facet_surface_center(ref_facet.second); + const Bare_point& ref_facet_scp = c3t3_.surface_center(ref_facet.first, ref_facet.second); const Bare_point& ref_point = tr_.get_closest_point(cp(position), ref_facet_scp); return std::make_pair(plane, ref_point); } diff --git a/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h b/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h index 74dbb09b2ca5..cba58d897887 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h +++ b/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h @@ -290,8 +290,7 @@ class Lloyd_move // calling a function 'get_closest_point(p, q)' that simply returns q // for a non-periodic triangulation, and checks all possible offsets for // periodic triangulations - points.push_back(tr.get_closest_point(cp(position), - cell->get_facet_surface_center(i))); + points.push_back(tr.get_closest_point(cp(position), c3t3.surface_center(cell, i))); } return points; diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 20dc7dab196b..a2fe85f16083 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -455,23 +455,23 @@ class Refine_facets_3_base { const Facet mirror = mirror_facet(f); - f.first->set_facet_surface_center(f.second, p); - mirror.first->set_facet_surface_center(mirror.second, p); + r_c3t3_.set_surface_center(f.first, f.second, p); + r_c3t3_.set_surface_center(mirror.first, mirror.second, p); - f.first->set_facet_surface_center_index(f.second,index); - mirror.first->set_facet_surface_center_index(mirror.second,index); + r_c3t3_.set_surface_center_index(f.first, f.second, index); + r_c3t3_.set_surface_center_index(mirror.first, mirror.second, index); } /// Returns facet surface center of `f`. - Bare_point get_facet_surface_center(const Facet& f) const + decltype(auto) get_facet_surface_center(const Facet& f) const { - return f.first->get_facet_surface_center(f.second); + return r_c3t3_.surface_center(f.first, f.second); } /// Returns index of surface center of facet `f`. Index get_facet_surface_center_index(const Facet& f) const { - return f.first->get_facet_surface_center_index(f.second); + return r_c3t3_.surface_center_index(f.first, f.second); } /// Sets `f` to surface facets, with index `index`. 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 e3c8bf0d4e5b..7940884c913d 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 @@ -136,7 +136,7 @@ class Refine_facets_manifold_base 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(); - const Bare_point& fcenter = f.first->get_facet_surface_center(f.second); + const Bare_point& fcenter = this->r_c3t3_.surface_center(f.first, f.second); const Weighted_point& wp = this->r_tr_.point(v); return this->r_tr_.min_squared_distance(fcenter, cp(wp)) - cw(wp); diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 45f11710d32a..f6fc4ba63b94 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -735,10 +735,8 @@ class Mesh_complex_3_in_triangulation_3 Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i)); if (is_in_complex(mirror_facet)) { - set_surface_patch_index(c, i, - surface_patch_index(mirror_facet)); - c->set_facet_surface_center(i, - mirror_facet.first->get_facet_surface_center(mirror_facet.second)); + set_surface_patch_index(c, i, surface_patch_index(mirror_facet)); + set_surface_center(c, i, surface_center(mirror_facet.first, mirror_facet.second)); } } /*int i_inf; @@ -746,10 +744,7 @@ class Mesh_complex_3_in_triangulation_3 { Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i_inf)); if (is_in_complex(mirror_facet)) - { - set_surface_patch_index(c, i_inf, - surface_patch_index(mirror_facet)); - } + set_surface_patch_index(c, i_inf, surface_patch_index(mirror_facet)); }*/ } } From a1f9533ade5dd03012bcffae4ff4afd8fa0c6211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 14:09:55 +0100 Subject: [PATCH 007/127] Template mesh criteria by the C3T3 and not the triangulation I need access to the C3T3 member functions. This could be restricted to surface facet criteria only, but might as well do it for everything. --- .../Mesh_3/Cell_criteria_visitor_with_balls.h | 17 +- .../Facet_criteria_visitor_with_balls.h | 39 ++-- .../Mesh_3/Facet_on_same_surface_criterion.h | 9 +- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 4 +- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 2 +- ...cet_topological_criterion_with_adjacency.h | 11 +- .../CGAL/Mesh_3/mesh_standard_cell_criteria.h | 120 ++++++----- .../CGAL/Mesh_3/mesh_standard_criteria.h | 44 ++-- .../Mesh_3/mesh_standard_facet_criteria.h | 197 ++++++++++-------- Mesh_3/include/CGAL/Mesh_cell_criteria_3.h | 26 +-- Mesh_3/include/CGAL/Mesh_criteria_3.h | 23 +- Mesh_3/include/CGAL/Mesh_edge_criteria_3.h | 3 +- Mesh_3/include/CGAL/Mesh_facet_criteria_3.h | 31 +-- 13 files changed, 284 insertions(+), 242 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Cell_criteria_visitor_with_balls.h b/Mesh_3/include/CGAL/Mesh_3/Cell_criteria_visitor_with_balls.h index 3e6824d27ea8..2f3eefb5a94f 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Cell_criteria_visitor_with_balls.h +++ b/Mesh_3/include/CGAL/Mesh_3/Cell_criteria_visitor_with_balls.h @@ -26,23 +26,24 @@ namespace CGAL { namespace Mesh_3 { -template +template class Cell_criteria_visitor_with_balls - : public Criterion_visitor + : public Criterion_visitor { - typedef Criterion_visitor Base; + typedef Criterion_visitor Base; typedef Cell_criteria_visitor_with_balls Self; public: - typedef Abstract_criterion Criterion; - typedef Mesh_3::Cell_radius_criterion Cell_radius_criterion; - typedef Mesh_3::Cell_radius_edge_criterion Cell_radius_edge_criterion; + typedef Abstract_criterion Criterion; + typedef Mesh_3::Cell_radius_criterion Cell_radius_criterion; + typedef Mesh_3::Cell_radius_edge_criterion Cell_radius_edge_criterion; typedef typename Base::Quality Cell_quality; typedef typename Base::Is_bad Is_cell_bad; typedef typename Base::Handle Handle; typedef Handle Cell_handle; + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Weighted_point Weighted_point; typedef typename Tr::Geom_traits GT; @@ -56,9 +57,11 @@ class Cell_criteria_visitor_with_balls typedef typename Tr::Vertex_handle Vertex_handle; // Constructor - Cell_criteria_visitor_with_balls(const Tr& tr, const Cell_handle& ch) + Cell_criteria_visitor_with_balls(const C3T3& c3t3, const Cell_handle& ch) : Base(tr, ch) { + const Tr& tr = c3t3.triangulation(); + typename GT::Compare_weighted_squared_radius_3 compare_sq_radius = tr.geom_traits().compare_weighted_squared_radius_3_object(); typename GT::Squared_radius_orthogonal_sphere sq_radius_ortho_sphere = diff --git a/Mesh_3/include/CGAL/Mesh_3/Facet_criteria_visitor_with_balls.h b/Mesh_3/include/CGAL/Mesh_3/Facet_criteria_visitor_with_balls.h index 0db721cd9d97..e80fbcaba6de 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Facet_criteria_visitor_with_balls.h +++ b/Mesh_3/include/CGAL/Mesh_3/Facet_criteria_visitor_with_balls.h @@ -27,20 +27,20 @@ namespace CGAL { namespace Mesh_3 { -template +template class Facet_criterion_visitor_with_balls - : public Mesh_3::Criterion_visitor + : public Mesh_3::Criterion_visitor { - typedef Mesh_3::Criterion_visitor Base; - typedef Facet_criterion_visitor_with_balls Self; + typedef Mesh_3::Criterion_visitor Base; + typedef Facet_criterion_visitor_with_balls Self; public: - typedef Mesh_3::Abstract_criterion Criterion; - typedef Mesh_3::Curvature_size_criterion Curvature_size_criterion; - typedef Mesh_3::Aspect_ratio_criterion Aspect_ratio_criterion; - typedef Mesh_3::Facet_on_surface_criterion Facet_on_surface_criterion; - typedef Mesh_3::Uniform_size_criterion Uniform_size_criterion; - typedef Mesh_3::Facet_on_same_surface_criterion Facet_on_same_surface_criterion; + typedef Mesh_3::Abstract_criterion Criterion; + typedef Mesh_3::Curvature_size_criterion Curvature_size_criterion; + typedef Mesh_3::Aspect_ratio_criterion Aspect_ratio_criterion; + typedef Mesh_3::Facet_on_surface_criterion Facet_on_surface_criterion; + typedef Mesh_3::Uniform_size_criterion Uniform_size_criterion; + typedef Mesh_3::Facet_on_same_surface_criterion Facet_on_same_surface_criterion; typedef typename Base::Quality Facet_quality; @@ -48,6 +48,7 @@ class Facet_criterion_visitor_with_balls typedef typename Base::Handle Handle; typedef Handle Facet; + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Weighted_point Weighted_point; typedef typename Tr::Geom_traits GT; @@ -62,24 +63,24 @@ class Facet_criterion_visitor_with_balls // Constructor - Facet_criterion_visitor_with_balls(const Tr& tr, const Facet& fh) - : Base(tr, fh) + Facet_criterion_visitor_with_balls(const C3T3& c3t3, const Facet& fh) + : Base(c3t3, fh) , wp_nb_(0) , radius_ortho_shpere(0.) , ratio(0.) { typename GT::Compare_weighted_squared_radius_3 compare_sq_radius = - tr.geom_traits().compare_weighted_squared_radius_3_object(); + c3t3.triangulation().geom_traits().compare_weighted_squared_radius_3_object(); typename GT::Compute_weight_3 cw = - tr.geom_traits().compute_weight_3_object(); + c3t3.triangulation().geom_traits().compute_weight_3_object(); typename GT::Construct_point_3 cp = - tr.geom_traits().construct_point_3_object(); + c3t3.triangulation().geom_traits().construct_point_3_object(); typename GT::Squared_radius_orthogonal_sphere sq_radius_ortho_sphere = - tr.geom_traits().compute_squared_radius_smallest_orthogonal_sphere_3_object(); + c3t3.triangulation().geom_traits().compute_squared_radius_smallest_orthogonal_sphere_3_object(); - Weighted_point wp1 = tr.point(fh.first, (fh.second+1)&3); - Weighted_point wp2 = tr.point(fh.first, (fh.second+2)&3); - Weighted_point wp3 = tr.point(fh.first, (fh.second+3)&3); + Weighted_point wp1 = c3t3.triangulation().point(fh.first, (fh.second+1)&3); + Weighted_point wp2 = c3t3.triangulation().point(fh.first, (fh.second+2)&3); + Weighted_point wp3 = c3t3.triangulation().point(fh.first, (fh.second+3)&3); if(compare_sq_radius(wp1, FT(0)) == CGAL::SMALLER) { ++wp_nb_; } if(compare_sq_radius(wp2, FT(0)) == CGAL::SMALLER) { ++wp_nb_; } diff --git a/Mesh_3/include/CGAL/Mesh_3/Facet_on_same_surface_criterion.h b/Mesh_3/include/CGAL/Mesh_3/Facet_on_same_surface_criterion.h index ed23d58d876b..0a644e6ff915 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Facet_on_same_surface_criterion.h +++ b/Mesh_3/include/CGAL/Mesh_3/Facet_on_same_surface_criterion.h @@ -28,18 +28,19 @@ namespace CGAL { namespace Mesh_3 { -//template +//template //class Facet_on_same_surface_criterion : -//public Mesh_3::Abstract_criterion +//public Mesh_3::Abstract_criterion //{ //private: +// typedef typename C3T3::Triangulation Tr; // typedef typename Tr::Facet Facet; // -// typedef Mesh_3::Abstract_criterion Base; +// typedef Mesh_3::Abstract_criterion Base; // typedef typename Base::Quality Quality; // typedef typename Base::Is_bad Is_bad; // -// typedef Facet_on_same_surface_criterion Self; +// typedef Facet_on_same_surface_criterion Self; // //public: // /// Constructor diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index eee8a2dc4e3e..51ccb633b09e 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -766,7 +766,7 @@ number_of_bad_elements_impl() const Subdomain subdomain = r_oracle_.is_in_domain_object()(r_tr_.dual(cell_it)); if ( subdomain ) { - const Is_cell_bad is_cell_bad = r_criteria_(r_tr_, cell_it); + const Is_cell_bad is_cell_bad = r_criteria_(r_c3t3_, cell_it); if( is_cell_bad ) ++count; } @@ -948,7 +948,7 @@ void Refine_cells_3:: is_bad(const Cell_handle& cell) { - const Is_cell_bad is_cell_bad = r_criteria_(r_tr_, cell); + const Is_cell_bad is_cell_bad = r_criteria_(r_c3t3_, cell); if( is_cell_bad ) { this->add_bad_element(this->from_cell_to_refinement_queue_element(cell), *is_cell_bad); diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index a2fe85f16083..bb9cc89b72d0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -1608,7 +1608,7 @@ treat_new_facet(Facet& facet) set_facet_on_surface(facet, surface_index); // Insert facet into refinement queue if needed - const Is_facet_bad is_facet_bad = r_criteria_(r_tr_, facet); + const Is_facet_bad is_facet_bad = r_criteria_(r_c3t3_, facet); if ( is_facet_bad ) { diff --git a/Mesh_3/include/CGAL/Mesh_3/experimental/Facet_topological_criterion_with_adjacency.h b/Mesh_3/include/CGAL/Mesh_3/experimental/Facet_topological_criterion_with_adjacency.h index 2e3f3e313bbc..b54f73942cbd 100644 --- a/Mesh_3/include/CGAL/Mesh_3/experimental/Facet_topological_criterion_with_adjacency.h +++ b/Mesh_3/include/CGAL/Mesh_3/experimental/Facet_topological_criterion_with_adjacency.h @@ -22,18 +22,19 @@ namespace CGAL { namespace Mesh_3 { -template +template class Facet_topological_criterion_with_adjacency : -public Mesh_3::Abstract_criterion +public Mesh_3::Abstract_criterion { private: + typedef typename C3T3::Triangualtion Tr; typedef typename Tr::Facet Facet; - typedef Mesh_3::Abstract_criterion Base; + typedef Mesh_3::Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Facet_topological_criterion_with_adjacency Self; + typedef Facet_topological_criterion_with_adjacency Self; typedef typename Tr::Geom_traits::FT FT; @@ -60,7 +61,7 @@ public Mesh_3::Abstract_criterion return new Self(*this); } - virtual Is_bad do_is_bad (const Tr& /*tr*/, const Facet& f) const + virtual Is_bad do_is_bad (const C3T3& /*c3t3*/, const Facet& f) const { typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_cell_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_cell_criteria.h index e9543925efbf..2328ccdfb398 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_cell_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_cell_criteria.h @@ -34,18 +34,19 @@ namespace CGAL { namespace Mesh_3 { -template +template class Cell_radius_edge_criterion - : public Abstract_criterion + : public Abstract_criterion { + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Geom_traits::FT FT; - typedef Abstract_criterion Base; + typedef Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Cell_radius_edge_criterion Self; + typedef Cell_radius_edge_criterion Self; public: // Constructor @@ -69,7 +70,7 @@ class Cell_radius_edge_criterion return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& tr, const Cell_handle& ch) const + virtual Is_bad do_is_bad(const C3T3& c3t3, const Cell_handle& ch) const { typedef typename Tr::Geom_traits Geom_traits; typedef typename Tr::Bare_point Bare_point; @@ -79,6 +80,8 @@ class Cell_radius_edge_criterion typedef typename Geom_traits::Compute_squared_radius_3 Radius; typedef typename Geom_traits::Construct_point_3 Construct_point_3; + const Tr& tr = c3t3.triangulation(); + Distance distance = tr.geom_traits().compute_squared_distance_3_object(); Radius sq_radius = tr.geom_traits().compute_squared_radius_3_object(); Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); @@ -121,24 +124,25 @@ class Cell_radius_edge_criterion -template +template class Cell_size_criterion - : public Abstract_criterion + : public Abstract_criterion { }; -template +template class Cell_uniform_size_criterion - : public Cell_size_criterion + : public Cell_size_criterion { + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Geom_traits::FT FT; - typedef Abstract_criterion Base; + typedef Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Cell_uniform_size_criterion Self; + typedef Cell_uniform_size_criterion Self; public: // Constructor @@ -168,7 +172,7 @@ class Cell_uniform_size_criterion return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& tr, const Cell_handle& ch) const + virtual Is_bad do_is_bad(const C3T3& c3t3, const Cell_handle& ch) const { typedef typename Tr::Geom_traits Geom_traits; typedef typename Tr::Bare_point Bare_point; @@ -176,6 +180,9 @@ class Cell_uniform_size_criterion typedef typename Geom_traits::Compute_squared_radius_3 Radius; typedef typename Geom_traits::Construct_point_3 Construct_point_3; + + const Tr& tr = c3t3.triangulation(); + Radius sq_radius = tr.geom_traits().compute_squared_radius_3_object(); Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); @@ -217,19 +224,20 @@ class Cell_uniform_size_criterion }; // end class Cell_uniform_size_criterion -template +template class Cell_variable_size_criterion -: public Cell_size_criterion +: public Cell_size_criterion { + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Geom_traits::FT FT; typedef typename Tr::Vertex::Index Index; - typedef Abstract_criterion Base; + typedef Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Cell_variable_size_criterion Self; + typedef Cell_variable_size_criterion Self; typedef SizingField Sizing_field; public: @@ -252,7 +260,7 @@ class Cell_variable_size_criterion return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& tr, const Cell_handle& ch) const + virtual Is_bad do_is_bad(const C3T3& c3t3, const Cell_handle& ch) const { typedef typename Tr::Geom_traits Geom_traits; typedef typename Tr::Bare_point Bare_point; @@ -260,6 +268,9 @@ class Cell_variable_size_criterion typedef typename Geom_traits::Compute_squared_radius_3 Radius; typedef typename Geom_traits::Construct_point_3 Construct_point_3; + + const Tr& tr = c3t3.triangulation(); + Radius sq_radius = tr.geom_traits().compute_squared_radius_3_object(); Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); @@ -295,20 +306,19 @@ class Cell_variable_size_criterion /// New cell criterion that disallows a cell to have points on different /// surfaces, if they are all of dimension 2. -template +template class No_bridge_cell_criterion - : public Abstract_criterion + : public Abstract_criterion { - typedef C3t3_ C3t3; - typedef typename C3t3::Triangulation Tr; + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Geom_traits::FT FT; - typedef Abstract_criterion Base; + typedef Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef No_bridge_cell_criterion Self; + typedef No_bridge_cell_criterion Self; public: // Constructor @@ -331,7 +341,7 @@ class No_bridge_cell_criterion return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& /*tr*/, const Cell_handle& ch) const + virtual Is_bad do_is_bad(const C3T3& /*c3t3*/, const Cell_handle& ch) const { typedef typename Tr::Vertex_handle Vertex_handle; @@ -346,7 +356,7 @@ class No_bridge_cell_criterion vs->in_dimension() != 2) return Is_bad(); - typedef typename C3t3::Index Index; + typedef typename C3T3::Index Index; const Index& vp_index = vp->index(); if(vq->index() != vp_index || @@ -359,15 +369,15 @@ class No_bridge_cell_criterion }; // end class No_bridge_cell_criterion -template +template class Cell_criterion_visitor - : public Criterion_visitor + : public Criterion_visitor { - typedef Criterion_visitor Base; - typedef Cell_criterion_visitor Self; + typedef Criterion_visitor Base; + typedef Cell_criterion_visitor Self; public: - typedef Abstract_criterion Criterion; + typedef Abstract_criterion Criterion; typedef typename Base::Quality Cell_quality; typedef typename Base::Is_bad Is_cell_bad; typedef typename Base::Handle Handle; @@ -388,13 +398,14 @@ class Cell_criterion_visitor }; // end class Cell_criterion_visitor -template +template class Cell_criteria_visitor_with_features - : public Criterion_visitor + : public Criterion_visitor { - typedef Criterion_visitor Base; - typedef Cell_criteria_visitor_with_features Self; + typedef Criterion_visitor Base; + typedef Cell_criteria_visitor_with_features Self; + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Geom_traits GT; typedef typename GT::FT FT; typedef typename Tr::Weighted_point Weighted_point; @@ -407,13 +418,15 @@ class Cell_criteria_visitor_with_features typedef Handle Cell_handle; // Constructor - Cell_criteria_visitor_with_features(const Tr& tr, const Cell_handle& ch) - : Base(tr, ch) + Cell_criteria_visitor_with_features(const C3T3& c3t3, const Cell_handle& ch) + : Base(c3t3, ch) , wp_nb_(0) , do_spheres_intersect_(false) , ratio_(0) , size_ratio_(0.5*0.5*4.) { + const Tr& tr = c3t3.triangulation(); + typename GT::Compare_weighted_squared_radius_3 compare = tr.geom_traits().compare_weighted_squared_radius_3_object(); typename GT::Compute_weight_3 cw = @@ -513,8 +526,8 @@ class Cell_criteria_visitor_with_features ~Cell_criteria_visitor_with_features() {} // visit functions - template - void visit(const Mesh_3::Cell_size_criterion& criterion) + template + void visit(const Mesh_3::Cell_size_criterion& criterion) { if ( ratio_ < size_ratio_ && (do_spheres_intersect_ || 1 == wp_nb_) ) @@ -526,8 +539,8 @@ class Cell_criteria_visitor_with_features Base::do_visit(criterion); } - template - void visit(const Mesh_3::Cell_radius_edge_criterion& criterion) + template + void visit(const Mesh_3::Cell_radius_edge_criterion& criterion) { if ( (wp_nb_ >= 2 && do_spheres_intersect_) || 1 == wp_nb_ ) @@ -539,8 +552,8 @@ class Cell_criteria_visitor_with_features Base::do_visit(criterion); } - template - void visit(const Abstract_criterion& criterion) + template + void visit(const Abstract_criterion& criterion) { Base::do_visit(criterion); } @@ -553,13 +566,14 @@ class Cell_criteria_visitor_with_features }; // end class Cell_criteria_visitor_with_features -template +template class Cell_criterion_visitor_with_radius_lower_bound - : public Cell_criteria_visitor_with_features + : public Cell_criteria_visitor_with_features { - typedef Cell_criteria_visitor_with_features Base; - typedef Cell_criterion_visitor_with_radius_lower_bound Self; + typedef Cell_criteria_visitor_with_features Base; + typedef Cell_criterion_visitor_with_radius_lower_bound Self; + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Geom_traits GT; typedef typename GT::FT FT; @@ -570,9 +584,9 @@ class Cell_criterion_visitor_with_radius_lower_bound typedef Handle Cell_handle; // Constructor - Cell_criterion_visitor_with_radius_lower_bound(const Tr& tr, + Cell_criterion_visitor_with_radius_lower_bound(const C3T3& c3t3, const Cell_handle& ch) - : Base(tr, ch) + : Base(c3t3, ch) , dont_go_further_(false) {} @@ -581,7 +595,7 @@ class Cell_criterion_visitor_with_radius_lower_bound if (dont_go_further_) return Is_cell_bad(); else - return Base::is_bad(); + return Base::is_bad(); } bool go_further() const @@ -599,14 +613,14 @@ class Cell_criterion_visitor_with_radius_lower_bound Base::visit(criterion); } - template - void visit(const Mesh_3::Abstract_criterion& criterion) + template + void visit(const Mesh_3::Abstract_criterion& criterion) { Base::visit(criterion); } - template - void visit(const Mesh_3::Cell_uniform_size_criterion& criterion) + template + void visit(const Mesh_3::Cell_uniform_size_criterion& criterion) { Base::visit(criterion); diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_criteria.h index a3564c1b946c..74397589b01b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_criteria.h @@ -33,11 +33,13 @@ namespace Mesh_3 { /** * @class Abstract_criterion */ -template +template class Abstract_criterion { + typedef Abstract_criterion Self; + + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Geom_traits::FT FT; - typedef Abstract_criterion Self; public: typedef FT Quality; @@ -48,36 +50,36 @@ class Abstract_criterion virtual ~Abstract_criterion() {} void accept(Visitor_& v) const { do_accept(v); } - Is_bad is_bad(const Tr& tr, const Handle& h) const { return do_is_bad(tr, h); } + Is_bad is_bad(const C3T3& c3t3, const Handle& h) const { return do_is_bad(c3t3, h); } Self* clone() const { return do_clone(); } protected: virtual void do_accept(Visitor_& v) const = 0; - virtual Is_bad do_is_bad(const Tr& tr, const Handle& h) const = 0; + virtual Is_bad do_is_bad(const C3T3& c3t3, const Handle& h) const = 0; virtual Self* do_clone() const = 0; }; // end class Abstract_criterion -template +template inline -Abstract_criterion* -new_clone(const Abstract_criterion& criterion) +Abstract_criterion* +new_clone(const Abstract_criterion& criterion) { return criterion.clone(); } -template +template class Criterion_visitor { - typedef Criterion_visitor Self; + typedef Criterion_visitor Self; public: typedef Handle_ Handle; protected: - typedef Abstract_criterion Criterion; + typedef Abstract_criterion Criterion; public: typedef std::pair Quality; @@ -85,8 +87,8 @@ class Criterion_visitor // Constructor - Criterion_visitor(const Tr& tr, const Handle_& h) - : tr_(tr) + Criterion_visitor(const C3T3& c3t3, const Handle_& h) + : c3t3_(c3t3) , handle_(h) , is_bad_() , criterion_counter_(0) {} @@ -116,11 +118,11 @@ class Criterion_visitor } template - void do_visit(const Abstract_criterion& criterion) + void do_visit(const Abstract_criterion& criterion) { - typedef typename Abstract_criterion::Is_bad Is_bad; + typedef typename Abstract_criterion::Is_bad Is_bad; - const Is_bad is_bad = criterion.is_bad(tr_, handle_); + const Is_bad is_bad = criterion.is_bad(c3t3_, handle_); if ( is_bad ) is_bad_ = std::make_pair(criterion_counter_, *is_bad); @@ -128,7 +130,7 @@ class Criterion_visitor } private: - const Tr& tr_; + const C3T3& c3t3_; Handle_ handle_; Is_bad is_bad_; int criterion_counter_; @@ -137,12 +139,12 @@ class Criterion_visitor -template +template class Criteria { - typedef Criteria Self; + typedef Criteria Self; - typedef Abstract_criterion Criterion; + typedef Abstract_criterion Criterion; typedef boost::ptr_vector Criterion_vector; typedef typename Visitor_::Quality Quality; typedef typename Visitor_::Is_bad Is_bad; @@ -164,10 +166,10 @@ class Criteria criterion_vector_.push_back(criterion); } - Is_bad operator()(const Tr& tr, + Is_bad operator()(const C3T3& c3t3, const typename Visitor_::Handle& h) const { - Visitor_ visitor(tr, h); + Visitor_ visitor(c3t3, h); typename Criterion_vector::const_iterator it = criterion_vector_.begin(); for ( ; it != criterion_vector_.end() ; ++it ) 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 4e42d3810054..04e952dcc76c 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 @@ -50,19 +50,20 @@ namespace details { // Aspect_ratio Criterion class -template +template class Aspect_ratio_criterion : - public Mesh_3::Abstract_criterion + public Mesh_3::Abstract_criterion { private: + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Facet Facet; typedef typename Tr::Geom_traits::FT FT; - typedef Mesh_3::Abstract_criterion Base; + typedef Mesh_3::Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Aspect_ratio_criterion Self; + typedef Aspect_ratio_criterion Self; public: // Nb: the default bound of the criterion is such that the criterion @@ -97,9 +98,9 @@ class Aspect_ratio_criterion : } } - virtual Is_bad do_is_bad(const Tr& tr, const Facet& f) const + virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion (f.first->is_facet_on_surface(f.second)); + CGAL_assertion (c3t3.is_in_complex(f.first, f.second)); CGAL_assertion (B_ != 0); typedef typename Tr::Geom_traits GT; @@ -111,6 +112,8 @@ class Aspect_ratio_criterion : typedef typename GT::Construct_point_3 Construct_point_3; typedef typename GT::Construct_triangle_3 Construct_triangle_3; + const Tr& tr = c3t3.triangulation(); + Area area = tr.geom_traits().compute_squared_area_3_object(); Distance distance = tr.geom_traits().compute_squared_distance_3_object(); Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); @@ -152,24 +155,25 @@ class Aspect_ratio_criterion : // Curvature_adapted size Criterion class -template +template class Curvature_size_criterion : - public Mesh_3::Abstract_criterion + public Mesh_3::Abstract_criterion {}; -template +template class Uniform_curvature_size_criterion : - public Curvature_size_criterion + public Curvature_size_criterion { private: + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Facet Facet; typedef typename Tr::Geom_traits::FT FT; - typedef Mesh_3::Abstract_criterion Base; + typedef Mesh_3::Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Uniform_curvature_size_criterion Self; + typedef Uniform_curvature_size_criterion Self; public: // Nb: the default bound of the criterion is such that the criterion @@ -188,15 +192,17 @@ class Uniform_curvature_size_criterion : return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& tr, const Facet& f) const + virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion(f.first->is_facet_on_surface(f.second)); + CGAL_assertion(c3t3.is_in_complex(f.first, f.second)); CGAL_assertion (B_ != 0); typedef typename Tr::Geom_traits GT; typedef typename Tr::Weighted_point Weighted_point; typedef typename Tr::Bare_point Bare_point; + const Tr& tr = c3t3.triangulation(); + typename GT::Construct_weighted_circumcenter_3 weighted_circumcenter = tr.geom_traits().construct_weighted_circumcenter_3_object(); @@ -205,7 +211,7 @@ class Uniform_curvature_size_criterion : const Weighted_point& p3 = tr.point(f.first, (f.second+3)&3); const Bare_point c = weighted_circumcenter(p1,p2,p3); - const Bare_point& center = f.first->get_facet_surface_center(f.second); + const Bare_point& center = c3t3.surface_center(f.first, f.second); const FT sq_dist = tr.min_squared_distance(c, center); @@ -227,20 +233,21 @@ class Uniform_curvature_size_criterion : }; // end Uniform_curvature_size_criterion // Variable size Criterion class -template +template class Variable_curvature_size_criterion : - public Curvature_size_criterion + public Curvature_size_criterion { private: + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Facet Facet; typedef typename Tr::Geom_traits::FT FT; typedef typename Tr::Vertex::Index Index; - typedef Mesh_3::Abstract_criterion Base; + typedef Mesh_3::Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Variable_curvature_size_criterion Self; + typedef Variable_curvature_size_criterion Self; typedef SizingField Sizing_field; public: @@ -260,14 +267,16 @@ class Variable_curvature_size_criterion : return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& tr, const Facet& f) const + virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion (f.first->is_facet_on_surface(f.second)); + CGAL_assertion (c3t3.is_in_complex(f.first, f.second)); typedef typename Tr::Geom_traits GT; typedef typename Tr::Weighted_point Weighted_point; typedef typename Tr::Bare_point Bare_point; + const Tr& tr = c3t3.triangulation(); + typename GT::Construct_weighted_circumcenter_3 weighted_circumcenter = tr.geom_traits().construct_weighted_circumcenter_3_object(); @@ -276,8 +285,8 @@ class Variable_curvature_size_criterion : const Weighted_point& p3 = tr.point(f.first, (f.second+3)&3); const Bare_point c = weighted_circumcenter(p1,p2,p3); - const Bare_point& ball_center = f.first->get_facet_surface_center(f.second); - const Index& index = f.first->get_facet_surface_center_index(f.second); + const Bare_point& ball_center = c3t3.surface_center(f.first, f.second); + const Index& index = c3t3.surface_center_index(f.first, f.second); const FT sq_dist = tr.min_squared_distance(c, ball_center); const FT sq_bound = CGAL::square(size_(ball_center, 2, index)); @@ -302,27 +311,28 @@ class Variable_curvature_size_criterion : }; // end Variable_curvature_size_criterion // Size Criterion base class -template < typename Tr, typename Visitor_ > +template < typename C3T3, typename Visitor_ > class Facet_size_criterion : - public Mesh_3::Abstract_criterion + public Mesh_3::Abstract_criterion { }; // Variable size Criterion class -template +template class Variable_size_criterion : - public Facet_size_criterion + public Facet_size_criterion { private: + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Facet Facet; typedef typename Tr::Geom_traits::FT FT; typedef typename Tr::Vertex::Index Index; - typedef Mesh_3::Abstract_criterion Base; + typedef Mesh_3::Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Variable_size_criterion Self; + typedef Variable_size_criterion Self; typedef SizingField Sizing_field; public: @@ -342,20 +352,22 @@ class Variable_size_criterion : return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& tr, const Facet& f) const + virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion (f.first->is_facet_on_surface(f.second)); + CGAL_assertion (c3t3.is_in_complex(f.first, f.second)); typedef typename Tr::Geom_traits GT; typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Weighted_point Weighted_point; + const Tr& tr = c3t3.triangulation(); + typename GT::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); const Weighted_point& wp1 = tr.point(f.first, (f.second+1)&3); const Bare_point& p1 = cp(wp1); - const Bare_point& ball_center = f.first->get_facet_surface_center(f.second); - const Index& index = f.first->get_facet_surface_center_index(f.second); + const Bare_point& ball_center = c3t3.surface_center(f.first, f.second); + const Index& index = c3t3.surface_center_index(f.first, f.second); const FT sq_radius = tr.min_squared_distance(p1, ball_center); const FT sq_bound = CGAL::square(size_(ball_center, 2, index)); @@ -381,19 +393,20 @@ class Variable_size_criterion : // Uniform size Criterion class -template +template class Uniform_size_criterion : - public Facet_size_criterion + public Facet_size_criterion { private: + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Facet Facet; typedef typename Tr::Geom_traits::FT FT; - typedef Mesh_3::Abstract_criterion Base; + typedef Mesh_3::Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Uniform_size_criterion Self; + typedef Uniform_size_criterion Self; public: // Nb: the default bound of the criterion is such that the criterion @@ -421,20 +434,22 @@ class Uniform_size_criterion : return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& tr, const Facet& f) const + virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion (f.first->is_facet_on_surface(f.second)); + CGAL_assertion (c3t3.is_in_complex(f.first, f.second)); CGAL_assertion (B_ != 0); typedef typename Tr::Geom_traits GT; typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Weighted_point Weighted_point; + const Tr& tr = c3t3.triangulation(); + typename GT::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); const Weighted_point& wp1 = tr.point(f.first, (f.second+1)&3); const Bare_point p1 = cp(wp1); - const Bare_point& ball_center = f.first->get_facet_surface_center(f.second); + const Bare_point& ball_center = c3t3.surface_center(f.first, f.second); const FT sq_radius = tr.min_squared_distance(p1, ball_center); @@ -466,18 +481,19 @@ class Uniform_size_criterion : -template +template class Facet_on_surface_criterion : - public Mesh_3::Abstract_criterion + public Mesh_3::Abstract_criterion { private: + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Facet Facet; - typedef Mesh_3::Abstract_criterion Base; + typedef Mesh_3::Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Facet_on_surface_criterion Self; + typedef Facet_on_surface_criterion Self; public: /// Constructor @@ -497,7 +513,7 @@ class Facet_on_surface_criterion : return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& /* tr */, const Facet& f) const + virtual Is_bad do_is_bad(const C3T3& /*c3t3*/, const Facet& f) const { typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; @@ -524,18 +540,19 @@ class Facet_on_surface_criterion : }; // end class Facet_on_surface_criterion -template +template class Facet_on_same_surface_criterion : -public Mesh_3::Abstract_criterion +public Mesh_3::Abstract_criterion { private: + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Facet Facet; - typedef Mesh_3::Abstract_criterion Base; + typedef Mesh_3::Abstract_criterion Base; typedef typename Base::Quality Quality; typedef typename Base::Is_bad Is_bad; - typedef Facet_on_same_surface_criterion Self; + typedef Facet_on_same_surface_criterion Self; public: /// Constructor @@ -555,7 +572,7 @@ public Mesh_3::Abstract_criterion return new Self(*this); } - virtual Is_bad do_is_bad(const Tr& /* tr */, const Facet& f) const + virtual Is_bad do_is_bad(const C3T3& /*c3t3*/, const Facet& f) const { typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; @@ -616,15 +633,15 @@ public Mesh_3::Abstract_criterion -template +template class Facet_criterion_visitor - : public Mesh_3::Criterion_visitor + : public Mesh_3::Criterion_visitor { - typedef Mesh_3::Criterion_visitor Base; - typedef Facet_criterion_visitor Self; + typedef Mesh_3::Criterion_visitor Base; + typedef Facet_criterion_visitor Self; public: - typedef Mesh_3::Abstract_criterion Criterion; + typedef Mesh_3::Abstract_criterion Criterion; typedef typename Base::Quality Facet_quality; typedef typename Base::Is_bad Is_facet_bad; typedef typename Base::Handle Handle; @@ -645,16 +662,19 @@ class Facet_criterion_visitor }; // end class Facet_criterion_visitor - -template +template class Facet_criterion_visitor_with_features - : public Mesh_3::Criterion_visitor + : public Mesh_3::Criterion_visitor { - typedef Mesh_3::Criterion_visitor Base; - typedef Facet_criterion_visitor_with_features Self; + typedef Mesh_3::Criterion_visitor Base; + typedef Facet_criterion_visitor_with_features Self; + + typedef typename C3T3::Triangulation Tr; + typedef typename Tr::Weighted_point Weighted_point; + typedef typename Tr::Cell_handle Cell_handle; - typedef typename Tr::Geom_traits GT; - typedef typename GT::FT FT; + typedef typename Tr::Geom_traits GT; + typedef typename GT::FT FT; public: typedef typename Base::Quality Facet_quality; @@ -663,8 +683,8 @@ class Facet_criterion_visitor_with_features typedef Handle Facet; // Constructor - Facet_criterion_visitor_with_features(const Tr& tr, const Facet& fh) - : Base(tr, fh) + Facet_criterion_visitor_with_features(const C3T3& c3t3, const Facet& fh) + : Base(c3t3, fh) , wp_nb_(0) , do_spheres_intersect_(false) , ratio_(0.) @@ -672,9 +692,7 @@ class Facet_criterion_visitor_with_features , angle_ratio_(0.5*0.5*4.) , size_ratio_(0.4*0.4*4.) { - typedef typename Tr::Geom_traits GT; - typedef typename Tr::Weighted_point Weighted_point; - typedef typename Tr::Cell_handle Cell_handle; + const Tr& tr = c3t3.triangulation(); typename GT::Compute_squared_radius_smallest_orthogonal_sphere_3 sq_radius = tr.geom_traits().compute_squared_radius_smallest_orthogonal_sphere_3_object(); @@ -748,8 +766,8 @@ class Facet_criterion_visitor_with_features } // visit functions - template - void visit(const Mesh_3::Abstract_criterion& criterion) + template + void visit(const Mesh_3::Abstract_criterion& criterion) { if ( 3 == wp_nb_ && do_spheres_intersect_ ) { @@ -760,8 +778,8 @@ class Facet_criterion_visitor_with_features Base::do_visit(criterion); } - template - void visit(const Mesh_3::Curvature_size_criterion& criterion) + template + void visit(const Mesh_3::Curvature_size_criterion& criterion) { if ( ratio_ < approx_ratio_ && (do_spheres_intersect_ || 1 == wp_nb_ ) ) @@ -773,8 +791,8 @@ class Facet_criterion_visitor_with_features Base::do_visit(criterion); } - template - void visit(const Mesh_3::Aspect_ratio_criterion& criterion) + template + void visit(const Mesh_3::Aspect_ratio_criterion& criterion) { if ( ratio_ < angle_ratio_ && (do_spheres_intersect_ || 1 == wp_nb_) ) @@ -786,8 +804,8 @@ class Facet_criterion_visitor_with_features Base::do_visit(criterion); } - template - void visit(const Mesh_3::Facet_size_criterion& criterion) + template + void visit(const Mesh_3::Facet_size_criterion& criterion) { if ( ratio_ < size_ratio_ && (do_spheres_intersect_ || 1 == wp_nb_) ) @@ -807,18 +825,19 @@ class Facet_criterion_visitor_with_features FT angle_ratio_; FT size_ratio_; -}; // end class Facet_criterion_visitor +}; // end class Facet_criterion_visitor_with_features -template +template class Facet_criterion_visitor_with_radius_lower_bound - : public Facet_criterion_visitor_with_features + : public Facet_criterion_visitor_with_features { - typedef Facet_criterion_visitor_with_features Base; - typedef Facet_criterion_visitor_with_radius_lower_bound Self; + typedef Facet_criterion_visitor_with_features Base; + typedef Facet_criterion_visitor_with_radius_lower_bound Self; - typedef typename Tr::Geom_traits GT; - typedef typename GT::FT FT; + typedef typename C3T3::Triangulation Tr; + typedef typename Tr::Geom_traits GT; + typedef typename GT::FT FT; public: typedef typename Base::Quality Facet_quality; @@ -827,8 +846,8 @@ class Facet_criterion_visitor_with_radius_lower_bound typedef Handle Facet; // Constructor - Facet_criterion_visitor_with_radius_lower_bound(const Tr& tr, const Facet& fh) - : Base(tr, fh) + Facet_criterion_visitor_with_radius_lower_bound(const C3T3& c3t3, const Facet& fh) + : Base(c3t3, fh) , dont_go_further_(false) {} @@ -855,14 +874,14 @@ class Facet_criterion_visitor_with_radius_lower_bound Base::visit(criterion); } - template - void visit(const Mesh_3::Abstract_criterion& criterion) + template + void visit(const Mesh_3::Abstract_criterion& criterion) { Base::visit(criterion); } - template - void visit(const Mesh_3::Uniform_size_criterion& criterion) + template + void visit(const Mesh_3::Uniform_size_criterion& criterion) { Base::visit(criterion); @@ -872,8 +891,6 @@ class Facet_criterion_visitor_with_radius_lower_bound private: bool dont_go_further_; - - };// end class Facet_criterion_visitor_with_radius_lower_bound diff --git a/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h b/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h index 4627578c5efd..a2510c298a10 100644 --- a/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h @@ -45,9 +45,9 @@ and a sizing field which may be a uniform or variable field. \sa `CGAL::Mesh_criteria_3` \sa `CGAL::make_mesh_3()` */ -template + ,typename Visitor_ = Mesh_3::Cell_criterion_visitor_with_radius_lower_bound #endif > class Mesh_cell_criteria_3 @@ -56,6 +56,8 @@ class Mesh_cell_criteria_3 /// \name Types /// @{ + typedef typename C3T3::Triangulation Tr; + /*! Numerical type */ @@ -67,13 +69,13 @@ class Mesh_cell_criteria_3 typedef typename Visitor::Cell_quality Cell_quality; typedef typename Visitor::Is_cell_bad Is_cell_bad; - typedef Mesh_3::Abstract_criterion Abstract_criterion; + typedef Mesh_3::Abstract_criterion Abstract_criterion; private: - typedef Mesh_3::Criteria Criteria; + typedef Mesh_3::Criteria Criteria; typedef typename Tr::Cell_handle Cell_handle; - typedef Mesh_cell_criteria_3 Self; + typedef Mesh_cell_criteria_3 Self; public: @@ -127,7 +129,7 @@ class Mesh_cell_criteria_3 ,const FT& min_radius_bound = 0. #ifndef DOXYGEN_RUNNING ,std::enable_if_t< - Mesh_3::Is_mesh_domain_field_3::value + Mesh_3::Is_mesh_domain_field_3::value >* = 0 #endif ) @@ -151,9 +153,9 @@ class Mesh_cell_criteria_3 * @param tr the triangulation within which `cell` lives * @param cell the cell */ - Is_cell_bad operator()(const Tr& tr, const Cell_handle& cell) const + Is_cell_bad operator()(const C3T3& c3t3, const Cell_handle& cell) const { - return criteria_(tr, cell); + return criteria_(c3t3, cell); } #ifndef DOXYGEN_RUNNING @@ -166,20 +168,20 @@ class Mesh_cell_criteria_3 private: void init_radius_edge(const FT& radius_edge_bound) { - typedef Mesh_3::Cell_radius_edge_criterion Radius_edge_criterion; + typedef Mesh_3::Cell_radius_edge_criterion Radius_edge_criterion; criteria_.add(new Radius_edge_criterion(radius_edge_bound)); } void init_radius(const FT& radius_bound) { - typedef Mesh_3::Cell_uniform_size_criterion Radius_criterion; + typedef Mesh_3::Cell_uniform_size_criterion Radius_criterion; criteria_.add(new Radius_criterion(radius_bound)); } template < typename Sizing_field> void init_radius(const Sizing_field& radius_bound) { - typedef Mesh_3::Cell_variable_size_criterion + typedef Mesh_3::Cell_variable_size_criterion Radius_criterion; criteria_.add(new Radius_criterion(radius_bound)); @@ -187,7 +189,7 @@ class Mesh_cell_criteria_3 void init_min_radius(const FT& min_radius_bound) { - typedef Mesh_3::Cell_uniform_size_criterion Radius_criterion; + typedef Mesh_3::Cell_uniform_size_criterion Radius_criterion; criteria_.add(new Radius_criterion(min_radius_bound, true/*lower bound*/)); } diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index 8186b2980743..1fdc32e58efc 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -30,17 +30,16 @@ #include // for the macro DBL_MAX namespace CGAL { - - namespace internal { // Class Mesh_criteria_3_impl -template < typename Tr, +template < typename C3T3, typename EdgeCriteria, typename FacetCriteria, typename CellCriteria > class Mesh_criteria_3_impl { + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Geom_traits::FT FT; public: @@ -172,19 +171,19 @@ Mesh_criteria_3 criteria (parameters::cell_radius_edge_ratio(2). \sa `CGAL::Mesh_facet_topology` */ -template , - typename FacetCriteria = Mesh_facet_criteria_3, - typename CellCriteria = Mesh_cell_criteria_3 > +template , + typename FacetCriteria = Mesh_facet_criteria_3, + typename CellCriteria = Mesh_cell_criteria_3 > class Mesh_criteria_3 #ifndef DOXYGEN_RUNNING - : public internal::Mesh_criteria_3_impl< Tr, + : public internal::Mesh_criteria_3_impl< C3T3, EdgeCriteria, FacetCriteria, CellCriteria > #endif { - typedef internal::Mesh_criteria_3_impl< Tr, + typedef internal::Mesh_criteria_3_impl< C3T3, EdgeCriteria, FacetCriteria, CellCriteria> Base; @@ -197,18 +196,18 @@ class Mesh_criteria_3 /*! The criteria for edges. */ -typedef Mesh_edge_criteria_3 Edge_criteria; +typedef Mesh_edge_criteria_3 Edge_criteria; /*! The criteria for facets. */ -typedef Mesh_facet_criteria_3 Facet_criteria; +typedef Mesh_facet_criteria_3 Facet_criteria; /*! The criteria for cells. */ -typedef Mesh_cell_criteria_3 Cell_criteria; +typedef Mesh_cell_criteria_3 Cell_criteria; /// @} #else diff --git a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h index f743eb3f0fa3..3d8926618ae9 100644 --- a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h @@ -99,11 +99,12 @@ provides bounds for the size and approximation criteria. \sa `CGAL::Mesh_criteria_3` \sa `MeshDomainField_3` */ -template < typename Tr > +template < typename C3T3 > class Mesh_edge_criteria_3 { private: typedef Mesh_edge_criteria_3 Self; + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Geom_traits GT; public: diff --git a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h index 5292e0e94787..0f6967d43424 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h @@ -53,13 +53,14 @@ namespace CGAL { \sa `CGAL::make_mesh_3()` */ -template + ,typename Visitor_ = Mesh_3::Facet_criterion_visitor_with_radius_lower_bound #endif > class Mesh_facet_criteria_3 { + typedef typename C3T3::Triangulation Tr; public: /// \name Types @@ -76,14 +77,14 @@ class Mesh_facet_criteria_3 typedef typename Visitor::Facet_quality Facet_quality; typedef typename Visitor::Is_facet_bad Is_facet_bad; - typedef Mesh_3::Abstract_criterion Abstract_criterion; + typedef Mesh_3::Abstract_criterion Abstract_criterion; private: - typedef Mesh_3::Criteria Criteria; + typedef Mesh_3::Criteria Criteria; typedef typename Tr::Facet Facet; - typedef Mesh_facet_criteria_3 Self; + typedef Mesh_facet_criteria_3 Self; public: typedef CGAL::Tag_true Has_manifold_criterion; @@ -165,9 +166,9 @@ class Mesh_facet_criteria_3 * @param tr the triangulation within which `facet` lives * @param facet the facet */ - Is_facet_bad operator()(const Tr& tr, const Facet& facet) const + Is_facet_bad operator()(const C3T3& c3t3, const Facet& facet) const { - return criteria_(tr, facet); + return criteria_(c3t3, facet); } void add(Abstract_criterion* criterion) @@ -193,41 +194,41 @@ class Mesh_facet_criteria_3 private: void init_aspect(const FT& angle_bound) { - typedef Mesh_3::Aspect_ratio_criterion Aspect_criterion; + typedef Mesh_3::Aspect_ratio_criterion Aspect_criterion; criteria_.add(new Aspect_criterion(angle_bound)); } void init_radius(const FT& radius_bound, Tag_false) { if(FT(0) == radius_bound) return; - typedef Mesh_3::Uniform_size_criterion Uniform_size_criterion; + typedef Mesh_3::Uniform_size_criterion Uniform_size_criterion; criteria_.add(new Uniform_size_criterion(radius_bound)); } template void init_radius(const Sizing_field& radius_bound, Tag_true) { - typedef Mesh_3::Variable_size_criterion Variable_size_criterion; + typedef Mesh_3::Variable_size_criterion Variable_size_criterion; criteria_.add(new Variable_size_criterion(radius_bound)); } void init_min_radius(const FT& min_radius_bound) { - typedef Mesh_3::Uniform_size_criterion Uniform_size_criterion; + typedef Mesh_3::Uniform_size_criterion Uniform_size_criterion; criteria_.add(new Uniform_size_criterion(min_radius_bound, true/*lower bound*/)); } void init_distance(const FT& distance_bound, Tag_false) { if(FT(0) == distance_bound) return; - typedef Mesh_3::Uniform_curvature_size_criterion Criterion; + typedef Mesh_3::Uniform_curvature_size_criterion Criterion; criteria_.add(new Criterion(distance_bound)); } template void init_distance(const Sizing_field& distance_bound, Tag_true) { - typedef Mesh_3::Variable_curvature_size_criterion Criterion; criteria_.add(new Criterion(distance_bound)); @@ -240,7 +241,7 @@ class Mesh_facet_criteria_3 { case FACET_VERTICES_ON_SURFACE: { - typedef Mesh_3::Facet_on_surface_criterion On_surface_criterion; + typedef Mesh_3::Facet_on_surface_criterion On_surface_criterion; criteria_.add(new On_surface_criterion()); break; } @@ -249,7 +250,7 @@ class Mesh_facet_criteria_3 case FACET_VERTICES_ON_SAME_SURFACE_PATCH_WITH_ADJACENCY_CHECK: // @TODO: Implement adjacency check ! { - typedef Mesh_3::Facet_on_same_surface_criterion Same_surface_criterion; + typedef Mesh_3::Facet_on_same_surface_criterion Same_surface_criterion; criteria_.add(new Same_surface_criterion()); break; } From 4e6dd171b767ff31e68936e4fba58f4144800955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 14:12:18 +0100 Subject: [PATCH 008/127] WIP: Optimize Compact_mesh_cell_base_3: - Do not use a base_base - Avoid the sliver cache: all values are positive, so squat -2 as a cache. - Do not use surface info arrays, use the C3T3 maps - Re-order for byte padding --- .../include/CGAL/Compact_mesh_cell_base_3.h | 116 +++++++++++++++--- 1 file changed, 102 insertions(+), 14 deletions(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 0b1ceffc369b..91f5ad49abb7 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -257,10 +257,61 @@ template< class Point_3, class Index_, class TDS> class Compact_mesh_cell_3 +#ifndef CGAL_MESH_3_NO_COMPACT_BASE_BASE : public Compact_mesh_cell_base_3_base +#endif { +#ifndef CGAL_MESH_3_NO_COMPACT_BASE_BASE typedef Compact_mesh_cell_base_3_base Base; using Base::weighted_circumcenter_; +#else +public: +# if defined(CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE) \ + || defined(CGAL_MESH_3_USE_LAZY_UNSORTED_REFINEMENT_QUEUE) + + // Erase counter (cf. Compact_container) + unsigned int erase_counter() const + { + return this->m_erase_counter; + } + void set_erase_counter(unsigned int c) + { + this->m_erase_counter = c; + } + void increment_erase_counter() + { + ++this->m_erase_counter; + } +# endif + + /// Marks `facet` as visited + void set_facet_visited (const int facet) + { + CGAL_precondition(facet>=0 && facet <4); + bits_ |= char(1 << facet); + } + + /// Marks `facet` as not visited + void reset_visited (const int facet) + { + CGAL_precondition(facet>=0 && facet<4); + bits_ = char(bits_ & (15 & ~(1 << facet))); + } + + /// Returns `true` if `facet` is marked as visited + bool is_facet_visited (const int facet) const + { + CGAL_precondition(facet>=0 && facet<4); + return ( (bits_ & (1 << facet)) != 0 ); + } + + /// Precondition weighted_circumcenter_ == nullptr + void try_to_set_circumcenter(Point_3 *cc) const + { + CGAL_precondition(weighted_circumcenter_ == nullptr); + weighted_circumcenter_ = cc; + } +#endif // CGAL_MESH_3_NO_COMPACT_BASE_BASE public: typedef TDS Triangulation_data_structure; @@ -307,13 +358,17 @@ class Compact_mesh_cell_3 , time_stamp_(rhs.time_stamp_) , sliver_value_(rhs.sliver_value_) , subdomain_index_(rhs.subdomain_index_) +#ifndef CGAL_MESH_3_NO_SLIVER_CACHE , sliver_cache_validity_(false) +#endif { +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL for(int i=0; i <4; i++){ surface_index_table_[i] = rhs.surface_index_table_[i]; surface_center_table_[i]= rhs.surface_center_table_[i]; surface_center_index_table_[i] = rhs.surface_center_index_table_[i]; } +#endif } Compact_mesh_cell_3 (Vertex_handle v0, @@ -513,7 +568,9 @@ class Compact_mesh_cell_3 void set_sliver_value(double value) { +#ifndef CGAL_MESH_3_NO_SLIVER_CACHE sliver_cache_validity_ = true; +#endif sliver_value_ = value; } @@ -523,9 +580,15 @@ class Compact_mesh_cell_3 return sliver_value_; } +#ifdef CGAL_MESH_3_NO_SLIVER_CACHE + bool is_cache_valid() const { return sliver_value_ >= 0; } + void reset_cache_validity() { sliver_value_ = -2; } +#else bool is_cache_valid() const { return sliver_cache_validity_; } void reset_cache_validity() const { sliver_cache_validity_ = false; } +#endif +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL /// Set surface index of `facet` to `index` void set_surface_patch_index(const int facet, const Surface_patch_index& index) { @@ -574,6 +637,7 @@ class Compact_mesh_cell_3 CGAL_precondition(facet>=0 && facet<4); return ( !( Surface_patch_index() == surface_index_table_[facet] )); } +#endif // ----------------------------------- // Backward Compatibility @@ -630,37 +694,61 @@ class Compact_mesh_cell_3 ///@} private: +#ifdef CGAL_MESH_3_NO_SLIVER_CACHE + double sliver_value_ = -2.; +#else + double sliver_value_ = 0.; +#endif - - /// Stores surface_index for each facet of the cell - std::array surface_index_table_ = {}; - /// Stores surface center of each facet of the cell - std::array surface_center_table_ = {}; - /// Stores surface center index of each facet of the cell + std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; std::array N; std::array V; + // Point_container _hidden; + +#ifdef CGAL_MESH_3_NO_COMPACT_BASE_BASE + mutable Point_3* weighted_circumcenter_ = nullptr; +#endif + #ifdef CGAL_INTRUSIVE_LIST Cell_handle next_intrusive_ = {}, previous_intrusive_ = {}; #endif - std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; - std::array surface_center_index_table_ = {}; + // The index of the cell of the input complex that contains me + Subdomain_index subdomain_index_ = {}; + +#ifdef CGAL_MESH_3_NO_COMPACT_BASE_BASE /// Stores visited facets (4 first bits) + char bits_ = 0; +#endif - // Point_container _hidden; + TDS_data _tds_data; - double sliver_value_ = 0.; + // -- Below is unused -- - // The index of the cell of the input complex that contains me - Subdomain_index subdomain_index_ = {}; +#ifdef CGAL_MESH_3_NO_COMPACT_BASE_BASE +# if defined(CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE) \ + || defined(CGAL_MESH_3_USE_LAZY_UNSORTED_REFINEMENT_QUEUE) + typedef unsigned int Erase_counter_type; + Erase_counter_type m_erase_counter; +# endif +#endif // CGAL_MESH_3_NO_COMPACT_BASE_BASE - TDS_data _tds_data; +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL + /// Stores surface_index for each facet of the cell + std::array surface_index_table_ = {}; + /// Stores surface center of each facet of the cell + std::array surface_center_table_ = {}; + /// Stores surface center index of each facet of the cell + std::array surface_center_index_table_ = {}; +#endif + +#ifndef CGAL_MESH_3_NO_SLIVER_CACHE mutable bool sliver_cache_validity_ = false; +#endif public: - friend std::istream& operator>>(std::istream &is, Compact_mesh_cell_3 &c) { Subdomain_index index; From a35a04841a796e18d51ed7dc07f665965329b9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 14:14:20 +0100 Subject: [PATCH 009/127] TMP: disable some code --- Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h | 16 ++++++++-------- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 91f5ad49abb7..899d48ecbce8 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -767,7 +767,7 @@ class Compact_mesh_cell_3 { read(is, i2); } - c.set_surface_patch_index(i, i2); + // c.set_surface_patch_index(i, i2); // @tmp } } return is; @@ -780,13 +780,13 @@ class Compact_mesh_cell_3 os << c.subdomain_index(); else write(os, c.subdomain_index()); - for(int i = 0; i < 4; ++i) - { - if(IO::is_ascii(os)) - os << ' ' << IO::oformat(c.surface_patch_index(i)); - else - write(os, c.surface_patch_index(i)); - } + // for(int i = 0; i < 4; ++i) // @tmp + // { + // if(IO::is_ascii(os)) + // os << ' ' << IO::oformat(c.surface_patch_index(i)); + // else + // write(os, c.surface_patch_index(i)); + // } return os; } diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 09de0aa33711..408731c22012 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1404,6 +1404,7 @@ class C3T3_helpers private: void backup_finite_cell(const Cell_handle& c) { +#ifndef CGAL_MESH_3_USE_C3T3_MAPS if(c->is_cache_valid()) sliver_value_ = c->sliver_value(); else @@ -1421,11 +1422,15 @@ class C3T3_helpers //are lost by 'backup' and 'restore', //because all cells are changing during the move //they are not used in update_mesh functions involving a Sliver_criterion +#else + std::exit(1); +#endif } void backup_infinite_cell(const Cell_handle& c, const C3T3& c3t3) { +#ifndef CGAL_MESH_3_USE_C3T3_MAPS for (int ii = 0; ii < 4; ++ii) { if (c3t3.triangulation().is_infinite(c->vertex(ii))) @@ -1436,6 +1441,9 @@ class C3T3_helpers break; } } +#else + std::exit(1); +#endif } public: @@ -1482,6 +1490,7 @@ class C3T3_helpers const IndexMap& index_map,//new_to_old_indices C3T3& c3t3) { +#ifndef CGAL_MESH_3_USE_C3T3_MAPS if(sliver_value_ > 0.) c->set_sliver_value(sliver_value_); @@ -1512,11 +1521,15 @@ class C3T3_helpers const Facet mirror = c3t3.triangulation().mirror_facet(Facet(c, i)); mirror.first->set_facet_surface_center(mirror.second, facet_surface_center_[old_i]); } +#else + std::exit(1); +#endif } void restore_infinite_cell(Cell_handle c, C3T3& c3t3) { +#ifndef CGAL_MESH_3_USE_C3T3_MAPS c3t3.remove_from_complex(c);//infinite for (unsigned int i = 0; i < 4; ++i) { @@ -1534,6 +1547,9 @@ class C3T3_helpers return; } } +#else + std::exit(1); +#endif } private: From e0f60f6daa68a5881f9346a9ccafc876325f8d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 14:14:47 +0100 Subject: [PATCH 010/127] TMP: Surface checks for both API --- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 40 ++++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index 51ccb633b09e..24a0cf21c294 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -899,17 +899,39 @@ update_star_self(const Vertex_handle& vertex) const Cell_handle& neighbor_cell = mirror_f.first; const int& neighb_k = mirror_f.second; - if ( neighbor_cell->is_facet_on_surface(neighb_k) ) - { - // Facet(*cell_it,k) is on surface - (*cell_it)->set_surface_patch_index( - k,neighbor_cell->surface_patch_index(neighb_k)); +#ifdef CGAL_MESH_3_USE_C3T3_MAPS + const bool cond_new = r_c3t3_.is_in_complex(neighbor_cell, neighb_k); +#endif + +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL + const bool cond_old =neighbor_cell->is_facet_on_surface(neighb_k); - (*cell_it)->set_facet_surface_center( - k,neighbor_cell->get_facet_surface_center(neighb_k)); +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + if (cond_old != cond_new) { + std::cerr << "new cond = " << cond_new << std::endl; + std::cerr << "new cond = " << cond_new << std::endl; + std::exit(1); + } +# endif - (*cell_it)->set_facet_surface_center_index( - k,neighbor_cell->get_facet_surface_center_index(neighb_k)); + if (cond_old) +#else +# ifdef CGAL_MESH_3_USE_C3T3_MAPS + if (cond_new) +# else + std::exit(1); +# endif +#endif + + { + // Facet(*cell_it,k) is on surface + r_c3t3_.set_surface_patch_index(*cell_it, k, r_c3t3_.surface_patch_index(neighbor_cell, neighb_k)); + r_c3t3_.set_surface_center(*cell_it, k, r_c3t3_.surface_center(neighbor_cell, neighb_k)); + r_c3t3_.set_surface_center_index(*cell_it, k, r_c3t3_.surface_center_index(neighbor_cell, neighb_k)); + } + else + { + r_c3t3_.set_surface_patch_index(*cell_it, k, Subdomain_index()); } // Set subdomain index From c77a5b8b96bb8984c1884b434b9eac09d6bdbde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Feb 2026 14:15:23 +0100 Subject: [PATCH 011/127] TMP: dump map size --- Mesh_3/include/CGAL/Mesh_3/Mesher_3.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h index f2e5a29f7a7f..63768b13d826 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h @@ -626,6 +626,12 @@ refine_mesh(std::string dump_after_refine_surface_prefix, const bool surface_onl std::cerr << "Total refining time: " << timer.time() + elapsed_time << "s" << std::endl; std::cerr << std::endl; + // memory footprint of r_c3t3_.surface_facet_info_ + std::cout << "final surfacic element map size:" << std::endl; + std::cout << " surface facet info: " << r_c3t3_.surface_facet_info_.size() << std::endl; + std::cout << " surface facet info size in bytes: " + << r_c3t3_.surface_facet_info_.size() * sizeof(typename C3T3::Surface_facet_info) << std::endl; + CGAL_postcondition(r_tr.is_valid()); #endif From 0f831f7a03a6c63b31e5621c451927c5a425bfe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 18 Feb 2026 13:08:05 +0100 Subject: [PATCH 012/127] Fix index type --- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index 24a0cf21c294..8b947ccfd780 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -262,6 +262,7 @@ class Refine_cells_3 typedef typename Tr::Facet Facet; typedef typename Tr::Lock_data_structure Lock_data_structure; typedef typename MeshDomain::Subdomain_index Subdomain_index; + typedef typename MeshDomain::Surface_patch_index Surface_patch_index; typedef typename MeshDomain::Index Index; typedef typename Criteria::Is_cell_bad Is_cell_bad; @@ -931,7 +932,7 @@ update_star_self(const Vertex_handle& vertex) } else { - r_c3t3_.set_surface_patch_index(*cell_it, k, Subdomain_index()); + r_c3t3_.set_surface_patch_index(*cell_it, k, Surface_patch_index()); } // Set subdomain index @@ -991,7 +992,7 @@ insert_impl(const Weighted_point& point, for ( ; cit != zone.cells.end() ; ++cit ) { for (int i = 0 ; i < 4 ; ++i) - r_c3t3_.set_surface_patch_index(*cit, i, Subdomain_index()); + r_c3t3_.set_surface_patch_index(*cit, i, Surface_patch_index()); } // TODO: look at this From 259bde306436c8c3a984e49aeae0a25ccdaccc03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 18 Feb 2026 13:08:22 +0100 Subject: [PATCH 013/127] Fix missing typedef --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index f6fc4ba63b94..56c335c06049 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -207,6 +207,7 @@ class Mesh_complex_3_in_triangulation_3 /// @{ typedef Tr Triangulation; typedef typename Tr::size_type size_type; + typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Point Point; typedef typename Tr::Edge Edge; typedef typename Tr::Facet Facet; From 6f4a1b1c6eb9f845cf34cd53e30ece8dd9276945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 18 Feb 2026 13:08:31 +0100 Subject: [PATCH 014/127] Erase no-longer-surface facets from the C3T3 surface info map --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 56c335c06049..943748d9b34f 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -490,7 +490,10 @@ class Mesh_complex_3_in_triangulation_3 { #ifdef CGAL_MESH_3_USE_C3T3_MAPS // std::cout << "set " << &*(cell) << " " << i << " to " << index << " (new)" << std::endl; - surface_facet_info_[Facet(cell, i)].patch_index_ = index; + if (index == Surface_patch_index()) + surface_facet_info_.erase(Facet(cell, i)); + else + surface_facet_info_[Facet(cell, i)].patch_index_ = index; #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL From 8c6dd57bfb3e811a2ca56cddf5dfbba42fedecf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 18 Feb 2026 15:45:44 +0100 Subject: [PATCH 015/127] Avoid copies of shared data parameters --- AABB_tree/include/CGAL/AABB_tree.h | 2 +- .../include/CGAL/Minkowski_sum_2/AABB_tree_with_join.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_tree.h b/AABB_tree/include/CGAL/AABB_tree.h index 8476d671875e..6382bef9976f 100644 --- a/AABB_tree/include/CGAL/AABB_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree.h @@ -218,7 +218,7 @@ namespace CGAL { private: template - void set_primitive_data_impl(CGAL::Boolean_tag,T ... ){} + void set_primitive_data_impl(CGAL::Boolean_tag,const T& ... ){} template void set_primitive_data_impl(CGAL::Boolean_tag,T&& ... t) {m_traits.set_shared_data(std::forward(t)...);} diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_tree_with_join.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_tree_with_join.h index 2be3e2d094d9..a910f93a29ca 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_tree_with_join.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_tree_with_join.h @@ -194,7 +194,7 @@ namespace CGAL { private: template - void set_primitive_data_impl(CGAL::Boolean_tag,T ... ){} + void set_primitive_data_impl(CGAL::Boolean_tag,const T& ... ){} template void set_primitive_data_impl(CGAL::Boolean_tag,T ... t) {m_traits.set_shared_data(t...);} From b5357bf8afc7bb8be9b34e40697730954165bdd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 18 Feb 2026 16:49:27 +0100 Subject: [PATCH 016/127] Add move constructions to Polyhedral_mesh_domain_with_features --- .../Polyhedral_mesh_domain_with_features_3.h | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h index 833adbc5e578..2286be1e6192 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h @@ -171,20 +171,20 @@ class Polyhedral_mesh_domain_with_features_3 If `polyhedron` is closed, its inside will be meshed, otherwise there will be no interior and only the surface will be meshed. */ - Polyhedral_mesh_domain_with_features_3(const Polyhedron& polyhedron + Polyhedral_mesh_domain_with_features_3(Polyhedron polyhedron #ifndef DOXYGEN_RUNNING , CGAL::Random* p_rng = nullptr #endif ) : Base(p_rng) , borders_detected_(false) { - stored_polyhedra.resize(1); - stored_polyhedra[0] = polyhedron; + stored_polyhedra.emplace_back(std::move(polyhedron)); get(face_patch_id_t(), stored_polyhedra[0]); this->add_primitives(stored_polyhedra[0]); + this->build(); - if(!is_closed(polyhedron)) + if(!is_closed(stored_polyhedra[0])) this->set_surface_only(); } @@ -225,22 +225,21 @@ class Polyhedral_mesh_domain_with_features_3 Using this constructor enables to mesh a polyhedral surface which is not closed, or has holes. The inside of `bounding_polyhedron` will be meshed. */ - Polyhedral_mesh_domain_with_features_3(const Polyhedron& polyhedron, - const Polyhedron& bounding_polyhedron + Polyhedral_mesh_domain_with_features_3(Polyhedron polyhedron, + Polyhedron bounding_polyhedron #ifndef DOXYGEN_RUNNING , CGAL::Random* p_rng = nullptr #endif ) : Base(p_rng) , borders_detected_(false) { - stored_polyhedra.resize(2); - stored_polyhedra[0] = polyhedron; - stored_polyhedra[1] = bounding_polyhedron; + stored_polyhedra.emplace_back(std::move(polyhedron)); + stored_polyhedra.emplace_back(std::move(bounding_polyhedron)); get(face_patch_id_t(), stored_polyhedra[0]); get(face_patch_id_t(), stored_polyhedra[1]); this->add_primitives(stored_polyhedra[0]); this->add_primitives(stored_polyhedra[1]); - if(CGAL::is_empty(bounding_polyhedron)) { + if(CGAL::is_empty(stored_polyhedra[1])) { this->set_surface_only(); } else { this->add_primitives_to_bounding_tree(stored_polyhedra[1]); @@ -269,7 +268,7 @@ class Polyhedral_mesh_domain_with_features_3 { stored_polyhedra.reserve(std::distance(begin, end)); for (; begin != end; ++begin) { - stored_polyhedra.push_back(**begin); + stored_polyhedra.emplace_back(std::move(**begin)); get(face_patch_id_t(), stored_polyhedra.back()); this->add_primitives(stored_polyhedra.back()); } @@ -301,7 +300,7 @@ class Polyhedral_mesh_domain_with_features_3 stored_polyhedra.reserve(std::distance(begin, end)+1); if(begin != end) { for (; begin != end; ++begin) { - stored_polyhedra.push_back(**begin); + stored_polyhedra.emplace_back(std::move(**begin)); get(face_patch_id_t(), stored_polyhedra.back()); this->add_primitives(stored_polyhedra.back()); } From 565fde014dd8371977c8e297204c4f315923fb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 18 Feb 2026 17:48:04 +0100 Subject: [PATCH 017/127] Deal with warnings --- Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h | 7 ++++--- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 16 ++++++++-------- Mesh_3/include/CGAL/Mesh_vertex_base_3.h | 6 +++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 899d48ecbce8..f68cf9d15bb4 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -349,14 +349,15 @@ class Compact_mesh_cell_3 {} Compact_mesh_cell_3(const Compact_mesh_cell_3& rhs) - : N(rhs.N) + : + sliver_value_(rhs.sliver_value_) + , time_stamp_(rhs.time_stamp_) + , N(rhs.N) , V(rhs.V) #ifdef CGAL_INTRUSIVE_LIST , next_intrusive_(rhs.next_intrusive_) , previous_intrusive_(rhs.previous_intrusive_) #endif - , time_stamp_(rhs.time_stamp_) - , sliver_value_(rhs.sliver_value_) , subdomain_index_(rhs.subdomain_index_) #ifndef CGAL_MESH_3_NO_SLIVER_CACHE , sliver_cache_validity_(false) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 408731c22012..37859e1ea9af 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1402,7 +1402,7 @@ class C3T3_helpers } private: - void backup_finite_cell(const Cell_handle& c) + void backup_finite_cell(const Cell_handle& /*c*/) { #ifndef CGAL_MESH_3_USE_C3T3_MAPS if(c->is_cache_valid()) @@ -1427,8 +1427,8 @@ class C3T3_helpers #endif } - void backup_infinite_cell(const Cell_handle& c, - const C3T3& c3t3) + void backup_infinite_cell(const Cell_handle& /*c*/, + const C3T3& /*c3t3*/) { #ifndef CGAL_MESH_3_USE_C3T3_MAPS for (int ii = 0; ii < 4; ++ii) @@ -1486,9 +1486,9 @@ class C3T3_helpers private: typedef std::array IndexMap; - void restore(Cell_handle c, - const IndexMap& index_map,//new_to_old_indices - C3T3& c3t3) + void restore(Cell_handle /*c*/, + const IndexMap& /*index_map*/,//new_to_old_indices + C3T3& /*c3t3*/) { #ifndef CGAL_MESH_3_USE_C3T3_MAPS if(sliver_value_ > 0.) @@ -1526,8 +1526,8 @@ class C3T3_helpers #endif } - void restore_infinite_cell(Cell_handle c, - C3T3& c3t3) + void restore_infinite_cell(Cell_handle /*c*/, + C3T3& /*c3t3*/) { #ifndef CGAL_MESH_3_USE_C3T3_MAPS c3t3.remove_from_complex(c);//infinite diff --git a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h index 7595c3f8c733..ca950486cee6 100644 --- a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h @@ -120,13 +120,13 @@ class Mesh_vertex_3 // Constructor Mesh_vertex_3() : Vb() - , index_() - , meshing_info_(0) - , dimension_(-1) #ifdef CGAL_INTRUSIVE_LIST , next_intrusive_() , previous_intrusive_() #endif //CGAL_INTRUSIVE_LIST + , meshing_info_(0) + , index_() + , dimension_(-1) {} // Default copy constructor and assignment operator are ok From d3b9bfa3f697f0e7b6432c1640e91da195e9f451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 19 Feb 2026 12:49:18 +0100 Subject: [PATCH 018/127] Back to using compact_base_bases, but with good padding --- .../include/CGAL/Compact_mesh_cell_base_3.h | 112 ++++-------------- 1 file changed, 23 insertions(+), 89 deletions(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index f68cf9d15bb4..d87084f5684c 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -150,9 +150,10 @@ class Compact_mesh_cell_base_3_base weighted_circumcenter_ = cc; } -private: - char bits_; +protected: + mutable Point_3* weighted_circumcenter_; +private: #if defined(CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE) \ || defined(CGAL_MESH_3_USE_LAZY_UNSORTED_REFINEMENT_QUEUE) @@ -160,8 +161,7 @@ class Compact_mesh_cell_base_3_base Erase_counter_type m_erase_counter; #endif -protected: - mutable Point_3* weighted_circumcenter_; +char bits_; }; @@ -234,14 +234,15 @@ class Compact_mesh_cell_base_3_base delete cc; } +protected: + mutable std::atomic weighted_circumcenter_; + private: typedef std::atomic Erase_counter_type; Erase_counter_type m_erase_counter; + /// Stores visited facets (4 first bits) std::atomic bits_; - -protected: - mutable std::atomic weighted_circumcenter_; }; #endif // CGAL_LINKED_WITH_TBB @@ -257,61 +258,10 @@ template< class Point_3, class Index_, class TDS> class Compact_mesh_cell_3 -#ifndef CGAL_MESH_3_NO_COMPACT_BASE_BASE : public Compact_mesh_cell_base_3_base -#endif { -#ifndef CGAL_MESH_3_NO_COMPACT_BASE_BASE typedef Compact_mesh_cell_base_3_base Base; using Base::weighted_circumcenter_; -#else -public: -# if defined(CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE) \ - || defined(CGAL_MESH_3_USE_LAZY_UNSORTED_REFINEMENT_QUEUE) - - // Erase counter (cf. Compact_container) - unsigned int erase_counter() const - { - return this->m_erase_counter; - } - void set_erase_counter(unsigned int c) - { - this->m_erase_counter = c; - } - void increment_erase_counter() - { - ++this->m_erase_counter; - } -# endif - - /// Marks `facet` as visited - void set_facet_visited (const int facet) - { - CGAL_precondition(facet>=0 && facet <4); - bits_ |= char(1 << facet); - } - - /// Marks `facet` as not visited - void reset_visited (const int facet) - { - CGAL_precondition(facet>=0 && facet<4); - bits_ = char(bits_ & (15 & ~(1 << facet))); - } - - /// Returns `true` if `facet` is marked as visited - bool is_facet_visited (const int facet) const - { - CGAL_precondition(facet>=0 && facet<4); - return ( (bits_ & (1 << facet)) != 0 ); - } - - /// Precondition weighted_circumcenter_ == nullptr - void try_to_set_circumcenter(Point_3 *cc) const - { - CGAL_precondition(weighted_circumcenter_ == nullptr); - weighted_circumcenter_ = cc; - } -#endif // CGAL_MESH_3_NO_COMPACT_BASE_BASE public: typedef TDS Triangulation_data_structure; @@ -349,16 +299,15 @@ class Compact_mesh_cell_3 {} Compact_mesh_cell_3(const Compact_mesh_cell_3& rhs) - : - sliver_value_(rhs.sliver_value_) - , time_stamp_(rhs.time_stamp_) + : subdomain_index_(rhs.subdomain_index_) , N(rhs.N) , V(rhs.V) -#ifdef CGAL_INTRUSIVE_LIST + #ifdef CGAL_INTRUSIVE_LIST , next_intrusive_(rhs.next_intrusive_) , previous_intrusive_(rhs.previous_intrusive_) #endif - , subdomain_index_(rhs.subdomain_index_) + , time_stamp_(rhs.time_stamp_) + , sliver_value_(rhs.sliver_value_) #ifndef CGAL_MESH_3_NO_SLIVER_CACHE , sliver_cache_validity_(false) #endif @@ -695,46 +644,31 @@ class Compact_mesh_cell_3 ///@} private: -#ifdef CGAL_MESH_3_NO_SLIVER_CACHE - double sliver_value_ = -2.; -#else - double sliver_value_ = 0.; -#endif + // tds_data (1 byte) and subdomain index (4, usually) are at the top of the class members + // to use the tail padding from the base_base class (usually 8+1, or 8+4+1 with lazy queues) + TDS_data _tds_data; - std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; + // The index of the cell of the input complex that contains me + Subdomain_index subdomain_index_ = {}; std::array N; std::array V; - // Point_container _hidden; - -#ifdef CGAL_MESH_3_NO_COMPACT_BASE_BASE - mutable Point_3* weighted_circumcenter_ = nullptr; -#endif - #ifdef CGAL_INTRUSIVE_LIST Cell_handle next_intrusive_ = {}, previous_intrusive_ = {}; #endif - // The index of the cell of the input complex that contains me - Subdomain_index subdomain_index_ = {}; + std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; -#ifdef CGAL_MESH_3_NO_COMPACT_BASE_BASE - /// Stores visited facets (4 first bits) - char bits_ = 0; +#ifdef CGAL_MESH_3_NO_SLIVER_CACHE + double sliver_value_ = -2.; +#else + double sliver_value_ = 0.; #endif - TDS_data _tds_data; - // -- Below is unused -- -#ifdef CGAL_MESH_3_NO_COMPACT_BASE_BASE -# if defined(CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE) \ - || defined(CGAL_MESH_3_USE_LAZY_UNSORTED_REFINEMENT_QUEUE) - typedef unsigned int Erase_counter_type; - Erase_counter_type m_erase_counter; -# endif -#endif // CGAL_MESH_3_NO_COMPACT_BASE_BASE + // Point_container _hidden; #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL /// Stores surface_index for each facet of the cell From 898a78f25f6db4579c7e253360e65fff86130a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 19 Feb 2026 12:49:40 +0100 Subject: [PATCH 019/127] Fix macro choice --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 37859e1ea9af..d89ec44035ec 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1404,7 +1404,7 @@ class C3T3_helpers private: void backup_finite_cell(const Cell_handle& /*c*/) { -#ifndef CGAL_MESH_3_USE_C3T3_MAPS +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL if(c->is_cache_valid()) sliver_value_ = c->sliver_value(); else @@ -1430,7 +1430,7 @@ class C3T3_helpers void backup_infinite_cell(const Cell_handle& /*c*/, const C3T3& /*c3t3*/) { -#ifndef CGAL_MESH_3_USE_C3T3_MAPS +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL for (int ii = 0; ii < 4; ++ii) { if (c3t3.triangulation().is_infinite(c->vertex(ii))) @@ -1490,7 +1490,7 @@ class C3T3_helpers const IndexMap& /*index_map*/,//new_to_old_indices C3T3& /*c3t3*/) { -#ifndef CGAL_MESH_3_USE_C3T3_MAPS +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL if(sliver_value_ > 0.) c->set_sliver_value(sliver_value_); @@ -1529,7 +1529,7 @@ class C3T3_helpers void restore_infinite_cell(Cell_handle /*c*/, C3T3& /*c3t3*/) { -#ifndef CGAL_MESH_3_USE_C3T3_MAPS +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL c3t3.remove_from_complex(c);//infinite for (unsigned int i = 0; i < 4; ++i) { From 16c34b9559ba116ad65d1c23b8cde5828a5f8a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 20 Feb 2026 11:21:01 +0100 Subject: [PATCH 020/127] Parallel Facet->Surface info map + factorize/fix Edge Facet counter --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 296 ++++++++++++------ 1 file changed, 195 insertions(+), 101 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 943748d9b34f..9b9db0ac041c 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -45,56 +45,49 @@ #include #include - #ifdef CGAL_LINKED_WITH_TBB -#include #include +#include +#endif namespace CGAL { - template < class DSC, bool Const > - std::size_t tbb_hasher(const CGAL::internal::CC_iterator& it) +namespace SMDS_3 { +namespace details { + +struct Pair_hash +{ + template + std::size_t operator()(const std::pair& p) const { - return CGAL::internal::hash_value(it); + return boost::hash >()(p); } - // As Marc Glisse pointed out the TBB hash of a std::pair is - // simplistic and leads to the - // TBB Warning: Performance is not optimal because the hash function - // produces bad randomness in lower bits in class - // tbb::interface5::concurrent_hash_map - template < class DSC, bool Const > - std::size_t tbb_hasher(const std::pair, - CGAL::internal::CC_iterator >& p) + template + std::size_t hash(const Pair& p) const { - return boost::hash, - CGAL::internal::CC_iterator > >()(p); + return this->operator()(p); } - struct Hash_compare_for_TBB { - template < class DSC, bool Const > - std::size_t hash(const std::pair, - CGAL::internal::CC_iterator >& p) const - { - return tbb_hasher(p); - } - template < class DSC, bool Const > - std::size_t operator()(const CGAL::internal::CC_iterator& it) - { - return CGAL::internal::hash_value(it); - } - template - bool equal(const T& v1, const T& v2) const { - return v1 == v2; - } - }; -}//end namespace CGAL -#endif - -namespace CGAL { + template + bool equal(const T& v1, const T& v2) const { + return v1 == v2; + } +}; - namespace SMDS_3 { +template +struct Hash_map_of_pairs_type +{ + typedef std::unordered_map type; +}; - namespace details { +#ifdef CGAL_LINKED_WITH_TBB +template +struct Hash_map_of_pairs_type +{ + typedef tbb::concurrent_hash_map type; +}; +#endif template class C3t3_helper_class @@ -129,8 +122,8 @@ namespace CGAL { } }; // end class template C3t3_helper_class - } // end namespace SMDS_3::details - } //end namespace SMDS_3 +} // namespace details +} // namespace SMDS_3 /*! \ingroup PkgSMDS3Classes @@ -490,10 +483,26 @@ class Mesh_complex_3_in_triangulation_3 { #ifdef CGAL_MESH_3_USE_C3T3_MAPS // std::cout << "set " << &*(cell) << " " << i << " to " << index << " (new)" << std::endl; + if (index == Surface_patch_index()) + { surface_facet_info_.erase(Facet(cell, i)); + } else - surface_facet_info_[Facet(cell, i)].patch_index_ = index; + { +# ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, Facet(cell, i)); + accessor->second.patch_index_ = index; + } + else +# endif + { + surface_facet_info_[Facet(cell, i)].patch_index_ = index; + } + } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL @@ -507,7 +516,18 @@ class Mesh_complex_3_in_triangulation_3 const Bare_point& p) const { #ifdef CGAL_MESH_3_USE_C3T3_MAPS - surface_facet_info_[Facet(cell, i)].center_ = p; +# ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, Facet(cell, i)); + accessor->second.center_ = p; + } + else +# endif + { + surface_facet_info_[Facet(cell, i)].center_ = p; + } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL @@ -521,7 +541,18 @@ class Mesh_complex_3_in_triangulation_3 const Index& index) const { #ifdef CGAL_MESH_3_USE_C3T3_MAPS - surface_facet_info_[Facet(cell, i)].center_index_ = index; +# ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, Facet(cell, i)); + accessor->second.center_index_ = index; + } + else +# endif + { + surface_facet_info_[Facet(cell, i)].center_index_ = index; + } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL @@ -568,7 +599,21 @@ class Mesh_complex_3_in_triangulation_3 const int i) const { #ifdef CGAL_MESH_3_USE_C3T3_MAPS - Surface_patch_index res_new = surface_facet_info_[Facet(cell, i)].patch_index_; + Surface_patch_index res_new {}; +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::const_accessor accessor; + if (surface_facet_info_.find(accessor, Facet(cell, i))) + res_new = accessor->second.patch_index_; + } + else +# endif + { + auto it = surface_facet_info_.find(Facet(cell, i)); + if (it != surface_facet_info_.end()) + res_new = it->second.patch_index_; + } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL @@ -600,7 +645,23 @@ class Mesh_complex_3_in_triangulation_3 CGAL_precondition(is_in_complex(cell, i)); #ifdef CGAL_MESH_3_USE_C3T3_MAPS - const auto& res_new = surface_facet_info_[Facet(cell, i)].center_; + Bare_point res_new; // return directly when the comparison code is gone +# ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::const_accessor accessor; + CGAL_assume_code(bool found =) + surface_facet_info_.find(accessor, Facet(cell, i)); + CGAL_assume(found); + res_new = accessor->second.center_; + } + else +# endif + { + auto it = surface_facet_info_.find(Facet(cell, i)); + CGAL_assume(it != surface_facet_info_.end()); + res_new = it->second.center_; + } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL @@ -632,11 +693,27 @@ class Mesh_complex_3_in_triangulation_3 CGAL_precondition(is_in_complex(cell, i)); #ifdef CGAL_MESH_3_USE_C3T3_MAPS - const auto& res_new = surface_facet_info_[Facet(cell, i)].center_index_; + Index res_new; // return directly when the comparison code is gone +# ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::const_accessor accessor; + CGAL_assume_code(bool found =) + surface_facet_info_.find(accessor, Facet(cell, i)); + CGAL_assume(found); + res_new = accessor->second.center_index_; + } + else +# endif + { + auto it = surface_facet_info_.find(Facet(cell, i)); + CGAL_assume(it != surface_facet_info_.end()); + res_new = it->second.center_index_; + } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - const auto res_old = cell->get_facet_surface_center_index(i); + const Index res_old = cell->get_facet_surface_center_index(i); # ifdef CGAL_MESH_3_USE_C3T3_MAPS if (res_new != res_old) { @@ -904,8 +981,23 @@ class Mesh_complex_3_in_triangulation_3 bool is_in_complex(const Cell_handle& cell, const int i) const { #ifdef CGAL_MESH_3_USE_C3T3_MAPS - auto it = surface_facet_info_.find(Facet(cell, i)); - bool res_new = (it != surface_facet_info_.end() && it->second.patch_index_ != Subdomain_index()); + // if we always erase when trying to insert a default constructed Subdomain_index, + // we + bool res_new = false; +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::const_accessor accessor; + if (surface_facet_info_.find(accessor, Facet(cell, i))) + res_new = accessor->second.patch_index_ != Surface_patch_index(); + } + else +# endif + { + auto it = surface_facet_info_.find(Facet(cell, i)); + if (it != surface_facet_info_.end()) + res_new = (it->second.patch_index_ != Surface_patch_index()); + } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL @@ -916,9 +1008,7 @@ class Mesh_complex_3_in_triangulation_3 std::cerr << __FILE__ << " " << __LINE__ << std::endl; std::cerr << &*cell << " " << i << std::endl; std::cerr << "new res = " << res_new << std::endl; - std::cerr << "patch index (new) = " << it->second.patch_index_ << std::endl; std::cerr << "old res = " << res_old << std::endl; - std::cerr << "patch index (old) = " << cell->surface_patch_index(i) << std::endl; CGAL_assertion(false); std::exit(1); } @@ -1512,19 +1602,29 @@ class Mesh_complex_3_in_triangulation_3 if (!manifold_info_initialized_) init_manifold_info(); #ifdef CGAL_LINKED_WITH_TBB - typename Edge_facet_counter::const_accessor accessor; - if (!edge_facet_counter_.find(accessor, - this->make_ordered_pair(edge))) - return NOT_IN_COMPLEX; - switch (accessor->second) -#else // not CGAL_LINKED_WITH_TBB - switch (edge_facet_counter_[this->make_ordered_pair(edge)]) -#endif // not CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) { - case 0: return NOT_IN_COMPLEX; - case 1: return BOUNDARY; - case 2: return REGULAR; - default: return SINGULAR; + typename Edge_facet_counter::const_accessor accessor; + if (!edge_facet_counter_.find(accessor, this->make_ordered_pair(edge))) + return NOT_IN_COMPLEX; + switch (accessor->second) + { + case 0: return NOT_IN_COMPLEX; + case 1: return BOUNDARY; + case 2: return REGULAR; + default: return SINGULAR; + } + } + else +#endif + { + switch (edge_facet_counter_[this->make_ordered_pair(edge)]) + { + case 0: return NOT_IN_COMPLEX; + case 1: return BOUNDARY; + case 2: return REGULAR; + default: return SINGULAR; + } } } @@ -1726,16 +1826,18 @@ class Mesh_complex_3_in_triangulation_3 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); -#ifndef CGAL_LINKED_WITH_TBB - ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; -#else // CGAL_LINKED_WITH_TBB +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) { typename Edge_facet_counter::accessor accessor; - edge_facet_counter_.insert(accessor, - this->make_ordered_pair(edge_va, edge_vb)); + edge_facet_counter_.insert(accessor, this->make_ordered_pair(edge_va, edge_vb)); ++accessor->second; } -#endif // CGAL_LINKED_WITH_TBB + else +#endif + { + ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; + } const std::size_t n = edge_va->cached_number_of_incident_facets(); edge_va->set_c2t3_cache(n + 1, (std::numeric_limits::max)()); @@ -1870,37 +1972,25 @@ class Mesh_complex_3_in_triangulation_3 // Private data members Triangulation tr_; +private: typedef typename Base::Pair_of_vertices Pair_of_vertices; -#ifdef CGAL_LINKED_WITH_TBB - typedef tbb::concurrent_hash_map Edge_facet_counter; -#else // not CGAL_LINKED_WITH_TBB - typedef std::map Edge_facet_counter; -#endif // not CGAL_LINKED_WITH_TBB - + typedef typename SMDS_3::details::Hash_map_of_pairs_type::type Edge_facet_counter; mutable Edge_facet_counter edge_facet_counter_; - struct Facet_hash - { - std::size_t operator()(const Facet& f) const - { - std::size_t seed = 0; - Hash_handles_with_or_without_timestamps cell_hasher; - boost::hash_combine(seed, cell_hasher(f.first)); - boost::hash_combine(seed, f.second); - return seed; - } - }; - -public: - struct Surface_facet_info +public: // @tmp + struct Facet_surface_info { Bare_point center_; Surface_patch_index patch_index_; Index center_index_; }; - mutable std::unordered_map surface_facet_info_; + typedef typename SMDS_3::details::Hash_map_of_pairs_type::type Surface_facet_info; + mutable Surface_facet_info surface_facet_info_; private: typename Number_of_elements::type number_of_facets_; @@ -2117,15 +2207,17 @@ add_to_complex(const Cell_handle& cell, Vertex_handle edge_va = cell->vertex(edge_index_va); Vertex_handle edge_vb = cell->vertex(edge_index_vb); #ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) { typename Edge_facet_counter::accessor accessor; - edge_facet_counter_.insert(accessor, - this->make_ordered_pair(edge_va, edge_vb)); + edge_facet_counter_.insert(accessor, this->make_ordered_pair(edge_va, edge_vb)); ++accessor->second; } -#else // not CGAL_LINKED_WITH_TBB - ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; -#endif // not CGAL_LINKED_WITH_TBB + else +#endif + { + ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; + } const std::size_t n = edge_va->cached_number_of_incident_facets(); const std::size_t m = edge_va->cached_number_of_components(); @@ -2167,15 +2259,17 @@ remove_from_complex(const Facet& facet) const Vertex_handle edge_va = cell->vertex(edge_index_va); const Vertex_handle edge_vb = cell->vertex(edge_index_vb); #ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) { typename Edge_facet_counter::accessor accessor; - edge_facet_counter_.insert(accessor, - this->make_ordered_pair(edge_va, edge_vb)); + edge_facet_counter_.insert(accessor, this->make_ordered_pair(edge_va, edge_vb)); --accessor->second; } -#else // not CGAL_LINKED_WITH_TBB - --edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; -#endif // not CGAL_LINKED_WITH_TBB + else +#endif + { + --edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; + } const std::size_t n = edge_va->cached_number_of_incident_facets(); CGAL_assertion(n > 0); From 6237d676fad1f5fb58f92a4b5dae084abd113301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 20 Feb 2026 15:37:53 +0100 Subject: [PATCH 021/127] Avoid some map look ups --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 28 ++++++++++----------- Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h | 28 ++++++++------------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index d89ec44035ec..8f020df8a9ef 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -2050,16 +2050,16 @@ class C3T3_helpers fit != facets.end() ; ++fit ) { - if ( c3t3_.is_in_complex(*fit) ) - { + Surface_patch_index pid = c3t3_.surface_patch_index(*fit); + const bool facet_in_complex = (pid != Surface_patch_index()); + if ( facet_in_complex ) surface_facets.push_back(*fit); - } + const Surface_patch sp = checker(*fit, false, /* do not update c3t3 */ true); /* update surface centers */ // false means "do not update the c3t3" - if ( c3t3_.is_in_complex(*fit) != (bool)sp || - ((bool)sp && !(c3t3_.surface_patch_index(*fit) == *sp) ) ) + if ( facet_in_complex != (bool)sp || ((bool)sp && !(pid == *sp) ) ) return false; } @@ -2400,7 +2400,8 @@ class C3T3_helpers m_updater(facet); // Update m_vertex_to_proj - if ( m_c3t3.is_in_complex(facet) ) + Surface_patch_index pid = m_c3t3.surface_patch_index(facet); + if ( pid != Surface_patch_index() ) // // is facet in complex { // Iterate on vertices int k = facet.second; @@ -2409,8 +2410,7 @@ class C3T3_helpers const Vertex_handle& v = facet.first->vertex((k+i)&3); if ( m_c3t3.in_dimension(v) > 2 ) { - std::pair p - = std::make_pair(v, m_c3t3.surface_patch_index(facet)); + std::pair p = std::make_pair(v, pid); m_c3t3_helpers.lock_vertex_to_proj(); m_vertex_to_proj.insert(p); m_c3t3_helpers.unlock_vertex_to_proj(); @@ -2876,7 +2876,8 @@ rebuild_restricted_delaunay(ForwardIterator first_cell, updater(*fit); // Update vertex_to_proj - if ( c3t3_.is_in_complex(*fit) ) + Surface_patch_index pid = c3t3_.surface_patch_index(*fit); + if ( pid != Surface_patch_index() ) // is facet in complex { // Iterate on vertices int k = fit->second; @@ -2884,10 +2885,7 @@ rebuild_restricted_delaunay(ForwardIterator first_cell, { const Vertex_handle& v = fit->first->vertex((k+i)&3); if ( c3t3_.in_dimension(v) > 2 ) - { - vertex_to_proj.insert( - std::make_pair(v, c3t3_.surface_patch_index(*fit))); - } + vertex_to_proj.emplace(v, pid); } } } @@ -3956,9 +3954,9 @@ get_surface_boundary(const Vertex_handle& moving_vertex, typename Facet_vector::const_iterator fit = facets.begin(); for ( ; fit != facets.end() ; ++fit ) { - if ( c3t3_.is_in_complex(*fit) ) + const Surface_patch_index surface_index = c3t3_.surface_patch_index(*fit); + if ( surface_index != Surface_patch_index() ) // is facet in complex { - const Surface_patch_index surface_index = c3t3_.surface_patch_index(*fit); const int k = fit->second; Vertex_handle v1 = fit->first->vertex((k+1)&3); Vertex_handle v2 = fit->first->vertex((k+2)&3); diff --git a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h index 4235a7bd998f..5dd9e2b1e24b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h +++ b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h @@ -1367,9 +1367,10 @@ get_umbrella(const Facet_vector& facets, // internal_facets of conflict zone typename Facet_vector::const_iterator fit = facets.begin(); for ( ; fit != facets.end() ; ++fit ) { - if ( c3t3_.is_in_complex(*fit) ) + Facet f = *fit; + Surface_patch_index pid = c3t3_.surface_patch_index(f); + if ( pid != Surface_patch_index() ) { - Facet f = *fit; Vertex_handle v1 = f.first->vertex((f.second+1)%4); Vertex_handle v2 = f.first->vertex((f.second+2)%4); Vertex_handle v3 = f.first->vertex((f.second+3)%4); @@ -1381,22 +1382,13 @@ get_umbrella(const Facet_vector& facets, // internal_facets of conflict zone for(std::size_t i = 0; i < 3; ++i) { - Ordered_edge oe = edges[i]; - typename Umbrella::iterator uit = umbrella.find(oe); - if(uit == umbrella.end()) //umbrella does not contain oe yet - { - umbrella.insert(std::make_pair(oe, - std::make_pair(c3t3_.surface_patch_index(f), 1))); - } - else //umbrella already contains oe. Increment counter or return - { - std::size_t count = (*uit).second.second; - if(count == 2) //there will be more than 3 after insertion - return std::nullopt; //non-manifold configuration - - umbrella.insert(uit, - std::make_pair(oe, - std::make_pair(c3t3_.surface_patch_index(f), count + 1))); + const Ordered_edge& oe = edges[i]; + auto result = umbrella.emplace(oe, std::make_pair(pid, 1)); + if(!result.second) { // already existed + auto& value = result.first->second; + if(value.second == 2) // there will be more than 3 after insertion + return std::nullopt; // non-manifold configuration + ++value.second; } } } From 6e9beb294d3ddf15370322472b295afa6224abc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 20 Feb 2026 15:40:08 +0100 Subject: [PATCH 022/127] Avoid some cell -> facet -> cell conversions --- .../Mesh_3/mesh_standard_facet_criteria.h | 10 +- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 157 +++++++++++------- 2 files changed, 99 insertions(+), 68 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 04e952dcc76c..086d76bf3882 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 @@ -100,7 +100,7 @@ class Aspect_ratio_criterion : virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion (c3t3.is_in_complex(f.first, f.second)); + CGAL_assertion (c3t3.is_in_complex(f)); CGAL_assertion (B_ != 0); typedef typename Tr::Geom_traits GT; @@ -194,7 +194,7 @@ class Uniform_curvature_size_criterion : virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion(c3t3.is_in_complex(f.first, f.second)); + CGAL_assertion (c3t3.is_in_complex(f)); CGAL_assertion (B_ != 0); typedef typename Tr::Geom_traits GT; @@ -269,7 +269,7 @@ class Variable_curvature_size_criterion : virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion (c3t3.is_in_complex(f.first, f.second)); + CGAL_assertion (c3t3.is_in_complex(f)); typedef typename Tr::Geom_traits GT; typedef typename Tr::Weighted_point Weighted_point; @@ -354,7 +354,7 @@ class Variable_size_criterion : virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion (c3t3.is_in_complex(f.first, f.second)); + CGAL_assertion (c3t3.is_in_complex(f)); typedef typename Tr::Geom_traits GT; typedef typename Tr::Bare_point Bare_point; @@ -436,7 +436,7 @@ class Uniform_size_criterion : virtual Is_bad do_is_bad(const C3T3& c3t3, const Facet& f) const { - CGAL_assertion (c3t3.is_in_complex(f.first, f.second)); + CGAL_assertion (c3t3.is_in_complex(f)); CGAL_assertion (B_ != 0); typedef typename Tr::Geom_traits GT; diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 9b9db0ac041c..1d5894b79fa0 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -228,6 +228,12 @@ class Mesh_complex_3_in_triangulation_3 typedef CurveIndex Curve_index; /// @} + struct Facet_surface_info + { + Bare_point center_; + Surface_patch_index patch_index_; + Index center_index_; + }; private: // Type to store the edges: @@ -469,24 +475,18 @@ class Mesh_complex_3_in_triangulation_3 { vertex->set_index(index); } - /** sets the surface index of facet \p facet to \p index - */ - void set_surface_patch_index(const Facet& f, const Surface_patch_index& index) - { - set_surface_patch_index(f.first, f.second, index); - } - /** sets the surface index of facet(\p cell, \p i) to \p index + + /** sets the surface index of facet \p f to \p index */ - void set_surface_patch_index(const Cell_handle& cell, - const int i, + void set_surface_patch_index(const Facet& f, const Surface_patch_index& index) const { -#ifdef CGAL_MESH_3_USE_C3T3_MAPS // std::cout << "set " << &*(cell) << " " << i << " to " << index << " (new)" << std::endl; +#ifdef CGAL_MESH_3_USE_C3T3_MAPS if (index == Surface_patch_index()) { - surface_facet_info_.erase(Facet(cell, i)); + surface_facet_info_.erase(f); } else { @@ -494,25 +494,32 @@ class Mesh_complex_3_in_triangulation_3 if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, Facet(cell, i)); + surface_facet_info_.insert(accessor, f); accessor->second.patch_index_ = index; } else # endif { - surface_facet_info_[Facet(cell, i)].patch_index_ = index; + surface_facet_info_[f].patch_index_ = index; } } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - cell->set_surface_patch_index(i, index); + cell->set_surface_patch_index(f.first, f.second, index); #endif } - /** sets the surface center of facet(\p cell, \p i) to \p p + + /** sets the surface index of facet(\p cell, \p i) to \p index */ - void set_surface_center(const Cell_handle& cell, - const int i, + void set_surface_patch_index(const Cell_handle& cell, + const int i, + const Surface_patch_index& index) const + { + return set_surface_patch_index(Facet(cell, i), index); + } + + void set_surface_center(const Facet& f, const Bare_point& p) const { #ifdef CGAL_MESH_3_USE_C3T3_MAPS @@ -520,13 +527,13 @@ class Mesh_complex_3_in_triangulation_3 if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, Facet(cell, i)); + surface_facet_info_.insert(accessor, f); accessor->second.center_ = p; } else # endif { - surface_facet_info_[Facet(cell, i)].center_ = p; + surface_facet_info_[f].center_ = p; } #endif @@ -534,10 +541,17 @@ class Mesh_complex_3_in_triangulation_3 cell->set_facet_surface_center(i, p); #endif } - /** sets the surface center index of facet(\p cell, \p i) to \p index + + /** sets the surface center of facet(\p cell, \p i) to \p p */ - void set_surface_center_index(const Cell_handle& cell, - const int i, + void set_surface_center(const Cell_handle& cell, + const int i, + const Bare_point& p) const + { + return set_surface_center(Facet(cell, i), p); + } + + void set_surface_center_index(const Facet& f, const Index& index) const { #ifdef CGAL_MESH_3_USE_C3T3_MAPS @@ -545,13 +559,13 @@ class Mesh_complex_3_in_triangulation_3 if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, Facet(cell, i)); + surface_facet_info_.insert(accessor, f); accessor->second.center_index_ = index; } else # endif { - surface_facet_info_[Facet(cell, i)].center_index_ = index; + surface_facet_info_[f].center_index_ = index; } #endif @@ -559,10 +573,20 @@ class Mesh_complex_3_in_triangulation_3 cell->set_facet_surface_center_index(i, index); #endif } + + /** sets the surface center index of facet(\p cell, \p i) to \p index + */ + void set_surface_center_index(const Cell_handle& cell, + const int i, + const Index& index) const + { + return set_surface_center_index(Facet(cell, i), index); + } + /** sets the subdomain index of cell \p cell to \p index */ void set_subdomain_index(const Cell_handle& cell, - const Subdomain_index& index) const + const Subdomain_index& index) const { cell->set_subdomain_index(index); } @@ -590,27 +614,19 @@ class Mesh_complex_3_in_triangulation_3 */ Surface_patch_index surface_patch_index(const Facet& f) const { - return surface_patch_index(f.first, f.second); - } - - /** returns the surface index of facet(\p cell, \p i) - */ - Surface_patch_index surface_patch_index(const Cell_handle& cell, - const int i) const - { #ifdef CGAL_MESH_3_USE_C3T3_MAPS Surface_patch_index res_new {}; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; - if (surface_facet_info_.find(accessor, Facet(cell, i))) + if (surface_facet_info_.find(accessor, f)) res_new = accessor->second.patch_index_; } else # endif { - auto it = surface_facet_info_.find(Facet(cell, i)); + auto it = surface_facet_info_.find(f); if (it != surface_facet_info_.end()) res_new = it->second.patch_index_; } @@ -637,10 +653,16 @@ class Mesh_complex_3_in_triangulation_3 CGAL_assertion(false); std::exit(1); } - /** returns the surface center of facet(\p cell, \p i) + + /** returns the surface index of facet(\p cell, \p i) */ - decltype(auto) surface_center(const Cell_handle& cell, - const int i) const + Surface_patch_index surface_patch_index(const Cell_handle& cell, + const int i) const + { + return surface_patch_index(Facet(cell, i)); + } + + decltype(auto) surface_center(const Facet& f) const { CGAL_precondition(is_in_complex(cell, i)); @@ -651,14 +673,14 @@ class Mesh_complex_3_in_triangulation_3 { typename Surface_facet_info::const_accessor accessor; CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, Facet(cell, i)); + surface_facet_info_.find(accessor, f); CGAL_assume(found); res_new = accessor->second.center_; } else # endif { - auto it = surface_facet_info_.find(Facet(cell, i)); + auto it = surface_facet_info_.find(f); CGAL_assume(it != surface_facet_info_.end()); res_new = it->second.center_; } @@ -685,10 +707,16 @@ class Mesh_complex_3_in_triangulation_3 CGAL_assertion(false); std::exit(1); } - /** returns the surface center index of facet(\p cell, \p i) + + /** returns the surface center of facet(\p cell, \p i) */ - Index surface_center_index(const Cell_handle& cell, - const int i) const + decltype(auto) surface_center(const Cell_handle& cell, + const int i) const + { + return surface_center(Facet(cell, i)); + } + + Index surface_center_index(const Facet& f) const { CGAL_precondition(is_in_complex(cell, i)); @@ -699,14 +727,14 @@ class Mesh_complex_3_in_triangulation_3 { typename Surface_facet_info::const_accessor accessor; CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, Facet(cell, i)); + surface_facet_info_.find(accessor, f); CGAL_assume(found); res_new = accessor->second.center_index_; } else # endif { - auto it = surface_facet_info_.find(Facet(cell, i)); + auto it = surface_facet_info_.find(f); CGAL_assume(it != surface_facet_info_.end()); res_new = it->second.center_index_; } @@ -733,6 +761,15 @@ class Mesh_complex_3_in_triangulation_3 CGAL_assertion(false); std::exit(1); } + + /** returns the surface center index of facet(\p cell, \p i) + */ + Index surface_center_index(const Cell_handle& cell, + const int i) const + { + return surface_center_index(Facet(cell, i)); + } + /** returns the dimension of the lowest dimensional face of the input 3D * complex that contains the vertex */ @@ -969,16 +1006,9 @@ class Mesh_complex_3_in_triangulation_3 { return !(subdomain_index(cell) == Subdomain_index()); } - /** returns true if facet \p facet belongs to the 2D complex + /** returns true if facet \p f belongs to the 2D complex */ - bool is_in_complex(const Facet& facet) const - { - return is_in_complex(facet.first, facet.second); - } - - /** returns true if facet (\p cell, \p i) belongs to the 2D complex - */ - bool is_in_complex(const Cell_handle& cell, const int i) const + bool is_in_complex(const Facet& f) const { #ifdef CGAL_MESH_3_USE_C3T3_MAPS // if we always erase when trying to insert a default constructed Subdomain_index, @@ -988,13 +1018,13 @@ class Mesh_complex_3_in_triangulation_3 if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; - if (surface_facet_info_.find(accessor, Facet(cell, i))) + if (surface_facet_info_.find(accessor, f)) res_new = accessor->second.patch_index_ != Surface_patch_index(); } else # endif { - auto it = surface_facet_info_.find(Facet(cell, i)); + auto it = surface_facet_info_.find(f); if (it != surface_facet_info_.end()) res_new = (it->second.patch_index_ != Surface_patch_index()); } @@ -1022,6 +1052,14 @@ class Mesh_complex_3_in_triangulation_3 CGAL_assertion(false); std::exit(1); } + + /** returns true if facet (\p cell, \p i) belongs to the 2D complex + */ + bool is_in_complex(const Cell_handle& cell, const int i) const + { + return is_in_complex(Facet(cell, i)); + } + /** * returns true if edge \p e belongs to the 1D complex */ @@ -1980,13 +2018,6 @@ class Mesh_complex_3_in_triangulation_3 mutable Edge_facet_counter edge_facet_counter_; public: // @tmp - struct Facet_surface_info - { - Bare_point center_; - Surface_patch_index patch_index_; - Index center_index_; - }; - typedef typename SMDS_3::details::Hash_map_of_pairs_type::type Surface_facet_info; From 6e90c4eaee8f1bfae1410ce57d450ab041e1da7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 23 Feb 2026 12:17:57 +0100 Subject: [PATCH 023/127] Fix documentation of internal function --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 104 +++++++----------- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 24 ++-- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 73 ++++++------ .../CGAL/Mesh_complex_3_in_triangulation_3.h | 91 +++++++++++---- 4 files changed, 156 insertions(+), 136 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 8f020df8a9ef..ff011afaea2e 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1383,6 +1383,8 @@ class C3T3_helpers class Cell_data_backup { + typedef std::array IndexMap; + public: Cell_data_backup(const C3T3& c3t3, const Cell_handle& c, @@ -1395,28 +1397,27 @@ class C3T3_helpers if(do_backup) { if (!c3t3.triangulation().is_infinite(c)) - backup_finite_cell(c); + backup_finite_cell(c, c3t3); else backup_infinite_cell(c, c3t3); } } private: - void backup_finite_cell(const Cell_handle& /*c*/) + void backup_finite_cell(const Cell_handle& c, + const C3T3& c3t3) { -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL if(c->is_cache_valid()) sliver_value_ = c->sliver_value(); else sliver_value_ = 0.; +#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL subdomain_index_ = c->subdomain_index(); for(std::size_t i = 0; i < 4; ++i) { const int ii = static_cast(i);//avoid warnings - surface_index_table_[i] = c->surface_patch_index(ii); - facet_surface_center_[i] = c->get_facet_surface_center(ii); - surface_center_index_table_[i] = c->get_facet_surface_center_index(ii); + surface_prop_table_[i] = c3t3.surface_info(Facet(c, ii)); } //note c->next_intrusive() and c->previous_intrusive() //are lost by 'backup' and 'restore', @@ -1427,23 +1428,11 @@ class C3T3_helpers #endif } - void backup_infinite_cell(const Cell_handle& /*c*/, - const C3T3& /*c3t3*/) + void backup_infinite_cell(const Cell_handle& c, + const C3T3& c3t3) { -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - for (int ii = 0; ii < 4; ++ii) - { - if (c3t3.triangulation().is_infinite(c->vertex(ii))) - { - surface_index_table_[0] = c->surface_patch_index(ii); - facet_surface_center_[0] = c->get_facet_surface_center(ii); - surface_center_index_table_[0] = c->get_facet_surface_center_index(ii); - break; - } - } -#else - std::exit(1); -#endif + int infinite_index = c->index(c3t3.triangulation().infinite_vertex()); + surface_prop_table_[0] = c3t3.surface_info(Facet(c, infinite_index)); } public: @@ -1484,13 +1473,10 @@ class C3T3_helpers } private: - typedef std::array IndexMap; - - void restore(Cell_handle /*c*/, - const IndexMap& /*index_map*/,//new_to_old_indices - C3T3& /*c3t3*/) + void restore(Cell_handle c, + const IndexMap& index_map,//new_to_old_indices + C3T3& c3t3) { -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL if(sliver_value_ > 0.) c->set_sliver_value(sliver_value_); @@ -1509,60 +1495,48 @@ class C3T3_helpers for(int i = 0; i < 4; ++i) { + Facet f(c, i); std::size_t old_i = index_map.at(static_cast(i)); - Surface_patch_index index = surface_index_table_[old_i]; + Surface_patch_index index = surface_prop_table_[old_i].surface_index_; //add_to_complex sets the index, and updates the facet counter if(!( Surface_patch_index() == index )) - c3t3.add_to_complex(Facet(c, i), index); + c3t3.add_to_complex(f, index); else - c3t3.remove_from_complex(Facet(c,i)); + c3t3.remove_from_complex(f); - c->set_facet_surface_center(i, facet_surface_center_[old_i]); - const Facet mirror = c3t3.triangulation().mirror_facet(Facet(c, i)); - mirror.first->set_facet_surface_center(mirror.second, facet_surface_center_[old_i]); + c3t3.set_surface_info(f, surface_prop_table_[old_i]); + const Facet mirror = c3t3.triangulation().mirror_facet(f); + c3t3.set_surface_info(mirror, surface_prop_table_[old_i]); } -#else - std::exit(1); -#endif } - void restore_infinite_cell(Cell_handle /*c*/, - C3T3& /*c3t3*/) + void restore_infinite_cell(Cell_handle c, + C3T3& c3t3) { -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL c3t3.remove_from_complex(c);//infinite - for (unsigned int i = 0; i < 4; ++i) - { - if (!c3t3.triangulation().is_infinite(Facet(c,i))) - { - Surface_patch_index index = surface_index_table_[0]; - if (!( Surface_patch_index() == index )) - c3t3.add_to_complex(Facet(c, i), index); - else - c3t3.remove_from_complex(Facet(c, i)); - - c->set_facet_surface_center(i, facet_surface_center_[0]); - const Facet mirror = c3t3.triangulation().mirror_facet(Facet(c, i)); - mirror.first->set_facet_surface_center(mirror.second, facet_surface_center_[0]); - return; - } - } -#else - std::exit(1); -#endif + + const int i = c->index(c3t3.triangulation().infinite_vertex()); + Facet f(c, i); + + Surface_patch_index index = surface_prop_table_[0].surface_index_; + if (!( Surface_patch_index() == index )) + c3t3.add_to_complex(f, index); + else + c3t3.remove_from_complex(f); + + c3t3.set_surface_info(f, surface_prop_table_[0]); + const Facet mirror = c3t3.triangulation().mirror_facet(f); + c3t3.set_surface_info(mirror, surface_prop_table_[0]); } private: - typedef typename Tr::Cell::Subdomain_index Subdomain_index; - typedef typename Tr::Cell::Surface_patch_index Surface_patch_index; - typedef typename Tr::Cell::Index Index; + typedef typename C3T3::Subdomain_index Subdomain_index; + typedef typename C3T3::Facet_prop Facet_prop; Cell_from_ids cell_ids_; FT sliver_value_; Subdomain_index subdomain_index_; - std::array surface_index_table_; - std::array facet_surface_center_; - std::array surface_center_index_table_; + std::array surface_prop_table_; }; private: diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index 8b947ccfd780..5bfc8c5e23de 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -897,33 +897,24 @@ update_star_self(const Vertex_handle& vertex) // Restore surface const int& k = (*cell_it)->index(vertex); const Facet mirror_f = mirror_facet(*cell_it,k); - const Cell_handle& neighbor_cell = mirror_f.first; - const int& neighb_k = mirror_f.second; #ifdef CGAL_MESH_3_USE_C3T3_MAPS - const bool cond_new = r_c3t3_.is_in_complex(neighbor_cell, neighb_k); -#endif - -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - const bool cond_old =neighbor_cell->is_facet_on_surface(neighb_k); + if (r_c3t3_.is_in_complex(mirror_f)) // @todo here and below is 2 map looks up which should only be one. + r_c3t3_.set_surface_info(*cell_it, k, r_c3t3_.surface_info(mirror_f)); +#else // CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL has to be defined + const Cell_handle& neighbor_cell = mirror_f.first; + const int& neighb_k = mirror_f.second; + const bool cond_old = neighbor_cell->is_facet_on_surface(neighb_k); # ifdef CGAL_MESH_3_USE_C3T3_MAPS + const bool cond_new = r_c3t3_.surface_patch_index(mirror_f); if (cond_old != cond_new) { - std::cerr << "new cond = " << cond_new << std::endl; std::cerr << "new cond = " << cond_new << std::endl; std::exit(1); } # endif if (cond_old) -#else -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - if (cond_new) -# else - std::exit(1); -# endif -#endif - { // Facet(*cell_it,k) is on surface r_c3t3_.set_surface_patch_index(*cell_it, k, r_c3t3_.surface_patch_index(neighbor_cell, neighb_k)); @@ -934,6 +925,7 @@ update_star_self(const Vertex_handle& vertex) { r_c3t3_.set_surface_patch_index(*cell_it, k, Surface_patch_index()); } +#endif // Set subdomain index set_cell_in_domain(*cell_it, cells_subdomain); diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index bb9cc89b72d0..a20ef224f876 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -312,9 +312,16 @@ class Refine_facets_3_base << get_facet_surface_center(facet) << std::endl; #endif - CGAL_assertion (this->is_facet_on_surface(facet)); + CGAL_precondition(this->is_facet_on_surface(facet)); + +#ifndef CGAL_MESH_3_USE_C3T3_MAPS this->set_last_vertex_index(get_facet_surface_center_index(facet)); return get_facet_surface_center(facet); +#else + const auto& [surface_index, center_index, center] = this->r_c3t3_.surface_info(facet); + this->set_last_vertex_index(center_index); + return center; +#endif } Facet get_next_element_impl() @@ -448,20 +455,6 @@ class Refine_facets_3_base f.first->set_facet_visited(f.second); } - /// Sets the facet `f` and its mirrored facet's surface centers to `p`. - void set_facet_surface_center(const Facet& f, - const Bare_point& p, - const Index& index) const - { - const Facet mirror = mirror_facet(f); - - r_c3t3_.set_surface_center(f.first, f.second, p); - r_c3t3_.set_surface_center(mirror.first, mirror.second, p); - - r_c3t3_.set_surface_center_index(f.first, f.second, index); - r_c3t3_.set_surface_center_index(mirror.first, mirror.second, index); - } - /// Returns facet surface center of `f`. decltype(auto) get_facet_surface_center(const Facet& f) const { @@ -476,9 +469,26 @@ class Refine_facets_3_base /// Sets `f` to surface facets, with index `index`. void set_facet_on_surface(const Facet& f, - const Surface_patch_index& index) + const Surface_patch_index& surface_index, + const Index& center_index, + const Bare_point& center) { - r_c3t3_.add_to_complex(f, index); + r_c3t3_.add_to_complex(f, surface_index); + + const Facet mirror = mirror_facet(f); + +#ifndef CGAL_MESH_3_USE_C3T3_MAPS + r_c3t3_.set_surface_center(f.first, f.second, center); + r_c3t3_.set_surface_center(mirror.first, mirror.second, center); + + r_c3t3_.set_surface_center_index(f.first, f.second, center_index); + r_c3t3_.set_surface_center_index(mirror.first, mirror.second, center_index); +#else + // awkward: add it *after* add_to_complex() because otherwise the surface index is set up, + // and add_to_complex() will do nothing... + r_c3t3_.set_surface_info(f, {surface_index, center_index, center}); + r_c3t3_.set_surface_info(mirror, {surface_index, center_index, center}); +#endif } /// Returns index of facet `f`. @@ -622,11 +632,11 @@ class Refine_facets_3_base void treat_new_facet(Facet& facet); /** - * Computes simultaneously `is_facet_on_surface` and `facet_surface_center`. - * @param facet The input facet - * @return `true` if `facet` is on surface, `false` otherwise + * checks whether the facet is on the surface or not, and if it is, computes + * the surface patch index, the surface center, and the surface center index. */ - void compute_facet_properties(const Facet& facet, Facet_properties& fp, + void compute_facet_properties(const Facet& facet, + Facet_properties& fp, bool force_exact = false ) const; protected: @@ -1195,8 +1205,7 @@ number_of_bad_elements_impl() //const Bare_point& surface_center = std::get<2>(*properties); // Facet is on surface: set facet properties - //set_facet_surface_center(facet, surface_center, surface_center_index); - //set_facet_on_surface(facet, surface_index); + // set_facet_on_surface(facet, surface_index, surface_center_index, surface_center); const typename Rf_base::Is_facet_bad is_facet_bad = this->r_criteria_(this->r_tr_, facet); if ( is_facet_bad ) @@ -1375,11 +1384,9 @@ conflicts_zone_impl(const Weighted_point& point this->compute_facet_properties(facet, properties, /*force_exact=*/true); if ( properties ) { - const auto& [surface_index, surface_center_index, surface_center] = *properties; - // Facet is on surface: set facet properties - this->set_facet_surface_center(facet, surface_center, surface_center_index); - this->set_facet_on_surface(facet, surface_index); + const auto& [surface_index, surface_center_index, surface_center] = *properties; + this->set_facet_on_surface(facet, surface_index, surface_center_index, surface_center); } else { @@ -1435,11 +1442,9 @@ conflicts_zone_impl(const Weighted_point& point this->compute_facet_properties(facet, properties, /*force_exact=*/true); if ( properties ) { - const auto& [surface_index, surface_center_index, surface_center] = *properties; - // Facet is on surface: set facet properties - this->set_facet_surface_center(facet, surface_center, surface_center_index); - this->set_facet_on_surface(facet, surface_index); + const auto& [surface_index, surface_center_index, surface_center] = *properties; + this->set_facet_on_surface(facet, surface_index, surface_center_index, surface_center); } else { @@ -1601,11 +1606,9 @@ treat_new_facet(Facet& facet) compute_facet_properties(facet, properties); if ( properties ) { - const auto& [surface_index, surface_center_index, surface_center] = *properties; - // Facet is on surface: set facet properties - set_facet_surface_center(facet, surface_center, surface_center_index); - set_facet_on_surface(facet, surface_index); + const auto& [surface_index, surface_center_index, surface_center] = *properties; + set_facet_on_surface(facet, surface_index, surface_center_index, surface_center); // Insert facet into refinement queue if needed const Is_facet_bad is_facet_bad = r_criteria_(r_c3t3_, facet); diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 1d5894b79fa0..10525713a97e 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -228,11 +228,11 @@ class Mesh_complex_3_in_triangulation_3 typedef CurveIndex Curve_index; /// @} - struct Facet_surface_info + struct Facet_prop { - Bare_point center_; - Surface_patch_index patch_index_; + Surface_patch_index surface_index_; Index center_index_; + Bare_point center_; }; private: @@ -495,18 +495,18 @@ class Mesh_complex_3_in_triangulation_3 { typename Surface_facet_info::accessor accessor; surface_facet_info_.insert(accessor, f); - accessor->second.patch_index_ = index; + accessor->second.surface_index_ = index; } else # endif { - surface_facet_info_[f].patch_index_ = index; + surface_facet_info_[f].surface_index_ = index; } } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - cell->set_surface_patch_index(f.first, f.second, index); + f.first->set_surface_patch_index(f.second, index); #endif } @@ -538,7 +538,7 @@ class Mesh_complex_3_in_triangulation_3 #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - cell->set_facet_surface_center(i, p); + f.first->set_facet_surface_center(f.second, p); #endif } @@ -570,7 +570,7 @@ class Mesh_complex_3_in_triangulation_3 #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - cell->set_facet_surface_center_index(i, index); + f.first->set_facet_surface_center_index(f.second, index); #endif } @@ -583,6 +583,33 @@ class Mesh_complex_3_in_triangulation_3 return set_surface_center_index(Facet(cell, i), index); } + void set_surface_info(const Facet& f, + const Facet_prop& info) const + { +#ifndef CGAL_MESH_3_USE_C3T3_MAPS + std::exit(1); +#else +# ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, f); + accessor->second = info; + } + else +# endif + { + surface_facet_info_[f] = info; + } +#endif + } + + void set_surface_info(Cell_handle cell, int i, + const Facet_prop& info) const + { + return set_surface_info(Facet(cell, i), info); + } + /** sets the subdomain index of cell \p cell to \p index */ void set_subdomain_index(const Cell_handle& cell, @@ -621,19 +648,19 @@ class Mesh_complex_3_in_triangulation_3 { typename Surface_facet_info::const_accessor accessor; if (surface_facet_info_.find(accessor, f)) - res_new = accessor->second.patch_index_; + res_new = accessor->second.surface_index_; } else # endif { auto it = surface_facet_info_.find(f); if (it != surface_facet_info_.end()) - res_new = it->second.patch_index_; + res_new = it->second.surface_index_; } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - Surface_patch_index res_old = cell->surface_patch_index(i); + Surface_patch_index res_old = f.first->surface_patch_index(f.second); # ifdef CGAL_MESH_3_USE_C3T3_MAPS if (res_new != res_old) { @@ -664,7 +691,7 @@ class Mesh_complex_3_in_triangulation_3 decltype(auto) surface_center(const Facet& f) const { - CGAL_precondition(is_in_complex(cell, i)); + CGAL_precondition(is_in_complex(f)); #ifdef CGAL_MESH_3_USE_C3T3_MAPS Bare_point res_new; // return directly when the comparison code is gone @@ -687,7 +714,7 @@ class Mesh_complex_3_in_triangulation_3 #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - const auto res_old = cell->get_facet_surface_center(i); + const auto res_old = f.first->get_facet_surface_center(f.second); # ifdef CGAL_MESH_3_USE_C3T3_MAPS if (res_new != res_old) { @@ -718,7 +745,7 @@ class Mesh_complex_3_in_triangulation_3 Index surface_center_index(const Facet& f) const { - CGAL_precondition(is_in_complex(cell, i)); + CGAL_precondition(is_in_complex(f)); #ifdef CGAL_MESH_3_USE_C3T3_MAPS Index res_new; // return directly when the comparison code is gone @@ -741,7 +768,7 @@ class Mesh_complex_3_in_triangulation_3 #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - const Index res_old = cell->get_facet_surface_center_index(i); + const Index res_old = f.first->get_facet_surface_center_index(f.second); # ifdef CGAL_MESH_3_USE_C3T3_MAPS if (res_new != res_old) { @@ -770,6 +797,30 @@ class Mesh_complex_3_in_triangulation_3 return surface_center_index(Facet(cell, i)); } + const Facet_prop& surface_info(const Facet& f) const + { +#ifndef CGAL_MESH_3_USE_C3T3_MAPS + std::exit(1); +#else +# ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::const_accessor accessor; + CGAL_assume_code(bool found =) + surface_facet_info_.find(accessor, f); + CGAL_assume(found); + return accessor->second; + } + else +# endif + { + auto it = surface_facet_info_.find(f); + CGAL_assume(it != surface_facet_info_.end()); + return it->second; + } +#endif + } + /** returns the dimension of the lowest dimensional face of the input 3D * complex that contains the vertex */ @@ -1019,24 +1070,24 @@ class Mesh_complex_3_in_triangulation_3 { typename Surface_facet_info::const_accessor accessor; if (surface_facet_info_.find(accessor, f)) - res_new = accessor->second.patch_index_ != Surface_patch_index(); + res_new = accessor->second.surface_index_ != Surface_patch_index(); } else # endif { auto it = surface_facet_info_.find(f); if (it != surface_facet_info_.end()) - res_new = (it->second.patch_index_ != Surface_patch_index()); + res_new = (it->second.surface_index_ != Surface_patch_index()); } #endif #ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL - const bool res_old = cell->is_facet_on_surface(i); + const bool res_old = f.first->is_facet_on_surface(f.second); # ifdef CGAL_MESH_3_USE_C3T3_MAPS if (res_new != res_old) { std::cerr << __FILE__ << " " << __LINE__ << std::endl; - std::cerr << &*cell << " " << i << std::endl; + std::cerr << &*(f.first) << " " << f.second << std::endl; std::cerr << "new res = " << res_new << std::endl; std::cerr << "old res = " << res_old << std::endl; CGAL_assertion(false); @@ -2020,7 +2071,7 @@ class Mesh_complex_3_in_triangulation_3 public: // @tmp typedef typename SMDS_3::details::Hash_map_of_pairs_type::type Surface_facet_info; + Facet_prop /*value*/>::type Surface_facet_info; mutable Surface_facet_info surface_facet_info_; private: From df321311fc11adebd32c3a607296737b0074a2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 24 Feb 2026 12:37:10 +0100 Subject: [PATCH 024/127] Misc tiny fixes --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 15 +++++---------- .../include/CGAL/Triangulation_ds_vertex_base_3.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index a20ef224f876..eb28cfda36d6 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -43,12 +43,12 @@ #include #include -#include #include #include -#include #include +#include +#include namespace CGAL { @@ -1093,7 +1093,7 @@ Refine_facets_3:: number_of_bad_elements_impl() { typedef typename MD::Subdomain_index Subdomain_index; - typedef std::optional Subdomain; + typedef std::optional Subdomain; typedef typename Tr::Finite_facets_iterator Finite_facet_iterator; int count = 0, count_num_bad_surface_facets = 0; @@ -1889,8 +1889,6 @@ before_insertion_handle_facet_in_conflict_zone(Facet& facet, return ( (facet == source_facet) || (other_side == source_facet) ); } - - template void Refine_facets_3_base:: @@ -1907,11 +1905,8 @@ after_insertion_handle_incident_facet(Facet& facet) treat_new_facet(facet); } - -} // end namespace Mesh_3 - - -} // end namespace CGAL +} // namespace Mesh_3 +} // namespace CGAL #include diff --git a/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h b/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h index 61a02348a89a..316f09268bfe 100644 --- a/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h +++ b/TDS_3/include/CGAL/Triangulation_ds_vertex_base_3.h @@ -66,7 +66,7 @@ class Triangulation_ds_vertex_base_3 Cell_handle _c; // The typedef and the bool are used by Triangulation_data_structure::Vertex_extractor - // The names are chooses complicated so that we do not have to document them + // The names are chosen complicated so that we do not have to document them // (privacy by obfuscation) public: typedef bool Has_visited_for_vertex_extractor; From 84868dce87c745f7541f4a9d87133236d10e83d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 24 Feb 2026 12:37:20 +0100 Subject: [PATCH 025/127] Avoid some copies --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index eb28cfda36d6..c38abcf2f73f 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -300,7 +300,7 @@ class Refine_facets_3_base } /// Gets the point to insert from the element to refine - Bare_point refinement_point_impl(const Facet& facet) const + decltype(auto) refinement_point_impl(const Facet& facet) const { #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS const Cell_handle c = facet.first; @@ -844,7 +844,7 @@ class Refine_facets_3 int number_of_bad_elements_impl(); - Bare_point circumcenter_impl(const Facet& facet) const + decltype(auto) circumcenter_impl(const Facet& facet) const { return get_facet_surface_center(facet); } From aaad872974874c952e1e31dbfe556d97835d53ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 09:55:56 +0100 Subject: [PATCH 026/127] Template criteria by the C3t3 --- .../random_points_in_tetrahedral_mesh_3.cpp | 2 +- .../random_points_on_tetrahedral_mesh_3.cpp | 2 +- .../test/Generator/generic_random_test.cpp | 2 +- Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h | 2 +- .../Plugins/Mesh_3/Offset_meshing_plugin.cpp | 3 +-- .../Surface_reconstruction_poisson_impl.cpp | 2 +- .../Concepts/MeshCriteriaWithFeatures_3.h | 2 +- Mesh_3/doc/Mesh_3/Concepts/MeshCriteria_3.h | 2 +- Mesh_3/doc/Mesh_3/PackageDescription.txt | 2 +- Mesh_3/examples/Mesh_3/mesh_3D_gray_image.cpp | 2 +- .../mesh_3D_gray_image_multiple_values.cpp | 2 +- .../Mesh_3/mesh_3D_gray_vtk_image.cpp | 2 +- Mesh_3/examples/Mesh_3/mesh_3D_image.cpp | 2 +- .../Mesh_3/mesh_3D_image_variable_size.cpp | 2 +- ...sh_3D_image_with_custom_initialization.cpp | 2 +- ...sh_3D_image_with_detection_of_features.cpp | 2 +- .../Mesh_3/mesh_3D_image_with_features.cpp | 2 +- ...esh_3D_image_with_image_initialization.cpp | 2 +- .../mesh_3D_image_with_initial_points.cpp | 2 +- .../mesh_3D_image_with_input_features.cpp | 2 +- .../Mesh_3/mesh_3D_weighted_image.cpp | 2 +- ...ghted_image_with_detection_of_features.cpp | 2 +- .../Mesh_3/mesh_cubes_intersection.cpp | 2 +- .../mesh_cubes_intersection_with_features.cpp | 2 +- .../Mesh_3/mesh_hybrid_mesh_domain.cpp | 2 +- .../examples/Mesh_3/mesh_implicit_domains.cpp | 2 +- .../Mesh_3/mesh_implicit_domains_2.cpp | 2 +- .../Mesh_3/mesh_implicit_ellipsoid.cpp | 2 +- .../examples/Mesh_3/mesh_implicit_sphere.cpp | 2 +- .../mesh_implicit_sphere_variable_size.cpp | 2 +- .../Mesh_3/mesh_optimization_example.cpp | 2 +- .../mesh_optimization_lloyd_example.cpp | 2 +- .../Mesh_3/mesh_polyhedral_complex.cpp | 2 +- .../Mesh_3/mesh_polyhedral_complex_sm.cpp | 2 +- .../Mesh_3/mesh_polyhedral_domain.cpp | 2 +- .../Mesh_3/mesh_polyhedral_domain_sm.cpp | 2 +- ...h_polyhedral_domain_with_edge_distance.cpp | 2 +- .../mesh_polyhedral_domain_with_features.cpp | 2 +- ...polyhedral_domain_with_features_sizing.cpp | 2 +- ...esh_polyhedral_domain_with_features_sm.cpp | 2 +- ...olyhedral_domain_with_lipschitz_sizing.cpp | 2 +- ..._polyhedral_domain_with_surface_inside.cpp | 2 +- .../mesh_two_implicit_spheres_with_balls.cpp | 2 +- .../Mesh_3/remesh_polyhedral_surface.cpp | 2 +- .../Mesh_3/remesh_polyhedral_surface_sm.cpp | 2 +- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 6 ++--- Mesh_3/include/CGAL/Mesh_cell_criteria_3.h | 2 +- Mesh_3/include/CGAL/Mesh_criteria_3.h | 22 ++++++++--------- Mesh_3/include/CGAL/Mesh_edge_criteria_3.h | 2 +- Mesh_3/include/CGAL/Mesh_facet_criteria_3.h | 2 +- Mesh_3/include/CGAL/Mesh_facet_topology.h | 4 ++-- .../surface_Delaunay_remeshing.h | 2 +- Mesh_3/test/Mesh_3/test_criteria.cpp | 10 ++++---- Mesh_3/test/Mesh_3/test_max_edge_distance.cpp | 4 ++-- Mesh_3/test/Mesh_3/test_mesh_3_issue_1554.cpp | 2 +- Mesh_3/test/Mesh_3/test_mesh_3_issue_8773.cpp | 2 +- .../test_mesh_capsule_var_distance_bound.cpp | 2 +- .../Mesh_3/test_mesh_criteria_creation.cpp | 24 ++++++++++++------- ...hedral_domain_with_features_deprecated.cpp | 2 +- .../Mesh_3/test_meshing_3D_gray_image.cpp | 2 +- Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp | 2 +- .../test_meshing_3D_image_with_features.cpp | 2 +- .../test/Mesh_3/test_meshing_determinism.cpp | 2 +- .../Mesh_3/test_meshing_implicit_function.cpp | 2 +- .../test_meshing_polyhedral_complex.cpp | 2 +- ...ral_complex_with_manifold_and_min_size.cpp | 2 +- .../test/Mesh_3/test_meshing_polyhedron.cpp | 2 +- .../test_meshing_polyhedron_with_features.cpp | 2 +- .../Mesh_3/test_meshing_polylines_only.cpp | 2 +- .../Mesh_3/test_meshing_unit_tetrahedron.cpp | 2 +- .../Mesh_3/test_meshing_with_one_step.cpp | 2 +- ...st_meshing_with_one_step_with_features.cpp | 2 +- ...t_meshing_without_features_determinism.cpp | 2 +- Mesh_3/test/Mesh_3/test_min_edge_length.cpp | 2 +- Mesh_3/test/Mesh_3/test_min_size_criteria.cpp | 2 +- .../test/Mesh_3/test_remeshing_polyhedron.cpp | 2 +- .../Mesh_3/test_without_detect_features.cpp | 2 +- .../mesh_implicit_multi_domain.cpp | 2 +- .../Periodic_3_mesh_3/mesh_implicit_shape.cpp | 2 +- .../mesh_implicit_shape_with_features.cpp | 2 +- .../mesh_implicit_shape_with_optimizers.cpp | 2 +- .../mesh_implicit_shape_with_subdomains.cpp | 2 +- .../mesh_periodic_polyhedral_domain.cpp | 2 +- .../test_implicit_shapes_bunch.cpp | 2 +- .../test_implicit_shapes_with_features.cpp | 2 +- .../test_triply_periodic_minimal_surfaces.cpp | 2 +- .../poisson_and_parallel_mesh_3.cpp | 2 +- .../poisson_reconstruction.cpp | 2 +- .../poisson_reconstruction_example.cpp | 2 +- .../CGAL/poisson_surface_reconstruction.h | 2 +- ...e_mesh_3_vs_Poisson_implicit_surface_3.cpp | 2 +- .../poisson_reconstruction_test_mesh_3.cpp | 2 +- ...est_c3t3_extract_subdomains_boundaries.cpp | 2 +- .../mesh_and_remesh_c3t3.cpp | 2 +- ...remesh_polyhedral_domain_with_features.cpp | 2 +- .../mesh_and_remesh_with_adaptive_sizing.cpp | 2 +- .../mesh_and_remesh_with_sizing.cpp | 2 +- ...ral_remeshing_with_features_and_sizing.cpp | 2 +- .../features_and_adaptive_sizing.cpp | 2 +- .../test_mesh_and_remesh_image.cpp | 2 +- ...sh_and_remesh_polyhedron_with_features.cpp | 2 +- .../test_mesh_and_remesh_with_io.cpp | 2 +- ...test_mesh_and_remesh_with_sizing_field.cpp | 2 +- 103 files changed, 135 insertions(+), 130 deletions(-) diff --git a/Generator/examples/Generator/random_points_in_tetrahedral_mesh_3.cpp b/Generator/examples/Generator/random_points_in_tetrahedral_mesh_3.cpp index 79a1ea4fd14f..51c1853a9e61 100644 --- a/Generator/examples/Generator/random_points_in_tetrahedral_mesh_3.cpp +++ b/Generator/examples/Generator/random_points_in_tetrahedral_mesh_3.cpp @@ -32,7 +32,7 @@ typedef CGAL::Mesh_triangulation_3< typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // (Unweighted) point type typedef Tr::Bare_point Point; diff --git a/Generator/examples/Generator/random_points_on_tetrahedral_mesh_3.cpp b/Generator/examples/Generator/random_points_on_tetrahedral_mesh_3.cpp index d564ee7c2f39..6620c9fb5224 100644 --- a/Generator/examples/Generator/random_points_on_tetrahedral_mesh_3.cpp +++ b/Generator/examples/Generator/random_points_on_tetrahedral_mesh_3.cpp @@ -31,7 +31,7 @@ typedef CGAL::Mesh_triangulation_3< typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // (Unweighted) point type typedef Tr::Bare_point Point; diff --git a/Generator/test/Generator/generic_random_test.cpp b/Generator/test/Generator/generic_random_test.cpp index 2680e0b067c2..44690642f301 100644 --- a/Generator/test/Generator/generic_random_test.cpp +++ b/Generator/test/Generator/generic_random_test.cpp @@ -53,7 +53,7 @@ typedef Mesh_domain::Curve_index Curve_index; typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr, Corner_index, Curve_index> C3t3; -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef C3t3::Point Point; int test_triangles_2(const FT eps) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h index 433d6cfc5499..9d099f5a373e 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h @@ -118,7 +118,7 @@ class Mesh_function typedef C3t3::Vertex_handle Vertex_handle; typedef C3t3::Triangulation Tr; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Edge_criteria Edge_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Offset_meshing_plugin.cpp b/Lab/demo/Lab/Plugins/Mesh_3/Offset_meshing_plugin.cpp index a21cdbbf6556..6a5d2b85cadd 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Offset_meshing_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/Offset_meshing_plugin.cpp @@ -272,8 +272,7 @@ SMesh* cgal_off_meshing(QWidget*, using Mesh_domain_base = CGAL::Labeled_mesh_domain_3; using Mesh_domain = CGAL::Mesh_domain_with_polyline_features_3; - using Tr = C3t3::Triangulation; - using Mesh_criteria = CGAL::Mesh_criteria_3; + using Mesh_criteria = CGAL::Mesh_criteria_3; const CGAL::Bbox_3 bbox = source_item->bbox(); diff --git a/Lab/demo/Lab/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp b/Lab/demo/Lab/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp index 23b2b28d48d4..8dc61a8e9026 100644 --- a/Lab/demo/Lab/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp +++ b/Lab/demo/Lab/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp @@ -187,7 +187,7 @@ SMesh* poisson_reconstruct(Point_set& points, typedef CGAL::Labeled_mesh_domain_3 Mesh_domain; typedef typename CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; // AABB tree typedef CGAL::AABB_face_graph_triangle_primitive Primitive; diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshCriteriaWithFeatures_3.h b/Mesh_3/doc/Mesh_3/Concepts/MeshCriteriaWithFeatures_3.h index 895fa9e8c0f1..1f2ad95125a2 100644 --- a/Mesh_3/doc/Mesh_3/Concepts/MeshCriteriaWithFeatures_3.h +++ b/Mesh_3/doc/Mesh_3/Concepts/MeshCriteriaWithFeatures_3.h @@ -15,7 +15,7 @@ that describes the requirements, in terms of sizing, for the discretization of t \cgalRefines{MeshCriteria_3} \cgalHasModelsBegin -\cgalHasModels{CGAL::Mesh_criteria_3} +\cgalHasModels{CGAL::Mesh_criteria_3} \cgalHasModelsEnd \sa `MeshEdgeCriteria_3` diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshCriteria_3.h b/Mesh_3/doc/Mesh_3/Concepts/MeshCriteria_3.h index 22805028b7ed..063765b1f357 100644 --- a/Mesh_3/doc/Mesh_3/Concepts/MeshCriteria_3.h +++ b/Mesh_3/doc/Mesh_3/Concepts/MeshCriteria_3.h @@ -13,7 +13,7 @@ are described by the concept `MeshFacetCriteria_3`. The concept `MeshCriteria_3` encapsulates these concepts. \cgalHasModelsBegin -\cgalHasModels{CGAL::Mesh_criteria_3} +\cgalHasModels{CGAL::Mesh_criteria_3} \cgalHasModelsEnd \sa `MeshEdgeCriteria_3` diff --git a/Mesh_3/doc/Mesh_3/PackageDescription.txt b/Mesh_3/doc/Mesh_3/PackageDescription.txt index 9de466df99f1..2b0b12a15bc5 100644 --- a/Mesh_3/doc/Mesh_3/PackageDescription.txt +++ b/Mesh_3/doc/Mesh_3/PackageDescription.txt @@ -92,7 +92,7 @@ related to the template parameters of some models of the main concepts: - `CGAL::Mesh_vertex_base_3` - `CGAL::Compact_mesh_cell_base_3` - `CGAL::Mesh_cell_base_3` -- `CGAL::Mesh_criteria_3` +- `CGAL::Mesh_criteria_3` - `CGAL::Mesh_cell_criteria_3` - `CGAL::Mesh_facet_criteria_3` - `CGAL::Mesh_edge_criteria_3` diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_gray_image.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_gray_image.cpp index d877389a5306..e2fa296bcd94 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_gray_image.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_gray_image.cpp @@ -21,7 +21,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_gray_image_multiple_values.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_gray_image_multiple_values.cpp index 71b3a5950a42..011fa6decea0 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_gray_image_multiple_values.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_gray_image_multiple_values.cpp @@ -24,7 +24,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_gray_vtk_image.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_gray_vtk_image.cpp index d3d718138ad2..fc6bd8d90e25 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_gray_vtk_image.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_gray_vtk_image.cpp @@ -34,7 +34,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; template class Is_interior { diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_image.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_image.cpp index 484863d158c7..b22a0eadc591 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_image.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_image.cpp @@ -24,7 +24,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_image_variable_size.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_image_variable_size.cpp index c4d07143c0a1..9a963e277d18 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_image_variable_size.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_image_variable_size.cpp @@ -25,7 +25,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef CGAL::Mesh_constant_domain_field_3 Sizing_field; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_custom_initialization.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_custom_initialization.cpp index fd07fd1090fb..7d0d8fc84bf7 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_custom_initialization.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_custom_initialization.cpp @@ -30,7 +30,7 @@ using Tr = CGAL::Mesh_triangulation_3; // Criteria -using Mesh_criteria = CGAL::Mesh_criteria_3; +using Mesh_criteria = CGAL::Mesh_criteria_3; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_detection_of_features.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_detection_of_features.cpp index 0ab73c9748e9..5e8806c1b06a 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_detection_of_features.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_detection_of_features.cpp @@ -32,7 +32,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // To avoid verbose function and named parameters call namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_features.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_features.cpp index eab5ad9ef56e..384bc99f08ca 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_features.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_features.cpp @@ -32,7 +32,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_image_initialization.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_image_initialization.cpp index 133fec86966a..0c2948110030 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_image_initialization.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_image_initialization.cpp @@ -32,7 +32,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_initial_points.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_initial_points.cpp index 947fe4d890d4..255aff4d82f0 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_initial_points.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_initial_points.cpp @@ -30,7 +30,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_input_features.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_input_features.cpp index 8a83efae986d..e84cab304fd0 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_input_features.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_input_features.cpp @@ -30,7 +30,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image.cpp index c48c6cf8d98f..9e68deeaa07a 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image.cpp @@ -22,7 +22,7 @@ using Tr = CGAL::Mesh_triangulation_3; // Criteria -using Mesh_criteria = CGAL::Mesh_criteria_3; +using Mesh_criteria = CGAL::Mesh_criteria_3; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image_with_detection_of_features.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image_with_detection_of_features.cpp index 9d9033a69095..ae72c0222180 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image_with_detection_of_features.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_weighted_image_with_detection_of_features.cpp @@ -30,7 +30,7 @@ using Tr = CGAL::Mesh_triangulation_3 using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; // Criteria -using Mesh_criteria = CGAL::Mesh_criteria_3; +using Mesh_criteria = CGAL::Mesh_criteria_3; // To avoid verbose function and named parameters call using namespace CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_cubes_intersection.cpp b/Mesh_3/examples/Mesh_3/mesh_cubes_intersection.cpp index 8b413b1cec94..5df82b181d40 100644 --- a/Mesh_3/examples/Mesh_3/mesh_cubes_intersection.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_cubes_intersection.cpp @@ -35,7 +35,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Mesh Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/examples/Mesh_3/mesh_cubes_intersection_with_features.cpp b/Mesh_3/examples/Mesh_3/mesh_cubes_intersection_with_features.cpp index 9fe2a209ca3c..71c2d607f2db 100644 --- a/Mesh_3/examples/Mesh_3/mesh_cubes_intersection_with_features.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_cubes_intersection_with_features.cpp @@ -37,7 +37,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Mesh Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp b/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp index 32a612b7b1d0..b61acced4a1f 100644 --- a/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp @@ -172,7 +172,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Edge_criteria Edge_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/examples/Mesh_3/mesh_implicit_domains.cpp b/Mesh_3/examples/Mesh_3/mesh_implicit_domains.cpp index 68c7c4c5b37a..e8a3ba2473ef 100644 --- a/Mesh_3/examples/Mesh_3/mesh_implicit_domains.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_implicit_domains.cpp @@ -33,7 +33,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Mesh Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/examples/Mesh_3/mesh_implicit_domains_2.cpp b/Mesh_3/examples/Mesh_3/mesh_implicit_domains_2.cpp index 9c6eb9a00556..26e129af54e8 100644 --- a/Mesh_3/examples/Mesh_3/mesh_implicit_domains_2.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_implicit_domains_2.cpp @@ -25,7 +25,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Mesh Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/examples/Mesh_3/mesh_implicit_ellipsoid.cpp b/Mesh_3/examples/Mesh_3/mesh_implicit_ellipsoid.cpp index db7dabd145ef..48b7eaa472e4 100644 --- a/Mesh_3/examples/Mesh_3/mesh_implicit_ellipsoid.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_implicit_ellipsoid.cpp @@ -21,7 +21,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/examples/Mesh_3/mesh_implicit_sphere.cpp b/Mesh_3/examples/Mesh_3/mesh_implicit_sphere.cpp index d2cec7e4d940..3f3a2fa589da 100644 --- a/Mesh_3/examples/Mesh_3/mesh_implicit_sphere.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_implicit_sphere.cpp @@ -26,7 +26,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_implicit_sphere_variable_size.cpp b/Mesh_3/examples/Mesh_3/mesh_implicit_sphere_variable_size.cpp index 7c4ad34100b9..91d7dbc00ac9 100644 --- a/Mesh_3/examples/Mesh_3/mesh_implicit_sphere_variable_size.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_implicit_sphere_variable_size.cpp @@ -26,7 +26,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // Sizing field struct Spherical_sizing_field diff --git a/Mesh_3/examples/Mesh_3/mesh_optimization_example.cpp b/Mesh_3/examples/Mesh_3/mesh_optimization_example.cpp index 5d9354615ee8..d7bf0d025b4e 100644 --- a/Mesh_3/examples/Mesh_3/mesh_optimization_example.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_optimization_example.cpp @@ -24,7 +24,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Mesh Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_optimization_lloyd_example.cpp b/Mesh_3/examples/Mesh_3/mesh_optimization_lloyd_example.cpp index 42b8c1d0c4ac..dce3b9504122 100644 --- a/Mesh_3/examples/Mesh_3/mesh_optimization_lloyd_example.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_optimization_lloyd_example.cpp @@ -24,7 +24,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Mesh Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex.cpp index b502b7593e6b..dcd39174ae05 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex.cpp @@ -29,7 +29,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex_sm.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex_sm.cpp index 9bf6c3853705..a75f6956f8f0 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex_sm.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_complex_sm.cpp @@ -31,7 +31,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain.cpp index cd56e3bc5c77..a75ddbf43889 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain.cpp @@ -27,7 +27,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_sm.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_sm.cpp index eac3d9a47019..88940687fd3a 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_sm.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_sm.cpp @@ -26,7 +26,7 @@ typedef CGAL::Mesh_triangulation_3::t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_edge_distance.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_edge_distance.cpp index c553699c03af..3a20e40acfd4 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_edge_distance.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_edge_distance.cpp @@ -26,7 +26,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features.cpp index 917aeec1cf4f..229c59ff0e53 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features.cpp @@ -27,7 +27,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sizing.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sizing.cpp index fc69011dda5f..49954fd07b7c 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sizing.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sizing.cpp @@ -29,7 +29,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sm.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sm.cpp index cbdf8b90b97b..81a190530702 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sm.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_features_sm.cpp @@ -28,7 +28,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_lipschitz_sizing.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_lipschitz_sizing.cpp index 520c1b1eb4ca..42d6c5073b48 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_lipschitz_sizing.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_lipschitz_sizing.cpp @@ -29,7 +29,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // Sizing field typedef CGAL::Mesh_3::Lipschitz_sizing Lip_sizing; diff --git a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_surface_inside.cpp b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_surface_inside.cpp index 4f81ca6ce6f8..b0e0e5c294a9 100644 --- a/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_surface_inside.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_polyhedral_domain_with_surface_inside.cpp @@ -24,7 +24,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/mesh_two_implicit_spheres_with_balls.cpp b/Mesh_3/examples/Mesh_3/mesh_two_implicit_spheres_with_balls.cpp index 781631cdb5a7..5469c56a5a24 100644 --- a/Mesh_3/examples/Mesh_3/mesh_two_implicit_spheres_with_balls.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_two_implicit_spheres_with_balls.cpp @@ -35,7 +35,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface.cpp b/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface.cpp index c9b999250035..59f57ddde0f3 100644 --- a/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface.cpp +++ b/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface.cpp @@ -20,7 +20,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface_sm.cpp b/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface_sm.cpp index 58aadb62dc71..3678cd16f1bc 100644 --- a/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface_sm.cpp +++ b/Mesh_3/examples/Mesh_3/remesh_polyhedral_surface_sm.cpp @@ -19,7 +19,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index c38abcf2f73f..0a5c9423d72c 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -1146,7 +1146,7 @@ number_of_bad_elements_impl() const Facet f1(c, i); if (this->is_facet_on_surface(f1)) { - std::cerr << "*** f1 is " << (this->r_criteria_(this->r_tr_, f1) ? "bad" : "good") << std::endl; + std::cerr << "*** f1 is " << (this->r_criteria_(this->r_c3t3_, f1) ? "bad" : "good") << std::endl; #ifdef SHOW_REMAINING_BAD_ELEMENT_IN_RED c->mark = i; @@ -1164,7 +1164,7 @@ number_of_bad_elements_impl() const Facet f2(c, i); if (this->is_facet_on_surface(f2)) { - std::cerr << "*** f2 is " << (this->r_criteria_(this->r_tr_, f2) ? "bad" : "good") << std::endl; + std::cerr << "*** f2 is " << (this->r_criteria_(this->r_c3t3_, f2) ? "bad" : "good") << std::endl; #ifdef SHOW_REMAINING_BAD_ELEMENT_IN_RED mc->mark = i; @@ -1207,7 +1207,7 @@ number_of_bad_elements_impl() // Facet is on surface: set facet properties // set_facet_on_surface(facet, surface_index, surface_center_index, surface_center); - const typename Rf_base::Is_facet_bad is_facet_bad = this->r_criteria_(this->r_tr_, facet); + const typename Rf_base::Is_facet_bad is_facet_bad = this->r_criteria_(this->r_c3t3_, facet); if ( is_facet_bad ) { ++count; diff --git a/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h b/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h index a2510c298a10..6c1d0421c370 100644 --- a/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h @@ -42,7 +42,7 @@ and a sizing field which may be a uniform or variable field. \cgalModels{MeshCellCriteria_3} \sa `MeshCriteria_3` -\sa `CGAL::Mesh_criteria_3` +\sa `CGAL::Mesh_criteria_3` \sa `CGAL::make_mesh_3()` */ template object with all cell and facet parameters set -Mesh_criteria_3 criteria (parameters::facet_angle(30). - parameters::facet_size(1). - parameters::facet_distance(0.1). - parameters::cell_radius_edge_ratio(2). - parameters::cell_size(1.5)); - -// Create a Mesh_criteria_3 object with size ignored (note that the order changed) -Mesh_criteria_3 criteria (parameters::cell_radius_edge_ratio(2). - parameters::facet_angle(30). - parameters::facet_distance(0.1)); +// Create a Mesh_criteria_3 object with all cell and facet parameters set +Mesh_criteria_3 criteria (parameters::facet_angle(30). + parameters::facet_size(1). + parameters::facet_distance(0.1). + parameters::cell_radius_edge_ratio(2). + parameters::cell_size(1.5)); + +// Create a Mesh_criteria_3 object with size ignored (note that the order changed) +Mesh_criteria_3 criteria (parameters::cell_radius_edge_ratio(2). + parameters::facet_angle(30). + parameters::facet_distance(0.1)); \endcode diff --git a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h index 3d8926618ae9..2c2ed279a3d1 100644 --- a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h @@ -96,7 +96,7 @@ provides bounds for the size and approximation criteria. \cgalModels{MeshEdgeCriteria_3} \sa `MeshCriteriaWithFeatures_3` -\sa `CGAL::Mesh_criteria_3` +\sa `CGAL::Mesh_criteria_3` \sa `MeshDomainField_3` */ template < typename C3T3 > diff --git a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h index 0f6967d43424..8ff951c84b81 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h @@ -49,7 +49,7 @@ namespace CGAL { \sa `MeshFacetCriteria_3` \sa `MeshDomainField_3` \sa `CGAL::Mesh_facet_topology` - \sa `CGAL::Mesh_criteria_3` + \sa `CGAL::Mesh_criteria_3` \sa `CGAL::make_mesh_3()` */ diff --git a/Mesh_3/include/CGAL/Mesh_facet_topology.h b/Mesh_3/include/CGAL/Mesh_facet_topology.h index af660bdd936a..a8e7d5a18ff5 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_topology.h +++ b/Mesh_3/include/CGAL/Mesh_facet_topology.h @@ -28,8 +28,8 @@ namespace CGAL { The enum `Mesh_facet_topology` is designed to tell which constraints have to be checked on each surface facet during the mesh refinement process. -\sa `CGAL::Mesh_criteria_3`, -\sa `CGAL::Mesh_facet_criteria_3`. +\sa `CGAL::Mesh_criteria_3`, +\sa `CGAL::Mesh_facet_criteria_3`. */ enum Mesh_facet_topology { diff --git a/Mesh_3/include/CGAL/Polygon_mesh_processing/surface_Delaunay_remeshing.h b/Mesh_3/include/CGAL/Polygon_mesh_processing/surface_Delaunay_remeshing.h index fa9e55c1326e..84fb63854c7d 100644 --- a/Mesh_3/include/CGAL/Polygon_mesh_processing/surface_Delaunay_remeshing.h +++ b/Mesh_3/include/CGAL/Polygon_mesh_processing/surface_Delaunay_remeshing.h @@ -192,7 +192,7 @@ surface_Delaunay_remeshing(const TriangleMesh& tmesh, using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; - using Mesh_criteria = CGAL::Mesh_criteria_3; + using Mesh_criteria = CGAL::Mesh_criteria_3; using FT = typename GT::FT; using Point_3 = typename GT::Point_3; diff --git a/Mesh_3/test/Mesh_3/test_criteria.cpp b/Mesh_3/test/Mesh_3/test_criteria.cpp index a10460ceee22..8e3bdf480165 100644 --- a/Mesh_3/test/Mesh_3/test_criteria.cpp +++ b/Mesh_3/test/Mesh_3/test_criteria.cpp @@ -38,7 +38,7 @@ struct Tester typedef typename CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef typename Mesh_criteria::Facet_criteria Facet_criteria; typedef typename Mesh_criteria::Cell_criteria Cell_criteria; @@ -220,8 +220,8 @@ struct Tester Cell_criteria cell_criteria(radius_edge,radius); - Is_bad b1 = cell_criteria(tr, cell1); - Is_bad b2 = cell_criteria(tr, cell2); + Is_bad b1 = cell_criteria(c3t3_, cell1); + Is_bad b2 = cell_criteria(c3t3_, cell2); std::cerr << "\t[Radius bound: " << radius << " - Radius-edge bound: " << radius_edge @@ -267,8 +267,8 @@ struct Tester Facet_criteria criteria(angle, radius, distance); - Is_bad b1 = criteria(tr, f1); - Is_bad b2 = criteria(tr, f2); + Is_bad b1 = criteria(c3t3_, f1); + Is_bad b2 = criteria(c3t3_, f2); std::cerr << "\t[Angle bound: " << angle << " - Radius bound: " << radius diff --git a/Mesh_3/test/Mesh_3/test_max_edge_distance.cpp b/Mesh_3/test/Mesh_3/test_max_edge_distance.cpp index de988eb4aa8e..8d76903f3f85 100644 --- a/Mesh_3/test/Mesh_3/test_max_edge_distance.cpp +++ b/Mesh_3/test/Mesh_3/test_max_edge_distance.cpp @@ -117,7 +117,7 @@ struct Distance_polyhedral_tester : public Tester, public Edge_distance_t typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; public: void operator()(const std::size_t min_vertices_expected = 0, @@ -196,7 +196,7 @@ struct Distance_label_image_tester : public Tester, public Edge_distance_ typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; public: diff --git a/Mesh_3/test/Mesh_3/test_mesh_3_issue_1554.cpp b/Mesh_3/test/Mesh_3/test_mesh_3_issue_1554.cpp index f0371d3a96d3..d1b59f03f9c5 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_3_issue_1554.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_3_issue_1554.cpp @@ -31,7 +31,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // To avoid verbose function and named parameters call using namespace CGAL::parameters; diff --git a/Mesh_3/test/Mesh_3/test_mesh_3_issue_8773.cpp b/Mesh_3/test/Mesh_3/test_mesh_3_issue_8773.cpp index bc348b256766..24e4d234681c 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_3_issue_8773.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_3_issue_8773.cpp @@ -22,7 +22,7 @@ using Tr = CGAL::Mesh_triangulation_3; // Criteria -using Mesh_criteria = CGAL::Mesh_criteria_3; +using Mesh_criteria = CGAL::Mesh_criteria_3; namespace params = CGAL::parameters; diff --git a/Mesh_3/test/Mesh_3/test_mesh_capsule_var_distance_bound.cpp b/Mesh_3/test/Mesh_3/test_mesh_capsule_var_distance_bound.cpp index 9fa7eaad0c33..6ba7ab1ed107 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_capsule_var_distance_bound.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_capsule_var_distance_bound.cpp @@ -24,7 +24,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // To avoid verbose function and named parameters call using namespace CGAL::parameters; diff --git a/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp b/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp index 3ab51c43ba47..e586697d9c0e 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp @@ -1,5 +1,7 @@ #include + #include +#include #include #include @@ -9,8 +11,10 @@ typedef CGAL::Polyhedral_mesh_domain_with_features_3 Mesh_domain; // Triangulation typedef CGAL::Mesh_triangulation_3::type Tr; +typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + // Criteria -typedef CGAL::Mesh_criteria_3 Mc; +typedef CGAL::Mesh_criteria_3 Mc; typedef CGAL::Mesh_constant_domain_field_3 Sizing_field; @@ -28,7 +32,9 @@ int main() Tr::Point p3(0,1,0); Tr::Point p4(0,0,1); - Tr tr; + C3t3 c3t3; + Tr& tr = c3t3.triangulation(); + tr.insert(p1); tr.insert(p2); tr.insert(p3); @@ -102,10 +108,10 @@ int main() FT facet_size_ok = radius_facet*FT(10); Mc fc1(facet_size = facet_size_ok); - assert( ! fc1.facet_criteria_object()(tr, f) ); + assert( ! fc1.facet_criteria_object()(c3t3, f) ); Mc fc3(facet_size = Fsf(facet_size_ok)); - assert( ! fc3.facet_criteria_object()(tr, f) ); + assert( ! fc3.facet_criteria_object()(c3t3, f) ); Mc fc8(facet_distance = 8.); Mc fc9(facet_angle = 9.); @@ -126,10 +132,10 @@ int main() // Test topological criterion creation Mc fc14(facet_topology = CGAL::FACET_VERTICES_ON_SURFACE); - assert( ! fc14.facet_criteria_object()(tr, f) ); + assert( ! fc14.facet_criteria_object()(c3t3, f) ); Mc fc15(facet_topology = CGAL::FACET_VERTICES_ON_SAME_SURFACE_PATCH); - assert( fc15.facet_criteria_object()(tr, f) ); + assert( fc15.facet_criteria_object()(c3t3, f) ); // ----------------------------------- // Test cell criteria @@ -142,13 +148,13 @@ int main() FT cell_size_ok = radius_cell*FT(10); Mc cc1(cell_size = cell_size_ok); - assert( ! cc1.cell_criteria_object()(tr, ch) ); + assert( ! cc1.cell_criteria_object()(c3t3, ch) ); Mc cc3(cell_size = Fsf(cell_size_ok)); - assert( ! cc3.cell_criteria_object()(tr, ch) ); + assert( ! cc3.cell_criteria_object()(c3t3, ch) ); Mc cc7(cell_size = Csf(cell_size_ok)); - assert( ! cc7.cell_criteria_object()(tr, ch) ); + assert( ! cc7.cell_criteria_object()(c3t3, ch) ); Mc cc8(cell_radius_edge_ratio = 8.); Mc cc9(cell_radius_edge_ratio = 9.1, diff --git a/Mesh_3/test/Mesh_3/test_mesh_polyhedral_domain_with_features_deprecated.cpp b/Mesh_3/test/Mesh_3/test_mesh_polyhedral_domain_with_features_deprecated.cpp index 9827a5f2b686..81af8b1ec33b 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_polyhedral_domain_with_features_deprecated.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_polyhedral_domain_with_features_deprecated.cpp @@ -23,7 +23,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_segment_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // To avoid verbose function and named parameters call using namespace CGAL::parameters; diff --git a/Mesh_3/test/Mesh_3/test_meshing_3D_gray_image.cpp b/Mesh_3/test/Mesh_3/test_meshing_3D_gray_image.cpp index 191ea47fafac..09201a24af4c 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_3D_gray_image.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_3D_gray_image.cpp @@ -47,7 +47,7 @@ struct Image_tester : public Tester CGAL::Kernel_traits::Kernel, Concurrency_tag>::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; CGAL_USE_TYPE(typename Mesh_domain::Surface_patch_index); diff --git a/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp b/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp index 379e1e5453db..47727fa936b3 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp @@ -35,7 +35,7 @@ struct Image_tester : public Tester Concurrency_tag>::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef typename Mesh_criteria::Facet_criteria Facet_criteria; typedef typename Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/test/Mesh_3/test_meshing_3D_image_with_features.cpp b/Mesh_3/test/Mesh_3/test_meshing_3D_image_with_features.cpp index 15682e0429be..ecc72cd8bb1b 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_3D_image_with_features.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_3D_image_with_features.cpp @@ -60,7 +60,7 @@ struct Image_tester : public Tester Concurrency_tag>::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; void mesh_and_verify(Mesh_domain& domain, const Image& image, const double volume) const { diff --git a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp index fcb314f6ea66..05a5afa3c599 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp @@ -44,7 +44,7 @@ void test() Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Mesh Criteria - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; // Domain std::cout << "\tSeed is\t 0" << std::endl; diff --git a/Mesh_3/test/Mesh_3/test_meshing_implicit_function.cpp b/Mesh_3/test/Mesh_3/test_meshing_implicit_function.cpp index c9a88cecf460..003f81c537c0 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_implicit_function.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_implicit_function.cpp @@ -26,7 +26,7 @@ struct Implicit_tester : public Tester Concurrency_tag>::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef typename Mesh_criteria::Facet_criteria Facet_criteria; typedef typename Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex.cpp index c3f7e999026c..e1bce75f4032 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex.cpp @@ -54,7 +54,7 @@ struct Polyhedral_complex_tester : public Tester Tr, typename Mesh_domain::Corner_index, typename Mesh_domain::Curve_index> C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; //Input const std::size_t nb_patches = sizeof(filenames) / sizeof(const char*); diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex_with_manifold_and_min_size.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex_with_manifold_and_min_size.cpp index 236e0069aece..f807119f966f 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex_with_manifold_and_min_size.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex_with_manifold_and_min_size.cpp @@ -28,7 +28,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; namespace params = CGAL::parameters; diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp index 9d43786e1a11..8d2c332a355f 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp @@ -46,7 +46,7 @@ struct Polyhedron_tester : public Tester Concurrency_tag>::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef typename Mesh_criteria::Facet_criteria Facet_criteria; typedef typename Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp index ac77144de614..f798165b39a2 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp @@ -91,7 +91,7 @@ struct Polyhedron_with_features_tester : public Tester typename Mesh_domain::Corner_index, typename Mesh_domain::Curve_index > C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef typename Mesh_criteria::Edge_criteria Edge_criteria; typedef typename Mesh_criteria::Facet_criteria Facet_criteria; typedef typename Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/test/Mesh_3/test_meshing_polylines_only.cpp b/Mesh_3/test/Mesh_3/test_meshing_polylines_only.cpp index 8dd7e0cbcb35..7577616e5289 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polylines_only.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polylines_only.cpp @@ -23,7 +23,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // To avoid verbose function and named parameters call using namespace CGAL::parameters; diff --git a/Mesh_3/test/Mesh_3/test_meshing_unit_tetrahedron.cpp b/Mesh_3/test/Mesh_3/test_meshing_unit_tetrahedron.cpp index 3e62a7d11ae6..8deb5409e7dd 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_unit_tetrahedron.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_unit_tetrahedron.cpp @@ -37,7 +37,7 @@ struct Polyhedron_tester : public Tester typename Mesh_domain::Curve_index> C3t3; // Criteria - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; MeshPolyhedron_3 P; diff --git a/Mesh_3/test/Mesh_3/test_meshing_with_one_step.cpp b/Mesh_3/test/Mesh_3/test_meshing_with_one_step.cpp index 19199d8e08f2..50bca77737d0 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_with_one_step.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_with_one_step.cpp @@ -25,7 +25,7 @@ typedef CGAL::Mesh_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef CGAL::Mesh_3::Mesher_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef CGAL::Mesh_3::Mesher_3 C3t3; // Mesh Criteria - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; // Domain std::cout << "\tSeed is\t 0" << std::endl; diff --git a/Mesh_3/test/Mesh_3/test_min_edge_length.cpp b/Mesh_3/test/Mesh_3/test_min_edge_length.cpp index c0169546f5dd..81113ec68669 100644 --- a/Mesh_3/test/Mesh_3/test_min_edge_length.cpp +++ b/Mesh_3/test/Mesh_3/test_min_edge_length.cpp @@ -25,7 +25,7 @@ struct Tester typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; void operator()(const std::string fname, const std::string out_fname) { diff --git a/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp b/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp index d42bef33f806..ca1d310a9e29 100644 --- a/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp +++ b/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp @@ -41,7 +41,7 @@ struct Image_tester : public Tester using FT = typename Tr::Geom_traits::FT; using Bare_point = typename Tr::Bare_point; - using Mesh_criteria = CGAL::Mesh_criteria_3; + using Mesh_criteria = CGAL::Mesh_criteria_3; using Facet_criteria = typename Mesh_criteria::Facet_criteria; using Cell_criteria = typename Mesh_criteria::Cell_criteria; diff --git a/Mesh_3/test/Mesh_3/test_remeshing_polyhedron.cpp b/Mesh_3/test/Mesh_3/test_remeshing_polyhedron.cpp index f05635e63c36..cd94f4e26b0b 100644 --- a/Mesh_3/test/Mesh_3/test_remeshing_polyhedron.cpp +++ b/Mesh_3/test/Mesh_3/test_remeshing_polyhedron.cpp @@ -36,7 +36,7 @@ struct Polyhedron_tester : public Tester using Mesh_domain = CGAL::Polyhedral_mesh_domain_3; using Tr = typename CGAL::Mesh_triangulation_3::type; using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; - using Mesh_criteria = CGAL::Mesh_criteria_3; + using Mesh_criteria = CGAL::Mesh_criteria_3; Polyhedron polyhedron; std::ifstream input(filename); diff --git a/Mesh_3/test/Mesh_3/test_without_detect_features.cpp b/Mesh_3/test/Mesh_3/test_without_detect_features.cpp index 2e5c76606d16..88fc67d9e1cf 100644 --- a/Mesh_3/test/Mesh_3/test_without_detect_features.cpp +++ b/Mesh_3/test/Mesh_3/test_without_detect_features.cpp @@ -20,7 +20,7 @@ struct Tester { typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; int operator()(const std::string fname, const std::string /*out_fname*/) { diff --git a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_multi_domain.cpp b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_multi_domain.cpp index bdb3320e2401..243ca016fe2a 100644 --- a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_multi_domain.cpp +++ b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_multi_domain.cpp @@ -38,7 +38,7 @@ typedef CGAL::Periodic_3_mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; +typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; // To avoid verbose function and named parameters call namespace params = CGAL::parameters; diff --git a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape.cpp b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape.cpp index c742bc2d4cf1..d82b5e2eb58b 100644 --- a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape.cpp +++ b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape.cpp @@ -31,7 +31,7 @@ typedef CGAL::Periodic_3_mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; +typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; // To avoid verbose function and named parameters call namespace params = CGAL::parameters; diff --git a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_features.cpp b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_features.cpp index 0be891eaa35d..15146d08c1fd 100644 --- a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_features.cpp +++ b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_features.cpp @@ -42,7 +42,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr, Periodic_mesh_domain::Corner_index, Periodic_mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; +typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; // To avoid verbose function and named parameters call namespace params = CGAL::parameters; diff --git a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_optimizers.cpp b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_optimizers.cpp index 3aee4a2c6c7e..32ab9765cc73 100644 --- a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_optimizers.cpp +++ b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_optimizers.cpp @@ -31,7 +31,7 @@ typedef CGAL::Periodic_3_mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; +typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; // To avoid verbose function and named parameters call namespace params = CGAL::parameters; diff --git a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_subdomains.cpp b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_subdomains.cpp index 183e5e1674a5..b578a8fa684b 100644 --- a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_subdomains.cpp +++ b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_implicit_shape_with_subdomains.cpp @@ -33,7 +33,7 @@ typedef CGAL::Periodic_3_mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; +typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; // To avoid verbose function and named parameters call namespace params = CGAL::parameters; diff --git a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_periodic_polyhedral_domain.cpp b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_periodic_polyhedral_domain.cpp index 8e72bc854a74..1daebd7725c5 100644 --- a/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_periodic_polyhedral_domain.cpp +++ b/Periodic_3_mesh_3/examples/Periodic_3_mesh_3/mesh_periodic_polyhedral_domain.cpp @@ -84,7 +84,7 @@ using Tr = CGAL::Periodic_3_mesh_triangulation_3::type; using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; // Criteria -using Periodic_mesh_criteria = CGAL::Mesh_criteria_3; +using Periodic_mesh_criteria = CGAL::Mesh_criteria_3; // To avoid verbose function and named parameters call namespace params = CGAL::parameters; diff --git a/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_implicit_shapes_bunch.cpp b/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_implicit_shapes_bunch.cpp index 87669ceb91d5..b05b1216adf6 100644 --- a/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_implicit_shapes_bunch.cpp +++ b/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_implicit_shapes_bunch.cpp @@ -37,7 +37,7 @@ typedef CGAL::Periodic_3_mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; +typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; // To avoid verbose function and named parameters call using namespace CGAL::parameters; diff --git a/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_implicit_shapes_with_features.cpp b/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_implicit_shapes_with_features.cpp index 2a297d3f89b8..1bda2d4c0391 100644 --- a/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_implicit_shapes_with_features.cpp +++ b/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_implicit_shapes_with_features.cpp @@ -43,7 +43,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr, Periodic_mesh_domain::Corner_index, Periodic_mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; +typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; // To avoid verbose function and named parameters call using namespace CGAL::parameters; diff --git a/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_triply_periodic_minimal_surfaces.cpp b/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_triply_periodic_minimal_surfaces.cpp index 864dc9376edc..09f1a8b6d230 100644 --- a/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_triply_periodic_minimal_surfaces.cpp +++ b/Periodic_3_mesh_3/test/Periodic_3_mesh_3/test_triply_periodic_minimal_surfaces.cpp @@ -41,7 +41,7 @@ typedef CGAL::Periodic_3_mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; +typedef CGAL::Mesh_criteria_3 Periodic_mesh_criteria; // To avoid verbose function and named parameters call using namespace CGAL::parameters; diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp index 3706b1ec1968..51c5c341b58a 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp @@ -47,7 +47,7 @@ void poisson_reconstruction(const PointSet& points, const char* output) typedef CGAL::Poisson_mesh_domain_3 Mesh_domain; typedef typename CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; // Poisson options FT sm_angle = 20.0; // Min triangle angle in degrees. diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp index 82c3a623d2cf..34f8da79edcf 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp @@ -59,7 +59,7 @@ typedef CGAL::Poisson_reconstruction_function Poisson_reconstruction_fun typedef CGAL::Poisson_mesh_domain_3 Mesh_domain; typedef typename CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // AABB tree typedef CGAL::AABB_face_graph_triangle_primitive Primitive; diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp index 4d4806a7d256..0a789977ac78 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp @@ -35,7 +35,7 @@ typedef CGAL::Poisson_reconstruction_function Poisson_reconstruction_fun typedef CGAL::Poisson_mesh_domain_3 Mesh_domain; typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; int main(void) { diff --git a/Poisson_surface_reconstruction_3/include/CGAL/poisson_surface_reconstruction.h b/Poisson_surface_reconstruction_3/include/CGAL/poisson_surface_reconstruction.h index fa39d55b131c..ce75f1e05d26 100644 --- a/Poisson_surface_reconstruction_3/include/CGAL/poisson_surface_reconstruction.h +++ b/Poisson_surface_reconstruction_3/include/CGAL/poisson_surface_reconstruction.h @@ -102,7 +102,7 @@ namespace CGAL { typedef CGAL::Poisson_mesh_domain_3 Mesh_domain; typedef typename CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; Poisson_reconstruction_function function(begin, end, point_map, normal_map); if ( ! function.compute_implicit_function() ) diff --git a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/compare_mesh_3_vs_Poisson_implicit_surface_3.cpp b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/compare_mesh_3_vs_Poisson_implicit_surface_3.cpp index 117ccf977294..27a9db80a4f1 100644 --- a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/compare_mesh_3_vs_Poisson_implicit_surface_3.cpp +++ b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/compare_mesh_3_vs_Poisson_implicit_surface_3.cpp @@ -70,7 +70,7 @@ typedef CGAL::Mesh_criteria_3 LMesh_criteria; typedef CGAL::Poisson_mesh_domain_3 Mesh_domain; typedef typename CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; struct Counter { diff --git a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/poisson_reconstruction_test_mesh_3.cpp b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/poisson_reconstruction_test_mesh_3.cpp index 720e3f4b18b2..587fad01d2af 100644 --- a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/poisson_reconstruction_test_mesh_3.cpp +++ b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/poisson_reconstruction_test_mesh_3.cpp @@ -62,7 +62,7 @@ typedef CGAL::Poisson_reconstruction_function Poisson_reconstruction_fun typedef CGAL::Labeled_mesh_domain_3 Mesh_domain; typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // Mesh_3 using Poisson_mesh_domain_3 typedef CGAL::Poisson_mesh_domain_3 Poisson_mesh_domain; diff --git a/SMDS_3/test/SMDS_3/test_c3t3_extract_subdomains_boundaries.cpp b/SMDS_3/test/SMDS_3/test_c3t3_extract_subdomains_boundaries.cpp index 851e8fe38c6f..1c0da907716c 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3_extract_subdomains_boundaries.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3_extract_subdomains_boundaries.cpp @@ -53,7 +53,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Mesh Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp index ba0dbe1d30d2..8723aaf60c13 100644 --- a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp +++ b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp @@ -32,7 +32,7 @@ using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3< Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index>; // Criteria -using Mesh_criteria = CGAL::Mesh_criteria_3; +using Mesh_criteria = CGAL::Mesh_criteria_3; // Triangulation for Remeshing using Triangulation_3 = CGAL::Triangulation_3; // Criteria -using Mesh_criteria = CGAL::Mesh_criteria_3; +using Mesh_criteria = CGAL::Mesh_criteria_3; // Triangulation for Remeshing using Triangulation_3 = CGAL::Triangulation_3::type; using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; // Criteria -using Mesh_criteria = CGAL::Mesh_criteria_3; +using Mesh_criteria = CGAL::Mesh_criteria_3; // Triangulation for Remeshing using T3 = CGAL::Triangulation_3: typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // Triangulation for Remeshing using T3 = CGAL::Triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // Triangulation for Remeshing typedef CGAL::Triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // Triangulation for Remeshing typedef CGAL::Triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Mesh Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_polyhedron_with_features.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_polyhedron_with_features.cpp index 405b3a34c6c1..15e044e26a8c 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_polyhedron_with_features.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_polyhedron_with_features.cpp @@ -28,7 +28,7 @@ typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index> C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; // To avoid verbose function and named parameters call using namespace CGAL::parameters; diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_io.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_io.cpp index ae25746ac5bd..2f041e220436 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_io.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_io.cpp @@ -26,7 +26,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Mesh Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_sizing_field.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_sizing_field.cpp index 5cff611db9bd..44d52e7007c1 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_sizing_field.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_sizing_field.cpp @@ -28,7 +28,7 @@ typedef CGAL::Triangulation_3 T3_remeshing; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; From a941c55cd89902014ff538cb0c617c12df4af84b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 13:21:05 +0100 Subject: [PATCH 027/127] EqualityComparable gives only operator== --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 8 ++++---- Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h | 2 +- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 4 ++-- .../CGAL/Tetrahedral_remeshing/internal/flip_edges.h | 2 +- .../CGAL/Tetrahedral_remeshing/internal/smooth_vertices.h | 2 +- .../internal/tetrahedral_adaptive_remeshing_impl.h | 2 +- .../internal/tetrahedral_remeshing_helpers.h | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index ff011afaea2e..8156f01eac83 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -2025,7 +2025,7 @@ class C3T3_helpers ++fit ) { Surface_patch_index pid = c3t3_.surface_patch_index(*fit); - const bool facet_in_complex = (pid != Surface_patch_index()); + const bool facet_in_complex = !(pid == Surface_patch_index()); if ( facet_in_complex ) surface_facets.push_back(*fit); @@ -2375,7 +2375,7 @@ class C3T3_helpers // Update m_vertex_to_proj Surface_patch_index pid = m_c3t3.surface_patch_index(facet); - if ( pid != Surface_patch_index() ) // // is facet in complex + if ( !(pid == Surface_patch_index()) ) // // is facet in complex { // Iterate on vertices int k = facet.second; @@ -2851,7 +2851,7 @@ rebuild_restricted_delaunay(ForwardIterator first_cell, // Update vertex_to_proj Surface_patch_index pid = c3t3_.surface_patch_index(*fit); - if ( pid != Surface_patch_index() ) // is facet in complex + if ( !(pid == Surface_patch_index()) ) // is facet in complex { // Iterate on vertices int k = fit->second; @@ -3929,7 +3929,7 @@ get_surface_boundary(const Vertex_handle& moving_vertex, for ( ; fit != facets.end() ; ++fit ) { const Surface_patch_index surface_index = c3t3_.surface_patch_index(*fit); - if ( surface_index != Surface_patch_index() ) // is facet in complex + if ( !(surface_index == Surface_patch_index()) ) // is facet in complex { const int k = fit->second; Vertex_handle v1 = fit->first->vertex((k+1)&3); diff --git a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h index 5dd9e2b1e24b..5287af6e944b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h +++ b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h @@ -1369,7 +1369,7 @@ get_umbrella(const Facet_vector& facets, // internal_facets of conflict zone { Facet f = *fit; Surface_patch_index pid = c3t3_.surface_patch_index(f); - if ( pid != Surface_patch_index() ) + if ( !(pid == Surface_patch_index()) ) { Vertex_handle v1 = f.first->vertex((f.second+1)%4); Vertex_handle v2 = f.first->vertex((f.second+2)%4); diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 10525713a97e..43439945b7bf 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -1070,14 +1070,14 @@ class Mesh_complex_3_in_triangulation_3 { typename Surface_facet_info::const_accessor accessor; if (surface_facet_info_.find(accessor, f)) - res_new = accessor->second.surface_index_ != Surface_patch_index(); + res_new = !(accessor->second.surface_index_ == Surface_patch_index()); } else # endif { auto it = surface_facet_info_.find(f); if (it != surface_facet_info_.end()) - res_new = (it->second.surface_index_ != Surface_patch_index()); + res_new = !(it->second.surface_index_ == Surface_patch_index()); } #endif diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h index ed22929e6086..3eaccfe024f1 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h @@ -1478,7 +1478,7 @@ Sliver_removal_result flip_on_surface(C3T3& c3t3, return NOT_FLIPPABLE; #endif Surface_patch_index patch = c3t3.surface_patch_index(ch0, ch0->index(vh4)); - CGAL_assertion(patch != Surface_patch_index()); + CGAL_assertion(!(patch == Surface_patch_index())); CGAL_assertion(c3t3.is_in_complex(ch0, ch0->index(vh4))); c3t3.remove_from_complex(ch0, ch0->index(vh4)); CGAL_assertion(c3t3.is_in_complex(ch3, ch3->index(vh4))); diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/smooth_vertices.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/smooth_vertices.h index cf73ab88891c..850f8186667d 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/smooth_vertices.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/smooth_vertices.h @@ -833,7 +833,7 @@ std::size_t smooth_vertices_on_surfaces(C3t3& c3t3, continue; const Surface_patch_index si = incident_surface_patches[0]; - CGAL_assertion(si != Surface_patch_index()); + CGAL_assertion(!(si == Surface_patch_index())); CGAL_expensive_assertion_code(auto siv = surface_patch_index(v, c3t3)); CGAL_expensive_assertion(si == siv); diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h index c60d95dc1d01..7b73dffb323f 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h @@ -555,7 +555,7 @@ class Adaptive_remesher for (Cell_handle cit : tr().finite_cell_handles()) { const Subdomain_index cid = cit->subdomain_index(); - if (cid > max_index && cid != Subdomain_index()) + if (cid > max_index && !(cid == Subdomain_index())) max_index = cid; } return max_index; diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h index 73b8da185dba..87a173b99aca 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h @@ -2506,7 +2506,7 @@ void dump_cells_with_small_dihedral_angle(const Tr& tr, for (Cell_handle c : tr.finite_cell_handles()) { - if (c->subdomain_index() != Subdomain_index() && get(cell_select, c)) + if (!(c->subdomain_index() == Subdomain_index()) && get(cell_select, c)) { double dh = min_dihedral_angle(tr, c); if (dh < angle_bound) From dd96342e2b776251937006631a9b05dec2f1bfb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 21:45:47 +0100 Subject: [PATCH 028/127] Misc tiny changes --- Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp | 2 +- Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h | 2 +- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 4 ++-- Periodic_3_mesh_3/include/CGAL/make_periodic_3_mesh_3.h | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp b/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp index b61acced4a1f..ecd1f5eb3bf5 100644 --- a/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp @@ -172,7 +172,7 @@ typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef Mesh_criteria::Edge_criteria Edge_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index d87084f5684c..b277c58c2e38 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -161,7 +161,7 @@ class Compact_mesh_cell_base_3_base Erase_counter_type m_erase_counter; #endif -char bits_; + char bits_; }; diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 8156f01eac83..fb8c57cd76b0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -680,7 +680,7 @@ class C3T3_helpers // ----------------------------------- // Public interface // ----------------------------------- - typedef std::optional Update_mesh; + typedef std::optional Update_mesh; using Base::try_lock_point; using Base::try_lock_vertex; @@ -2122,7 +2122,7 @@ class C3T3_helpers template void reset_sliver_cache(CellForwardIterator cells_begin, - CellForwardIterator cells_end) const + CellForwardIterator cells_end) const { while(cells_begin != cells_end) { (*cells_begin)->reset_cache_validity(); diff --git a/Periodic_3_mesh_3/include/CGAL/make_periodic_3_mesh_3.h b/Periodic_3_mesh_3/include/CGAL/make_periodic_3_mesh_3.h index 5bed7b2a3c15..b44c5d78ccba 100644 --- a/Periodic_3_mesh_3/include/CGAL/make_periodic_3_mesh_3.h +++ b/Periodic_3_mesh_3/include/CGAL/make_periodic_3_mesh_3.h @@ -27,7 +27,6 @@ #include #include -#include #include #include From 866cb297aca223b93cdb7a2d05fd72d983662504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 21:46:35 +0100 Subject: [PATCH 029/127] Rename macro --- Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h | 6 +++--- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 4 ---- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 2 +- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 14 +++++++------- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index b277c58c2e38..2a40f9f35f73 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -312,7 +312,7 @@ class Compact_mesh_cell_3 , sliver_cache_validity_(false) #endif { -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL for(int i=0; i <4; i++){ surface_index_table_[i] = rhs.surface_index_table_[i]; surface_center_table_[i]= rhs.surface_center_table_[i]; @@ -538,7 +538,7 @@ class Compact_mesh_cell_3 void reset_cache_validity() const { sliver_cache_validity_ = false; } #endif -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL /// Set surface index of `facet` to `index` void set_surface_patch_index(const int facet, const Surface_patch_index& index) { @@ -670,7 +670,7 @@ class Compact_mesh_cell_3 // Point_container _hidden; -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL /// Stores surface_index for each facet of the cell std::array surface_index_table_ = {}; /// Stores surface center of each facet of the cell diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index fb8c57cd76b0..47d73dc10867 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1412,7 +1412,6 @@ class C3T3_helpers else sliver_value_ = 0.; -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL subdomain_index_ = c->subdomain_index(); for(std::size_t i = 0; i < 4; ++i) { @@ -1423,9 +1422,6 @@ class C3T3_helpers //are lost by 'backup' and 'restore', //because all cells are changing during the move //they are not used in update_mesh functions involving a Sliver_criterion -#else - std::exit(1); -#endif } void backup_infinite_cell(const Cell_handle& c, diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index 5bfc8c5e23de..641353520fe4 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -901,7 +901,7 @@ update_star_self(const Vertex_handle& vertex) #ifdef CGAL_MESH_3_USE_C3T3_MAPS if (r_c3t3_.is_in_complex(mirror_f)) // @todo here and below is 2 map looks up which should only be one. r_c3t3_.set_surface_info(*cell_it, k, r_c3t3_.surface_info(mirror_f)); -#else // CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL has to be defined +#else // CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL has to be defined const Cell_handle& neighbor_cell = mirror_f.first; const int& neighb_k = mirror_f.second; const bool cond_old = neighbor_cell->is_facet_on_surface(neighb_k); diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 43439945b7bf..9affdcbeaefc 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -505,7 +505,7 @@ class Mesh_complex_3_in_triangulation_3 } #endif -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL f.first->set_surface_patch_index(f.second, index); #endif } @@ -537,7 +537,7 @@ class Mesh_complex_3_in_triangulation_3 } #endif -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL f.first->set_facet_surface_center(f.second, p); #endif } @@ -569,7 +569,7 @@ class Mesh_complex_3_in_triangulation_3 } #endif -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL f.first->set_facet_surface_center_index(f.second, index); #endif } @@ -659,7 +659,7 @@ class Mesh_complex_3_in_triangulation_3 } #endif -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL Surface_patch_index res_old = f.first->surface_patch_index(f.second); # ifdef CGAL_MESH_3_USE_C3T3_MAPS @@ -713,7 +713,7 @@ class Mesh_complex_3_in_triangulation_3 } #endif -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL const auto res_old = f.first->get_facet_surface_center(f.second); # ifdef CGAL_MESH_3_USE_C3T3_MAPS @@ -767,7 +767,7 @@ class Mesh_complex_3_in_triangulation_3 } #endif -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL const Index res_old = f.first->get_facet_surface_center_index(f.second); # ifdef CGAL_MESH_3_USE_C3T3_MAPS @@ -1081,7 +1081,7 @@ class Mesh_complex_3_in_triangulation_3 } #endif -#ifndef CGAL_MESH_3_DO_NOT_STORE_SURFACE_INFO_IN_CELL +#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL const bool res_old = f.first->is_facet_on_surface(f.second); # ifdef CGAL_MESH_3_USE_C3T3_MAPS From 8d3d92c67c799cc4727aa5a7be268d2fc7102a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 21:51:56 +0100 Subject: [PATCH 030/127] Remove old get_facets code --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 14 +------------- Mesh_3/include/CGAL/Mesh_3/config.h | 1 - 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 47d73dc10867..b6f41ca8fd90 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -968,15 +968,10 @@ class C3T3_helpers void operator()(const Cell_handle& cell) { -#ifndef CGAL_MESH_3_NEW_GET_FACETS - for ( int i=0 ; i<4 ; ++i ) - if ( !tr_.is_infinite(cell,i) ) - *out_++ = canonical_facet(cell,i); -#else // Instead of iterating over the facets we iterate over the vertices // If a vertex is infinite we report only the facet opposite to it and return // If all vertices are finite we report all facets - // This approach makes less tests if vertices are infinite + // This approach performs fewer tests than a naive loop over all finite facets int i=0; for ( ; i<4 ; ++i ){ if ( tr_.is_infinite(cell->vertex(i)) ){ @@ -987,24 +982,17 @@ class C3T3_helpers for ( i=0 ; i<4 ; ++i ){ *out_++ = canonical_facet(cell,i); } -#endif } private: Facet canonical_facet(const Cell_handle& c, const int i) const { -#ifndef CGAL_MESH_3_NEW_GET_FACETS - Facet facet(c,i); - Facet mirror = tr_.mirror_facet(facet); - return ( (mirrorneighbor(i); if(c < n){ return Facet(c,i); }else{ return Facet(n,n->index(c)); } -#endif } private: diff --git a/Mesh_3/include/CGAL/Mesh_3/config.h b/Mesh_3/include/CGAL/Mesh_3/config.h index 3fd66c2f8666..91342688bfc2 100644 --- a/Mesh_3/include/CGAL/Mesh_3/config.h +++ b/Mesh_3/include/CGAL/Mesh_3/config.h @@ -20,7 +20,6 @@ // Use optimizations of Mesh_3 # define CGAL_CONSTRUCT_INTRUSIVE_LIST_RANGE_CONSTRUCTOR 1 -# define CGAL_MESH_3_NEW_GET_FACETS 1 # define CGAL_MESH_3_GET_FACETS_USING_INTRUSIVE_LIST 1 # define CGAL_MESH_3_SIZING_FIELD_INEXACT_LOCATE 1 # define FORCE_STRUCTURAL_FILTERING 1 From 361795e8fd1528fa56468721d7dc12889d4b2e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 22:17:17 +0100 Subject: [PATCH 031/127] Harmonize the definition of canonical facet --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 6 +----- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 11 +++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index b6f41ca8fd90..f9818763476a 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -988,11 +988,7 @@ class C3T3_helpers Facet canonical_facet(const Cell_handle& c, const int i) const { Cell_handle n = c->neighbor(i); - if(c < n){ - return Facet(c,i); - }else{ - return Facet(n,n->index(c)); - } + return (c < n) ? Facet(c, i) : Facet(n, n->index(c)); } private: diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 0a5c9423d72c..4b40d2fd3ab0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -169,12 +169,12 @@ class Refine_facets_3_handle_queue_base #else - Facet + const Facet& from_facet_to_refinement_queue_element(const Facet &facet, const Facet &mirror) const { // Returns canonical facet - return (facet < mirror) ? facet : mirror; + return (facet.first < mirror.first) ? facet : mirror; } public: @@ -435,12 +435,11 @@ class Refine_facets_3_base }; typedef typename std::optional Facet_properties; - /// Returns canonical facet of facet - Facet canonical_facet(const Facet& facet) const + Facet canonical_facet(const Facet& f) const { - const Facet mirror = mirror_facet(facet); - return ( (facet < mirror)?facet:mirror ); + Cell_handle n = f.first->neighbor(f.second); + return (f.first < n) ? f : Facet(n, n->index(f.first)); } /// Returns true if `f` has already been visited. From b540350a5a2c9b341c98f2dec8133bffb98004de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 22:36:55 +0100 Subject: [PATCH 032/127] Make new_incident_slivers() baseline --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 42 ------------------- Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h | 16 ++----- Mesh_3/include/CGAL/Mesh_3/config.h | 1 - .../include/CGAL/Mesh_3/vertex_perturbation.h | 9 +--- 4 files changed, 4 insertions(+), 64 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index f9818763476a..62af35a968af 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -880,14 +880,6 @@ class C3T3_helpers const FT& sliver_bound, OutputIterator out) const; - - template - OutputIterator - new_incident_slivers(const Vertex_handle& v, - const SliverCriterion& criterion, - const FT& sliver_bound, - OutputIterator out) const; - /** * Returns the sliver (wrt `criterion` and `sliver_bound`) incident to `v` */ @@ -902,17 +894,6 @@ class C3T3_helpers return slivers; } - template - Cell_vector - new_incident_slivers(const Vertex_handle& v, - const SliverCriterion& criterion, - const FT& sliver_bound) const - { - Cell_vector slivers; - new_incident_slivers(v, criterion, sliver_bound, std::back_inserter(slivers)); - return slivers; - } - /** * Returns the number of slivers incident to `v` @@ -3606,7 +3587,6 @@ try_lock_and_get_incident_slivers(const Vertex_handle& v, return try_lock_and_get_incident_cells(v, slivers, i_s); } - template template OutputIterator @@ -3617,28 +3597,6 @@ incident_slivers(const Vertex_handle& v, OutputIterator out) const { typedef SliverCriterion Sc; - - std::vector incident_cells_; - tr_.incident_cells(v, std::back_inserter(incident_cells_)); - - std::remove_copy_if(incident_cells_.begin(), - incident_cells_.end(), - out, - std::not_fn(Is_sliver(c3t3_, criterion, sliver_bound))); - - return out; -} - -template -template -OutputIterator -C3T3_helpers:: -new_incident_slivers(const Vertex_handle& v, - const SliverCriterion& criterion, - const FT& sliver_bound, - OutputIterator out) const -{ - typedef SliverCriterion Sc; typedef Filter > F; Is_sliver i_s(c3t3_, criterion, sliver_bound); diff --git a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h index 8d452ee80368..01d950ee1a65 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h +++ b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h @@ -962,14 +962,9 @@ perturb(const FT& sliver_bound, PQueue& pqueue, Visitor& visitor) const CGAL_assertion(pv.is_perturbable()); // Get pvertex slivers list -# ifdef CGAL_NEW_INCIDENT_SLIVERS Cell_vector slivers; - helper_.new_incident_slivers(pv.vertex(), sliver_criterion_, sliver_bound, - std::back_inserter(slivers)); -# else - Cell_vector slivers = - helper_.incident_slivers(pv.vertex(), sliver_criterion_, sliver_bound); -# endif + helper_.incident_slivers(pv.vertex(), sliver_criterion_, sliver_bound, + std::back_inserter(slivers)); CGAL_assertion(slivers.size() == pv.sliver_nb()); @@ -1426,13 +1421,8 @@ void Sliver_perturber:: update_pvertex(PVertex& pv, const FT& sliver_bound) const { -#ifdef CGAL_NEW_INCIDENT_SLIVERS Cell_vector slivers; - helper_.new_incident_slivers(pv.vertex(), sliver_criterion_, sliver_bound, std::back_inserter(slivers)); -#else - Cell_vector slivers = - helper_.incident_slivers(pv.vertex(), sliver_criterion_, sliver_bound); -#endif + helper_.incident_slivers(pv.vertex(), sliver_criterion_, sliver_bound, std::back_inserter(slivers)); pv.set_sliver_nb(static_cast(slivers.size())); pv.set_min_value(helper_.min_sliver_value(slivers, sliver_criterion_)); diff --git a/Mesh_3/include/CGAL/Mesh_3/config.h b/Mesh_3/include/CGAL/Mesh_3/config.h index 91342688bfc2..075356f82465 100644 --- a/Mesh_3/include/CGAL/Mesh_3/config.h +++ b/Mesh_3/include/CGAL/Mesh_3/config.h @@ -23,7 +23,6 @@ # define CGAL_MESH_3_GET_FACETS_USING_INTRUSIVE_LIST 1 # define CGAL_MESH_3_SIZING_FIELD_INEXACT_LOCATE 1 # define FORCE_STRUCTURAL_FILTERING 1 -# define CGAL_NEW_INCIDENT_SLIVERS 1 # define CGAL_INTRUSIVE_LIST 1 //experimental diff --git a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h index c37712db4589..63e734d5b96a 100644 --- a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h +++ b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h @@ -1383,14 +1383,7 @@ class Li_random_perturbation mod_vertices.insert(tmp_mod_vertices.begin(), tmp_mod_vertices.end()); - std::size_t nois; -#ifdef CGAL_NEW_INCIDENT_SLIVERS - nois = helper.number_of_incident_slivers(moving_vertex, criterion, sliver_bound); -#else - std::vector new_slivers = - helper.incident_slivers(moving_vertex, criterion, sliver_bound); - nois = new_slivers.size(); -#endif + std::size_t nois = helper.number_of_incident_slivers(moving_vertex, criterion, sliver_bound); // If sliver number has decreased, we won if(nois < slivers.size() ) From 34697809ce3005b210e52ca7dda4666f93ad3efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 22:50:48 +0100 Subject: [PATCH 033/127] Remove obsolete min dihedral computation code --- Mesh_3/include/CGAL/Mesh_3/config.h | 3 - .../include/CGAL/Mesh_3/min_dihedral_angle.h | 55 ------------------- 2 files changed, 58 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/config.h b/Mesh_3/include/CGAL/Mesh_3/config.h index 075356f82465..1a72af3adccf 100644 --- a/Mesh_3/include/CGAL/Mesh_3/config.h +++ b/Mesh_3/include/CGAL/Mesh_3/config.h @@ -30,9 +30,6 @@ //# define CGAL_SEQUENTIAL_MESH_3_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE //# define CGAL_PARALLEL_MESH_3_DO_NOT_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE // slower / not recommended -//should not be used -//#define CGAL_MESH_3_OLD_MINIMUM_DIHEDRAL_ANGLE 1 - //experimental #define CGAL_MESH_3_NO_PROTECTION_NON_LINEAR 1 #define CGAL_MESH_3_NEW_ROBUST_INTERSECTION_TRAITS 1 diff --git a/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h b/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h index 7678bc3eaf8a..6f7d407f50b6 100644 --- a/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h +++ b/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h @@ -22,61 +22,8 @@ #include namespace CGAL { - namespace Mesh_3 { -#ifdef CGAL_MESH_3_OLD_MINIMUM_DIHEDRAL_ANGLE - -template -typename K::FT -minimum_dihedral_angle( - const typename K::Point_3& p0, - const typename K::Point_3& p1, - const typename K::Point_3& p2, - const typename K::Point_3& p3, - const K& k = K()) -{ - typedef typename K::FT FT; - - typename K::Compute_squared_distance_3 sq_distance = - k.compute_squared_distance_3_object(); - typename K::Compute_volume_3 volume = - k.compute_volume_3_object(); - typename K::Compute_area_3 area = - k.compute_area_3_object(); - - FT a_012 = area(p0,p1,p2); - FT a_013 = area(p0,p1,p3); - FT a_123 = area(p1,p2,p3); - FT a_023 = area(p0,p2,p3); - - FT min_quotient = - CGAL::sqrt(sq_distance(p0, p1)) / a_012 / a_013; - - min_quotient = - (CGAL::min)(min_quotient, - CGAL::sqrt(sq_distance(p0, p2)) / a_012 / a_023); - min_quotient = - (CGAL::min)(min_quotient, - CGAL::sqrt(sq_distance(p0, p3)) / a_013 / a_023); - min_quotient = - (CGAL::min)(min_quotient, - CGAL::sqrt(sq_distance(p1, p2)) / a_012 / a_123); - min_quotient = - (CGAL::min)(min_quotient, - CGAL::sqrt(sq_distance(p1, p3)) / a_013 / a_123); - min_quotient = - (CGAL::min)(min_quotient, - CGAL::sqrt(sq_distance(p2, p3)) / a_023 / a_123); - - const FT result (std::asin( FT(1.5) * volume(p0, p1, p2, p3) * min_quotient ) - * FT(180) / FT(CGAL_PI)); - - return CGAL::abs(result); -} - -#else // not CGAL_MESH_3_OLD_MINIMUM_DIHEDRAL_ANGLE - template typename K::FT minimum_dihedral_angle( @@ -135,8 +82,6 @@ minimum_dihedral_angle( * FT(180) / FT(CGAL_PI)); } -#endif // CGAL_MESH_3_OLD_MINIMUM_DIHEDRAL_ANGLE - template typename K::FT minimum_dihedral_angle(const typename K::Tetrahedron_3& t , const K& k = K()) From 99f0342f07f526a7ca37996173e3862219d5d103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 22:57:53 +0100 Subject: [PATCH 034/127] Use function objects, not global functions --- Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h b/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h index 6f7d407f50b6..b666b37c08b1 100644 --- a/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h +++ b/Mesh_3/include/CGAL/Mesh_3/min_dihedral_angle.h @@ -69,7 +69,7 @@ minimum_dihedral_angle( min_quotient = (CGAL::min)(min_quotient, sp(v02,v02) / (a_012 * a_023)); min_quotient = (CGAL::min)(min_quotient, - (v03*v03) / (a_013 * a_023)); + sp(v03,v03) / (a_013 * a_023)); min_quotient = (CGAL::min)(min_quotient, sp(v12,v12) / (a_012 * a_123)); min_quotient = (CGAL::min)(min_quotient, From f4153b0daec285842d84b247741d84c900b0de25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 23:35:43 +0100 Subject: [PATCH 035/127] Make the faster perturbation queue filling algorithm baseline --- Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h | 37 ------------------- Mesh_3/include/CGAL/Mesh_3/config.h | 1 - 2 files changed, 38 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h index 01d950ee1a65..2c61270f9955 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h +++ b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h @@ -1059,9 +1059,6 @@ perturb(const FT& sliver_bound, PQueue& pqueue, Visitor& visitor) const return bad_vertices.empty(); } - -#ifdef CGAL_FASTER_BUILD_QUEUE - template int Sliver_perturber:: @@ -1122,40 +1119,6 @@ build_priority_queue(const FT& sliver_bound, PQueue& pqueue) const return pqueue_size; } -#else // not CGAL_FASTER_BUILD_QUEUE - -template -int -Sliver_perturber:: -build_priority_queue(const FT& sliver_bound, PQueue& pqueue) const -{ - CGAL_precondition(pqueue.empty()); - -#ifdef CGAL_MESH_3_PERTURBER_HIGH_VERBOSITY - CGAL::Real_timer timer; - timer.start(); - std::cerr << "Build pqueue..."; -#endif - - int pqueue_size = 0; - - for ( typename Tr::Finite_vertices_iterator vit = tr_.finite_vertices_begin(); - vit != tr_.finite_vertices_end() ; - ++vit ) - { - PVertex pv = make_pvertex(vit, sliver_bound, get_pvertex_id(vit)); - pqueue_size += update_priority_queue(pv, pqueue); - } - -#ifdef CGAL_MESH_3_PERTURBER_HIGH_VERBOSITY - std::cerr << "done (" << pqueue_size << " vertices inserted in " - << timer.time() << "s)\n"; -#endif - - return pqueue_size; -} -#endif // not CGAL_FASTER_BUILD_QUEUE - template int diff --git a/Mesh_3/include/CGAL/Mesh_3/config.h b/Mesh_3/include/CGAL/Mesh_3/config.h index 1a72af3adccf..4103a1f5d475 100644 --- a/Mesh_3/include/CGAL/Mesh_3/config.h +++ b/Mesh_3/include/CGAL/Mesh_3/config.h @@ -26,7 +26,6 @@ # define CGAL_INTRUSIVE_LIST 1 //experimental -# define CGAL_FASTER_BUILD_QUEUE 1 //# define CGAL_SEQUENTIAL_MESH_3_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE //# define CGAL_PARALLEL_MESH_3_DO_NOT_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE // slower / not recommended From 0fda0f24ed91e2529312d060035d80afcae1d2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 25 Feb 2026 23:43:31 +0100 Subject: [PATCH 036/127] Get rid of 'CGAL_MESH_3_NO_PROTECTION_NON_LINEAR' Anyway, make_mesh_3() overrides this setting immediately after the constructor of Protect_edges_sizing_field, see 9b05a3a. --- Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h | 3 --- Mesh_3/include/CGAL/Mesh_3/config.h | 1 - .../CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h | 3 --- 3 files changed, 7 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index a8842c2518b4..84cc61cdbb46 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -538,9 +538,6 @@ Protect_edges_sizing_field(C3T3& c3t3, const MD& domain, , stop_ptr_(stop_ptr) #endif { -#ifndef CGAL_MESH_3_NO_PROTECTION_NON_LINEAR - set_nonlinear_growth_of_balls(); -#endif } diff --git a/Mesh_3/include/CGAL/Mesh_3/config.h b/Mesh_3/include/CGAL/Mesh_3/config.h index 4103a1f5d475..3da2ab5ca77a 100644 --- a/Mesh_3/include/CGAL/Mesh_3/config.h +++ b/Mesh_3/include/CGAL/Mesh_3/config.h @@ -30,7 +30,6 @@ //# define CGAL_PARALLEL_MESH_3_DO_NOT_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE // slower / not recommended //experimental -#define CGAL_MESH_3_NO_PROTECTION_NON_LINEAR 1 #define CGAL_MESH_3_NEW_ROBUST_INTERSECTION_TRAITS 1 diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h index fd1e0b9e104c..600763661c14 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h @@ -553,9 +553,6 @@ Protect_edges_sizing_field(C3T3& c3t3, const MD& domain, , nonlinear_growth_of_balls(false) , vertex_handle_to_full_space_position() { -#ifndef CGAL_MESH_3_NO_PROTECTION_NON_LINEAR - set_nonlinear_growth_of_balls(); -#endif } From a5382fd7f74a36baac4545a0e0551049dce5ec41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 26 Feb 2026 11:15:44 +0100 Subject: [PATCH 037/127] Misc cleaning --- .../CGAL/Mesh_3/Protect_edges_sizing_field.h | 14 ++++++------ .../Mesh_3/Robust_intersection_traits_3.h | 2 +- Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h | 5 ++--- .../CGAL/Mesh_3/Triangulation_helpers.h | 11 +++------- .../Mesh_3/mesh_standard_facet_criteria.h | 3 --- Mesh_3/test/Mesh_3/test_min_size_criteria.cpp | 5 +++-- .../Protect_edges_sizing_field.h | 22 +++++++++---------- .../include/CGAL/Periodic_3_mesh_3/config.h | 4 ++-- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 2 +- 9 files changed, 30 insertions(+), 38 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index 84cc61cdbb46..aead7d064a0c 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -800,13 +800,13 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, V #if CGAL_MESH_3_PROTECTION_DEBUG & 16 std::cerr << "Nearest power vertex of (" << p << ") is " - << &*nearest_vh << " (" << c3t3_.triangulation().point(nearest_vh) << ") " + << &*nearest_vh << " (" << tr.point(nearest_vh) << ") " << "at distance: " << sq_d << std::endl; #endif // if sq_d < nearest_vh's weight while ( ! is_special(nearest_vh) && - cwsr(c3t3_.triangulation().point(nearest_vh), - sq_d) == CGAL::SMALLER ) + cwsr(tr.point(nearest_vh), - sq_d) == CGAL::SMALLER ) { CGAL_assertion( use_minimal_size() || sq_d > 0); @@ -830,7 +830,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, V } if( is_special(nearest_vh) && - cwsr(c3t3_.triangulation().point(nearest_vh), - sq_d) == CGAL::SMALLER ) + cwsr(tr.point(nearest_vh), - sq_d) == CGAL::SMALLER ) { w = minimal_weight_; insert_a_special_ball = true; @@ -856,7 +856,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, V for(int i=0, d=tr.dimension(); i<=d; ++i) { const Vertex_handle v = cit->vertex(i); - if(c3t3_.triangulation().is_infinite(v)) + if(tr.is_infinite(v)) continue; if(!vertices_in_conflict_zone_set.insert(v).second) continue; @@ -866,7 +866,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, V if(use_minimal_size() && sq_d < minimal_weight()) { insert_a_special_ball = true; #if CGAL_MESH_3_PROTECTION_DEBUG & 1 - nearest_point = c3t3_.triangulation().point(v); + nearest_point = tr.point(v); #endif min_sq_d = minimal_weight(); if(! is_special(v)) @@ -880,7 +880,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, V if(sq_d < min_sq_d) { #if CGAL_MESH_3_PROTECTION_DEBUG & 1 - nearest_point = c3t3_.triangulation().point(v); + nearest_point = tr.point(v); #endif min_sq_d = sq_d; } @@ -951,7 +951,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, V if(sq_d < min_sq_d) { min_sq_d = sq_d; #if CGAL_MESH_3_PROTECTION_DEBUG & 1 - nearest_point = c3t3_.triangulation().point(it); + nearest_point = tr.point(it); #endif } } diff --git a/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h b/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h index 4bb670cbaa98..eedbd918a243 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Robust_intersection_traits_3.h @@ -179,7 +179,7 @@ struct Vector_plane_orientation_3_static_filter : }; // end struct template Vector_plane_orientation_3_static_filter // An exact line-plane intersection that returns always a point. -// The line it (pq), and the plane is (abc). +// The line is (pq), and the plane is (abc). // // Precondition: [pq] and [abc] are not coplanar. template diff --git a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h index 5287af6e944b..0b8adccf6b13 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h +++ b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h @@ -18,9 +18,9 @@ #include #include + #include #include - #include #include #include @@ -36,11 +36,10 @@ #include #include #include - #include - #include #include + #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h b/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h index c0451ceee4b9..fbb35d6bcefd 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h @@ -393,7 +393,7 @@ inside_protecting_balls(const Tr& tr, if(cwsr(nvwp, FT(0)) == CGAL::SMALLER) { - typename Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); + typename GT::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); const Point& nvwp = tr.point(nv); // 'true' if the distance between 'p' and 'nv' is smaller or equal than the weight of 'nv' return (cwsr(nvwp , - tr.min_squared_distance(p, cp(nvwp))) != CGAL::LARGER); @@ -528,7 +528,6 @@ Triangulation_helpers:: well_oriented(const Tr& tr, const Cell_vector& cells_tos) const { - typedef typename Tr::Geom_traits GT; typename GT::Orientation_3 orientation = tr.geom_traits().orientation_3_object(); typename GT::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); @@ -574,7 +573,6 @@ well_oriented(const Tr& tr, const Cell_vector& cells_tos, const Point_getter& pg) const { - typedef typename Tr::Geom_traits GT; typename GT::Orientation_3 orientation = tr.geom_traits().orientation_3_object(); typename GT::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); @@ -602,10 +600,7 @@ well_oriented(const Tr& tr, return true; } - - -} // end namespace Mesh_3 - -} //namespace CGAL +} // namespace Mesh_3 +} // namespace CGAL #endif // CGAL_MESH_3_TRIANGULATION_HELPERS_H 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 086d76bf3882..967c4ce29f83 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 @@ -32,7 +32,6 @@ namespace CGAL { namespace Mesh_3 { - namespace details { template @@ -47,8 +46,6 @@ namespace details { } // end namespace details - - // Aspect_ratio Criterion class template class Aspect_ratio_criterion : diff --git a/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp b/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp index ca1d310a9e29..b147421f9b19 100644 --- a/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp +++ b/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp @@ -79,6 +79,7 @@ struct Image_tester : public Tester CGAL::parameters::no_perturb()); const Tr& tr = c3t3.triangulation(); + typename GT::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); typename GT::Compute_squared_radius_3 sq_radius = tr.geom_traits().compute_squared_radius_3_object(); @@ -105,7 +106,7 @@ struct Image_tester : public Tester max_sq_cell_radius = (std::max)(max_sq_cell_radius, sqr); } - const std::size_t nbv = c3t3.triangulation().number_of_vertices(); + const std::size_t nbv = tr.number_of_vertices(); std::cout << "C3t3 initial = " << nbv << std::endl; //new criteria with really small facet_size and cell_size @@ -123,7 +124,7 @@ struct Image_tester : public Tester CGAL::parameters::no_perturb(), CGAL::parameters::no_exude()); - const std::size_t nbv2 = c3t3.triangulation().number_of_vertices(); + const std::size_t nbv2 = tr.number_of_vertices(); std::cout << "C3t3 after refinement = " << nbv2 << std::endl; assert(nbv == nbv2); diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h index 600763661c14..18d86e0e80e3 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h @@ -1602,7 +1602,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, #if CGAL_MESH_3_PROTECTION_DEBUG & 2 std::cerr << "locate returns: " << &*ch << " lt: " << lt << " lilj: " << li << " " << lj << std::endl; for(int i=0; i<4; ++i) - std::cerr << " -> " << c3t3_.triangulation().point(ch, i) << std::endl; + std::cerr << " -> " << tr.point(ch, i) << std::endl; #endif if(lt == Tr::VERTEX) @@ -1627,12 +1627,12 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, // Note that incident_cells = finite_incident_cells for P3DT3 std::vector finite_incident_cells; finite_incident_cells.reserve(64); - c3t3_.triangulation().incident_cells(v, std::back_inserter(finite_incident_cells)); + tr.incident_cells(v, std::back_inserter(finite_incident_cells)); Tr_helpers tr_helpers; const FT nearest_sq_dist = tr_helpers.template get_sq_distance_to_closest_vertex >( - c3t3_.triangulation(), v, finite_incident_cells); + tr, v, finite_incident_cells); CGAL_assertion(nearest_sq_dist > 0.); @@ -1641,9 +1641,9 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, Vector_3 rnd_direction(1., 0., 0.); // arbitrary direction typename Gt::Construct_translated_point_3 translate = - c3t3_.triangulation().geom_traits().construct_translated_point_3_object(); + tr.geom_traits().construct_translated_point_3_object(); typename Gt::Construct_point_3 cp = - c3t3_.triangulation().geom_traits().construct_point_3_object(); + tr.geom_traits().construct_point_3_object(); // small perturbation close_pt = cwp(translate(cp(close_pt), 1e-5 * CGAL::sqrt(nearest_sq_dist) * rnd_direction)); @@ -1678,7 +1678,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, #if CGAL_MESH_3_PROTECTION_DEBUG & 16 std::cerr << "Nearest power vertex of (" << p << ") is " - << &*nearest_vh << " (" << c3t3_.triangulation().point(nearest_vh) << ") " + << &*nearest_vh << " (" << tr.point(nearest_vh) << ") " << "at distance: " << sq_d << std::endl; Index nearest_vh_index = c3t3_.index(nearest_vh); @@ -1689,7 +1689,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, // This will never happen for a dummy point while(! is_special(nearest_vh) && - cwsr(c3t3_.triangulation().point(nearest_vh), - sq_d) == CGAL::SMALLER) + cwsr(tr.point(nearest_vh), - sq_d) == CGAL::SMALLER) { CGAL_assertion(minimal_size_ > 0 || sq_d > 0); @@ -1713,7 +1713,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, } if(is_special(nearest_vh) && - cwsr(c3t3_.triangulation().point(nearest_vh), - sq_d) == CGAL::SMALLER) + cwsr(tr.point(nearest_vh), - sq_d) == CGAL::SMALLER) { w = minimal_weight_; insert_a_special_ball = true; @@ -1794,7 +1794,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, std::cerr << "smart_insert_point: weight " << w << " reduced to " << min_sq_distance << "\n (near existing point: " - << c3t3_.triangulation().point(nearest_vertex) << ")\n"; + << tr.point(nearest_vertex) << ")\n"; Index nearest_vertex_index = c3t3_.index(nearest_vertex); i = std::get_if(&nearest_vertex_index); @@ -1865,8 +1865,8 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, #endif } - CGAL_expensive_postcondition(c3t3_.triangulation().tds().is_valid()); - CGAL_expensive_postcondition(c3t3_.triangulation().is_valid()); + CGAL_expensive_postcondition(tr.tds().is_valid()); + CGAL_expensive_postcondition(tr.is_valid()); CGAL_expensive_postcondition(c3t3_.is_valid()); } #endif diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/config.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/config.h index 4b529afbce7c..1ad328dbbc74 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/config.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/config.h @@ -48,8 +48,8 @@ * available with some periodic triangulation traits. (cf. Periodic_3_triangulation_remove_traits_3.h) * Indeed, this feature needs the Triangulation_3::inexact_orientation() method. * - * A better solution would be to make Triangulation_3 compatible 'any' traits. - * By this way, Triangulation_3 would require the Bare_point concept which would use in + * A better solution would be to make Triangulation_3 compatible with 'any' traits. + * This way, Triangulation_3 would require the Bare_point concept which would use in * inexact_orientation(). So, we'd work with a Bare_point instead of a Point in this method. * In the 'default' Triangulation_3 traits, Bare_point would be equal to Point_3 * (or const Point_3& <- for avoiding useless copies). diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 9affdcbeaefc..425c256fee68 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -965,7 +965,7 @@ class Mesh_complex_3_in_triangulation_3 for (Facet f :this->facets_in_complex()) { - for (int i = 1; i < 4; ++i) + for (int i = 1; i < 4; ++i) { Vertex_handle vi = f.first->vertex((f.second + i) % 4); vi->set_meshing_info(vi->meshing_info() + 1); From e21e2099edebb2b47012d83d59afee80b09bac3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 26 Feb 2026 15:16:45 +0100 Subject: [PATCH 038/127] Get rid Mesh_regular_triangulation_3_wrapper - Mesh_3's default triangulation is once again a simple CGAL::Regular_triangulation_3 - The generic functions used to distinguish between Mesh_3 and Periodic_3_mesh_3 are moved to CGAL::Mesh_3::Triangulation_helpers, and the periodic tag is used to distinguish. --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 6 +- .../Construct_initial_points_labeled_image.h | 7 +- Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h | 5 +- .../CGAL/Mesh_3/Protect_edges_sizing_field.h | 8 +- .../CGAL/Mesh_3/Refine_facets_manifold_base.h | 4 +- Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h | 8 +- .../CGAL/Mesh_3/Triangulation_helpers.h | 136 +++++++-- .../Mesh_3/mesh_standard_facet_criteria.h | 24 +- .../include/CGAL/Mesh_3/vertex_perturbation.h | 4 +- Mesh_3/include/CGAL/Mesh_triangulation_3.h | 87 +----- Mesh_3/test/Mesh_3/test_min_size_criteria.cpp | 3 +- .../Protect_edges_sizing_field.h | 20 +- .../Periodic_3_mesh_3/Triangulation_helpers.h | 267 ++++++++++++++++++ .../CGAL/Periodic_3_mesh_triangulation_3.h | 228 ++------------- .../include/CGAL/make_periodic_3_mesh_3.h | 9 +- .../include/CGAL/refine_periodic_3_mesh_3.h | 13 +- .../CGAL/Periodic_3_regular_triangulation_3.h | 2 +- 17 files changed, 462 insertions(+), 369 deletions(-) create mode 100644 Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Triangulation_helpers.h diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 62af35a968af..2077b8820474 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -3298,7 +3298,7 @@ move_point_no_topo_change(const Vertex_handle& old_vertex, const Weighted_point& new_position) const { // Change vertex position - tr_.set_point(old_vertex, move, new_position); + Th().set_point(tr_, old_vertex, move, new_position); CGAL_expensive_postcondition(tr_.is_valid()); return old_vertex; } @@ -3408,7 +3408,7 @@ get_least_square_surface_plane(const Vertex_handle& v, if(ref_facet.first == Cell_handle()) ref_facet = f; - const Triangle ct = tr_.get_incident_triangle(f, v); + const Triangle ct = Th().get_incident_triangle(tr_, f, v); triangles.push_back(ct); } } @@ -3430,7 +3430,7 @@ get_least_square_surface_plane(const Vertex_handle& v, // The surface center of a facet might have an offset in periodic triangulations const Bare_point& ref_facet_scp = c3t3_.surface_center(ref_facet.first, ref_facet.second); - const Bare_point& ref_point = tr_.get_closest_point(cp(position), ref_facet_scp); + const Bare_point& ref_point = Th().get_closest_point(tr_, cp(position), ref_facet_scp); return std::make_pair(plane, ref_point); } diff --git a/Mesh_3/include/CGAL/Mesh_3/Construct_initial_points_labeled_image.h b/Mesh_3/include/CGAL/Mesh_3/Construct_initial_points_labeled_image.h index 5f591a439df9..3affc916926e 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Construct_initial_points_labeled_image.h +++ b/Mesh_3/include/CGAL/Mesh_3/Construct_initial_points_labeled_image.h @@ -170,13 +170,16 @@ struct Construct_initial_points_labeled_image typedef typename MeshDomain::Index Index; typedef typename C3t3::Triangulation Tr; + typedef Mesh_3::Triangulation_helpers Th; + typedef typename Tr::Geom_traits GT; typedef typename GT::FT FT; typedef typename Tr::Weighted_point Weighted_point; typedef typename Tr::Segment Segment_3; + typedef typename GT::Vector_3 Vector_3; + typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; - typedef typename GT::Vector_3 Vector_3; C3t3 c3t3; Tr& tr = c3t3.triangulation(); @@ -328,7 +331,7 @@ struct Construct_initial_points_labeled_image continue; // if the (squared) distance between intersect_point and cv is smaller or equal than cv's weight - if (cwsr(cv_wp, - tr.min_squared_distance(intersect_point, cp(cv_wp))) != CGAL::LARGER) + if (cwsr(cv_wp, - Th().min_squared_distance(tr, intersect_point, cp(cv_wp))) != CGAL::LARGER) { pi_inside_protecting_sphere = true; break; diff --git a/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h b/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h index cba58d897887..59f5ad4ab352 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h +++ b/Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h @@ -20,8 +20,10 @@ #include #include + #include #include +#include #include #include @@ -44,6 +46,7 @@ template Th; typedef typename Tr::Geom_traits GT; typedef typename Tr::Vertex_handle Vertex_handle; @@ -290,7 +293,7 @@ class Lloyd_move // calling a function 'get_closest_point(p, q)' that simply returns q // for a non-periodic triangulation, and checks all possible offsets for // periodic triangulations - points.push_back(tr.get_closest_point(cp(position), c3t3.surface_center(cell, i))); + points.push_back(Th().get_closest_point(tr, cp(position), c3t3.surface_center(cell, i))); } return points; diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index aead7d064a0c..4115ce55b6e5 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -123,6 +123,8 @@ class Protect_edges_sizing_field public: typedef typename C3T3::Triangulation Tr; + typedef Mesh_3::Triangulation_helpers Th; + typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Weighted_point Weighted_point; typedef typename Weighted_point::Weight Weight; @@ -861,7 +863,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, V if(!vertices_in_conflict_zone_set.insert(v).second) continue; - const FT sq_d = tr.min_squared_distance(p, cp(c3t3_.triangulation().point(v))); + const FT sq_d = Th().min_squared_distance(tr, p, cp(tr.point(v))); if(use_minimal_size() && sq_d < minimal_weight()) { insert_a_special_ball = true; @@ -918,7 +920,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, V end = tr.finite_vertices_end() ; it != end ; ++it ) { const Weighted_point& it_wp = tr.point(it); - FT sq_d = tr.min_squared_distance(p, cp(it_wp)); + FT sq_d = Th().min_squared_distance(tr, p, cp(it_wp)); if ( cwsr(it_wp, - sq_d) == CGAL::SMALLER ) { bool special_ball = false; @@ -947,7 +949,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, V end = tr.finite_vertices_end() ; it != end ; ++it ) { const Weighted_point& it_wp = tr.point(it); - FT sq_d = tr.min_squared_distance(p, cp(it_wp)); + FT sq_d = Th().min_squared_distance(tr, p, cp(it_wp)); if(sq_d < min_sq_d) { min_sq_d = sq_d; #if CGAL_MESH_3_PROTECTION_DEBUG & 1 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 7940884c913d..adedf1679270 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 @@ -71,6 +71,8 @@ class Refine_facets_manifold_base typedef typename Triangulation_mesher_level_traits_3::Zone Zone; protected: + typedef Triangulation_helpers Th; + typedef typename Tr::Geom_traits GT; typedef typename GT::FT FT; @@ -139,7 +141,7 @@ class Refine_facets_manifold_base const Bare_point& fcenter = this->r_c3t3_.surface_center(f.first, f.second); const Weighted_point& wp = this->r_tr_.point(v); - return this->r_tr_.min_squared_distance(fcenter, cp(wp)) - cw(wp); + return Th().min_squared_distance(this->r_tr_, fcenter, cp(wp)) - cw(wp); } std::pair diff --git a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h index 0b8adccf6b13..1be34e6a56b8 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h +++ b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h @@ -354,6 +354,8 @@ class Slivers_exuder typedef Slivers_exuder Self; typedef typename C3T3::Triangulation Tr; + typedef Triangulation_helpers Th; + typedef typename Tr::Weighted_point Weighted_point; typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Cell_handle Cell_handle; @@ -1105,7 +1107,7 @@ initialize_prestar_and_criterion_values(const Vertex_handle& v, const Cell_handle opposite_cell = opposite_facet.first; const int index_in_opposite = opposite_cell->index(c); FT power_distance_to_power_sphere = - tr_.compute_power_distance_to_power_sphere(opposite_facet.first, index_in_opposite); + Th().compute_power_distance_to_power_sphere(tr_, opposite_facet.first, index_in_opposite); pre_star.insert(f, power_distance_to_power_sphere); } } @@ -1181,7 +1183,7 @@ expand_prestar(const Cell_handle& cell_to_add, if ( ! tr_.is_infinite(current_mirror_cell) ) { new_power_distance_to_power_sphere = - tr_.compute_power_distance_to_power_sphere(current_mirror_cell, pumped_vertex); + Th().compute_power_distance_to_power_sphere(tr_, current_mirror_cell, pumped_vertex); pre_star.insert(current_facet, new_power_distance_to_power_sphere); @@ -1223,7 +1225,7 @@ expand_prestar(const Cell_handle& cell_to_add, // We can't use 'new_power_distance_to_power_sphere' because 'current_mirror_cell' // is infinite. So we compute the power distance to 'cell_to_add' instead. CGAL_assertion(!tr_.is_infinite(cell_to_add)); - new_weight += tr_.compute_power_distance_to_power_sphere(cell_to_add, pumped_vertex); + new_weight += Th().compute_power_distance_to_power_sphere(tr_, cell_to_add, pumped_vertex); curr_f = current_facet; } diff --git a/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h b/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h index fbb35d6bcefd..45df6f091882 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/Triangulation_helpers.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -34,18 +35,32 @@ #include #include - namespace CGAL { - namespace Mesh_3 { +namespace internal { + +// Trait to detect if Tr has a nested type Periodic_tag +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_periodic_tag, Periodic_tag, false) + +template +struct Get_periodic_tag +{ + typedef typename boost::mpl::if_c::value, + typename Tr::Periodic_tag, + CGAL::Tag_false>::type type; +}; -template +} // namespace internal + +template ::type> class Triangulation_helpers { typedef typename Tr::Geom_traits GT; typedef typename GT::FT FT; typedef typename GT::Vector_3 Vector_3; + typedef typename GT::Triangle_3 Triangle_3; // If `Tr` is not a triangulation that has defined Bare_point, // use Point_3 as defined in the traits class. @@ -55,6 +70,8 @@ class Triangulation_helpers boost::mpl::identity >::type Bare_point; + typedef typename GT::Weighted_point_3 Weighted_point_3; + // 'Point' is either a bare point or a weighted point, depending on the triangulation. // Since 'Triangulation_helpers' can be templated by an unweighted triangulation, // this is one of the rare cases where we use 'Point'. @@ -62,6 +79,7 @@ class Triangulation_helpers typedef typename Tr::Vertex Vertex; typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename Tr::Facet Facet; typedef typename Tr::Cell Cell; typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Cell_iterator Cell_iterator; @@ -153,6 +171,66 @@ class Triangulation_helpers const Cell_vector& incident_cells, typename std::enable_if_t* = nullptr) const; + // The undocumented, straightforward functions below are required for Mesh_3 + // because of Periodic_3_mesh_3: they are functions for which both triangulations + // have fundamentally different implementations (usually, Periodic_3_mesh_3 + // does not know the offset of a point and must brute-force check for all + // possibilities). To enable Periodic_3_mesh_3 to use Mesh_3's files, + // each mesh triangulation implements its own version. + + const Bare_point& get_closest_point(const Tr& /*tr*/, + const Bare_point& /*p*/, + const Bare_point& q) const + { + return q; + } + + Triangle_3 get_incident_triangle(const Tr& tr, + const Facet& f, + const Vertex_handle) const + { + return tr.triangle(f); + } + + void set_point(const Tr& /*tr*/, + const Vertex_handle v, + const Vector_3& /*move*/, + const Weighted_point_3& new_position) const + { + v->set_point(new_position); + } + + FT compute_power_distance_to_power_sphere(const Tr& tr, + const Cell_handle c, + const Vertex_handle v) const + { + typedef typename GT::Compute_power_distance_to_power_sphere_3 Critical_radius; + + Critical_radius critical_radius = + tr.geom_traits().compute_power_distance_to_power_sphere_3_object(); + + return critical_radius(tr.point(c, 0), tr.point(c, 1), tr.point(c, 2), tr.point(c, 3), tr.point(v)); + } + + // \pre c->neighbor(i) is finite + FT compute_power_distance_to_power_sphere(const Tr& tr, + const Cell_handle c, + const int i) const + { + Cell_handle nc = c->neighbor(i); + CGAL_precondition(!tr.is_infinite(nc)); + Vertex_handle v = nc->vertex(nc->index(c)); + + return compute_power_distance_to_power_sphere(tr, c, v); + } + + typename GT::FT min_squared_distance(const Tr& tr, + const Bare_point& p, + const Bare_point& q) const + { + return tr.geom_traits().compute_squared_distance_3_object()(p, q); + } + private: /** * Returns `true` if `v` is well_oriented on each cell of `cell_tos`. @@ -166,9 +244,9 @@ class Triangulation_helpers const Point_getter& pg) const; }; -template +template bool -Triangulation_helpers:: +Triangulation_helpers:: no_topological_change(Tr& tr, const Vertex_handle v0, const Vector_3& move, @@ -196,12 +274,12 @@ no_topological_change(Tr& tr, const Point fp = tr.point(v0); // move the point - tr.set_point(v0, move, p); + set_point(tr, v0, move, p); if(!well_oriented(tr, cells_tos)) { // Reset (restore) v0 - tr.set_point(v0, cov(move), fp); + set_point(tr, v0, cov(move), fp); return false; } @@ -247,14 +325,14 @@ no_topological_change(Tr& tr, } // Reset (restore) v0 - tr.set_point(v0, cov(move), fp); + set_point(tr, v0, cov(move), fp); return np; } -template +template bool -Triangulation_helpers:: +Triangulation_helpers:: no_topological_change__without_set_point( const Tr& tr, const Vertex_handle v0, @@ -345,9 +423,9 @@ no_topological_change__without_set_point( } -template +template bool -Triangulation_helpers:: +Triangulation_helpers:: no_topological_change(Tr& tr, const Vertex_handle v0, const Vector_3& move, @@ -359,9 +437,9 @@ no_topological_change(Tr& tr, return no_topological_change(tr, v0, move, p, cells_tos); } -template +template bool -Triangulation_helpers:: +Triangulation_helpers:: no_topological_change__without_set_point( const Tr& tr, const Vertex_handle v0, @@ -374,9 +452,9 @@ no_topological_change__without_set_point( } -template +template bool -Triangulation_helpers:: +Triangulation_helpers:: inside_protecting_balls(const Tr& tr, const Vertex_handle v, const Bare_point& p) const @@ -396,7 +474,7 @@ inside_protecting_balls(const Tr& tr, typename GT::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); const Point& nvwp = tr.point(nv); // 'true' if the distance between 'p' and 'nv' is smaller or equal than the weight of 'nv' - return (cwsr(nvwp , - tr.min_squared_distance(p, cp(nvwp))) != CGAL::LARGER); + return (cwsr(nvwp , - min_squared_distance(tr, p, cp(nvwp))) != CGAL::LARGER); } return false; @@ -404,10 +482,10 @@ inside_protecting_balls(const Tr& tr, /// Return the squared distance from vh to its closest vertex /// if `Has_visited_for_vertex_extractor` is `true` -template +template template -typename Triangulation_helpers::FT -Triangulation_helpers:: +typename Triangulation_helpers::FT +Triangulation_helpers:: get_sq_distance_to_closest_vertex(const Tr& tr, const Vertex_handle& vh, const Cell_vector& incident_cells, @@ -417,7 +495,7 @@ get_sq_distance_to_closest_vertex(const Tr& tr, typedef std::vector Vertex_container; - // There is no need to use tr.min_squared_distance() here because we are computing + // There is no need to use Th::min_squared_distance() here because we are computing // distances between 'v' and a neighboring vertex within a common cell, which means // that even if we are using a periodic triangulation, the distance is correctly computed. typename GT::Compute_squared_distance_3 csqd = tr.geom_traits().compute_squared_distance_3_object(); @@ -463,10 +541,10 @@ get_sq_distance_to_closest_vertex(const Tr& tr, /// Return the squared distance from vh to its closest vertex /// if `Has_visited_for_vertex_extractor` is `false` -template +template template -typename Triangulation_helpers::FT -Triangulation_helpers:: +typename Triangulation_helpers::FT +Triangulation_helpers:: get_sq_distance_to_closest_vertex(const Tr& tr, const Vertex_handle& vh, const Cell_vector& incident_cells, @@ -478,7 +556,7 @@ get_sq_distance_to_closest_vertex(const Tr& tr, typedef boost::unordered_set Vertex_container; typedef typename Vertex_container::iterator VC_it; - // There is no need to use tr.min_squared_distance() here because we are computing + // There is no need to use Th::min_squared_distance() here because we are computing // distances between 'v' and a neighboring vertex within a common cell, which means // that even if we are using a periodic triangulation, the distance is correctly computed. typename GT::Compute_squared_distance_3 csqd = tr.geom_traits().compute_squared_distance_3_object(); @@ -522,9 +600,9 @@ get_sq_distance_to_closest_vertex(const Tr& tr, /// This function well_oriented is called by no_topological_change after the /// position of the vertex has been (tentatively) modified. -template +template bool -Triangulation_helpers:: +Triangulation_helpers:: well_oriented(const Tr& tr, const Cell_vector& cells_tos) const { @@ -566,9 +644,9 @@ well_oriented(const Tr& tr, /// Another version for the parallel version /// Here, the set_point is not done before, but we use a Point_getter instance /// to get the point of a vertex. -template +template bool -Triangulation_helpers:: +Triangulation_helpers:: well_oriented(const Tr& tr, const Cell_vector& cells_tos, const Point_getter& pg) const 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 967c4ce29f83..d8b338524bcc 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 @@ -21,16 +21,16 @@ #include - #include -#include // for to_double #include -#include +#include +#include // for to_double -namespace CGAL { +#include +namespace CGAL { namespace Mesh_3 { namespace details { @@ -163,6 +163,8 @@ class Uniform_curvature_size_criterion : { private: typedef typename C3T3::Triangulation Tr; + typedef Triangulation_helpers Th; + typedef typename Tr::Facet Facet; typedef typename Tr::Geom_traits::FT FT; @@ -210,7 +212,7 @@ class Uniform_curvature_size_criterion : const Bare_point c = weighted_circumcenter(p1,p2,p3); const Bare_point& center = c3t3.surface_center(f.first, f.second); - const FT sq_dist = tr.min_squared_distance(c, center); + const FT sq_dist = Th().min_squared_distance(tr, c, center); if ( sq_dist > B_ ) { @@ -236,6 +238,8 @@ class Variable_curvature_size_criterion : { private: typedef typename C3T3::Triangulation Tr; + typedef Triangulation_helpers Th; + typedef typename Tr::Facet Facet; typedef typename Tr::Geom_traits::FT FT; typedef typename Tr::Vertex::Index Index; @@ -285,7 +289,7 @@ class Variable_curvature_size_criterion : const Bare_point& ball_center = c3t3.surface_center(f.first, f.second); const Index& index = c3t3.surface_center_index(f.first, f.second); - const FT sq_dist = tr.min_squared_distance(c, ball_center); + const FT sq_dist = Th().min_squared_distance(tr, c, ball_center); const FT sq_bound = CGAL::square(size_(ball_center, 2, index)); CGAL_assertion(sq_bound > FT(0)); @@ -321,6 +325,8 @@ class Variable_size_criterion : { private: typedef typename C3T3::Triangulation Tr; + typedef Triangulation_helpers Th; + typedef typename Tr::Facet Facet; typedef typename Tr::Geom_traits::FT FT; typedef typename Tr::Vertex::Index Index; @@ -366,7 +372,7 @@ class Variable_size_criterion : const Bare_point& ball_center = c3t3.surface_center(f.first, f.second); const Index& index = c3t3.surface_center_index(f.first, f.second); - const FT sq_radius = tr.min_squared_distance(p1, ball_center); + const FT sq_radius = Th().min_squared_distance(tr, p1, ball_center); const FT sq_bound = CGAL::square(size_(ball_center, 2, index)); CGAL_assertion(sq_bound > FT(0)); @@ -396,6 +402,8 @@ class Uniform_size_criterion : { private: typedef typename C3T3::Triangulation Tr; + typedef Triangulation_helpers Th; + typedef typename Tr::Facet Facet; typedef typename Tr::Geom_traits::FT FT; @@ -448,7 +456,7 @@ class Uniform_size_criterion : const Bare_point p1 = cp(wp1); const Bare_point& ball_center = c3t3.surface_center(f.first, f.second); - const FT sq_radius = tr.min_squared_distance(p1, ball_center); + const FT sq_radius = Th().min_squared_distance(tr, p1, ball_center); if (!is_lower_bound() && sq_radius > B_ ) { diff --git a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h index 63e734d5b96a..6b145367975e 100644 --- a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h +++ b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h @@ -119,7 +119,7 @@ edge_sq_length(const typename Tr::Edge& e, typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Weighted_point Weighted_point; - // There is no need to use tr.min_squared_distance() here because we are computing + // There is no need to use Th::min_squared_distance() here because we are computing // distances between vertices within a common cell, which means that even // if we are using a periodic triangulation, the distance is correctly computed. typename GT::Compute_squared_distance_3 sq_distance = @@ -982,7 +982,7 @@ class Dihedral_angle_perturbation CGAL_assertion(cell->has_vertex(v)); const typename C3T3::Triangulation& tr = c3t3.triangulation(); - // There is no need to use tr.min_squared_distance() here because we are computing + // There is no need to use Th::min_squared_distance() here because we are computing // distances between vertices within a common cell, which means that even // if we are using a periodic triangulation, the distance is correctly computed. typename GT::Compute_squared_distance_3 sq_distance = diff --git a/Mesh_3/include/CGAL/Mesh_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_triangulation_3.h index db6db640c79d..70b05b02a275 100644 --- a/Mesh_3/include/CGAL/Mesh_triangulation_3.h +++ b/Mesh_3/include/CGAL/Mesh_triangulation_3.h @@ -45,85 +45,7 @@ struct Mesh_geom_traits_generator typedef type Type; }; // end struct Mesh_geom_traits_generator -} // end namespace details - -template -class Mesh_3_regular_triangulation_3_wrapper - : public Regular_triangulation_3 -{ -public: - typedef Regular_triangulation_3 Base; - - typedef typename Base::Geom_traits Geom_traits; - - typedef typename Geom_traits::FT FT; - typedef typename Base::Bare_point Bare_point; - typedef typename Base::Weighted_point Weighted_point; - typedef typename Base::Triangle Triangle; - - typedef typename Base::Vertex_handle Vertex_handle; - typedef typename Base::Facet Facet; - typedef typename Base::Cell_handle Cell_handle; - - typedef typename Geom_traits::Vector_3 Vector; - - using Base::geom_traits; - using Base::point; - using Base::triangle; - - static std::string io_signature() { return Get_io_signature()(); } - - // The undocumented, straightforward functions below are required for Mesh_3 - // because of Periodic_3_mesh_3: they are functions for which both triangulations - // have fundamentally different implementations (usually, Periodic_3_mesh_3 - // does not know the offset of a point and must brute-force check for all - // possibilities). To enable Periodic_3_mesh_3 to use Mesh_3's files, - // each mesh triangulation implements its own version. - - const Bare_point& get_closest_point(const Bare_point& /*p*/, const Bare_point& q) const - { - return q; - } - - Triangle get_incident_triangle(const Facet& f, const Vertex_handle) const - { - return triangle(f); - } - - void set_point(const Vertex_handle v, - const Vector& /*move*/, - const Weighted_point& new_position) - { - v->set_point(new_position); - } - - FT compute_power_distance_to_power_sphere(const Cell_handle c, - const Vertex_handle v) const - { - typedef typename Geom_traits::Compute_power_distance_to_power_sphere_3 Critical_radius; - - Critical_radius critical_radius = - geom_traits().compute_power_distance_to_power_sphere_3_object(); - - return critical_radius(point(c, 0), point(c, 1), point(c, 2), point(c, 3), point(v)); - } - - // \pre c->neighbor(i) is finite - FT compute_power_distance_to_power_sphere(const Cell_handle c, const int i) const - { - Cell_handle nc = c->neighbor(i); - CGAL_precondition(!this->is_infinite(nc)); - Vertex_handle v = nc->vertex(nc->index(c)); - - return compute_power_distance_to_power_sphere(c, v); - } - - typename Geom_traits::FT min_squared_distance(const Bare_point& p, const Bare_point& q) const - { - return geom_traits().compute_squared_distance_3_object()(p, q); - } -}; - +} // namespace details /*! \ingroup PkgMesh3MeshClasses @@ -188,8 +110,7 @@ struct Mesh_triangulation_3 typename Default::Get::type; struct Tds : public Triangulation_data_structure_3 {}; - using Triangulation = - Mesh_3_regular_triangulation_3_wrapper; + using Triangulation = Regular_triangulation_3; public: #ifndef DOXYGEN_RUNNING @@ -201,8 +122,8 @@ struct Mesh_triangulation_3 /*! The triangulation type to be used for the 3D triangulation embedding the mesh. - This type is a wrapper around the type `CGAL::Regular_triangulation_3`, whose vertex - and cell base classes are respectively `VertexBase` and `CellBase`. + This type is a `Regular_triangulation_3` type whose vertex and cell base classes are respectively + `VertexBase` and `CellBase`. */ typedef unspecified_type type; diff --git a/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp b/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp index b147421f9b19..95865417ae22 100644 --- a/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp +++ b/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp @@ -36,6 +36,7 @@ struct Image_tester : public Tester CGAL::Kernel_traits::Kernel, Concurrency_tag>::type; using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; + using Th = CGAL::Mesh_3::Triangulation_helpers; using GT = typename Tr::Geom_traits; using FT = typename Tr::Geom_traits::FT; @@ -91,7 +92,7 @@ struct Image_tester : public Tester const Bare_point p1 = cp(tr.point(f.first, (f.second + 1) & 3)); const Bare_point& ball_center = f.first->get_facet_surface_center(f.second); - const FT sqr = tr.min_squared_distance(p1, ball_center); + const FT sqr = Th().min_squared_distance(tr, p1, ball_center); max_sq_facet_radius = (std::max)(max_sq_facet_radius, sqr); } diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h index 18d86e0e80e3..a6982513ba76 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h @@ -33,7 +33,7 @@ #endif #include #include -#include +#include #if CGAL_MESH_3_PROTECTION_DEBUG # include #endif @@ -81,6 +81,8 @@ class Protect_edges_sizing_field public: typedef typename C3T3::Triangulation Tr; + typedef CGAL::Mesh_3::Triangulation_helpers Th; + typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Weighted_point Weighted_point; typedef typename Weighted_point::Weight Weight; @@ -384,7 +386,7 @@ class Protect_edges_sizing_field /// Compute the Euclidean distance between the bare points `p` and `q`. FT compute_distance(const Bare_point& p, const Bare_point& q) const { - // No need to call min_squared_distance() because 'p' and 'q' have been + // No need to call Th::min_squared_distance() because 'p' and 'q' have been // built to have proper respective positions in space return CGAL::sqrt(c3t3_.triangulation().geom_traits(). compute_squared_distance_3_object()(p,q)); @@ -407,7 +409,7 @@ class Protect_edges_sizing_field const Weighted_point& wpa = c3t3_.triangulation().point(va); const Weighted_point& wpb = c3t3_.triangulation().point(vb); - return CGAL::sqrt(c3t3_.triangulation().min_squared_distance(cp(wpa), cp(wpb))); + return CGAL::sqrt(Th().min_squared_distance(c3t3_.triangulation(), cp(wpa), cp(wpb))); } /// Return the radius of the ball of vertex `v`. @@ -655,7 +657,7 @@ insert_in_correspondence_map(const Vertex_handle v, { CGAL_precondition(c3t3_.triangulation().geom_traits().construct_point_3_object()( c3t3_.triangulation().point(v)) == - c3t3_.triangulation().canonicalize_point(p)); + Th().canonicalize_point(c3t3_.triangulation(), p)); typename Curve_index_container::const_iterator cicit = curve_indices.begin(), ciend = curve_indices.end(); @@ -1318,7 +1320,7 @@ try_to_move_close_dummy_vertex(Vertex_handle& protection_vertex, const Weighted_point& pv_wp = c3t3_.triangulation().point(protection_vertex); const Weighted_point& dv_wp = c3t3_.triangulation().point(dummy_vertex); - const Weighted_point canonical_dv_wp = c3t3_.triangulation().get_closest_point(pv_wp, dv_wp); + const Weighted_point canonical_dv_wp = Th().get_closest_point(c3t3_.triangulation(), pv_wp, dv_wp); CGAL_precondition(pv_wp != canonical_dv_wp); Vector_3 dir(cp(pv_wp), cp(canonical_dv_wp)); @@ -1383,7 +1385,7 @@ insert_corners() end = corners.end() ; it != end ; ++it) { const Bare_point& p = it->second; - Dt_Vertex_handle dtvh = dt.insert(c3t3_.triangulation().canonicalize_point(p)); + Dt_Vertex_handle dtvh = dt.insert(Th().canonicalize_point(c3t3_.triangulation(), p)); CGAL_assertion(dtvh != Dt_Vertex_handle()); dt_point_vh_map[p] = dtvh; // note that p is not canonicalized here (there's no point to) } @@ -1674,7 +1676,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, FT sq_d; std::tie(nearest_vh, sq_d) = tr.nearest_power_vertex_with_sq_distance(p, ch); CGAL_assertion(nearest_vh != Vertex_handle()); - CGAL_assertion(tr.point(nearest_vh) != cwp(tr.canonicalize_point(p))); + CGAL_assertion(tr.point(nearest_vh) != cwp(Th().canonicalize_point(tr, p))); #if CGAL_MESH_3_PROTECTION_DEBUG & 16 std::cerr << "Nearest power vertex of (" << p << ") is " @@ -1754,7 +1756,7 @@ smart_insert_point(const Bare_point& p, Weight w, int dim, const Index& index, bool is_v_dummy_vertex(id && *id == 0); #endif - const FT sq_d = tr.min_squared_distance(p, cp(c3t3_.triangulation().point(v))); + const FT sq_d = Th().min_squared_distance(tr, p, cp(tr.point(v))); if(minimal_weight_ != Weight() && sq_d < minimal_weight_) { @@ -2449,7 +2451,7 @@ do_balls_intersect(const Vertex_handle& va, const Vertex_handle& vb) const const Weighted_point& wpb = c3t3_.triangulation().point(vb); CGAL_precondition(va != vb && wpa != wpb); - return (c3t3_.triangulation().min_squared_distance(cp(wpa), cp(wpb)) <= + return (Th().min_squared_distance(c3t3_.triangulation(), cp(wpa), cp(wpb)) <= CGAL::square(CGAL::sqrt(cw(wpa)) + CGAL::sqrt(cw(wpa)))); } diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Triangulation_helpers.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Triangulation_helpers.h new file mode 100644 index 000000000000..a3b84d730a26 --- /dev/null +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Triangulation_helpers.h @@ -0,0 +1,267 @@ +// Copyright (c) 2009 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Stephane Tayeb +// +//****************************************************************************** +// File Description : +//****************************************************************************** + +#ifndef CGAL_PERIODIC_3_MESH_3_TRIANGULATION_HELPERS_H +#define CGAL_PERIODIC_3_MESH_3_TRIANGULATION_HELPERS_H + +#include + +#include + +#include + +namespace CGAL { +namespace Mesh_3 { + +template +class Triangulation_helpers; + +// specialize for periodic triangulations +template +class Triangulation_helpers + : public Triangulation_helpers // inherit the non-periodic functions +{ + typedef typename Tr::Geom_traits GT; + typedef typename Tr::FT FT; + typedef typename GT::Vector_3 Vector_3; + typedef typename GT::Triangle_3 Triangle_3; + + // If `Tr` is not a triangulation that has defined Bare_point, + // use Point_3 as defined in the traits class. + typedef typename boost::mpl::eval_if_c< + CGAL::internal::Has_nested_type_Bare_point::value, + typename CGAL::internal::Bare_point_type, + boost::mpl::identity + >::type Bare_point; + + typedef typename GT::Weighted_point_3 Weighted_point_3; + + typedef typename Tr::Offset Offset; + + typedef typename Tr::Vertex Vertex; + typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename Tr::Facet Facet; + typedef typename Tr::Cell Cell; + typedef typename Tr::Cell_handle Cell_handle; + +public: + Bare_point canonicalize_point(const Tr& tr, const Bare_point& p) const + { + return P3T3::internal::construct_canonical_point(p, tr.geom_traits()); + } + + // @fixme it might be dangerous to call robust_canonicalize() without also changing + // = construct_periodic_point(p) (lack of consistency in the result) + Weighted_point_3 canonicalize_point(const Tr& tr, const Weighted_point_3& p) const + { + return P3T3::internal::construct_canonical_point(p, tr.geom_traits()); + } + + // Warning: This function finds which offset 'Oq' should be applied to 'q' such + // that the distance between 'p' and '(q, Oq)' is minimal. + // + // \pre 'p' lives in the canonical instance. + Bare_point get_closest_point(const Tr& tr, + const Bare_point& p, + const Bare_point& q) const + { + CGAL_precondition(p.x() < tr.domain().xmax()); + CGAL_precondition(p.y() < tr.domain().ymax()); + CGAL_precondition(p.z() < tr.domain().zmax()); + CGAL_precondition(p.x() >= tr.domain().xmin()); + CGAL_precondition(p.y() >= tr.domain().ymin()); + CGAL_precondition(p.z() >= tr.domain().zmin()); + + typename GT::Compare_squared_distance_3 compare_sd = + tr.geom_traits().compare_squared_distance_3_object(); + typename GT::Construct_point_3 cp = + tr.geom_traits().construct_point_3_object(); + + std::pair pp_q = P3T3::internal::construct_periodic_point(q, tr.geom_traits()); + + Offset min_off; + Offset null_offset(0,0,0); + + for(int i = 0; i < 3; ++i) { + for(int j = 0; j < 3; ++j) { + for(int k = 0; k < 3; ++k) + { + const Offset o(i-1, j-1, k-1); + + if((i == 0 && j == 0 && k == 0) || + compare_sd(p, q, p, q, + null_offset, pp_q.second + o, + null_offset, pp_q.second + min_off) == SMALLER) + { + min_off = o; + } + } + } + } + + return cp(q, pp_q.second + min_off); + } + + Weighted_point_3 get_closest_point(const Tr& tr, + const Weighted_point_3& wp, + const Weighted_point_3& wq) const + { + 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(); + typename GT::Construct_weighted_point_3 cwp = tr.geom_traits().construct_weighted_point_3_object(); + + return cwp(get_closest_point(tr, cp(wp), cp(wq)), cw(wq)); + } + + // returns the triangle corresponding to f, with a geometric shift + // so that it is incident to ref_v's canonical position + Triangle_3 get_incident_triangle(const Tr& tr, + const Facet& f, + const Vertex_handle ref_v) const + { + typename GT::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); + typename GT::Construct_translated_point_3 tp = tr.geom_traits().construct_translated_point_3_object(); + typename GT::Construct_vector_3 cv = tr.geom_traits().construct_vector_3_object(); + typename GT::Construct_triangle_3 ct = tr.geom_traits().construct_triangle_3_object(); + + CGAL_precondition(f.first != Cell_handle() && f.first->has_vertex(ref_v)); + const int ref_v_pos = f.first->index(ref_v); + const Bare_point& ref_p = cp(tr.point(ref_v)); + const Bare_point ref_p_in_f = cp(tr.point(f.first, ref_v_pos)); + Vector_3 move_to_canonical = cv(ref_p_in_f, ref_p); + + const int s = f.second; + const Bare_point mp0 = tp(cp(tr.point(f.first, (s+1)%4)), move_to_canonical); + const Bare_point mp1 = tp(cp(tr.point(f.first, (s+2)%4)), move_to_canonical); + const Bare_point mp2 = tp(cp(tr.point(f.first, (s+3)%4)), move_to_canonical); + const Triangle_3 t = ct(mp0, mp1, mp2); + + return t; + } + + void set_point(const Tr& tr, + const Vertex_handle v, + const Vector_3& move, + const Weighted_point_3& new_position) const + { + // calling robust canonical here means we don't necessarily have + // canonical(v + move) = new_position... @fixme + return tr.set_point(v, move, canonicalize_point(tr, new_position)); + } + + FT compute_power_distance_to_power_sphere(const Tr& tr, + const Cell_handle c, + const int i) const + { + typename GT::Compute_power_distance_to_power_sphere_3 cr = + tr.geom_traits().compute_power_distance_to_power_sphere_3_object(); + + Offset o_nb = tr.neighbor_offset(c, i, c->neighbor(i)); + Offset o_vt = tr.get_offset(c->neighbor(i), c->neighbor(i)->index(c)); + + const Weighted_point_3& wp0 = tr.point(c->vertex(0)); // need the canonical point + const Weighted_point_3& wp1 = tr.point(c->vertex(1)); + const Weighted_point_3& wp2 = tr.point(c->vertex(2)); + const Weighted_point_3& wp3 = tr.point(c->vertex(3)); + const Weighted_point_3& wq = tr.point(c->neighbor(i)->vertex(c->neighbor(i)->index(c))); + const Offset& op0 = tr.get_offset(c, 0); + const Offset& op1 = tr.get_offset(c, 1); + const Offset& op2 = tr.get_offset(c, 2); + const Offset& op3 = tr.get_offset(c, 3); + const Offset oq = o_vt - o_nb; + + return cr(wp0, wp1, wp2, wp3, wq, op0, op1, op2, op3, oq); + } + + // The functions below are used in Mesh_3 and need a specific implementation + // for the periodic case because we need to try with different offsets to get the result + FT compute_power_distance_to_power_sphere(const Tr& tr, + const Cell_handle c, + const Vertex_handle v) const + { + // @fixme need to introduce Compare_power_distances_to_power_sphere_3(4 points, query) + typename GT::Compute_power_distance_to_power_sphere_3 cr = + tr.geom_traits().compute_power_distance_to_power_sphere_3_object(); + + FT min_power_dist = std::numeric_limits::infinity(); + + const Weighted_point_3& wp0 = tr.point(c->vertex(0)); // need the canonical point + const Weighted_point_3& wp1 = tr.point(c->vertex(1)); + const Weighted_point_3& wp2 = tr.point(c->vertex(2)); + const Weighted_point_3& wp3 = tr.point(c->vertex(3)); + const Weighted_point_3& wq = tr.point(v); + const Offset& op0 = tr.get_offset(c, 0); + const Offset& op1 = tr.get_offset(c, 1); + const Offset& op2 = tr.get_offset(c, 2); + const Offset& op3 = tr.get_offset(c, 3); + + for(int i = 0; i < 3; ++i) { + for(int j = 0; j < 3; ++j) { + for(int k = 0; k < 3; ++k) { + const Offset oq(i-1, j-1, k-1); + + FT power_dist = cr(wp0, wp1, wp2, wp3, wq, op0, op1, op2, op3, oq); + + if(power_dist < min_power_dist) + min_power_dist = power_dist; + } + } + } + + return min_power_dist; + } + + // Warning: This is a periodic version that computes the smallest possible distance + // between 'p' and 'q', for all possible combinations of offsets + FT min_squared_distance(const Tr& tr, + const Bare_point& p, + const Bare_point& q) const + { + typename GT::Compare_squared_distance_3 compare_sd = + tr.geom_traits().compare_squared_distance_3_object(); + typename GT::Compute_squared_distance_3 compute_sd = + tr.geom_traits().compute_squared_distance_3_object(); + + std::pair pp_p = P3T3::internal::construct_periodic_point(p, tr.geom_traits()); + std::pair pp_q = P3T3::internal::construct_periodic_point(q, tr.geom_traits()); + + Offset min_off; + + for(int i = 0; i < 3; ++i) { + for(int j = 0; j < 3; ++j) { + for(int k = 0; k < 3; ++k) + { + const Offset o(i-1, j-1, k-1); + + if((i == 0 && j == 0 && k == 0) || + compare_sd(q, p, q, p, + pp_q.second, pp_p.second + o, + pp_q.second, pp_p.second + min_off) == SMALLER) + { + min_off = o; + } + } + } + } + + return compute_sd(q, p, pp_q.second, pp_p.second + min_off); + } +}; + +} // namespace Mesh_3 +} // namespace CGAL + +#endif // CGAL_PERIODIC_3_MESH_3_TRIANGULATION_HELPERS_H diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_triangulation_3.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_triangulation_3.h index fc1a3791cb41..fc231886779d 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_triangulation_3.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_triangulation_3.h @@ -19,8 +19,8 @@ #include -// traits class -#include +#include + #include #include #include @@ -66,8 +66,11 @@ class Periodic_3_regular_triangulation_3_wrapper void *get_lock_data_structure() const { return 0; } void set_lock_data_structure(void *) const { } + typedef Periodic_3_regular_triangulation_3_wrapper Self; typedef Periodic_3_regular_triangulation_3 Base; + typedef Mesh_3::Triangulation_helpers Th; + typedef typename Base::Geom_traits Geom_traits; typedef typename Base::Triangulation_data_structure Triangulation_data_structure; @@ -186,23 +189,6 @@ class Periodic_3_regular_triangulation_3_wrapper return (number_of_vertices() == 0) ? -2 : 3; } - void set_domain(const Iso_cuboid& domain) - { - Base::set_domain(domain); - } - - Bare_point canonicalize_point(const Bare_point& p) const - { - return P3T3::internal::construct_canonical_point(p, geom_traits()); - } - - // @fixme it might be dangerous to call robust_canonicalize() without also changing - // = construct_periodic_point(p) (lack of consistency in the result) - Weighted_point canonicalize_point(const Weighted_point& p) const - { - return P3T3::internal::construct_canonical_point(p, geom_traits()); - } - // 1-cover, so we can take a const& const Weighted_point& point(const Vertex_handle v) const { @@ -308,70 +294,11 @@ class Periodic_3_regular_triangulation_3_wrapper this->v_offsets.clear(); } - FT compute_power_distance_to_power_sphere(const Cell_handle c, const int i) const - { - typename Geom_traits::Compute_power_distance_to_power_sphere_3 cr = - geom_traits().compute_power_distance_to_power_sphere_3_object(); - - Offset o_nb = this->neighbor_offset(c, i, c->neighbor(i)); - Offset o_vt = get_offset(c->neighbor(i), c->neighbor(i)->index(c)); - - const Weighted_point& wp0 = point(c->vertex(0)); // need the canonical point - const Weighted_point& wp1 = point(c->vertex(1)); - const Weighted_point& wp2 = point(c->vertex(2)); - const Weighted_point& wp3 = point(c->vertex(3)); - const Weighted_point& wq = point(c->neighbor(i)->vertex(c->neighbor(i)->index(c))); - const Offset& op0 = get_offset(c, 0); - const Offset& op1 = get_offset(c, 1); - const Offset& op2 = get_offset(c, 2); - const Offset& op3 = get_offset(c, 3); - const Offset oq = o_vt - o_nb; - - return cr(wp0, wp1, wp2, wp3, wq, op0, op1, op2, op3, oq); - } - - // The functions below are used in Mesh_3 and need a specific implementation - // for the periodic case because we need to try with different offsets to get the result - FT compute_power_distance_to_power_sphere(const Cell_handle c, - const Vertex_handle v) const - { - // @fixme need to introduce Compare_power_distances_to_power_sphere_3(4 points, query) - typename Geom_traits::Compute_power_distance_to_power_sphere_3 cr = - geom_traits().compute_power_distance_to_power_sphere_3_object(); - - FT min_power_dist = std::numeric_limits::infinity(); - - const Weighted_point& wp0 = point(c->vertex(0)); // need the canonical point - const Weighted_point& wp1 = point(c->vertex(1)); - const Weighted_point& wp2 = point(c->vertex(2)); - const Weighted_point& wp3 = point(c->vertex(3)); - const Weighted_point& wq = point(v); - const Offset& op0 = get_offset(c, 0); - const Offset& op1 = get_offset(c, 1); - const Offset& op2 = get_offset(c, 2); - const Offset& op3 = get_offset(c, 3); - - for(int i = 0; i < 3; ++i) { - for(int j = 0; j < 3; ++j) { - for(int k = 0; k < 3; ++k) { - const Offset oq(i-1, j-1, k-1); - - FT power_dist = cr(wp0, wp1, wp2, wp3, wq, op0, op1, op2, op3, oq); - - if(power_dist < min_power_dist) - min_power_dist = power_dist; - } - } - } - - return min_power_dist; - } - // Return the tetrahedron made of 'f' + 'wp' // \pre there exists an offset such that 'f.first' is in conflict with 'wp' Tetrahedron tetrahedron(const Facet& f, const Weighted_point& wp) const { - Weighted_point canonic_wp = canonicalize_point(wp); + Weighted_point canonic_wp = Th().canonicalize_point(*this, wp); Conflict_tester tester(canonic_wp, this); const Cell_handle c = f.first; @@ -403,7 +330,7 @@ class Periodic_3_regular_triangulation_3_wrapper Bounded_side side_of_power_sphere(const Cell_handle c, const Weighted_point& p, bool perturb = false) const { - Weighted_point canonical_p = canonicalize_point(p); + Weighted_point canonical_p = Th().canonicalize_point(*this, p); Bounded_side bs = ON_UNBOUNDED_SIDE; for(int i = 0; i < 3; ++i) { @@ -421,116 +348,6 @@ class Periodic_3_regular_triangulation_3_wrapper return bs; } - // Warning: This is a periodic version that computes the smallest possible distance - // between 'p' and 'q', for all possible combinations of offsets - FT min_squared_distance(const Bare_point& p, const Bare_point& q) const - { - typename Geom_traits::Compare_squared_distance_3 compare_sd = - geom_traits().compare_squared_distance_3_object(); - typename Geom_traits::Compute_squared_distance_3 compute_sd = - geom_traits().compute_squared_distance_3_object(); - - std::pair pp_p = P3T3::internal::construct_periodic_point(p, geom_traits()); - std::pair pp_q = P3T3::internal::construct_periodic_point(q, geom_traits()); - - Offset min_off; - - for(int i = 0; i < 3; ++i) { - for(int j = 0; j < 3; ++j) { - for(int k = 0; k < 3; ++k) - { - const Offset o(i-1, j-1, k-1); - - if((i == 0 && j == 0 && k == 0) || - compare_sd(q, p, q, p, - pp_q.second, pp_p.second + o, - pp_q.second, pp_p.second + min_off) == SMALLER) - { - min_off = o; - } - } - } - } - - return compute_sd(q, p, pp_q.second, pp_p.second + min_off); - } - - // Warning: This function finds which offset 'Oq' should be applied to 'q' such - // that the distance between 'p' and '(q, Oq)' is minimal. - // - // \pre 'p' lives in the canonical instance. - Bare_point get_closest_point(const Bare_point& p, const Bare_point& q) const - { - CGAL_precondition(p.x() < domain().xmax()); - CGAL_precondition(p.y() < domain().ymax()); - CGAL_precondition(p.z() < domain().zmax()); - CGAL_precondition(p.x() >= domain().xmin()); - CGAL_precondition(p.y() >= domain().ymin()); - CGAL_precondition(p.z() >= domain().zmin()); - - typename Geom_traits::Compare_squared_distance_3 compare_sd = - geom_traits().compare_squared_distance_3_object(); - typename Geom_traits::Construct_point_3 cp = - geom_traits().construct_point_3_object(); - - std::pair pp_q = P3T3::internal::construct_periodic_point(q, geom_traits()); - - Offset min_off; - Offset null_offset(0,0,0); - - for(int i = 0; i < 3; ++i) { - for(int j = 0; j < 3; ++j) { - for(int k = 0; k < 3; ++k) - { - const Offset o(i-1, j-1, k-1); - - if((i == 0 && j == 0 && k == 0) || - compare_sd(p, q, p, q, - null_offset, pp_q.second + o, - null_offset, pp_q.second + min_off) == SMALLER) - { - min_off = o; - } - } - } - } - - return cp(q, pp_q.second + min_off); - } - - Weighted_point get_closest_point(const Weighted_point& wp, const Weighted_point& wq) const - { - typename Geom_traits::Compute_weight_3 cw = geom_traits().compute_weight_3_object(); - typename Geom_traits::Construct_point_3 cp = geom_traits().construct_point_3_object(); - typename Geom_traits::Construct_weighted_point_3 cwp = geom_traits().construct_weighted_point_3_object(); - - return cwp(get_closest_point(cp(wp), cp(wq)), cw(wq)); - } - - // returns the triangle corresponding to f, with a geometric shift - // so that it is incident to ref_v's canonical position - Triangle get_incident_triangle(const Facet& f, const Vertex_handle ref_v) const - { - typename Geom_traits::Construct_point_3 cp = geom_traits().construct_point_3_object(); - typename Geom_traits::Construct_translated_point_3 tr = geom_traits().construct_translated_point_3_object(); - typename Geom_traits::Construct_vector_3 cv = geom_traits().construct_vector_3_object(); - typename Geom_traits::Construct_triangle_3 ct = geom_traits().construct_triangle_3_object(); - - CGAL_precondition(f.first != Cell_handle() && f.first->has_vertex(ref_v)); - const int ref_v_pos = f.first->index(ref_v); - const Bare_point& ref_p = cp(point(ref_v)); - const Bare_point ref_p_in_f = cp(point(f.first, ref_v_pos)); - Vector_3 move_to_canonical = cv(ref_p_in_f, ref_p); - - const int s = f.second; - const Bare_point mp0 = tr(cp(point(f.first, (s+1)%4)), move_to_canonical); - const Bare_point mp1 = tr(cp(point(f.first, (s+2)%4)), move_to_canonical); - const Bare_point mp2 = tr(cp(point(f.first, (s+3)%4)), move_to_canonical); - const Triangle t = ct(mp0, mp1, mp2); - - return t; - } - // Warning: This is a periodic version that computes the smallest possible // distances between p and q, and between p and r FOR ALL POSSIBLE OFFSETS // before comparing these distances. @@ -597,12 +414,12 @@ class Periodic_3_regular_triangulation_3_wrapper /// @{ bool is_vertex(const Weighted_point& p, Vertex_handle& v) const { - return Base::is_vertex(canonicalize_point(p), v); + return Base::is_vertex(Th().canonicalize_point(*this, p), v); } Vertex_handle nearest_power_vertex(const Bare_point& p, Cell_handle start) const { - return Base::nearest_power_vertex(canonicalize_point(p), start); + return Base::nearest_power_vertex(Th().canonicalize_point(*this, p), start); } /// Return the squared distance (note: _NOT_ the power distance) @@ -614,7 +431,7 @@ class Periodic_3_regular_triangulation_3_wrapper // Any change should be mirrored. CGAL_precondition(number_of_vertices() > 0); - Bare_point canonical_p = canonicalize_point(p); + Bare_point canonical_p = Th().canonicalize_point(*this, p); Locate_type lt; int li, lj; @@ -718,7 +535,7 @@ class Periodic_3_regular_triangulation_3_wrapper bool* CGAL_assertion_code(could_lock_zone) = nullptr) const { CGAL_assertion(could_lock_zone == nullptr); - return Base::locate(canonicalize_point(p), start); + return Base::locate(Th().canonicalize_point(*this, p), start); } Cell_handle locate(const Weighted_point& p, @@ -728,7 +545,7 @@ class Periodic_3_regular_triangulation_3_wrapper CGAL_assertion(could_lock_zone == nullptr); // Compared to the non-periodic version in T3, the infinite cell cannot // be used as default hint, so `Cell_handle()` is used instead. - return Base::locate(canonicalize_point(p), + return Base::locate(Th().canonicalize_point(*this, p), hint == Vertex_handle() ? Cell_handle() : hint->cell()); } @@ -738,7 +555,7 @@ class Periodic_3_regular_triangulation_3_wrapper bool* CGAL_assertion_code(could_lock_zone) = nullptr) const { CGAL_assertion(could_lock_zone == nullptr); - return Base::locate(canonicalize_point(p), l, i, j, start); + return Base::locate(Th().canonicalize_point(*this, p), l, i, j, start); } Cell_handle locate(const Weighted_point& p, @@ -747,7 +564,7 @@ class Periodic_3_regular_triangulation_3_wrapper bool* CGAL_assertion_code(could_lock_zone) = nullptr) const { CGAL_assertion(could_lock_zone == nullptr); - return Base::locate(canonicalize_point(p), l, i, j, + return Base::locate(Th().canonicalize_point(*this, p), l, i, j, hint == Vertex_handle() ? Cell_handle() : hint->cell()); } /// @} @@ -786,7 +603,7 @@ class Periodic_3_regular_triangulation_3_wrapper clear_v_offsets(); - Weighted_point canonic_p = canonicalize_point(p); + Weighted_point canonic_p = Th().canonicalize_point(*this, p); Locate_type lt; int li, lj; @@ -841,15 +658,6 @@ class Periodic_3_regular_triangulation_3_wrapper } /// @} - void set_point(const Vertex_handle v, - const Vector_3& move, - const Weighted_point& new_position) - { - // calling robust canonical here means we don't necessarily have - // canonical(v + move) = new_position... @fixme - return Base::set_point(v, move, canonicalize_point(new_position)); - } - /// \name Insert functions /// /// Insert points in the triangulation. @@ -873,7 +681,7 @@ class Periodic_3_regular_triangulation_3_wrapper bool* CGAL_assertion_code(could_lock_zone) = nullptr) { CGAL_assertion(could_lock_zone == nullptr); - return Base::insert(canonicalize_point(p), start); + return Base::insert(Th().canonicalize_point(*this, p), start); } Vertex_handle insert(const Weighted_point& p, @@ -883,7 +691,7 @@ class Periodic_3_regular_triangulation_3_wrapper CGAL_assertion(could_lock_zone == nullptr); // compared to the non-periodic version in T3, the infinite cell cannot // be used; `Cell_handle()` is used instead - return Base::insert(canonicalize_point(p), + return Base::insert(Th().canonicalize_point(*this, p), hint == Vertex_handle() ? Cell_handle() : hint->cell()); } @@ -892,7 +700,7 @@ class Periodic_3_regular_triangulation_3_wrapper bool* CGAL_assertion_code(could_lock_zone) = nullptr) { CGAL_assertion(could_lock_zone == nullptr); - return Base::insert(canonicalize_point(p), lt, loc, li, lj); + return Base::insert(Th().canonicalize_point(*this, p), lt, loc, li, lj); } /// @} diff --git a/Periodic_3_mesh_3/include/CGAL/make_periodic_3_mesh_3.h b/Periodic_3_mesh_3/include/CGAL/make_periodic_3_mesh_3.h index b44c5d78ccba..8d2dc8c9d535 100644 --- a/Periodic_3_mesh_3/include/CGAL/make_periodic_3_mesh_3.h +++ b/Periodic_3_mesh_3/include/CGAL/make_periodic_3_mesh_3.h @@ -233,11 +233,10 @@ struct C3t3_initializer * \tparam C3T3 is required to be a model of * the concept `MeshComplex_3InTriangulation_3`. This is the return type. * The type `C3T3` is in particular required to provide a nested type - * `C3T3::Triangulation` for the 3D triangulation - * embedding the mesh. The vertex and cell base classes of the - * triangulation `C3T3::Triangulation` are required to be models of the - * concepts `MeshVertexBase_3` and `MeshCellBase_3` - * respectively. + * `C3T3::Triangulation` for the 3D triangulation embedding the mesh. + * This type must be a `CGAL::Periodic_3_mesh_triangulation_3` whose + * vertex and cell base classes are be models of the + * concepts `MeshVertexBase_3` and `MeshCellBase_3`, respectively. * * \tparam MD is required to be a model of * the concept `MeshDomain_3`, or of the refined concept diff --git a/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h b/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h index bbaffe38f2fd..dbe5a77996e3 100644 --- a/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h +++ b/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h @@ -234,9 +234,7 @@ void project_dummy_points_of_surface(C3T3& c3t3, * will always satisfy this condition. * * - * \tparam C3T3 is required to be a model of - * the concept - * `MeshComplex_3InTriangulation_3`. + * \tparam C3T3 is required to be a model of the concept `MeshComplex_3InTriangulation_3`. * The argument `c3t3` is passed by * reference as this object is modified by the refinement process. As the * refinement process only adds points to the triangulation, all @@ -245,11 +243,10 @@ void project_dummy_points_of_surface(C3T3& c3t3, * specific points in the domain to ensure that they will be contained in the * final triangulation. * The type `C3T3` is in particular required to provide a nested type - * `C3T3::Triangulation` for the 3D triangulation - * embedding the mesh. The vertex and cell base classes of the - * triangulation `C3T3::Triangulation` are required to be models of the - * concepts `MeshVertexBase_3` and `MeshCellBase_3` - * respectively. + * `C3T3::Triangulation` for the 3D triangulation embedding the mesh. + * This type must be a `CGAL::Periodic_3_mesh_triangulation_3` whose + * vertex and cell base classes are be models of the + * concepts `MeshVertexBase_3` and `MeshCellBase_3`, respectively. * * \tparam MD is required to be a model of * the concept `Periodic_3MeshDomain_3` or of the refined concept diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h index 957b73bec46f..eac6aecdccbe 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_regular_triangulation_3.h @@ -780,7 +780,7 @@ class Periodic_3_regular_triangulation_3 // They do not check the validity of the mesh. void set_point(const Vertex_handle v, const Vector& move, - const Weighted_point& new_position) + const Weighted_point& new_position) const { Bare_point p = geom_traits().construct_point_3_object()(point(v)); Bare_point moved_p = p + move; From cd1a1a92f2e4d89781c20b99bb4f55bac3617014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 26 Feb 2026 15:30:36 +0100 Subject: [PATCH 039/127] Dot not assume Tr::FT exists, FT is in GT --- Mesh_3/include/CGAL/Mesh_3/Is_mesh_domain_field_3.h | 2 +- Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h | 2 +- .../include/CGAL/Poisson_mesh_cell_criteria_3.h | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Is_mesh_domain_field_3.h b/Mesh_3/include/CGAL/Mesh_3/Is_mesh_domain_field_3.h index aab7f327d526..5e9bb84ac69f 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Is_mesh_domain_field_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Is_mesh_domain_field_3.h @@ -32,7 +32,7 @@ namespace CGAL { public CGAL::Boolean_tag < boost::callable_traits::is_invocable_r< - typename Tr::FT, + typename Tr::Geom_traits::FT, Type, typename Tr::Bare_point, int, diff --git a/Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h b/Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h index b1c6080f30cb..cc333af5b36d 100644 --- a/Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h +++ b/Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h @@ -35,7 +35,7 @@ bool has_non_protecting_weights(const Triangulation& tr, { const bool with_features = ::CGAL::internal::Has_features::value; - typedef typename Triangulation::FT FT; + typedef typename Triangulation::Geom_traits::FT FT; typedef typename Triangulation::Weighted_point Weighted_point; typename Triangulation::Geom_traits::Compare_weighted_squared_radius_3 cwsr = diff --git a/Poisson_surface_reconstruction_3/include/CGAL/Poisson_mesh_cell_criteria_3.h b/Poisson_surface_reconstruction_3/include/CGAL/Poisson_mesh_cell_criteria_3.h index 513d2be4376e..a5391e8f38d6 100644 --- a/Poisson_surface_reconstruction_3/include/CGAL/Poisson_mesh_cell_criteria_3.h +++ b/Poisson_surface_reconstruction_3/include/CGAL/Poisson_mesh_cell_criteria_3.h @@ -21,13 +21,12 @@ #include // for min namespace CGAL { - namespace internal { namespace Poisson { template class Constant_sizing_field { - typedef typename Tr::FT FT; + typedef typename Tr::Geom_traits::FT FT; FT sq_radius_bound; public: FT cell_radius_bound() const { return CGAL::approximate_sqrt(sq_radius_bound); } From b573478ae2235455d5c16ac112c4088f46eb1664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 26 Feb 2026 15:31:11 +0100 Subject: [PATCH 040/127] Add commas --- Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h | 1 + .../doc/Triangulation_3/Concepts/TriangulationTraits_3.h | 2 +- Triangulation_3/doc/Triangulation_3/Triangulation_3.txt | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h b/Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h index cc333af5b36d..d87b7fc6923a 100644 --- a/Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h +++ b/Mesh_3/include/CGAL/Mesh_3/internal/check_weights.h @@ -23,6 +23,7 @@ #include #include #include + #include namespace CGAL { diff --git a/Triangulation_3/doc/Triangulation_3/Concepts/TriangulationTraits_3.h b/Triangulation_3/doc/Triangulation_3/Concepts/TriangulationTraits_3.h index 9bb4aa99b70c..8f29ac49b23a 100644 --- a/Triangulation_3/doc/Triangulation_3/Concepts/TriangulationTraits_3.h +++ b/Triangulation_3/doc/Triangulation_3/Concepts/TriangulationTraits_3.h @@ -7,7 +7,7 @@ The concept `TriangulationTraits_3` is the first template parameter of the class `CGAL::Triangulation_3`. It defines the geometric objects (points, segments, -triangles and tetrahedra) forming the triangulation together with a few +triangles, and tetrahedra) forming the triangulation together with a few geometric predicates and constructions on these objects: lexicographical comparison, orientation in case of coplanar points and orientation in space. diff --git a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt index 51cee200cf87..5c24b06d73a1 100644 --- a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt +++ b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt @@ -255,7 +255,7 @@ The first template parameter of the triangulation class `Triangulation_3` is the geometric traits class, described by the concept `TriangulationTraits_3`. It must define the types of the geometric objects -(points, segments, triangles and tetrahedra) forming the triangulation together +(points, segments, triangles, and tetrahedra) forming the triangulation together with a few geometric predicates on these objects: orientation in space, orientation in case of coplanar points, order of collinear points. From a8bdce7e52591c10187fd8b4f3c64c223419f047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Feb 2026 10:34:53 +0100 Subject: [PATCH 041/127] Avoid a copy --- Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 2a40f9f35f73..e7e80fcbb818 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -561,7 +561,7 @@ class Compact_mesh_cell_3 } /// Returns surface center of `facet` - Point_3 get_facet_surface_center(const int facet) const + const Point_3& get_facet_surface_center(const int facet) const { CGAL_precondition(facet>=0 && facet<4); return surface_center_table_[facet]; From 82c3b043cf19ecce7a40cbd93a199642473e8207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Feb 2026 10:35:14 +0100 Subject: [PATCH 042/127] Remove unused function object --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 2077b8820474..f30037f9d87c 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -2757,7 +2757,6 @@ rebuild_restricted_delaunay(ForwardIterator first_cell, { typename GT::Construct_point_3 cp = tr_.geom_traits().construct_point_3_object(); typename GT::Construct_vector_3 vector = tr_.geom_traits().construct_vector_3_object(); - typename GT::Equal_3 equal = tr_.geom_traits().equal_3_object(); Update_c3t3 updater(domain_,c3t3_); From b4cf28268d0b8e777a1cf11244270b3ceaeccde5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Feb 2026 10:41:14 +0100 Subject: [PATCH 043/127] Make the C3T3 surface info maps baseline --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 6 +- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 29 +-- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 17 +- .../Mesh_3/mesh_standard_facet_criteria.h | 14 +- Mesh_3/test/Mesh_3/test_criteria.cpp | 4 +- .../Mesh_3/test_mesh_criteria_creation.cpp | 6 +- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 192 ++++-------------- 7 files changed, 59 insertions(+), 209 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index f30037f9d87c..ee512f587060 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1381,7 +1381,8 @@ class C3T3_helpers for(std::size_t i = 0; i < 4; ++i) { const int ii = static_cast(i);//avoid warnings - surface_prop_table_[i] = c3t3.surface_info(Facet(c, ii)); + if (c3t3.is_in_complex(Facet(c, ii))) + surface_prop_table_[i] = c3t3.surface_info(Facet(c, ii)); } //note c->next_intrusive() and c->previous_intrusive() //are lost by 'backup' and 'restore', @@ -1393,7 +1394,8 @@ class C3T3_helpers const C3T3& c3t3) { int infinite_index = c->index(c3t3.triangulation().infinite_vertex()); - surface_prop_table_[0] = c3t3.surface_info(Facet(c, infinite_index)); + if (c3t3.is_in_complex(Facet(c, infinite_index))) + surface_prop_table_[0] = c3t3.surface_info(Facet(c, infinite_index)); } public: diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index 641353520fe4..b3a60a3a75ec 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -898,34 +898,9 @@ update_star_self(const Vertex_handle& vertex) const int& k = (*cell_it)->index(vertex); const Facet mirror_f = mirror_facet(*cell_it,k); -#ifdef CGAL_MESH_3_USE_C3T3_MAPS - if (r_c3t3_.is_in_complex(mirror_f)) // @todo here and below is 2 map looks up which should only be one. + // @todo here and below is 2 map looks up which could be only one. + if (r_c3t3_.is_in_complex(mirror_f)) r_c3t3_.set_surface_info(*cell_it, k, r_c3t3_.surface_info(mirror_f)); -#else // CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL has to be defined - const Cell_handle& neighbor_cell = mirror_f.first; - const int& neighb_k = mirror_f.second; - const bool cond_old = neighbor_cell->is_facet_on_surface(neighb_k); - -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - const bool cond_new = r_c3t3_.surface_patch_index(mirror_f); - if (cond_old != cond_new) { - std::cerr << "new cond = " << cond_new << std::endl; - std::exit(1); - } -# endif - - if (cond_old) - { - // Facet(*cell_it,k) is on surface - r_c3t3_.set_surface_patch_index(*cell_it, k, r_c3t3_.surface_patch_index(neighbor_cell, neighb_k)); - r_c3t3_.set_surface_center(*cell_it, k, r_c3t3_.surface_center(neighbor_cell, neighb_k)); - r_c3t3_.set_surface_center_index(*cell_it, k, r_c3t3_.surface_center_index(neighbor_cell, neighb_k)); - } - else - { - r_c3t3_.set_surface_patch_index(*cell_it, k, Surface_patch_index()); - } -#endif // Set subdomain index set_cell_in_domain(*cell_it, cells_subdomain); diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 4b40d2fd3ab0..9014764ede9f 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -314,14 +314,9 @@ class Refine_facets_3_base CGAL_precondition(this->is_facet_on_surface(facet)); -#ifndef CGAL_MESH_3_USE_C3T3_MAPS - this->set_last_vertex_index(get_facet_surface_center_index(facet)); - return get_facet_surface_center(facet); -#else const auto& [surface_index, center_index, center] = this->r_c3t3_.surface_info(facet); this->set_last_vertex_index(center_index); return center; -#endif } Facet get_next_element_impl() @@ -476,18 +471,10 @@ class Refine_facets_3_base const Facet mirror = mirror_facet(f); -#ifndef CGAL_MESH_3_USE_C3T3_MAPS - r_c3t3_.set_surface_center(f.first, f.second, center); - r_c3t3_.set_surface_center(mirror.first, mirror.second, center); - - r_c3t3_.set_surface_center_index(f.first, f.second, center_index); - r_c3t3_.set_surface_center_index(mirror.first, mirror.second, center_index); -#else - // awkward: add it *after* add_to_complex() because otherwise the surface index is set up, - // and add_to_complex() will do nothing... + // a little awkward: these are performed after add_to_complex() because otherwise + // the surface index is set up, and add_to_complex() will do nothing... r_c3t3_.set_surface_info(f, {surface_index, center_index, center}); r_c3t3_.set_surface_info(mirror, {surface_index, center_index, center}); -#endif } /// Returns index of facet `f`. 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 d8b338524bcc..798fc30a2ea2 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 @@ -210,7 +210,7 @@ class Uniform_curvature_size_criterion : const Weighted_point& p3 = tr.point(f.first, (f.second+3)&3); const Bare_point c = weighted_circumcenter(p1,p2,p3); - const Bare_point& center = c3t3.surface_center(f.first, f.second); + const Bare_point& center = c3t3.surface_center(f); const FT sq_dist = Th().min_squared_distance(tr, c, center); @@ -286,8 +286,10 @@ class Variable_curvature_size_criterion : const Weighted_point& p3 = tr.point(f.first, (f.second+3)&3); const Bare_point c = weighted_circumcenter(p1,p2,p3); - const Bare_point& ball_center = c3t3.surface_center(f.first, f.second); - const Index& index = c3t3.surface_center_index(f.first, f.second); + + // @todo use surface_info() + const Bare_point& ball_center = c3t3.surface_center(f); + const Index& index = c3t3.surface_center_index(f); const FT sq_dist = Th().min_squared_distance(tr, c, ball_center); const FT sq_bound = CGAL::square(size_(ball_center, 2, index)); @@ -369,8 +371,8 @@ class Variable_size_criterion : const Weighted_point& wp1 = tr.point(f.first, (f.second+1)&3); const Bare_point& p1 = cp(wp1); - const Bare_point& ball_center = c3t3.surface_center(f.first, f.second); - const Index& index = c3t3.surface_center_index(f.first, f.second); + const Bare_point& ball_center = c3t3.surface_center(f); + const Index& index = c3t3.surface_center_index(f); const FT sq_radius = Th().min_squared_distance(tr, p1, ball_center); const FT sq_bound = CGAL::square(size_(ball_center, 2, index)); @@ -454,7 +456,7 @@ class Uniform_size_criterion : const Weighted_point& wp1 = tr.point(f.first, (f.second+1)&3); const Bare_point p1 = cp(wp1); - const Bare_point& ball_center = c3t3.surface_center(f.first, f.second); + const Bare_point& ball_center = c3t3.surface_center(f); const FT sq_radius = Th().min_squared_distance(tr, p1, ball_center); diff --git a/Mesh_3/test/Mesh_3/test_criteria.cpp b/Mesh_3/test/Mesh_3/test_criteria.cpp index 8e3bdf480165..37739b7bcfd6 100644 --- a/Mesh_3/test/Mesh_3/test_criteria.cpp +++ b/Mesh_3/test/Mesh_3/test_criteria.cpp @@ -85,8 +85,8 @@ struct Tester void init_facet(const Facet& f, const Bare_point& p) const { - f.first->set_surface_patch_index(f.second,Surface_patch_index(0,1)); - f.first->set_facet_surface_center(f.second,p); + c3t3_.set_surface_patch_index(f, Surface_patch_index(0,1)); + c3t3_.set_surface_center(f, p); for ( int i=0; i<4 ; ++i ) { diff --git a/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp b/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp index e586697d9c0e..94d3d35a5a9f 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp @@ -58,9 +58,9 @@ int main() tr.geom_traits().construct_weighted_circumcenter_3_object()( tr.point(ch, k+1), tr.point(ch, k+2), tr.point(ch, k+3)); - ch->set_surface_patch_index(k,surf_index); - ch->set_facet_surface_center(k,facet_circum); - ch->set_facet_surface_center_index(k,index); + c3t3.set_surface_patch_index(ch, k, surf_index); + c3t3.set_surface_center(ch, k, facet_circum); + c3t3.set_surface_center_index(ch, k, index); // Init vertices ch->vertex(0)->set_dimension(2); diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 425c256fee68..0f88dc362a6e 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -483,14 +483,13 @@ class Mesh_complex_3_in_triangulation_3 { // std::cout << "set " << &*(cell) << " " << i << " to " << index << " (new)" << std::endl; -#ifdef CGAL_MESH_3_USE_C3T3_MAPS if (index == Surface_patch_index()) { surface_facet_info_.erase(f); } else { -# ifdef CGAL_LINKED_WITH_TBB +#ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; @@ -498,16 +497,11 @@ class Mesh_complex_3_in_triangulation_3 accessor->second.surface_index_ = index; } else -# endif +#endif { surface_facet_info_[f].surface_index_ = index; } } -#endif - -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL - f.first->set_surface_patch_index(f.second, index); -#endif } /** sets the surface index of facet(\p cell, \p i) to \p index @@ -522,8 +516,7 @@ class Mesh_complex_3_in_triangulation_3 void set_surface_center(const Facet& f, const Bare_point& p) const { -#ifdef CGAL_MESH_3_USE_C3T3_MAPS -# ifdef CGAL_LINKED_WITH_TBB +#ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; @@ -531,15 +524,10 @@ class Mesh_complex_3_in_triangulation_3 accessor->second.center_ = p; } else -# endif +#endif { surface_facet_info_[f].center_ = p; } -#endif - -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL - f.first->set_facet_surface_center(f.second, p); -#endif } /** sets the surface center of facet(\p cell, \p i) to \p p @@ -554,8 +542,7 @@ class Mesh_complex_3_in_triangulation_3 void set_surface_center_index(const Facet& f, const Index& index) const { -#ifdef CGAL_MESH_3_USE_C3T3_MAPS -# ifdef CGAL_LINKED_WITH_TBB +#ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; @@ -563,15 +550,10 @@ class Mesh_complex_3_in_triangulation_3 accessor->second.center_index_ = index; } else -# endif +#endif { surface_facet_info_[f].center_index_ = index; } -#endif - -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL - f.first->set_facet_surface_center_index(f.second, index); -#endif } /** sets the surface center index of facet(\p cell, \p i) to \p index @@ -586,25 +568,28 @@ class Mesh_complex_3_in_triangulation_3 void set_surface_info(const Facet& f, const Facet_prop& info) const { -#ifndef CGAL_MESH_3_USE_C3T3_MAPS - std::exit(1); -#else -# ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) + if (info.surface_index_ == Surface_patch_index()) { - typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, f); - accessor->second = info; + surface_facet_info_.erase(f); } else -# endif { - surface_facet_info_[f] = info; - } +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, f); + accessor->second = info; + } + else #endif + { + surface_facet_info_[f] = info; + } + } } - void set_surface_info(Cell_handle cell, int i, + void set_surface_info(const Cell_handle& cell, int i, const Facet_prop& info) const { return set_surface_info(Facet(cell, i), info); @@ -641,44 +626,21 @@ class Mesh_complex_3_in_triangulation_3 */ Surface_patch_index surface_patch_index(const Facet& f) const { -#ifdef CGAL_MESH_3_USE_C3T3_MAPS - Surface_patch_index res_new {}; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; if (surface_facet_info_.find(accessor, f)) - res_new = accessor->second.surface_index_; + return accessor->second.surface_index_; } else -# endif +#endif { auto it = surface_facet_info_.find(f); if (it != surface_facet_info_.end()) - res_new = it->second.surface_index_; + return it->second.surface_index_; } -#endif - -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL - Surface_patch_index res_old = f.first->surface_patch_index(f.second); - -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - if (res_new != res_old) { - std::cerr << __FILE__ << " " << __LINE__ << std::endl; - std::cerr << "new res = " << res_new << std::endl; - std::cerr << "old res = " << res_old << std::endl; - CGAL_assertion(false); - std::exit(1); - } -# endif - return res_old; -#else -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - return res_new; -# endif -#endif - CGAL_assertion(false); - std::exit(1); + return Surface_patch_index(); } /** returns the surface index of facet(\p cell, \p i) @@ -693,8 +655,6 @@ class Mesh_complex_3_in_triangulation_3 { CGAL_precondition(is_in_complex(f)); -#ifdef CGAL_MESH_3_USE_C3T3_MAPS - Bare_point res_new; // return directly when the comparison code is gone # ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { @@ -702,37 +662,15 @@ class Mesh_complex_3_in_triangulation_3 CGAL_assume_code(bool found =) surface_facet_info_.find(accessor, f); CGAL_assume(found); - res_new = accessor->second.center_; + return accessor->second.center_; } else -# endif +#endif { auto it = surface_facet_info_.find(f); CGAL_assume(it != surface_facet_info_.end()); - res_new = it->second.center_; + return it->second.center_; } -#endif - -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL - const auto res_old = f.first->get_facet_surface_center(f.second); - -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - if (res_new != res_old) { - std::cerr << __FILE__ << " " << __LINE__ << std::endl; - std::cerr << "new res = " << res_new << std::endl; - std::cerr << "old res = " << res_old << std::endl; - CGAL_assertion(false); - std::exit(1); - } -# endif - return res_old; -#else -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - return res_new; -# endif -#endif - CGAL_assertion(false); - std::exit(1); } /** returns the surface center of facet(\p cell, \p i) @@ -747,8 +685,6 @@ class Mesh_complex_3_in_triangulation_3 { CGAL_precondition(is_in_complex(f)); -#ifdef CGAL_MESH_3_USE_C3T3_MAPS - Index res_new; // return directly when the comparison code is gone # ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { @@ -756,37 +692,15 @@ class Mesh_complex_3_in_triangulation_3 CGAL_assume_code(bool found =) surface_facet_info_.find(accessor, f); CGAL_assume(found); - res_new = accessor->second.center_index_; + return accessor->second.center_index_; } else -# endif +#endif { auto it = surface_facet_info_.find(f); CGAL_assume(it != surface_facet_info_.end()); - res_new = it->second.center_index_; + return it->second.center_index_; } -#endif - -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL - const Index res_old = f.first->get_facet_surface_center_index(f.second); - -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - if (res_new != res_old) { - std::cerr << __FILE__ << " " << __LINE__ << std::endl; - std::cerr << "new res = " << res_new << std::endl; - std::cerr << "old res = " << res_old << std::endl; - CGAL_assertion(false); - std::exit(1); - } -# endif - return res_old; -#else -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - return res_new; -# endif -#endif - CGAL_assertion(false); - std::exit(1); } /** returns the surface center index of facet(\p cell, \p i) @@ -797,12 +711,9 @@ class Mesh_complex_3_in_triangulation_3 return surface_center_index(Facet(cell, i)); } - const Facet_prop& surface_info(const Facet& f) const + decltype(auto) surface_info(const Facet& f) const { -#ifndef CGAL_MESH_3_USE_C3T3_MAPS - std::exit(1); -#else -# ifdef CGAL_LINKED_WITH_TBB +#ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; @@ -812,13 +723,12 @@ class Mesh_complex_3_in_triangulation_3 return accessor->second; } else -# endif +#endif { auto it = surface_facet_info_.find(f); CGAL_assume(it != surface_facet_info_.end()); return it->second; } -#endif } /** returns the dimension of the lowest dimensional face of the input 3D @@ -1061,47 +971,21 @@ class Mesh_complex_3_in_triangulation_3 */ bool is_in_complex(const Facet& f) const { -#ifdef CGAL_MESH_3_USE_C3T3_MAPS - // if we always erase when trying to insert a default constructed Subdomain_index, - // we - bool res_new = false; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; if (surface_facet_info_.find(accessor, f)) - res_new = !(accessor->second.surface_index_ == Surface_patch_index()); + return !(accessor->second.surface_index_ == Surface_patch_index()); } else -# endif +#endif { auto it = surface_facet_info_.find(f); if (it != surface_facet_info_.end()) - res_new = !(it->second.surface_index_ == Surface_patch_index()); - } -#endif - -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL - const bool res_old = f.first->is_facet_on_surface(f.second); - -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - if (res_new != res_old) { - std::cerr << __FILE__ << " " << __LINE__ << std::endl; - std::cerr << &*(f.first) << " " << f.second << std::endl; - std::cerr << "new res = " << res_new << std::endl; - std::cerr << "old res = " << res_old << std::endl; - CGAL_assertion(false); - std::exit(1); + return !(it->second.surface_index_ == Surface_patch_index()); } -# endif - return res_old; -#else -# ifdef CGAL_MESH_3_USE_C3T3_MAPS - return res_new; -# endif -#endif - CGAL_assertion(false); - std::exit(1); + return false; } /** returns true if facet (\p cell, \p i) belongs to the 2D complex From 92445a7f623aa00c01b77e7600c1dff018a12164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Feb 2026 10:41:51 +0100 Subject: [PATCH 044/127] Reduce to 'int' some 'std::size_t' vertex base members --- .../CGAL/Mesh_3/Refine_facets_manifold_base.h | 5 ++-- Mesh_3/include/CGAL/Mesh_vertex_base_3.h | 25 ++++++++++--------- .../Concepts/SimplicialMeshVertexBase_3.h | 4 +-- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 21 ++++++++-------- .../CGAL/Simplicial_mesh_vertex_base_3.h | 14 +++++------ 5 files changed, 34 insertions(+), 35 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 adedf1679270..49a968e4b8ee 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 @@ -160,7 +160,7 @@ class Refine_facets_manifold_base typename std::vector::iterator fit = facets.begin(); while(fit != facets.end() && !this->r_c3t3_.is_in_complex(*fit)) ++fit; CGAL_assertion(fit!=facets.end()); - CGAL_assertion_code(std::size_t facet_counter = 1); + CGAL_assertion_code(int facet_counter = 1); Facet biggest_facet = *fit++; FT biggest_sq_dist = compute_sq_distance_to_facet_center(biggest_facet, v); @@ -189,8 +189,7 @@ class Refine_facets_manifold_base ++fit; while(fit != facets.end() && !this->r_c3t3_.is_in_complex(*fit)) ++fit; } - CGAL_assertion(v->cached_number_of_incident_facets() == - facet_counter); + CGAL_assertion(v->cached_number_of_incident_facets() == facet_counter); CGAL_assertion(this->r_c3t3_.is_in_complex(biggest_facet)); #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS std::cerr << "Biggest facet squared radius: " diff --git a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h index ca950486cee6..1efe722a938d 100644 --- a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h @@ -187,34 +187,34 @@ class Mesh_vertex_3 std::size_t time_stamp() const { return time_stamp_; } - void set_time_stamp(const std::size_t& ts) { + void set_time_stamp(const std::size_t ts) { time_stamp_ = ts; } ///@} bool is_c2t3_cache_valid() const { - return number_of_incident_facets_ != std::size_t(-2) && - number_of_components_ != std::size_t(-2); + return number_of_incident_facets_ != -1 && + number_of_components_ != -1; } void invalidate_c2t3_cache() { - number_of_incident_facets_ = std::size_t(-2); - number_of_components_ = std::size_t(-2); + number_of_incident_facets_ = -1; + number_of_components_ = -1; } - void set_c2t3_cache(const std::size_t i, const std::size_t j) + void set_c2t3_cache(const int i, const int j) { number_of_incident_facets_ = i; number_of_components_ = j; } - std::size_t cached_number_of_incident_facets() const + int cached_number_of_incident_facets() const { return number_of_incident_facets_; } - std::size_t cached_number_of_components() const + int cached_number_of_components() const { return number_of_components_; } @@ -234,10 +234,7 @@ class Mesh_vertex_3 Vertex_handle previous_intrusive_; #endif - std::size_t time_stamp_ = std::size_t(-2); - std::size_t number_of_incident_facets_ = std::size_t(-2); - std::size_t number_of_components_ = std::size_t(-2); // number of components in the adjacency - // graph of incident facets (in complex) + std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; // Stores info needed by optimizers FT meshing_info_; @@ -250,6 +247,10 @@ class Mesh_vertex_3 // that contains me. Negative values are a marker for special vertices. short dimension_; + int number_of_incident_facets_ = -1; + int number_of_components_ = -1; // number of components in the adjacency + // graph of incident facets (in complex) + public: friend std::istream& operator>>(std::istream &is, Mesh_vertex_3& v) { diff --git a/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h b/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h index 54283950ef68..1a2660ccf526 100644 --- a/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h +++ b/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h @@ -78,14 +78,14 @@ void invalidate_c2t3_cache(); /*! Returns the cached number of facets of the complex incident to the vertex. */ -std::size_t cached_number_of_incident_facets(); +int cached_number_of_incident_facets(); /*! This method concerns the adjacency graph of the facets of the complex incident to the vertex and returns a cached value for the number of connected components this graph. */ -std::size_t cached_number_of_components(); +int cached_number_of_components(); /// @} diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 0f88dc362a6e..8a2834012958 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -1539,7 +1539,7 @@ class Mesh_complex_3_in_triangulation_3 } // From here all incident edges (in complex) are REGULAR or BOUNDARY. - const std::size_t nb_components = union_find_of_incident_facets(v); + const int nb_components = union_find_of_incident_facets(v); if (nb_components > 1) { #ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS std::cerr << "singular vertex: nb_components=" << nb_components << std::endl; @@ -1780,7 +1780,7 @@ class Mesh_complex_3_in_triangulation_3 end = triangulation().finite_vertices_end(); vit != end; ++vit) { - vit->set_c2t3_cache(0, (std::numeric_limits::max)()); + vit->set_c2t3_cache(0, -1); } edge_facet_counter_.clear(); @@ -1813,7 +1813,7 @@ class Mesh_complex_3_in_triangulation_3 } const std::size_t n = edge_va->cached_number_of_incident_facets(); - edge_va->set_c2t3_cache(n + 1, (std::numeric_limits::max)()); + edge_va->set_c2t3_cache(n + 1, -1); } } } @@ -1822,12 +1822,12 @@ class Mesh_complex_3_in_triangulation_3 /// Extract the subset `F` of facets of the complex incident to `v` and /// return the number of connected component of the adjacency graph of `F`. - std::size_t union_find_of_incident_facets(const Vertex_handle v) const + int union_find_of_incident_facets(const Vertex_handle v) const { if (v->is_c2t3_cache_valid()) { - const std::size_t n = v->cached_number_of_components(); - if (n != (std::numeric_limits::max)()) return n; + const int n = v->cached_number_of_components(); + if (n != -1) return n; } Union_find facets; @@ -1875,10 +1875,11 @@ class Mesh_complex_3_in_triangulation_3 } } } - const std::size_t nb_components = facets.number_of_sets(); - const std::size_t n = v->cached_number_of_incident_facets(); + const int n = v->cached_number_of_incident_facets(); + const int nb_components = facets.number_of_sets(); v->set_c2t3_cache(n, nb_components); + return nb_components; } @@ -2185,8 +2186,8 @@ add_to_complex(const Cell_handle& cell, ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; } - const std::size_t n = edge_va->cached_number_of_incident_facets(); - const std::size_t m = edge_va->cached_number_of_components(); + const int n = edge_va->cached_number_of_incident_facets(); + const int m = edge_va->cached_number_of_components(); edge_va->set_c2t3_cache(n + 1, m); } const int dimension_plus_1 = tr_.dimension() + 1; diff --git a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h index 1a15aaf09d7c..b6ea0b15b63c 100644 --- a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h +++ b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h @@ -125,8 +125,6 @@ private : public: Simplicial_mesh_vertex_base_3() : Vb() - , number_of_incident_facets_(0) - , number_of_components_(0) , index_() , dimension_(-1) , cache_validity(false) @@ -177,19 +175,19 @@ private : cache_validity = false; } - void set_c2t3_cache(const std::size_t i, const std::size_t j) + void set_c2t3_cache(const int i, const int j) { number_of_incident_facets_ = i; number_of_components_ = j; cache_validity = true; } - std::size_t cached_number_of_incident_facets() const + int cached_number_of_incident_facets() const { return number_of_incident_facets_; } - std::size_t cached_number_of_components() const + int cached_number_of_components() const { return number_of_components_; } @@ -204,8 +202,8 @@ private : } private: - std::size_t number_of_incident_facets_; - std::size_t number_of_components_; // number of components in the adjacency + int number_of_incident_facets_ = 0; + int number_of_components_ = 0; // number of components in the adjacency // graph of incident facets (in complex) @@ -217,7 +215,7 @@ private : // that contains me. Negative values are a marker for special vertices. short dimension_; bool cache_validity; - std::size_t time_stamp_ = std::size_t(-2); + std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; public: friend std::istream& operator>>(std::istream& is, From 668d013d5effc6c37a8a977be36c15f33a7cb3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Feb 2026 23:57:46 +0100 Subject: [PATCH 045/127] Add move© for the facet surface info maps --- Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h | 2 +- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 69 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h index 1be34e6a56b8..279c7ec69179 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h +++ b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h @@ -1368,7 +1368,7 @@ get_umbrella(const Facet_vector& facets, // internal_facets of conflict zone typename Facet_vector::const_iterator fit = facets.begin(); for ( ; fit != facets.end() ; ++fit ) { - Facet f = *fit; + const Facet f = *fit; Surface_patch_index pid = c3t3_.surface_patch_index(f); if ( !(pid == Surface_patch_index()) ) { diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 8a2834012958..ae6b55154322 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -315,6 +315,8 @@ class Mesh_complex_3_in_triangulation_3 tr_.swap(rhs.tr_); swapper(rhs.number_of_cells_, number_of_cells_); + surface_facet_info_.swap(rhs.surface_facet_info_); + edges_.swap(rhs.edges_); corners_.swap(rhs.corners_); far_vertices_.swap(rhs.far_vertices_); @@ -2036,6 +2038,72 @@ Mesh_complex_3_in_triangulation_3(const Self& rhs) } CGAL_assertion(far_vertices_.size() == rhs.far_vertices_.size()); } + + for (const auto& e : rhs.surface_facet_info_) + { + auto get_this_vertex = [&](const Cell_handle& rhs_c, const int rhs_o) -> Vertex_handle { + if (rhs.triangulation().is_infinite(rhs_c->vertex(rhs_o))) { + return this->triangulation().infinite_vertex(); + } else { + const auto& rhs_p = rhs.triangulation().point(rhs_c, rhs_o); + Vertex_handle this_vh; + CGAL_assertion_code(bool found =) + this->triangulation().is_vertex(rhs_p, this_vh); + CGAL_assertion(found); + return this_vh; + } + }; + + // Find the corresponding facet in 'this' + const Facet& rhs_facet = e.first; + const Cell_handle& rhs_c = rhs_facet.first; + const int rhs_i = rhs_facet.second; + + Vertex_handle rhs_nv[5]; + rhs_nv[0] = get_this_vertex(rhs_c, rhs_i); + rhs_nv[1] = get_this_vertex(rhs_c, (rhs_i + 1) % 4); + rhs_nv[2] = get_this_vertex(rhs_c, (rhs_i + 2) % 4); + rhs_nv[3] = get_this_vertex(rhs_c, (rhs_i + 3) % 4); + + Cell_handle rhs_n = rhs_c->neighbor(rhs_i); + rhs_nv[4] = get_this_vertex(rhs_n, rhs_n->index(rhs_c)); + + Cell_handle this_cell; + CGAL_assertion_code(bool found =) + this->triangulation().is_cell(rhs_nv[0], rhs_nv[1], rhs_nv[2], rhs_nv[3], this_cell); + CGAL_assertion(found); + + Cell_handle this_n; + CGAL_assertion_code(found =) + this->triangulation().is_cell(rhs_nv[1], rhs_nv[2], rhs_nv[3], rhs_nv[4], this_n); + CGAL_assertion(found); + + const int this_opp = this_cell->index(this_n); + const Facet this_facet(this_cell, this_opp); + + // std::cout << "from rhs:\n"; + // std::cout << " facet: " << rhs.triangulation().point(rhs_c, (rhs_i + 1) % 4) << ", " + // << rhs.triangulation().point(rhs_c, (rhs_i + 2) % 4) << ", " + // << rhs.triangulation().point(rhs_c, (rhs_i + 3) % 4) << "\n"; + // std::cout << "to this:\n"; + // std::cout << " facet: " << this->triangulation().point(this_cell, (this_opp + 1) % 4) << ", " + // << this->triangulation().point(this_cell, (this_opp + 2) % 4) << ", " + // << this->triangulation().point(this_cell, (this_opp + 3) % 4) << "\n"; + +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, this_facet); + accessor->second = e.second; + } + else +#endif + { + surface_facet_info_[this_facet] = e.second; + } + } + CGAL_postcondition(surface_facet_info_.size() == rhs.surface_facet_info_.size()); } template @@ -2044,6 +2112,7 @@ Mesh_complex_3_in_triangulation_3(Self&& rhs) : Base() , tr_(std::move(rhs.tr_)) , edge_facet_counter_(std::move(rhs.edge_facet_counter_)) + , surface_facet_info_(std::move(rhs.surface_facet_info_)) , manifold_info_initialized_(std::exchange(rhs.manifold_info_initialized_, false)) , edges_(std::move(rhs.edges_)) , corners_(std::move(rhs.corners_)) From d03d86cf01a50927d4a8cdabb83ed3555d3270b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 28 Feb 2026 00:10:38 +0100 Subject: [PATCH 046/127] Remove extra semicolon --- SMDS_3/include/CGAL/IO/File_medit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SMDS_3/include/CGAL/IO/File_medit.h b/SMDS_3/include/CGAL/IO/File_medit.h index e6ec4f8dab9a..ad39e29fbcd2 100644 --- a/SMDS_3/include/CGAL/IO/File_medit.h +++ b/SMDS_3/include/CGAL/IO/File_medit.h @@ -788,7 +788,7 @@ void write_MEDIT(std::ostream& os, using parameters::get_parameter; using parameters::choose_parameter; - bool renumber_subdomain_indices = choose_parameter(get_parameter(np, internal_np::rebind_labels), false);; + bool renumber_subdomain_indices = choose_parameter(get_parameter(np, internal_np::rebind_labels), false); bool show_patches = choose_parameter(get_parameter(np, internal_np::show_patches), true); bool all_c = choose_parameter(get_parameter(np, internal_np::all_cells), true); bool all_v = all_c || choose_parameter(get_parameter(np, internal_np::all_vertices), true); From 90caef23b4a734733421d84cd86a90d089de8c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 28 Feb 2026 02:44:19 +0100 Subject: [PATCH 047/127] Fix some std::size_t that should be int's --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index ae6b55154322..e64c90ad3779 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -1509,7 +1509,7 @@ class Mesh_complex_3_in_triangulation_3 Face_status face_status(const Vertex_handle v) const { if (!manifold_info_initialized_) init_manifold_info(); - const std::size_t n = v->cached_number_of_incident_facets(); + const int n = v->cached_number_of_incident_facets(); if (n == 0) return NOT_IN_COMPLEX; @@ -1814,7 +1814,7 @@ class Mesh_complex_3_in_triangulation_3 ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; } - const std::size_t n = edge_va->cached_number_of_incident_facets(); + const int n = edge_va->cached_number_of_incident_facets(); edge_va->set_c2t3_cache(n + 1, -1); } } @@ -2307,9 +2307,9 @@ remove_from_complex(const Facet& facet) --edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; } - const std::size_t n = edge_va->cached_number_of_incident_facets(); + const int n = edge_va->cached_number_of_incident_facets(); CGAL_assertion(n > 0); - const std::size_t m = edge_va->cached_number_of_components(); + const int m = edge_va->cached_number_of_components(); edge_va->set_c2t3_cache(n - 1, m); } const int dimension_plus_1 = tr_.dimension() + 1; From d8aeca534f978f5136818ca191a4f0440ecedf0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 28 Feb 2026 02:44:55 +0100 Subject: [PATCH 048/127] Revert (at no mem cost) some mesh vertex base optimizations The initilizaton at -1 yields regressions. Since with the current alignment a Boolean costs nothing, let's revert. But in theory, it should be removable, and the init_manifold_...() function can be adapted with '0' default values. --- Mesh_3/include/CGAL/Mesh_vertex_base_3.h | 55 +++++++++++++----------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h index 1efe722a938d..1443b67e482c 100644 --- a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h @@ -104,9 +104,10 @@ template class Mesh_vertex_3 -: public Vb, - public Mesh_vertex_base_3_base< - typename Vb::Triangulation_data_structure::Concurrency_tag> +: public Mesh_vertex_base_3_base< + typename Vb::Triangulation_data_structure::Concurrency_tag>, + public Vb + { public: typedef Vb Cmvb3_base; @@ -120,13 +121,16 @@ class Mesh_vertex_3 // Constructor Mesh_vertex_3() : Vb() + , dimension_(-1) + , cache_validity(false) + , index_() + , number_of_incident_facets_(0) + , number_of_components_(0) + , meshing_info_(0) #ifdef CGAL_INTRUSIVE_LIST , next_intrusive_() , previous_intrusive_() #endif //CGAL_INTRUSIVE_LIST - , meshing_info_(0) - , index_() - , dimension_(-1) {} // Default copy constructor and assignment operator are ok @@ -193,20 +197,18 @@ class Mesh_vertex_3 ///@} bool is_c2t3_cache_valid() const { - return number_of_incident_facets_ != -1 && - number_of_components_ != -1; + return cache_validity; } - void invalidate_c2t3_cache() - { - number_of_incident_facets_ = -1; - number_of_components_ = -1; + void invalidate_c2t3_cache() { + cache_validity = false; } void set_c2t3_cache(const int i, const int j) { number_of_incident_facets_ = i; number_of_components_ = j; + cache_validity = true; } int cached_number_of_incident_facets() const @@ -229,28 +231,29 @@ class Mesh_vertex_3 } private: -#ifdef CGAL_INTRUSIVE_LIST - Vertex_handle next_intrusive_; - Vertex_handle previous_intrusive_; -#endif - - std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; + short dimension_; - // Stores info needed by optimizers - FT meshing_info_; + // Dimension of the lowest dimensional face of the input 3D complex + // that contains me. Negative values are a marker for special vertices. + bool cache_validity; // Index of the lowest dimensional face of the input 3D complex // that contains me Index index_; - // Dimension of the lowest dimensional face of the input 3D complex - // that contains me. Negative values are a marker for special vertices. - short dimension_; - - int number_of_incident_facets_ = -1; - int number_of_components_ = -1; // number of components in the adjacency + int number_of_incident_facets_; + int number_of_components_; // number of components in the adjacency // graph of incident facets (in complex) + // Stores info needed by optimizers + FT meshing_info_; + +#ifdef CGAL_INTRUSIVE_LIST + Vertex_handle next_intrusive_; + Vertex_handle previous_intrusive_; +#endif + std::size_t time_stamp_ = std::size_t(-2); + public: friend std::istream& operator>>(std::istream &is, Mesh_vertex_3& v) { From fe49620fcca24a4a52eebd87210ccca2b41b49d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 28 Feb 2026 02:47:19 +0100 Subject: [PATCH 049/127] Simplify code to compute a canonical facet --- SMDS_3/include/CGAL/IO/File_medit.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/SMDS_3/include/CGAL/IO/File_medit.h b/SMDS_3/include/CGAL/IO/File_medit.h index ad39e29fbcd2..b747fe3f7bc4 100644 --- a/SMDS_3/include/CGAL/IO/File_medit.h +++ b/SMDS_3/include/CGAL/IO/File_medit.h @@ -576,11 +576,10 @@ output_to_medit(std::ostream& os, auto [c, index] = f; // Apply priority among subdomains, to get consistent facet orientation per subdomain-pair interface. if (print_each_facet_twice) { - auto mirror_facet = tr.mirror_facet(f); - [[maybe_unused]] auto [c2, _] = mirror_facet; + auto n = c->neighbor(index); // NOTE: We mirror a facet when needed to make it consistent with Use_cell_indices_pmap. - if (get(cell_pmap, c) > get(cell_pmap, c2)) { - f = mirror_facet; + if (get(cell_pmap, c) > get(cell_pmap, n)) { + f = {n, n->index(c)}; } } From fefae5b06878f0629a2acef4436ef972d64e2bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 28 Feb 2026 02:47:44 +0100 Subject: [PATCH 050/127] Fix not removing facets from the complex during perturbation --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index e64c90ad3779..ecf07a661e1b 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -802,6 +802,20 @@ class Mesh_complex_3_in_triangulation_3 { Triangulation& tr = triangulation(); + std::vector old_cells; + old_cells.reserve(32); + tr.incident_cells(v, std::back_inserter(old_cells)); + + for (const Cell_handle& c : old_cells) + { + remove_from_complex(c); + for (int i = 0; i < 4; ++i) { + // Do *not* call the C3T3's remove_from_complex() because the information + // on the opposite facet must not be cleared for boundary facets. + set_surface_patch_index(c, i, Surface_patch_index()); + } + } + std::vector new_cells; new_cells.reserve(32); tr.remove_and_give_new_cells(v, std::back_inserter(new_cells)); From e732287923a18ce248aad7996bb411be349216a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 28 Feb 2026 02:48:45 +0100 Subject: [PATCH 051/127] Misc enhancements and fixes in Mesh_3/tests --- Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp | 2 + .../test/Mesh_3/test_meshing_determinism.cpp | 154 ++++++++++-------- ...ral_complex_with_manifold_and_min_size.cpp | 2 + Mesh_3/test/Mesh_3/test_meshing_utilities.h | 14 +- 4 files changed, 104 insertions(+), 68 deletions(-) diff --git a/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp b/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp index 47727fa936b3..9a01afad1405 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_3D_image.cpp @@ -90,5 +90,7 @@ int main() test_epic_p.image(); #endif + std::cout << "Done" << std::endl; + return EXIT_SUCCESS; } diff --git a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp index 05a5afa3c599..485b65d6b6e4 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp @@ -32,6 +32,7 @@ void test() unsigned int nb_odt = 2; double perturb_bound = 10.; double exude_bound = 15.; + std::size_t nb_operations = 5; // Domain typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -70,85 +71,110 @@ void test() std::vector output_c3t3; std::vector output_surfaces; - const std::size_t nb_operations = 5; - output_c3t3.reserve(nb_operations * nb_runs); for(std::size_t i = 0; i < nb_runs; ++i) { std::cout << "------- Iteration " << (i+1) << " -------" << std::endl; - C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, - no_perturb(), - no_exude()); - std::ostringstream oss; - CGAL::IO::write_MEDIT(oss, c3t3); - output_c3t3.push_back(oss.str()); //[5*i] - oss.clear(); - Polyhedron out_poly; - CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); - oss << out_poly; - output_surfaces.push_back(oss.str());//[5*i] - out_poly.clear(); - oss.clear(); - - //LLOYD (1) - CGAL::lloyd_optimize_mesh_3(c3t3, domain, max_iteration_number = nb_lloyd); - CGAL::IO::write_MEDIT(oss, c3t3); - output_c3t3.push_back(oss.str());//[i*5+1] - oss.clear(); - CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); - oss << out_poly; - output_surfaces.push_back(oss.str());//[i*5+1] - out_poly.clear(); - oss.clear(); - - //ODT (2) - CGAL::odt_optimize_mesh_3(c3t3, domain, max_iteration_number = nb_odt); - CGAL::IO::write_MEDIT(oss, c3t3); - output_c3t3.push_back(oss.str());//[i*5+2] - oss.clear(); - CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); - oss << out_poly; - output_surfaces.push_back(oss.str());//[i*5+2] - out_poly.clear(); - oss.clear(); - - //PERTURB (3) - CGAL::perturb_mesh_3(c3t3, domain, sliver_bound=perturb_bound); - CGAL::IO::write_MEDIT(oss, c3t3); - output_c3t3.push_back(oss.str());//[i*5+3] - oss.clear(); - CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); - oss << out_poly; - output_surfaces.push_back(oss.str());//[i*5+3] - out_poly.clear(); - oss.clear(); - - //EXUDE (4) - CGAL::exude_mesh_3(c3t3, sliver_bound=exude_bound); - CGAL::IO::write_MEDIT(oss, c3t3); - output_c3t3.push_back(oss.str());//[i*5+4] - oss.clear(); - CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); - oss << out_poly; - output_surfaces.push_back(oss.str());//[i*5+4] - out_poly.clear(); - oss.clear(); + + C3t3 c3t3; + + if (nb_operations >= 1) { + std::cout << " #1 Meshing..." << std::endl; + c3t3 = CGAL::make_mesh_3(domain, criteria, + no_perturb(), + no_exude()); + + std::stringstream oss; + CGAL::IO::write_MEDIT(oss, c3t3); + output_c3t3.push_back(oss.str()); //[5*i] + + std::stringstream oss_p; + Polyhedron out_poly; + CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); + oss_p << out_poly; + output_surfaces.push_back(oss_p.str());//[5*i] + } + + // LLOYD (1) + if (nb_operations >= 2) { + std::cout << " #2 Lloyd..." << std::endl; + CGAL::lloyd_optimize_mesh_3(c3t3, domain, max_iteration_number = nb_lloyd); + + std::stringstream oss; + CGAL::IO::write_MEDIT(oss, c3t3); + output_c3t3.push_back(oss.str());//[i*5+1] + + std::stringstream oss_p; + Polyhedron out_poly; + CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); + oss_p << out_poly; + output_surfaces.push_back(oss_p.str());//[i*5+1] + } + + // ODT (2) + if (nb_operations >= 3) { + std::cout << " #3 ODT..." << std::endl; + CGAL::odt_optimize_mesh_3(c3t3, domain, max_iteration_number = nb_odt); + + std::stringstream oss; + CGAL::IO::write_MEDIT(oss, c3t3); + output_c3t3.push_back(oss.str());//[i*5+2] + + std::stringstream oss_p; + Polyhedron out_poly; + CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); + oss_p << out_poly; + output_surfaces.push_back(oss_p.str());//[i*5+2] + } + + // PERTURB (3) + if (nb_operations >= 4) { + std::cout << " #4 Pertub..." << std::endl; + CGAL::perturb_mesh_3(c3t3, domain, sliver_bound=perturb_bound); + + std::stringstream oss; + CGAL::IO::write_MEDIT(oss, c3t3); + output_c3t3.push_back(oss.str());//[i*5+3] + std::cout << "oss " << oss.str() << std::endl; + + std::stringstream oss_p; + Polyhedron out_poly; + CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); + oss_p << out_poly; + output_surfaces.push_back(oss_p.str());//[i*5+3] + } + + // EXUDE (4) + if (nb_operations >= 5) { + std::cout << " #5 Exude..." << std::endl; + CGAL::exude_mesh_3(c3t3, sliver_bound=exude_bound); + + std::stringstream oss; + CGAL::IO::write_MEDIT(oss, c3t3); + output_c3t3.push_back(oss.str());//[i*5+4] + + std::stringstream oss_p; + Polyhedron out_poly; + CGAL::facets_in_complex_3_to_triangle_mesh(c3t3, out_poly); + oss_p << out_poly; + output_surfaces.push_back(oss_p.str());//[i*5+4] + } if(i == 0) continue; //else check - for(std::size_t j = 0; j < nb_operations; ++j) + for(std::size_t j=1; j<=nb_operations; ++j) { - std::size_t id1 = nb_operations * (i - 1) + j; - std::size_t id2 = nb_operations * i + j; + std::size_t id1 = nb_operations * (i - 1) + (j-1); + std::size_t id2 = nb_operations * i + (j-1); if(0 != output_c3t3[id1].compare(output_c3t3[id2])) { - std::cerr << "Meshing operation " << j << " is not deterministic.\n"; + std::cerr << "Meshing operation #" << j << " is not deterministic.\n"; assert(false); } if (0 != output_surfaces[id1].compare(output_surfaces[id2])) { - std::cerr << "Output surface after operation " << j << " is not deterministic.\n"; + std::cerr << "Output surface after operation #" << j << " is not deterministic.\n"; assert(false); } } diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex_with_manifold_and_min_size.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex_with_manifold_and_min_size.cpp index f807119f966f..1ae17f3e2c34 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex_with_manifold_and_min_size.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedral_complex_with_manifold_and_min_size.cpp @@ -85,5 +85,7 @@ int main() CGAL::IO::write_MEDIT(medit_file, c3t3); medit_file.close(); + std::cout << "Done" << std::endl; + return EXIT_SUCCESS; } diff --git a/Mesh_3/test/Mesh_3/test_meshing_utilities.h b/Mesh_3/test/Mesh_3/test_meshing_utilities.h index 72e2a245c311..56914ece70eb 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_utilities.h +++ b/Mesh_3/test/Mesh_3/test_meshing_utilities.h @@ -208,14 +208,20 @@ struct Tester //------------------------------------------------------- // Verifications //------------------------------------------------------- - std::cerr << "\tNumber of cells: " << c3t3.number_of_cells_in_complex() << "\n"; - std::cerr << "\tNumber of facets: " << c3t3.number_of_facets_in_complex() << "\n"; - std::cerr << "\tNumber of vertices: " << c3t3.triangulation().number_of_vertices() << "\n"; + std::cerr << "\tNumber of cells: " << c3t3.number_of_cells_in_complex() << " "; + std::cerr << "[expected: " << min_cells_expected << " - " << max_cells_expected << "]\n"; + std::cerr << "\tNumber of facets: " << c3t3.number_of_facets_in_complex() << " "; + std::cerr << "[expected: " << min_facets_expected << " - " << max_facets_expected << "]\n"; + std::cerr << "\tNumber of vertices: " << c3t3.triangulation().number_of_vertices() << " "; + std::cerr << "[expected: " << min_vertices_expected << " - " << max_vertices_expected << "]\n"; std::size_t dist_facets ( std::distance(c3t3.facets_in_complex_begin(), c3t3.facets_in_complex_end()) ); std::size_t dist_cells ( std::distance(c3t3.cells_in_complex_begin(), - c3t3.cells_in_complex_end()) ); + c3t3.cells_in_complex_end()) ); + + std::cout << "dist_facets " << dist_facets << std::endl; + std::cout << "dist_cells " << dist_cells << std::endl; assert(min_vertices_expected <= c3t3.triangulation().number_of_vertices()); assert(max_vertices_expected >= c3t3.triangulation().number_of_vertices()); From e754ecf368afe6b2084885e7602349c0aa3cfd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 28 Feb 2026 16:36:37 +0100 Subject: [PATCH 052/127] Do not assume the triangulation has a bare point --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index ecf07a661e1b..bc3320b6009f 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -200,8 +200,10 @@ class Mesh_complex_3_in_triangulation_3 /// @{ typedef Tr Triangulation; typedef typename Tr::size_type size_type; - typedef typename Tr::Bare_point Bare_point; + + typedef typename Tr::Geom_traits::Point_3 Bare_point; typedef typename Tr::Point Point; + typedef typename Tr::Edge Edge; typedef typename Tr::Facet Facet; typedef typename Tr::Vertex_handle Vertex_handle; From ab65fe3863a98e5c69d8d59c6e0c3753ceadaf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 28 Feb 2026 16:40:08 +0100 Subject: [PATCH 053/127] Misc cleaning --- Mesh_3/include/CGAL/Mesh_3/Mesher_3.h | 6 +++--- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h index 63768b13d826..aeb0c9fae2c4 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h @@ -627,9 +627,9 @@ refine_mesh(std::string dump_after_refine_surface_prefix, const bool surface_onl std::cerr << std::endl; // memory footprint of r_c3t3_.surface_facet_info_ - std::cout << "final surfacic element map size:" << std::endl; - std::cout << " surface facet info: " << r_c3t3_.surface_facet_info_.size() << std::endl; - std::cout << " surface facet info size in bytes: " + std::cout << "final surface info map size:" << std::endl; + std::cout << " surface facet size: " << r_c3t3_.surface_facet_info_.size() << std::endl; + std::cout << " surface facet mem footprint bytes: " << r_c3t3_.surface_facet_info_.size() * sizeof(typename C3T3::Surface_facet_info) << std::endl; CGAL_postcondition(r_tr.is_valid()); diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index b3a60a3a75ec..e2a131fcb8db 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -951,10 +951,9 @@ Refine_cells_3:: insert_impl(const Weighted_point& point, const Zone& zone) { - // @tmp - // Remove the cell's facets from the complex + // Remove the cell's facets from the complex (and from the hash map). // Do *not* call the C3T3's remove_from_complex() because the information - // on the opposite facet should not be cleared for boundary facets + // on the opposite facet must not be cleared for boundary facets. auto cit = zone.cells.begin(); for ( ; cit != zone.cells.end() ; ++cit ) { From 81d3e6ecc87a58d628a4487dcfcfdaf3ea637545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 28 Feb 2026 21:35:14 +0100 Subject: [PATCH 054/127] Fix leaving uninitialized prop table entries during perturb backup --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index ee512f587060..bf4f4034c2c5 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1383,6 +1383,8 @@ class C3T3_helpers const int ii = static_cast(i);//avoid warnings if (c3t3.is_in_complex(Facet(c, ii))) surface_prop_table_[i] = c3t3.surface_info(Facet(c, ii)); + else + surface_prop_table_[i] = {}; } //note c->next_intrusive() and c->previous_intrusive() //are lost by 'backup' and 'restore', @@ -1396,6 +1398,8 @@ class C3T3_helpers int infinite_index = c->index(c3t3.triangulation().infinite_vertex()); if (c3t3.is_in_complex(Facet(c, infinite_index))) surface_prop_table_[0] = c3t3.surface_info(Facet(c, infinite_index)); + else + surface_prop_table_[0] = {}; } public: From f0774201d236a70f29ef782dc4b2e9bf781d1fd1 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 2 Mar 2026 14:21:44 +0100 Subject: [PATCH 055/127] P3T3/Tr_helpers: missing #include --- .../include/CGAL/Periodic_3_mesh_3/Triangulation_helpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Triangulation_helpers.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Triangulation_helpers.h index a3b84d730a26..f2b0383b6837 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Triangulation_helpers.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Triangulation_helpers.h @@ -20,7 +20,7 @@ #include #include - +#include #include namespace CGAL { From 2c882e5a57fb805f9276b62159b5738fd33376ce Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 2 Mar 2026 14:23:15 +0100 Subject: [PATCH 056/127] Mesh_3: missing #include --- .../CGAL/Mesh_3/Construct_initial_points_labeled_image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Construct_initial_points_labeled_image.h b/Mesh_3/include/CGAL/Mesh_3/Construct_initial_points_labeled_image.h index 6098b2674199..37617efc4519 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Construct_initial_points_labeled_image.h +++ b/Mesh_3/include/CGAL/Mesh_3/Construct_initial_points_labeled_image.h @@ -16,7 +16,7 @@ #include #include - +#include #include #include #include From a33383ac899278b2130aa6031c40209bf02738ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 5 Mar 2026 09:25:31 +0100 Subject: [PATCH 057/127] fix doc warnings --- Mesh_3/include/CGAL/Mesh_cell_criteria_3.h | 2 +- Mesh_3/include/CGAL/Mesh_facet_criteria_3.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h b/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h index 6c1d0421c370..786d1c9e9c87 100644 --- a/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h @@ -150,7 +150,7 @@ class Mesh_cell_criteria_3 /** * @brief returns whether the cell `cell` is bad or not. - * @param tr the triangulation within which `cell` lives + * @param c3t3 the mesh complex within which `cell` lives * @param cell the cell */ Is_cell_bad operator()(const C3T3& c3t3, const Cell_handle& cell) const diff --git a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h index 8ff951c84b81..b5af488e2be7 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h @@ -163,7 +163,7 @@ class Mesh_facet_criteria_3 /** * @brief returns whether the facet `facet` is bad or not. * - * @param tr the triangulation within which `facet` lives + * @param c3t3 the mesh complex within which `facet` lives * @param facet the facet */ Is_facet_bad operator()(const C3T3& c3t3, const Facet& facet) const From 99873b168032f6a596fa598a2a1a330eb3791723 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 4 Mar 2026 08:06:16 +0100 Subject: [PATCH 058/127] minor change to display on std::cerr --- Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h index d4cebcab2bba..6c3717c6560b 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h +++ b/Lab/demo/Lab/Plugins/Mesh_3/Mesh_function.h @@ -409,10 +409,8 @@ launch() 0, &stop_); -#ifdef CGAL_MESH_3_PROFILING CGAL::Real_timer t; t.start(); -#endif #if CGAL_MESH_3_MESHER_STATUS_ACTIVATED mesher_->initialize(); @@ -430,7 +428,8 @@ launch() // Ensure c3t3 is ok (useful if process has been stop by the user) mesher_->fix_c3t3(); - std::cerr<<"Done."< Date: Thu, 5 Mar 2026 12:40:11 +0100 Subject: [PATCH 059/127] Fix compilation of Mesh_3/benchmark --- Mesh_3/benchmark/Mesh_3/benchmark_mesh_3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mesh_3/benchmark/Mesh_3/benchmark_mesh_3.cpp b/Mesh_3/benchmark/Mesh_3/benchmark_mesh_3.cpp index f8be26f174ac..bb0deeda7810 100644 --- a/Mesh_3/benchmark/Mesh_3/benchmark_mesh_3.cpp +++ b/Mesh_3/benchmark/Mesh_3/benchmark_mesh_3.cpp @@ -148,7 +148,7 @@ enum Exit_code // the call to Mesh_3 happens here template Exit_code make_mesh(const Domain& domain, - const CGAL::Mesh_criteria_3& criteria, + const CGAL::Mesh_criteria_3& criteria, const std::string& output_filename) { #ifdef _DEBUG @@ -244,7 +244,7 @@ Exit_code make_mesh(const Domain& domain, double cell_sizing, double cell_shape, const std::string& output_filename) { - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; const CGAL::Bbox_3 bbox = domain.bbox(); From 18f12590c399b3bae4b21e089a4b0c5db03b68df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2026 12:41:28 +0100 Subject: [PATCH 060/127] C3T3 I/O: Squat meshing_info() if available + avoid stringstream --- SMDS_3/include/CGAL/IO/File_medit.h | 59 +++++++++++++++++++---------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/SMDS_3/include/CGAL/IO/File_medit.h b/SMDS_3/include/CGAL/IO/File_medit.h index b747fe3f7bc4..20921d45f45b 100644 --- a/SMDS_3/include/CGAL/IO/File_medit.h +++ b/SMDS_3/include/CGAL/IO/File_medit.h @@ -20,10 +20,11 @@ #include #include -#include #include -#include #include +#include +#include +#include #include @@ -500,7 +501,7 @@ struct Medit_pmap_generator())>::type>::value; + std::unordered_map V; int inum = 1; - std::ostringstream oss; - oss.precision(os.precision()); - for(auto v: vertices) { - auto& v_num = V[v]; - if(v_num != 0) return; - v_num = inum++; + os << "Vertices\n" << vertices.size() << "\n"; + + // Assign unique ids to all vertices in the range, just like the map + for(auto v : vertices) { + if constexpr (use_meshing_info) { + v->set_meshing_info(inum++); + } else { + V[v] = inum++; + } + const auto& p = tr.point(v); - oss << CGAL::to_double(p.x()) << ' ' - << CGAL::to_double(p.y()) << ' ' - << CGAL::to_double(p.z()) << ' ' - << get(vertex_pmap, v) - << '\n'; + os << CGAL::to_double(p.x()) << ' ' + << CGAL::to_double(p.y()) << ' ' + << CGAL::to_double(p.z()) << ' ' + << get(vertex_pmap, v) + << '\n'; } - os << "Vertices\n" << V.size() << "\n"; - os << oss.str(); //------------------------------------------------------- // Facets @@ -586,12 +592,20 @@ output_to_medit(std::ostream& os, // Get facet vertices in CCW order. auto [vh1, vh2, vh3] = tr.vertices(f); - os << V[vh1] << ' ' << V[vh2] << ' ' << V[vh3] << ' '; + if constexpr (use_meshing_info) { + os << vh1->meshing_info() << ' ' << vh2->meshing_info() << ' ' << vh3->meshing_info() << ' '; + } else { + os << V[vh1] << ' ' << V[vh2] << ' ' << V[vh3] << ' '; + } os << get(facet_pmap, f) << '\n'; // Print triangle again if needed, with opposite orientation if (print_each_facet_twice) { - os << V[vh3] << ' ' << V[vh2] << ' ' << V[vh1] << ' '; + if constexpr (use_meshing_info) { + os << vh3->meshing_info() << ' ' << vh2->meshing_info() << ' ' << vh1->meshing_info() << ' '; + } else { + os << V[vh3] << ' ' << V[vh2] << ' ' << V[vh1] << ' '; + } os << get(facet_twice_pmap, f) << '\n'; } } @@ -602,8 +616,13 @@ output_to_medit(std::ostream& os, os << "Tetrahedra\n" << size(cells) << '\n'; for (const auto& c : cells) { - for (auto v : tr.vertices(c)) - os << V[v] << ' '; + for (auto v : tr.vertices(c)) { + if constexpr (use_meshing_info) { + os << v->meshing_info() << ' '; + } else { + os << V[v] << ' '; + } + } os << get(cell_pmap, c) << '\n'; } From 6634da06a49e1f498c6a76cd9f3cdc111aeb4be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2026 12:41:56 +0100 Subject: [PATCH 061/127] Avoid copying weighted circumcenters --- Triangulation_3/include/CGAL/Regular_triangulation_3.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 69c2a00a4104..02b984282b86 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -998,7 +998,7 @@ class Regular_triangulation_3 bool is_Gabriel(Vertex_handle v) const; // Dual functions - Bare_point dual(Cell_handle c) const; + decltype(auto) dual(Cell_handle c) const; Object dual(Cell_handle c, int i) const; Object dual(const Facet& facet) const; @@ -1751,7 +1751,7 @@ nearest_power_vertex(const Bare_point& p, Cell_handle start) const } template < class Gt, class Tds, class Lds > -typename Regular_triangulation_3::Bare_point +decltype(auto) Regular_triangulation_3:: dual(Cell_handle c) const { @@ -1764,7 +1764,7 @@ dual(Cell_handle c) const template < class Gt, class Tds, class Lds > void Regular_triangulation_3:: -dual_segment(Cell_handle c, int i, Bare_point& p, Bare_point&q) const +dual_segment(Cell_handle c, int i, Bare_point& p, Bare_point& q) const { Cell_handle n = c->neighbor(i); CGAL_assertion(! is_infinite(c) && ! is_infinite(n)); @@ -1947,8 +1947,8 @@ dual(Cell_handle c, int i) const if(! is_infinite(c) && ! is_infinite(n)) { // dual is a segment - Bare_point bp = dual(c); - Bare_point np = dual(n); + const auto& bp = dual(c); + const auto& np = dual(n); return construct_object(construct_segment(bp, np)); } From 4c128537499612dba1e8dca423f8d2de65235fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 10 Mar 2026 00:47:30 +0100 Subject: [PATCH 062/127] Misc fixes --- Generator/test/Generator/generic_random_test.cpp | 2 +- Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h | 1 - Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 4 ++-- Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h | 8 ++++---- Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h | 2 +- Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h | 9 ++++----- SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h | 2 +- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Generator/test/Generator/generic_random_test.cpp b/Generator/test/Generator/generic_random_test.cpp index 44690642f301..378867f250d1 100644 --- a/Generator/test/Generator/generic_random_test.cpp +++ b/Generator/test/Generator/generic_random_test.cpp @@ -53,7 +53,7 @@ typedef Mesh_domain::Curve_index Curve_index; typedef CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr, Corner_index, Curve_index> C3t3; -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef C3t3::Point Point; int test_triangles_2(const FT eps) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 3f1d082a83ed..41cb69919fab 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -256,7 +256,6 @@ class Compact_mesh_cell_base_3_base #endif // CGAL_LINKED_WITH_TBB - // Class Compact_mesh_cell_base_3 // Cell base class used in 3D meshing process. // Adds information to Cb about the cell of the input complex containing it diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 3e8a4c27f6b0..c74655c44a9b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -608,8 +608,8 @@ class C3T3_helpers_base template class C3T3_helpers -: public C3T3_helpers_base + : public C3T3_helpers_base { // ----------------------------------- // Private types diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h index 3f6b2bf536d2..b59a694ebee7 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h @@ -39,10 +39,6 @@ #include #endif -#include -#include -#include - #ifdef CGAL_LINKED_WITH_TBB # include # include @@ -50,6 +46,10 @@ # include #endif +#include +#include +#include + namespace CGAL { namespace Mesh_3 { diff --git a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h index 2c61270f9955..b5a765aabb67 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h +++ b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h @@ -422,7 +422,7 @@ class Sliver_perturber_base template < typename C3T3, typename MeshDomain, typename SliverCriterion = Mesh_3::Min_dihedral_angle_criterion - , + , typename Visitor_ = Null_perturber_visitor > class Sliver_perturber : public Sliver_perturber_basesecond.second == Subdomain_index() ) ) c3t3_.add_to_complex(*cit, it->second.second); - // if the new cell is in the domain, and it criterion value is less that + // if the new cell is in the domain, and its criterion value is less that // the maximum, push it in the cells queue. if( c3t3_.is_in_complex(*cit) ) { FT criterion_value = sliver_criteria_(*cit); - if( criterion_value < sliver_criteria_.sliver_bound() ) add_cell_to_queue(*cit, criterion_value); } @@ -1655,7 +1654,7 @@ check_pre_star(const Pre_star& pre_star, if(! tr_.is_infinite(opposite_facet.first) ) { pre_star2.insert( - *fit, tr_.compute_power_distance_to_power_sphere(opposite_facet.first, v)); + *fit, Th().compute_power_distance_to_power_sphere(tr_, opposite_facet.first, v)); } } @@ -1784,8 +1783,8 @@ template bool Slivers_exuder:: check_ratios(const Sliver_values& criterion_values, - const Weighted_point& wp, - const Vertex_handle& vh) const + const Weighted_point& wp, + const Vertex_handle& vh) const { Cell_vector deleted_cells; Facet_vector internal_facets; diff --git a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h index 8295dc67844f..b28da674ae6c 100644 --- a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h +++ b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h @@ -208,8 +208,8 @@ private : Get_io_signature()() + "+" + Get_io_signature()(); } -private: +private: int number_of_incident_facets_ = 0; int number_of_components_ = 0; // number of components in the adjacency // graph of incident facets (in complex) From ba47641731fbfe20ea19c64b3efb3be7ba784670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 12 Mar 2026 01:22:21 +0100 Subject: [PATCH 063/127] Move sliver value caching out of the compact mesh cell base --- .../include/CGAL/Compact_mesh_cell_base_3.h | 16 +- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 267 ++++++++---------- Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h | 18 +- .../include/CGAL/Mesh_3/Sliver_value_cache.h | 156 ++++++++++ Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h | 19 +- Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h | 104 +++++-- 6 files changed, 381 insertions(+), 199 deletions(-) create mode 100644 Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 41cb69919fab..20fa4a53284b 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -315,9 +315,11 @@ class Compact_mesh_cell_3 , previous_intrusive_(rhs.previous_intrusive_) #endif , time_stamp_(rhs.time_stamp_) +#ifndef CGAL_MESH_3_NO_SLIVER_VALUE , sliver_value_(rhs.sliver_value_) -#ifndef CGAL_MESH_3_NO_SLIVER_CACHE +# ifndef CGAL_MESH_3_NO_SLIVER_CACHE , sliver_cache_validity_(false) +# endif #endif { #ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL @@ -524,6 +526,7 @@ class Compact_mesh_cell_3 void set_subdomain_index(const Subdomain_index& index) { subdomain_index_ = index; } +#ifndef CGAL_MESH_3_NO_SLIVER_VALUE void set_sliver_value(double value) { #ifndef CGAL_MESH_3_NO_SLIVER_CACHE @@ -545,6 +548,7 @@ class Compact_mesh_cell_3 bool is_cache_valid() const { return sliver_cache_validity_; } void reset_cache_validity() const { sliver_cache_validity_ = false; } #endif +#endif // CGAL_MESH_3_NO_SLIVER_VALUE #ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL /// Set surface index of `facet` to `index` @@ -668,10 +672,12 @@ class Compact_mesh_cell_3 std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; -#ifdef CGAL_MESH_3_NO_SLIVER_CACHE +#ifndef CGAL_MESH_3_NO_SLIVER_VALUE +# ifdef CGAL_MESH_3_NO_SLIVER_CACHE double sliver_value_ = -2.; -#else +# else double sliver_value_ = 0.; +# endif #endif // -- Below is unused -- @@ -687,8 +693,10 @@ class Compact_mesh_cell_3 std::array surface_center_index_table_ = {}; #endif -#ifndef CGAL_MESH_3_NO_SLIVER_CACHE +#ifndef CGAL_MESH_3_NO_SLIVER_VALUE +# ifndef CGAL_MESH_3_NO_SLIVER_CACHE mutable bool sliver_cache_validity_ = false; +# endif #endif public: diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index c74655c44a9b..4a80e028ec83 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -922,16 +922,6 @@ class C3T3_helpers const SliverCriterion& criterion, const bool use_cache = true) const; - /** - * Reset cache validity of all cells of c3t3_ - */ - void reset_cache() const - { - for(typename C3T3::Cells_in_complex_iterator it = c3t3_.cells_in_complex_begin(); - it != c3t3_.cells_in_complex_end(); ++it) - it->reset_cache_validity(); - } - private: // ----------------------------------- // Useful Functors @@ -1010,28 +1000,19 @@ class C3T3_helpers const FT& bound = 0) : c3t3_(c3t3) , criterion_(criterion) - , bound_(bound) { } + , bound_(bound) + { + CGAL_assertion(bound_ <= criterion_.sliver_bound()); + } bool operator()(const Cell_handle& c) const { if ( c3t3_.is_in_complex(c) ) { - CGAL_assertion(!c3t3_.triangulation().is_infinite(c)); - - if ( ! c->is_cache_valid() ) - { - Sliver_criterion_value sc_value(c3t3_.triangulation(), - criterion_); - (void) sc_value(c); // 'sc_value::operator()' updates the cache of 'c' - } + if (bound_ > 0) + return (criterion_(c) <= bound_); else - { - CGAL_expensive_assertion(c->sliver_value() == criterion_(c)); - } - if(bound_ > 0) - return ( c->sliver_value() <= bound_ ); - else - return ( c->sliver_value() <= criterion_.sliver_bound() ); + return criterion_.is_sliver(c); } else return false; @@ -1263,52 +1244,13 @@ class C3T3_helpers }; // end class Facet_updater - - /** - * @class Sliver_criterion_value - * - * A functor which returns sliver criterion value for a Cell_handle - * and updates its cache value - */ - template - class Sliver_criterion_value - : public CGAL::cpp98::unary_function - { - public: - Sliver_criterion_value(const Tr& tr, - const SliverCriterion& criterion) - : p_tr_(&tr) - , criterion_(criterion) {} - - FT operator()(const Cell_handle& ch) const - { - CGAL_precondition(!p_tr_->is_infinite(ch)); - - if ( ! ch->is_cache_valid() ) - { - double sliver_value = criterion_(ch); - ch->set_sliver_value(sliver_value); - } - else - { - CGAL_expensive_assertion(ch->sliver_value() == criterion_(ch)); - } - return ch->sliver_value(); - } - - private: - // '=' is used, so p_tr_ must be a pointer ... - const Tr* p_tr_; - SliverCriterion criterion_; - }; - /** * to be used by the perturber */ class Cell_from_ids { public: - Cell_from_ids(const C3T3& c3t3, const Cell_handle& c) + Cell_from_ids(const Cell_handle& c, const C3T3& c3t3) : infinite_(c3t3.triangulation().is_infinite(c)) , vertices_() , sorted_vertices_() @@ -1353,10 +1295,12 @@ class C3T3_helpers typedef std::array IndexMap; public: - Cell_data_backup(const C3T3& c3t3, - const Cell_handle& c, + template + Cell_data_backup(const Cell_handle& c, + const C3T3& c3t3, + const SliverCriterion& criterion, const bool do_backup = true) - : cell_ids_(c3t3, c) + : cell_ids_(c, c3t3) { //backup is not done when constructor is called to //convert a newly created cell (has nothing to backup) @@ -1364,20 +1308,19 @@ class C3T3_helpers if(do_backup) { if (!c3t3.triangulation().is_infinite(c)) - backup_finite_cell(c, c3t3); + backup_finite_cell(c, c3t3, criterion); else backup_infinite_cell(c, c3t3); } } private: + template void backup_finite_cell(const Cell_handle& c, - const C3T3& c3t3) + const C3T3& c3t3, + const SliverCriterion& criterion) { - if(c->is_cache_valid()) - sliver_value_ = c->sliver_value(); - else - sliver_value_ = 0.; + sliver_value_ = criterion.is_sliver(c) ? criterion(c) : 0.; subdomain_index_ = c->subdomain_index(); for(std::size_t i = 0; i < 4; ++i) @@ -1415,7 +1358,10 @@ class C3T3_helpers * (checked before function is called) * resets new_cell's meta-data to its back-uped values */ - void restore(Cell_handle new_cell, C3T3& c3t3) + template + void restore(Cell_handle new_cell, + C3T3& c3t3, + const SliverCriterion& criterion) { if (c3t3.triangulation().is_infinite(new_cell)) return restore_infinite_cell(new_cell, c3t3); @@ -1438,16 +1384,18 @@ class C3T3_helpers }//end loop i CGAL_assertion(nbv_found == 4); - restore(new_cell, new_to_old_indices, c3t3); + restore_finite_cell(new_cell, new_to_old_indices, c3t3, criterion); } private: - void restore(Cell_handle c, - const IndexMap& index_map,//new_to_old_indices - C3T3& c3t3) + template + void restore_finite_cell(Cell_handle c, + const IndexMap& index_map,//new_to_old_indices + C3T3& c3t3, + const SliverCriterion& criterion) { if(sliver_value_ > 0.) - c->set_sliver_value(sliver_value_); + criterion.set_cache(c, sliver_value_); for(int i = 0; i < 4; ++i) c->reset_visited(i); @@ -1569,14 +1517,15 @@ class C3T3_helpers /** * Backup cells meta-data to a vector of Cell_data_backup */ - template + template void fill_cells_backup(const CellsVector& cells, + const SliverCriterion& criterion, CellDataSet& cells_backup) const; - template - void restore_from_cells_backup(const CellsVector& cells, - CellDataSet& cells_backup) const; - + template + void restore_from_cells_backup(CellDataSet& cells_backup, + const SliverCriterion& criterion, + const CellsVector& cells) const; /** * Update mesh iff sliver criterion value does not decrease. @@ -1594,8 +1543,8 @@ class C3T3_helpers * Move point and returns the set of cells that are not valid anymore, and * the set of cells which have been deleted by the move process. */ - template < typename OutdatedCellsOutputIterator, - typename DeletedCellsOutputIterator > + template Vertex_handle move_point(const Vertex_handle& old_vertex, const Vector_3& move, OutdatedCellsOutputIterator outdated_cells, @@ -1607,13 +1556,15 @@ class C3T3_helpers Outdated_cell_set& outdated_cells_set, bool *could_lock_zone = nullptr) const; - template < typename OutdatedCellsOutputIterator, - typename DeletedCellsOutputIterator > + template Vertex_handle move_point_topo_change(const Vertex_handle& old_vertex, const Weighted_point& new_position, OutdatedCellsOutputIterator outdated_cells, - DeletedCellsOutputIterator deleted_cells) const; + DeletedCellsOutputIterator deleted_cells, + SliverCriterion* criterion = nullptr) const; Vertex_handle move_point_topo_change(const Vertex_handle& old_vertex, const Weighted_point& new_position) const; @@ -1669,17 +1620,20 @@ class C3T3_helpers * vertex located at `old_point` * and an output iterator on outdated cells */ - template + template Vertex_handle revert_move(const Vertex_handle& new_vertex, const Weighted_point& old_point, - OutputIterator outdated_cells) + OutputIterator outdated_cells, + SliverCriterion* criterion) { // Move vertex Vertex_handle revert_vertex = move_point_topo_change(new_vertex, old_point, outdated_cells, - CGAL::Emptyset_iterator()); //deleted cells + CGAL::Emptyset_iterator(), // deleted cells + criterion); CGAL_assertion(Vertex_handle() != revert_vertex); return revert_vertex; @@ -1891,7 +1845,7 @@ class C3T3_helpers { tbb::parallel_for_each( outdated_cells.begin(), outdated_cells.end(), - Update_cell_facets(tr_, updater)); + Update_cell_facets(tr_, updater)); } // Sequential else @@ -1902,7 +1856,7 @@ class C3T3_helpers it != outdated_cells.end(); ++it) { - Update_cell_facets ucf(tr_, updater); + Update_cell_facets ucf(tr_, updater); ucf(*it); } } @@ -1920,7 +1874,7 @@ class C3T3_helpers tbb::parallel_for ( tbb::blocked_range(0, outdated_cells_vector.size()), - Update_cell_facets_for_parallel_for( + Update_cell_facets_for_parallel_for( tr_, updater, outdated_cells_vector) ); } @@ -1933,7 +1887,7 @@ class C3T3_helpers it != outdated_cells_vector.end(); ++it) { - Update_cell_facets ucf(tr_, updater); + Update_cell_facets ucf(tr_, updater); ucf(*it); } } @@ -2082,21 +2036,32 @@ class C3T3_helpers } } - template - void reset_sliver_cache(CellRange& cell_range) const +public: + template + void reset_sliver_cache(const SliverCriterion& criterion, + CellForwardIterator cells_begin, + CellForwardIterator cells_end) const { - reset_sliver_cache(std::begin(cell_range), - std::end(cell_range)); + for (; cells_begin != cells_end; ++cells_begin) { + criterion.reset_cache(*cells_begin); + } } - template - void reset_sliver_cache(CellForwardIterator cells_begin, - CellForwardIterator cells_end) const + template + void reset_sliver_cache(const SliverCriterion& criterion, + const CellRange& cell_range) const { - while(cells_begin != cells_end) { - (*cells_begin)->reset_cache_validity(); - ++cells_begin; - } + reset_sliver_cache(criterion, std::begin(cell_range), std::end(cell_range)); + } + + /** + * Reset cache validity of all cells of c3t3_ + */ + template + void reset_sliver_cache(const SliverCriterion& criterion) const + { + for (Cell_handle ch : c3t3_.cells_in_complex()) + criterion.reset_cache(ch); } template @@ -2108,7 +2073,7 @@ class C3T3_helpers template void reset_circumcenter_cache(CellForwardIterator cells_begin, - CellForwardIterator cells_end) const + CellForwardIterator cells_end) const { while(cells_begin != cells_end) { (*cells_begin)->invalidate_weighted_circumcenter_cache(); @@ -2116,11 +2081,9 @@ class C3T3_helpers } } - private: - // Functor for update_facets function (base) - template + template class Update_cell_facets { Tr & m_tr; @@ -2176,7 +2139,7 @@ class C3T3_helpers public: // Constructor Update_cell_facets(Tr &tr, - FacetUpdater_& fu) + FacetUpdater_& fu) : m_tr(tr), m_facet_updater(fu) {} @@ -2194,11 +2157,11 @@ class C3T3_helpers #ifdef CGAL_LINKED_WITH_TBB // Same functor: special version for tbb:parallel_for - template + template class Update_cell_facets_for_parallel_for - : Update_cell_facets + : Update_cell_facets { - typedef Update_cell_facets Base; + typedef Update_cell_facets Base; using Base::update; const std::vector & m_outdated_cells; @@ -2429,7 +2392,7 @@ update_mesh_no_topo_change(const Vertex_handle& old_vertex, //backup metadata std::set cells_backup; - fill_cells_backup(conflict_cells, cells_backup); + fill_cells_backup(conflict_cells, criterion, cells_backup); // Get old values criterion.before_move(c3t3_cells(conflict_cells)); @@ -2437,7 +2400,7 @@ update_mesh_no_topo_change(const Vertex_handle& old_vertex, // Move point reset_circumcenter_cache(conflict_cells); - reset_sliver_cache(conflict_cells); + reset_sliver_cache(criterion, conflict_cells); move_point_no_topo_change(old_vertex, move, new_position); // Check that surface mesh is still valid @@ -2461,13 +2424,13 @@ update_mesh_no_topo_change(const Vertex_handle& old_vertex, reset_circumcenter_cache(conflict_cells); // Sliver caches have been updated by valid_move - reset_sliver_cache(conflict_cells); + reset_sliver_cache(criterion, conflict_cells); move_point_no_topo_change(old_vertex, cov(move), old_position); // Restore meta-data (cells should have same connectivity as before move) // cells_backup does not contain infinite cells so they can be fewer CGAL_assertion(conflict_cells.size() >= cells_backup.size()); - restore_from_cells_backup(conflict_cells, cells_backup); + restore_from_cells_backup(cells_backup, criterion, conflict_cells); return std::make_pair(false, old_vertex); } @@ -2515,7 +2478,7 @@ update_mesh_topo_change(const Vertex_handle& old_vertex, // Backup metadata std::set cells_backup; - fill_cells_backup(conflict_cells, cells_backup); + fill_cells_backup(conflict_cells, criterion, cells_backup); CGAL_assertion(conflict_cells.size() == cells_backup.size()); criterion.before_move(c3t3_cells(conflict_cells)); @@ -2527,7 +2490,7 @@ update_mesh_topo_change(const Vertex_handle& old_vertex, get_surface_boundary(old_vertex, conflict_cells, old_incident_surface_vertices); reset_circumcenter_cache(conflict_cells); - reset_sliver_cache(conflict_cells); + reset_sliver_cache(criterion, conflict_cells); Cell_vector outdated_cells; outdated_cells.reserve(64); @@ -2575,17 +2538,18 @@ update_mesh_topo_change(const Vertex_handle& old_vertex, //reset caches in case cells are reused by the compact container reset_circumcenter_cache(outdated_cells); - reset_sliver_cache(outdated_cells); + reset_sliver_cache(criterion, outdated_cells); outdated_cells.clear(); // Revert move Vertex_handle revert_vertex = revert_move(new_vertex, old_position, - std::inserter(outdated_cells, outdated_cells.end())); + std::inserter(outdated_cells, outdated_cells.end()), + &criterion); //restore meta-data (cells should have same connectivity as before move) //cells should be the same (connectivity-wise) as before initial move CGAL_assertion(outdated_cells.size() == cells_backup.size()); - restore_from_cells_backup(outdated_cells, cells_backup); + restore_from_cells_backup(cells_backup, criterion, outdated_cells); return std::make_pair(false,revert_vertex); } @@ -2942,7 +2906,7 @@ move_point(const Vertex_handle& old_vertex, if ( Th().no_topological_change(tr_, old_vertex, move, new_position, incident_cells_) ) { reset_circumcenter_cache(incident_cells_); - reset_sliver_cache(incident_cells_); + // reset_sliver_cache(incident_cells_); // global only std::copy(incident_cells_.begin(),incident_cells_.end(), outdated_cells); return move_point_no_topo_change(old_vertex, move, new_position); } @@ -2981,7 +2945,7 @@ move_point(const Vertex_handle& old_vertex, if ( Th().no_topological_change(tr_, old_vertex, move, new_position, incident_cells_) ) { reset_circumcenter_cache(incident_cells_); - reset_sliver_cache(incident_cells_); + // reset_sliver_cache(incident_cells_); // global mesh std::copy(incident_cells_.begin(),incident_cells_.end(), std::inserter(outdated_cells_set, outdated_cells_set.end())); return move_point_no_topo_change(old_vertex, move, new_position); @@ -3048,7 +3012,7 @@ move_point(const Vertex_handle& old_vertex, if ( Th().no_topological_change(tr_, old_vertex, move, new_position, incident_cells_) ) { reset_circumcenter_cache(incident_cells_); - reset_sliver_cache(incident_cells_); + // reset_sliver_cache(incident_cells_); // this function is for global mesh optimizers only lock_outdated_cells(); std::copy(incident_cells_.begin(),incident_cells_.end(), @@ -3116,9 +3080,9 @@ move_point_topo_change(const Vertex_handle& old_vertex, //and old_vertex should not be removed if the nb_vertices will change reset_circumcenter_cache(removal_conflict_cells); - reset_sliver_cache(removal_conflict_cells); + // reset_sliver_cache(removal_conflict_cells); reset_circumcenter_cache(insertion_conflict_cells); - reset_sliver_cache(insertion_conflict_cells); + // reset_sliver_cache(insertion_conflict_cells); if (could_lock_zone && *could_lock_zone == false) return Vertex_handle(); @@ -3153,13 +3117,15 @@ move_point_topo_change(const Vertex_handle& old_vertex, template template + typename DeletedCellsOutputIterator, + typename SliverCriterion> typename C3T3_helpers::Vertex_handle C3T3_helpers:: move_point_topo_change(const Vertex_handle& old_vertex, const Weighted_point& new_position, OutdatedCellsOutputIterator outdated_cells, - DeletedCellsOutputIterator deleted_cells) const + DeletedCellsOutputIterator deleted_cells, + SliverCriterion* criterion) const { #ifdef CGAL_MESH_3_C3T3_HELPERS_VERBOSE std::cerr << "move_point_topo_change with delcells(" << (void*)(&*old_vertex) @@ -3178,9 +3144,13 @@ move_point_topo_change(const Vertex_handle& old_vertex, std::back_inserter(insertion_conflict_boundary), std::inserter(removal_conflict_cells, removal_conflict_cells.end())); reset_circumcenter_cache(removal_conflict_cells); - reset_sliver_cache(removal_conflict_cells); reset_circumcenter_cache(insertion_conflict_cells); - reset_sliver_cache(insertion_conflict_cells); + if constexpr (! std::is_same_v) { + if (criterion) { + reset_sliver_cache(*criterion, removal_conflict_cells); + reset_sliver_cache(*criterion, insertion_conflict_cells); + } + } if(insertion_conflict_boundary.empty()) return old_vertex; // new_location is a vertex already @@ -3681,18 +3651,11 @@ min_sliver_value(const Cell_vector& cells, if ( ! use_cache ) { - reset_sliver_cache(cells.begin(),cells.end()); + reset_sliver_cache(criterion, cells.begin(),cells.end()); } - // Return min dihedral angle - //Sliver_criterion_value sc_value(tr_,criterion); - // - //return *(std::min_element(make_transform_iterator(cells.begin(),sc_value), - // make_transform_iterator(cells.end(),sc_value))); FT min_value = criterion.get_max_value(); - for(typename Cell_vector::const_iterator it = cells.begin(); - it != cells.end(); - ++it) + for(typename Cell_vector::const_iterator it = cells.begin(); it != cells.end(); ++it) { min_value = (std::min)(criterion(*it), min_value); } @@ -3730,37 +3693,39 @@ fill_modified_vertices(InputIterator cells_begin, template -template +template void C3T3_helpers:: fill_cells_backup(const CellsVector& cells, + const SliverCriterion& criterion, CellDataSet& cells_backup) const { typedef typename CellDataSet::value_type Cell_data; typename CellsVector::const_iterator cit; for(cit = cells.begin(); cit != cells.end(); ++cit) { - cells_backup.insert(Cell_data(c3t3_,*cit)); + cells_backup.insert(Cell_data(*cit, c3t3_, criterion)); } } template -template +template void C3T3_helpers:: -restore_from_cells_backup(const CellsVector& cells, - CellDataSet& cells_backup) const +restore_from_cells_backup(CellDataSet& cells_backup, + const SliverCriterion& criterion, + const CellsVector& cells) const { for(typename CellsVector::const_iterator cit = cells.begin(); cit != cells.end(); ++cit) { typename CellDataSet::const_iterator cd_it - = cells_backup.find(Cell_data_backup(c3t3_, *cit, false/*don't backup*/)); + = cells_backup.find(Cell_data_backup(*cit, c3t3_, criterion, false/*don't backup*/)); if(cd_it != cells_backup.end()) { typename CellDataSet::value_type cell_data = *cd_it; - cell_data.restore(*cit, c3t3_); + cell_data.restore(*cit, c3t3_, criterion); cells_backup.erase(cd_it); } else CGAL_error(); diff --git a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h index b5a765aabb67..6d0b1d482c37 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h +++ b/Mesh_3/include/CGAL/Mesh_3/Sliver_perturber.h @@ -761,7 +761,7 @@ operator()(Visitor visitor) sliver_criterion_.set_sliver_bound(sliver_criterion_.get_default_value()); // Reset sliver value cache - helper_.reset_cache(); + helper_.reset_sliver_cache(sliver_criterion_); // Init time counter if (running_time_.is_running()) @@ -779,7 +779,6 @@ operator()(Visitor visitor) // Initialize vertices ids initialize_vertices_id(); - #if defined(CGAL_MESH_3_PERTURBER_VERBOSE) \ || defined(CGAL_MESH_3_PROFILING) std::cerr << "Running sliver perturbation..." << std::endl; @@ -816,8 +815,9 @@ operator()(Visitor visitor) #endif running_time_.stop(); - helper_.reset_cache();//in case we reuse caches in another operation - // after this perturbation + + // in case we reuse caches in another operation after this perturbation + helper_.reset_sliver_cache(sliver_criterion_); #ifdef CGAL_MESH_3_PERTURBER_VERBOSE std::cerr << std::endl @@ -1078,15 +1078,13 @@ build_priority_queue(const FT& sliver_bound, PQueue& pqueue) const typedef boost::unordered_map M; M vpm; - for ( typename Tr::Finite_cells_iterator cit = tr_.finite_cells_begin(); - cit != tr_.finite_cells_end() ; - ++cit ) + for (Cell_handle ch : c3t3_.cells_in_complex()) { - if(helper_.is_sliver(cit, sliver_criterion_, sliver_bound)) + const double d = sliver_criterion_(ch); + if(d < sliver_bound) { - double d = cit->sliver_value(); for(int i=0; i< 4; i++){ - Vertex_handle vh = cit->vertex(i); + Vertex_handle vh = ch->vertex(i); PVertex& pv = vpm[vh]; if(pv.sliver_nb() ==0) { diff --git a/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h b/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h new file mode 100644 index 000000000000..b0c5916b8fb0 --- /dev/null +++ b/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h @@ -0,0 +1,156 @@ +// Copyright (c) 2026 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : + +#ifndef CGAL_MESH_3_SLIVER_VALUE_CACHE_H +#define CGAL_MESH_3_SLIVER_VALUE_CACHE_H + +#include + +#ifdef CGAL_LINKED_WITH_TBB +#include +#endif + +#include +#include + +namespace CGAL { +namespace Mesh_3 { + +// Cell must provide sliver_value(), set_sliver_value(), invalidate_sliver_value(), and sliver_cache_valid() +// FT is the floating point type, Cell_handle is the cell handle type + +#ifndef CGAL_MESH_3_NO_SLIVER_VALUE +template +struct Sliver_value_cache_in_cell +{ + bool has_value(const Cell_handle& c) const { return c->is_cache_valid(); } + FT get(const Cell_handle& c) const { return c->sliver_value(); } + void set(const Cell_handle& c, FT v) const { c->set_sliver_value(v); } + void invalidate(const Cell_handle& c) const { c->reset_cache_validity(); } + void clear() const {} +}; +#endif + +// Non-concurrent map-based cache +template +struct Sliver_value_cache_map +{ + typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; + mutable std::unordered_map cache; + bool has_value(const Cell_handle& c) const { return cache.find(c) != cache.end(); } + FT get(const Cell_handle& c) const { return cache.at(c); } + void set(const Cell_handle& c, FT v) const { cache[c] = v; } + void invalidate(const Cell_handle& c) const { cache.erase(c); } + void clear() const { cache.clear(); } +}; + +#ifdef CGAL_LINKED_WITH_TBB +// Concurrent map-based cache +template +struct Sliver_value_cache_concurrent_map +{ + typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; + typedef tbb::concurrent_hash_map ConcurrentMap; + mutable ConcurrentMap cache; + bool has_value(const Cell_handle& c) const { + typename ConcurrentMap::const_accessor acc; + return cache.find(acc, c); + } + FT get(const Cell_handle& c) const { + typename ConcurrentMap::const_accessor acc; + if (cache.find(acc, c)) return acc->second; + throw std::out_of_range("Cell_handle not found in concurrent cache"); + } + void set(const Cell_handle& c, FT v) const { + typename ConcurrentMap::accessor acc; + cache.insert(acc, c); + acc->second = v; + } + void invalidate(const Cell_handle& c) const { + cache.erase(c); + } + void clear() const { cache.clear(); } +}; +#endif + +#ifndef CGAL_MESH_3_NO_SLIVER_VALUE +// Sanity checker cache: combines in-cell and map, checks consistency +template +struct Sliver_value_cache_sanity_checker +{ + Sliver_value_cache_in_cell in_cell; + Sliver_value_cache_map map; + + bool has_value(const Cell_handle& c) const { + bool a = in_cell.has_value(c); + bool b = map.has_value(c); + if (a != b) { + std::cerr << "[Sliver_value_cache_sanity_checker] has_value mismatch: in_cell=" << a << ", map=" << b << std::endl; + std::abort(); + } + return a; + } + + FT get(const Cell_handle& c) const { + FT a = in_cell.get(c); + FT b = map.get(c); + std::cout << "get sliver value of C#" << c->time_stamp() << " = " << a << std::endl; + if (a != b) { + std::cerr << "[Sliver_value_cache_sanity_checker] get mismatch: in_cell=" << a << ", map=" << b << std::endl; + std::abort(); + } + return a; + } + + void set(const Cell_handle& c, FT v) const { + std::cout << "set sliver value of C#" << c->time_stamp() << " to " << v << std::endl; + in_cell.set(c, v); + map.set(c, v); + } + + void invalidate(const Cell_handle& c) const { + in_cell.invalidate(c); + map.invalidate(c); + } + + void clear() const { + in_cell.clear(); + map.clear(); + } +}; +#endif + +// Metafunction to select the default sliver cache type for a triangulation +template +struct Default_sliver_cache +{ +#ifdef CGAL_MESH_3_NO_SLIVER_VALUE +# ifdef CGAL_LINKED_WITH_TBB + using type = std::conditional_t< + std::is_same::value, + Sliver_value_cache_concurrent_map, + Sliver_value_cache_map>; +# else + using type = Sliver_value_cache_map; +# endif +#else + using type = Sliver_value_cache_sanity_checker; +#endif +}; + +template +using Default_sliver_cache_t = typename Default_sliver_cache::type; + +} // namespace Mesh_3 +} // namespace CGAL + +#endif // CGAL_MESH_3_SLIVER_VALUE_CACHE_H diff --git a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h index 4bea94a4c13a..bb6f35806117 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h +++ b/Mesh_3/include/CGAL/Mesh_3/Slivers_exuder.h @@ -681,9 +681,7 @@ class Slivers_exuder cit != c3t3_.cells_in_complex_end() ; ++cit) { - const FT value = sliver_criteria_(cit); - - if( value < sliver_criteria_.sliver_bound() ) + if (sliver_criteria_.is_sliver(cit)) return false; } @@ -1092,9 +1090,9 @@ initialize_prestar_and_criterion_values(const Vertex_handle& v, const Facet opposite_facet = tr_.mirror_facet(f); // Sliver criterion values initialization - if( c3t3_.is_in_complex(c) ) - { - criterion_values[f] = sliver_criteria_(c); + if( c3t3_.is_in_complex(c) ) { + if (sliver_criteria_.is_sliver(c)) + criterion_values[f] = sliver_criteria_(c); } // Pre_star initialization @@ -1239,7 +1237,7 @@ expand_prestar(const Cell_handle& cell_to_add, Tetrahedron_3 tet = tr_.tetrahedron(curr_f, ncr_pwp); FT new_value = sliver_criteria_(tet); - criterion_values.insert(std::make_pair(current_facet, new_value)); + criterion_values.emplace(current_facet, new_value); } } } @@ -1565,6 +1563,10 @@ update_mesh(const Weighted_point& new_point, // Delete old cells from queue (they aren't in the triangulation anymore) this->delete_cells_from_queue(deleted_cells); + // Purge the cache + for (const Cell_handle& dc : deleted_cells) + sliver_criteria_.reset_cache(dc); + // Delete old cells & facets from c3t3 remove_from_c3t3(deleted_cells.begin(),deleted_cells.end()); remove_from_c3t3(boundary_facets.begin(),boundary_facets.end()); @@ -1816,6 +1818,9 @@ check_ratios(const Sliver_values& criterion_values, Tetrahedron_3 tet = tr_.tetrahedron(*it, wp); FT ratio = sliver_criteria_(tet); + if (ratio > sliver_criteria_.sliver_bound()) + continue; + expected_ratios.push_back(ratio); bool found = false; diff --git a/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h b/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h index 6ecabd1aa906..91006aaf61f0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h @@ -23,15 +23,25 @@ #include #include +#include + #include // for CGAL::IA_force_to_double + #include namespace CGAL { - namespace Mesh_3 { -template::type, + Sliver_caching_policy caching_policy = Sliver_caching_policy::BELOW_BOUND, typename Cell_vector_ = std::vector > class Sliver_criterion { @@ -44,17 +54,44 @@ class Sliver_criterion public: virtual double get_default_value() const = 0; virtual double get_max_value() const = 0; - //Sliver_perturber performs perturbation "unit-per-unit" + // Sliver_perturber performs perturbation "unit-per-unit" // so it needs to know how much is a unit for each criterion virtual double get_perturbation_unit() const = 0; + // Reset the entire cache (if any) + void reset_cache() const { + cache_.clear(); + } + + // Reset the cache for a single cell (if any) + void reset_cache(const Cell_handle& cell) const { + cache_.invalidate(cell); + } + + void set_cache(const Cell_handle& cell, const double value) const { + cache_.set(cell, value); + } + + bool is_sliver(Cell_handle cell) const + { + if (caching_policy == Sliver_caching_policy::BELOW_BOUND) { + return cache_.has_value(cell); + } else { + // if we cache everything, the operator() will return the cached value + return operator()(cell) < this->sliver_bound_; + } + } + // returns the value of the criterion for t virtual double operator()(Cell_handle cell) const { - if(update_sliver_cache) - { - if( ! cell->is_cache_valid() ) - { + if (caching_policy == Sliver_caching_policy::NEVER) { + return operator()(tr_.tetrahedron(cell)); + } else { + if (cache_.has_value(cell)) { + std::cout << "cache hit for C#" << cell->time_stamp() << " (operator())" << std::endl; + return cache_.get(cell); + } else { // cell->sliver_value() is stored in a plain 64 bits floating point // number, and the value computed by operator() might be // computed using the 80 bits floating point registers of the x87 @@ -63,13 +100,18 @@ class Sliver_criterion // inconsistent when comparing caches and registers values // (see also the comment below) // IA_force_to_double is available in CGAL/FPU.h - double value - = CGAL::IA_force_to_double(operator()(tr_.tetrahedron(cell))); - cell->set_sliver_value(value); + const double value = CGAL::IA_force_to_double(operator()(tr_.tetrahedron(cell))); + std::cout << "computed sliver value for C#" << cell->time_stamp() << " = " << value << std::endl; + + if (caching_policy == Sliver_caching_policy::BELOW_BOUND && value > this->sliver_bound_) { + return value; + } else { + std::cout << "cache sliver value for C#" << cell->time_stamp() << " = " << value << std::endl; + cache_.set(cell, value); + return value; + } } - return cell->sliver_value(); } - return operator()(tr_.tetrahedron(cell)); } virtual double operator()(const Tetrahedron_3& t) const = 0; @@ -84,9 +126,11 @@ class Sliver_criterion public: Sliver_criterion(const double& bound, - const Tr& tr) + const Tr& tr, + const Cache& cache = Cache()) : tr_(tr) , sliver_bound_(bound) + , cache_(cache) {} virtual ~Sliver_criterion(){} @@ -94,18 +138,20 @@ class Sliver_criterion protected: const Tr& tr_; double sliver_bound_; + mutable Cache cache_; }; template class Min_value; template + typename Cache = typename CGAL::Mesh_3::Default_sliver_cache::type, + Sliver_caching_policy caching_policy = Sliver_caching_policy::BELOW_BOUND> class Min_dihedral_angle_criterion - : public Sliver_criterion + : public Sliver_criterion { protected: - typedef Sliver_criterion Base; + typedef Sliver_criterion Base; typedef typename Base::Tetrahedron_3 Tetrahedron_3; typedef typename Base::Cell_vector Cell_vector; typedef typename Base::GT GT; @@ -147,8 +193,9 @@ class Min_dihedral_angle_criterion public: Min_dihedral_angle_criterion(const double& sliver_bound, - const Tr& tr) - : Base(sliver_bound, tr), min_value_before_move_(0.) + const Tr& tr, + const Cache& cache = Cache()) + : Base(sliver_bound, tr, cache), min_value_before_move_(0.) {} private: @@ -157,16 +204,18 @@ class Min_dihedral_angle_criterion template + typename Cache = typename CGAL::Mesh_3::Default_sliver_cache::type, + Sliver_caching_policy caching_policy = Sliver_caching_policy::BELOW_BOUND> class Radius_ratio_criterion - : public Sliver_criterion + : public Sliver_criterion { + typedef Radius_ratio_criterion Self; + protected: - typedef Sliver_criterion Base; + typedef Sliver_criterion Base; typedef typename Base::GT GT; typedef typename Base::Tetrahedron_3 Tetrahedron_3; typedef typename Base::Cell_vector Cell_vector; - typedef Radius_ratio_criterion RR_criterion; public: @@ -183,13 +232,13 @@ class Radius_ratio_criterion virtual void before_move(const Cell_vector& cells) const { - Min_value min_value_op(*this); + Min_value min_value_op(*this); min_value_before_move_ = min_value_op(cells); } virtual bool valid_move(const Cell_vector& cells, const bool soft = false) const { - Min_value min_value_op(*this); + Min_value min_value_op(*this); double min_val = min_value_op(cells); return (min_val > min_value_before_move_) || (soft && min_val > this->sliver_bound_); @@ -197,8 +246,9 @@ class Radius_ratio_criterion public: Radius_ratio_criterion(const double& sliver_bound, - const Tr& tr) - : Base(sliver_bound, tr) + const Tr& tr, + const Cache& cache = Cache()) + : Base(sliver_bound, tr, cache) {} private: From af08c3f89f32ceda949175f49ed3247a460f80ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 12 Mar 2026 01:23:15 +0100 Subject: [PATCH 064/127] Misc cleaning --- Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h | 2 +- Mesh_3/test/Mesh_3/test_meshing_determinism.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 20fa4a53284b..466ce8c0a93e 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -310,7 +310,7 @@ class Compact_mesh_cell_3 : subdomain_index_(rhs.subdomain_index_) , N(rhs.N) , V(rhs.V) - #ifdef CGAL_INTRUSIVE_LIST +#ifdef CGAL_INTRUSIVE_LIST , next_intrusive_(rhs.next_intrusive_) , previous_intrusive_(rhs.previous_intrusive_) #endif diff --git a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp index 485b65d6b6e4..8c5570346f55 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_determinism.cpp @@ -135,7 +135,6 @@ void test() std::stringstream oss; CGAL::IO::write_MEDIT(oss, c3t3); output_c3t3.push_back(oss.str());//[i*5+3] - std::cout << "oss " << oss.str() << std::endl; std::stringstream oss_p; Polyhedron out_poly; From 7af653098a7b1d0ba3f9a6fe1869226d6a086bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 12 Mar 2026 01:23:24 +0100 Subject: [PATCH 065/127] Disable intrusive lists (wip) --- Mesh_3/include/CGAL/Mesh_3/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/config.h b/Mesh_3/include/CGAL/Mesh_3/config.h index 3da2ab5ca77a..ee5067c7bd00 100644 --- a/Mesh_3/include/CGAL/Mesh_3/config.h +++ b/Mesh_3/include/CGAL/Mesh_3/config.h @@ -23,7 +23,7 @@ # define CGAL_MESH_3_GET_FACETS_USING_INTRUSIVE_LIST 1 # define CGAL_MESH_3_SIZING_FIELD_INEXACT_LOCATE 1 # define FORCE_STRUCTURAL_FILTERING 1 -# define CGAL_INTRUSIVE_LIST 1 +// # define CGAL_INTRUSIVE_LIST 1 //experimental //# define CGAL_SEQUENTIAL_MESH_3_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE From 7037982812ac24592779b9b6ba51a2444b39e139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 12 Mar 2026 22:21:06 +0100 Subject: [PATCH 066/127] Add missing license header include --- Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h b/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h index b0c5916b8fb0..15678848d6f3 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h +++ b/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h @@ -13,6 +13,8 @@ #ifndef CGAL_MESH_3_SLIVER_VALUE_CACHE_H #define CGAL_MESH_3_SLIVER_VALUE_CACHE_H +#include + #include #ifdef CGAL_LINKED_WITH_TBB From 245a9e4e4434721e5555420a2698c1df8b31f21f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 16 Mar 2026 15:46:40 +0100 Subject: [PATCH 067/127] Add some code to disable circumcenter caching in compact mesh cell base --- .../include/CGAL/Compact_mesh_cell_base_3.h | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 466ce8c0a93e..0b3c3a2e2849 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -109,7 +109,9 @@ class Compact_mesh_cell_base_3_base Compact_mesh_cell_base_3_base() : bits_(0) { +#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE internal_tbb::set_weighted_circumcenter(weighted_circumcenter_, nullptr); +#endif } public: @@ -152,15 +154,19 @@ class Compact_mesh_cell_base_3_base return ( (bits_ & (1 << facet)) != 0 ); } +#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE /// Precondition weighted_circumcenter_ == nullptr void try_to_set_circumcenter(Point_3 *cc) const { CGAL_precondition(weighted_circumcenter_ == nullptr); weighted_circumcenter_ = cc; } +#endif protected: +#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE mutable Point_3* weighted_circumcenter_; +#endif private: #if defined(CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE) \ @@ -184,7 +190,9 @@ class Compact_mesh_cell_base_3_base Compact_mesh_cell_base_3_base() { bits_ = 0; +#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE weighted_circumcenter_ = nullptr; +#endif } public: @@ -234,6 +242,7 @@ class Compact_mesh_cell_base_3_base return ( (bits_ & char(1 << facet)) != 0 ); } +#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE /// If the circumcenter is already set (weighted_circumcenter_ != nullptr), /// this function "deletes" cc void try_to_set_circumcenter(Point_3 *cc) const @@ -242,9 +251,12 @@ class Compact_mesh_cell_base_3_base if (!weighted_circumcenter_.compare_exchange_strong(base_test, cc)) delete cc; } +#endif protected: +#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE mutable std::atomic weighted_circumcenter_; +#endif private: typedef std::atomic Erase_counter_type; @@ -269,7 +281,10 @@ class Compact_mesh_cell_3 : public Compact_mesh_cell_base_3_base { typedef Compact_mesh_cell_base_3_base Base; + +#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE using Base::weighted_circumcenter_; +#endif public: typedef TDS Triangulation_data_structure; @@ -295,10 +310,12 @@ class Compact_mesh_cell_3 public: void invalidate_weighted_circumcenter_cache() const { +#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE if (!internal_tbb::is_null(weighted_circumcenter_)) { internal_tbb::delete_circumcenter(weighted_circumcenter_); internal_tbb::set_weighted_circumcenter(weighted_circumcenter_, nullptr); } +#endif } public: @@ -355,10 +372,12 @@ class Compact_mesh_cell_3 ~Compact_mesh_cell_3() { +#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE if(!internal_tbb::is_null(weighted_circumcenter_)){ internal_tbb::delete_circumcenter(weighted_circumcenter_); internal_tbb::set_weighted_circumcenter(weighted_circumcenter_, nullptr); } +#endif } // ACCESS FUNCTIONS @@ -498,8 +517,15 @@ class Compact_mesh_cell_3 } template - const Point_3& weighted_circumcenter(const GT_& gt) const + decltype(auto) weighted_circumcenter(const GT_& gt) const { +#ifdef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE + return gt.construct_weighted_circumcenter_3_object() + (this->vertex(0)->point(), + this->vertex(1)->point(), + this->vertex(2)->point(), + this->vertex(3)->point()); +#else static_assert(std::is_same::value); if (internal_tbb::is_null(weighted_circumcenter_)) { @@ -517,6 +543,7 @@ class Compact_mesh_cell_3 this->vertex(3)->point()) == *weighted_circumcenter_); } return *weighted_circumcenter_; +#endif } // Returns the index of the cell of the input complex that contains the cell From 2c4f46b2ead0a5bee603cfd23f867ca69c479022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 16 Mar 2026 15:47:01 +0100 Subject: [PATCH 068/127] Do not pollute the surface info map with non-surface facets --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 4a80e028ec83..60e0d14d7ef8 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1416,14 +1416,14 @@ class C3T3_helpers std::size_t old_i = index_map.at(static_cast(i)); Surface_patch_index index = surface_prop_table_[old_i].surface_index_; //add_to_complex sets the index, and updates the facet counter - if(!( Surface_patch_index() == index )) + if(!( Surface_patch_index() == index )) { c3t3.add_to_complex(f, index); - else + c3t3.set_surface_info(f, surface_prop_table_[old_i]); + const Facet mirror = c3t3.triangulation().mirror_facet(f); + c3t3.set_surface_info(mirror, surface_prop_table_[old_i]); + } else { c3t3.remove_from_complex(f); - - c3t3.set_surface_info(f, surface_prop_table_[old_i]); - const Facet mirror = c3t3.triangulation().mirror_facet(f); - c3t3.set_surface_info(mirror, surface_prop_table_[old_i]); + } } } @@ -1436,14 +1436,14 @@ class C3T3_helpers Facet f(c, i); Surface_patch_index index = surface_prop_table_[0].surface_index_; - if (!( Surface_patch_index() == index )) + if (!( Surface_patch_index() == index )) { c3t3.add_to_complex(f, index); - else + c3t3.set_surface_info(f, surface_prop_table_[0]); + const Facet mirror = c3t3.triangulation().mirror_facet(f); + c3t3.set_surface_info(mirror, surface_prop_table_[0]); + } else { c3t3.remove_from_complex(f); - - c3t3.set_surface_info(f, surface_prop_table_[0]); - const Facet mirror = c3t3.triangulation().mirror_facet(f); - c3t3.set_surface_info(mirror, surface_prop_table_[0]); + } } private: From 3f6894c02cf17daceab3c00b8f48c8b683bdafed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Mar 2026 09:25:46 +0100 Subject: [PATCH 069/127] Halve the memory map footprint by storing only once per facet pair --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 6 - Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 57 +++++- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 10 +- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 180 +++++++++--------- 4 files changed, 145 insertions(+), 108 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 60e0d14d7ef8..0762d423cd9d 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1177,7 +1177,6 @@ class C3T3_helpers if(update_surface_center) { - Facet facet_m = c3t3_.triangulation().mirror_facet(facet); if(surface) { #ifndef CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 @@ -1187,7 +1186,6 @@ class C3T3_helpers // Update facet surface center const Bare_point& surface_center = std::get<0>(intersection); c3t3_.set_surface_center(facet.first, facet.second, surface_center); - c3t3_.set_surface_center(facet_m.first, facet_m.second, surface_center); } } @@ -1419,8 +1417,6 @@ class C3T3_helpers if(!( Surface_patch_index() == index )) { c3t3.add_to_complex(f, index); c3t3.set_surface_info(f, surface_prop_table_[old_i]); - const Facet mirror = c3t3.triangulation().mirror_facet(f); - c3t3.set_surface_info(mirror, surface_prop_table_[old_i]); } else { c3t3.remove_from_complex(f); } @@ -1439,8 +1435,6 @@ class C3T3_helpers if (!( Surface_patch_index() == index )) { c3t3.add_to_complex(f, index); c3t3.set_surface_info(f, surface_prop_table_[0]); - const Facet mirror = c3t3.triangulation().mirror_facet(f); - c3t3.set_surface_info(mirror, surface_prop_table_[0]); } else { c3t3.remove_from_complex(f); } diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index e2a131fcb8db..346ae6e88c13 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -898,9 +898,27 @@ update_star_self(const Vertex_handle& vertex) const int& k = (*cell_it)->index(vertex); const Facet mirror_f = mirror_facet(*cell_it,k); - // @todo here and below is 2 map looks up which could be only one. - if (r_c3t3_.is_in_complex(mirror_f)) - r_c3t3_.set_surface_info(*cell_it, k, r_c3t3_.surface_info(mirror_f)); + CGAL_assertion(!r_c3t3_.is_in_complex(Facet(*cell_it, k), false /*do not canonicalize*/)); + + // See also the function insert_impl: if a facet is a surface facet, we mark its opposite facet + // before insertion regardless of canonicality because the boundary facet is destroyed but + // but not the opposite facet. Now, after the insertion, we must restore that the canonical + // facet is marked if the facet is a surface facet. + if ( r_c3t3_.is_in_complex(mirror_f, false /*do not canonicalize*/) ) + { + // Avoid duplicating information. + const Facet canonical_f = r_c3t3_.canonical_facet(*cell_it, k); + if (canonical_f != mirror_f) + { + const auto& sf = r_c3t3_.surface_info(mirror_f, false /*do not canonicalize*/); + r_c3t3_.set_surface_info(canonical_f, sf); + r_c3t3_.set_surface_patch_index(mirror_f, Surface_patch_index(), false /*do not canonicalize*/); + } + CGAL_postcondition(r_c3t3_.is_in_complex(*cell_it,k)); + CGAL_postcondition(r_c3t3_.is_in_complex(mirror_f)); + CGAL_postcondition(r_c3t3_.is_in_complex(canonical_f, false)); + CGAL_postcondition(!r_c3t3_.is_in_complex(r_c3t3_.triangulation().mirror_facet(canonical_f), false)); + } // Set subdomain index set_cell_in_domain(*cell_it, cells_subdomain); @@ -951,14 +969,33 @@ Refine_cells_3:: insert_impl(const Weighted_point& point, const Zone& zone) { - // Remove the cell's facets from the complex (and from the hash map). - // Do *not* call the C3T3's remove_from_complex() because the information - // on the opposite facet must not be cleared for boundary facets. - auto cit = zone.cells.begin(); - for ( ; cit != zone.cells.end() ; ++cit ) + // The block below shouldn't be needed because it would be an encroachment? + auto ifit = zone.internal_facets.begin(); + for ( ; ifit != zone.internal_facets.end() ; ++ifit ) + r_c3t3_.remove_from_complex(*ifit); + + // Surface facet info must be preserved throughout the insertion of the new vertex, + // but boundary facets of the conflict zone are destroyed. + // So we temporarily mark the opposite facet (which is not destroyed) regardless of canonicality, + // and we will check post-insertion if we have marked twice + auto bfit = zone.boundary_facets.begin(); + for ( ; bfit != zone.boundary_facets.end() ; ++bfit ) { - for (int i = 0 ; i < 4 ; ++i) - r_c3t3_.set_surface_patch_index(*cit, i, Surface_patch_index()); + // @todo three map accesses for bfit... + if (r_c3t3_.is_in_complex(*bfit)) { + const Facet mirror_f = mirror_facet(*bfit); + CGAL_assertion(*bfit != mirror_f); + + const auto& sf = r_c3t3_.surface_info(*bfit); + + r_c3t3_.set_surface_info(mirror_f, sf, false /*do not canonicalize*/); + CGAL_postcondition(r_c3t3_.is_in_complex(*bfit)); + CGAL_postcondition(r_c3t3_.is_in_complex(mirror_f, false /*do not canonicalize*/)); + + r_c3t3_.set_surface_patch_index(*bfit, Surface_patch_index(), false /*do not canonicalize*/); + CGAL_postcondition(!r_c3t3_.is_in_complex(*bfit, false /*do not canonicalize*/)); + CGAL_postcondition(r_c3t3_.is_in_complex(mirror_f, false /*do not canonicalize*/)); + } } // TODO: look at this diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 9014764ede9f..c6916994a8c2 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -468,19 +468,15 @@ class Refine_facets_3_base const Bare_point& center) { r_c3t3_.add_to_complex(f, surface_index); - - const Facet mirror = mirror_facet(f); - - // a little awkward: these are performed after add_to_complex() because otherwise - // the surface index is set up, and add_to_complex() will do nothing... + // a little awkward: this is performed after add_to_complex() because otherwise + // the surface index is set up, and add_to_complex() does nothing... r_c3t3_.set_surface_info(f, {surface_index, center_index, center}); - r_c3t3_.set_surface_info(mirror, {surface_index, center_index, center}); } /// Returns index of facet `f`. Surface_patch_index get_facet_surface_index(const Facet& f) const { - return r_c3t3_.surface_patch_index(f.first, f.second); + return r_c3t3_.surface_patch_index(f); } /// Sets index and dimension of vertex `v`. diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index c34511ea7102..27317f24cf2a 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -92,7 +92,7 @@ struct Hash_map_of_pairs_type template class C3t3_helper_class { - protected: + public: typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Facet Facet; @@ -116,10 +116,15 @@ struct Hash_map_of_pairs_type return make_ordered_pair(e.first->vertex(e.second), e.first->vertex(e.third)); } + Facet canonical_facet(Cell_handle c, int i) const { Cell_handle c2 = c->neighbor(i); return (c2 < c) ? std::make_pair(c2, c2->index(c)) : std::make_pair(c, i); } + + Facet canonical_facet(const Facet& f) const { + return canonical_facet(f.first, f.second); + } }; // end class template C3t3_helper_class } // namespace details @@ -483,13 +488,14 @@ class Mesh_complex_3_in_triangulation_3 /** sets the surface index of facet \p f to \p index */ void set_surface_patch_index(const Facet& f, - const Surface_patch_index& index) const + const Surface_patch_index& index, + const bool do_canonicalize = true) const { - // std::cout << "set " << &*(cell) << " " << i << " to " << index << " (new)" << std::endl; + const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; if (index == Surface_patch_index()) { - surface_facet_info_.erase(f); + surface_facet_info_.erase(cf); } else { @@ -497,13 +503,13 @@ class Mesh_complex_3_in_triangulation_3 if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, f); + surface_facet_info_.insert(accessor, cf); accessor->second.surface_index_ = index; } else #endif { - surface_facet_info_[f].surface_index_ = index; + surface_facet_info_[cf].surface_index_ = index; } } } @@ -512,25 +518,28 @@ class Mesh_complex_3_in_triangulation_3 */ void set_surface_patch_index(const Cell_handle& cell, const int i, - const Surface_patch_index& index) const + const Surface_patch_index& index, + const bool do_canonicalize = true) const { - return set_surface_patch_index(Facet(cell, i), index); + return set_surface_patch_index(Facet(cell, i), index, do_canonicalize); } void set_surface_center(const Facet& f, - const Bare_point& p) const + const Bare_point& p, + const bool do_canonicalize = true) const { + const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, f); + surface_facet_info_.insert(accessor, cf); accessor->second.center_ = p; } else #endif { - surface_facet_info_[f].center_ = p; + surface_facet_info_[cf].center_ = p; } } @@ -538,25 +547,28 @@ class Mesh_complex_3_in_triangulation_3 */ void set_surface_center(const Cell_handle& cell, const int i, - const Bare_point& p) const + const Bare_point& p, + const bool do_canonicalize = true) const { - return set_surface_center(Facet(cell, i), p); + return set_surface_center(Facet(cell, i), p, do_canonicalize); } void set_surface_center_index(const Facet& f, - const Index& index) const + const Index& index, + const bool do_canonicalize = true) const { + const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, f); + surface_facet_info_.insert(accessor, cf); accessor->second.center_index_ = index; } else #endif { - surface_facet_info_[f].center_index_ = index; + surface_facet_info_[cf].center_index_ = index; } } @@ -564,17 +576,20 @@ class Mesh_complex_3_in_triangulation_3 */ void set_surface_center_index(const Cell_handle& cell, const int i, - const Index& index) const + const Index& index, + const bool do_canonicalize = true) const { - return set_surface_center_index(Facet(cell, i), index); + return set_surface_center_index(Facet(cell, i), index, do_canonicalize); } void set_surface_info(const Facet& f, - const Facet_prop& info) const + const Facet_prop& info, + const bool do_canonicalize = true) const { + const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; if (info.surface_index_ == Surface_patch_index()) { - surface_facet_info_.erase(f); + surface_facet_info_.erase(cf); } else { @@ -582,21 +597,22 @@ class Mesh_complex_3_in_triangulation_3 if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, f); + surface_facet_info_.insert(accessor, cf); accessor->second = info; } else #endif { - surface_facet_info_[f] = info; + surface_facet_info_[cf] = info; } } } void set_surface_info(const Cell_handle& cell, int i, - const Facet_prop& info) const + const Facet_prop& info, + const bool do_canonicalize = true) const { - return set_surface_info(Facet(cell, i), info); + return set_surface_info(Facet(cell, i), info, do_canonicalize); } /** sets the subdomain index of cell \p cell to \p index @@ -628,19 +644,21 @@ class Mesh_complex_3_in_triangulation_3 } /** returns the surface index of facet \p f */ - Surface_patch_index surface_patch_index(const Facet& f) const + Surface_patch_index surface_patch_index(const Facet& f, + const bool do_canonicalize = true) const { + const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; - if (surface_facet_info_.find(accessor, f)) + if (surface_facet_info_.find(accessor, cf)) return accessor->second.surface_index_; } else #endif { - auto it = surface_facet_info_.find(f); + auto it = surface_facet_info_.find(cf); if (it != surface_facet_info_.end()) return it->second.surface_index_; } @@ -650,28 +668,31 @@ class Mesh_complex_3_in_triangulation_3 /** returns the surface index of facet(\p cell, \p i) */ Surface_patch_index surface_patch_index(const Cell_handle& cell, - const int i) const + const int i, + const bool do_canonicalize = true) const { - return surface_patch_index(Facet(cell, i)); + return surface_patch_index(Facet(cell, i), do_canonicalize); } - decltype(auto) surface_center(const Facet& f) const + decltype(auto) surface_center(const Facet& f, + const bool do_canonicalize = true) const { - CGAL_precondition(is_in_complex(f)); + const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; + CGAL_precondition(is_in_complex(cf)); # ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, f); + surface_facet_info_.find(accessor, cf); CGAL_assume(found); return accessor->second.center_; } else #endif { - auto it = surface_facet_info_.find(f); + auto it = surface_facet_info_.find(cf); CGAL_assume(it != surface_facet_info_.end()); return it->second.center_; } @@ -680,28 +701,31 @@ class Mesh_complex_3_in_triangulation_3 /** returns the surface center of facet(\p cell, \p i) */ decltype(auto) surface_center(const Cell_handle& cell, - const int i) const + const int i, + const bool do_canonicalize = true) const { - return surface_center(Facet(cell, i)); + return surface_center(Facet(cell, i), do_canonicalize); } - Index surface_center_index(const Facet& f) const + Index surface_center_index(const Facet& f, + const bool do_canonicalize = true) const { - CGAL_precondition(is_in_complex(f)); + const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; + CGAL_precondition(is_in_complex(cf)); # ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, f); + surface_facet_info_.find(accessor, cf); CGAL_assume(found); return accessor->second.center_index_; } else #endif { - auto it = surface_facet_info_.find(f); + auto it = surface_facet_info_.find(cf); CGAL_assume(it != surface_facet_info_.end()); return it->second.center_index_; } @@ -710,26 +734,29 @@ class Mesh_complex_3_in_triangulation_3 /** returns the surface center index of facet(\p cell, \p i) */ Index surface_center_index(const Cell_handle& cell, - const int i) const + const int i, + const bool do_canonicalize = true) const { - return surface_center_index(Facet(cell, i)); + return surface_center_index(Facet(cell, i), do_canonicalize); } - decltype(auto) surface_info(const Facet& f) const + decltype(auto) surface_info(const Facet& f, + const bool do_canonicalize = true) const { + const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, f); + surface_facet_info_.find(accessor, cf); CGAL_assume(found); return accessor->second; } else #endif { - auto it = surface_facet_info_.find(f); + auto it = surface_facet_info_.find(cf); CGAL_assume(it != surface_facet_info_.end()); return it->second; } @@ -808,41 +835,29 @@ class Mesh_complex_3_in_triangulation_3 old_cells.reserve(32); tr.incident_cells(v, std::back_inserter(old_cells)); + // The vertex 'v' is isolated from the complex, but the facets opposite to it in the incident + // cells may be in the complex and their surface info must be preserved. + std::unordered_map boundary_facet_infos; + for (const Cell_handle& c : old_cells) { - remove_from_complex(c); - for (int i = 0; i < 4; ++i) { - // Do *not* call the C3T3's remove_from_complex() because the information - // on the opposite facet must not be cleared for boundary facets. - set_surface_patch_index(c, i, Surface_patch_index()); - } + const Facet f(c, c->index(v)); + if (!is_in_complex(f)) + continue; + boundary_facet_infos[tr.mirror_facet(f)] = surface_info(f); + remove_from_complex(f); } std::vector new_cells; new_cells.reserve(32); tr.remove_and_give_new_cells(v, std::back_inserter(new_cells)); - typename std::vector::iterator nc_it = new_cells.begin(); - typename std::vector::iterator nc_it_end = new_cells.end(); - for (; nc_it != nc_it_end; ++nc_it) + for (const auto& e : boundary_facet_infos) { - Cell_handle c = *nc_it; - for (int i = 0; i < 4; ++i) - { - Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i)); - if (is_in_complex(mirror_facet)) - { - set_surface_patch_index(c, i, surface_patch_index(mirror_facet)); - set_surface_center(c, i, surface_center(mirror_facet.first, mirror_facet.second)); - } - } - /*int i_inf; - if (c->has_vertex(tr.infinite_vertex(), i_inf)) - { - Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i_inf)); - if (is_in_complex(mirror_facet)) - set_surface_patch_index(c, i_inf, surface_patch_index(mirror_facet)); - }*/ + const Facet& nf = e.first; + CGAL_assertion(is_in_complex(nf)); + add_to_complex(nf, e.second.surface_index_); + set_surface_info(nf, e.second); } } @@ -987,19 +1002,21 @@ class Mesh_complex_3_in_triangulation_3 } /** returns true if facet \p f belongs to the 2D complex */ - bool is_in_complex(const Facet& f) const + bool is_in_complex(const Facet& f, + const bool do_canonicalize = true) const { + const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; - if (surface_facet_info_.find(accessor, f)) + if (surface_facet_info_.find(accessor, cf)) return !(accessor->second.surface_index_ == Surface_patch_index()); } else #endif { - auto it = surface_facet_info_.find(f); + auto it = surface_facet_info_.find(cf); if (it != surface_facet_info_.end()) return !(it->second.surface_index_ == Surface_patch_index()); } @@ -1696,11 +1713,7 @@ class Mesh_complex_3_in_triangulation_3 ++fit) { const auto& facet = *fit; - set_surface_patch_index(facet.first, facet.second, Surface_patch_index()); - if (this->triangulation().dimension() > 2) { - const Facet& mirror = tr_.mirror_facet(facet); - set_surface_patch_index(mirror.first, mirror.second, Surface_patch_index()); - } + set_surface_patch_index(facet, Surface_patch_index()); } this->number_of_facets_ = 0; @@ -2096,6 +2109,7 @@ Mesh_complex_3_in_triangulation_3(const Self& rhs) const int this_opp = this_cell->index(this_n); const Facet this_facet(this_cell, this_opp); + const Facet this_canonical_facet = this->canonical_facet(this_facet); // std::cout << "from rhs:\n"; // std::cout << " facet: " << rhs.triangulation().point(rhs_c, (rhs_i + 1) % 4) << ", " @@ -2110,13 +2124,13 @@ Mesh_complex_3_in_triangulation_3(const Self& rhs) if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, this_facet); + surface_facet_info_.insert(accessor, this_canonical_facet); accessor->second = e.second; } else #endif { - surface_facet_info_[this_facet] = e.second; + surface_facet_info_[this_canonical_facet] = e.second; } } CGAL_postcondition(surface_facet_info_.size() == rhs.surface_facet_info_.size()); @@ -2247,9 +2261,7 @@ add_to_complex(const Cell_handle& cell, if (!is_in_complex(cell, i)) { - Facet mirror = tr_.mirror_facet(std::make_pair(cell, i)); set_surface_patch_index(cell, i, index); - set_surface_patch_index(mirror.first, mirror.second, index); ++number_of_facets_; if (manifold_info_initialized_) { for (int j = 0; j < 3; ++j) @@ -2297,9 +2309,7 @@ remove_from_complex(const Facet& facet) { if (is_in_complex(facet)) { - Facet mirror = tr_.mirror_facet(facet); - set_surface_patch_index(facet.first, facet.second, Surface_patch_index()); - set_surface_patch_index(mirror.first, mirror.second, Surface_patch_index()); + set_surface_patch_index(facet, Surface_patch_index()); --number_of_facets_; if (manifold_info_initialized_) { const Cell_handle cell = facet.first; From 2bc46e0d838152043411322c94af218e5703ee2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Mar 2026 09:41:52 +0100 Subject: [PATCH 070/127] Purge obsolete code --- Lab/demo/Lab/Plugins/Mesh_3/config_mesh_3.h | 1 - Mesh_3/benchmark/Mesh_3/benchmark_config.h | 1 - Mesh_3/include/CGAL/Mesh_3/Mesher_3.h | 17 ----------------- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 4 ---- Mesh_3/test/Mesh_3/test_meshing_utilities.h | 2 -- 5 files changed, 25 deletions(-) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/config_mesh_3.h b/Lab/demo/Lab/Plugins/Mesh_3/config_mesh_3.h index 451f8843d0a2..0d21c6e1d6ae 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/config_mesh_3.h +++ b/Lab/demo/Lab/Plugins/Mesh_3/config_mesh_3.h @@ -54,7 +54,6 @@ // MESH_3 GENERAL PARAMETERS // ========================================================================== -//#define CGAL_MESH_3_USE_OLD_SURFACE_RESTRICTED_DELAUNAY_UPDATE // WARNING: VERY SLOW //#define CGAL_MESH_3_INITIAL_POINTS_NO_RANDOM_SHOOTING //#define CGAL_MESHES_DEBUG_REFINEMENT_POINTS //#define CHECK_AND_DISPLAY_THE_NUMBER_OF_BAD_ELEMENTS_IN_THE_END diff --git a/Mesh_3/benchmark/Mesh_3/benchmark_config.h b/Mesh_3/benchmark/Mesh_3/benchmark_config.h index 0416e8abf930..3be8e88c5a7f 100644 --- a/Mesh_3/benchmark/Mesh_3/benchmark_config.h +++ b/Mesh_3/benchmark/Mesh_3/benchmark_config.h @@ -28,7 +28,6 @@ // #define CGAL_MESH_3_POLYHEDRON_WITH_FEATURES // #define CGAL_MESH_3_IMPLICIT_WITH_FEATURES -// #define CGAL_MESH_3_USE_OLD_SURFACE_RESTRICTED_DELAUNAY_UPDATE // WARNING: VERY SLOW #define CGAL_MESH_3_INITIAL_POINTS_NO_RANDOM_SHOOTING // #define CGAL_MESH_3_BENCHMARK_LLOYD diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h index aeb0c9fae2c4..7740fbc7a3d1 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h @@ -47,10 +47,6 @@ #include #include -#ifdef CGAL_MESH_3_USE_OLD_SURFACE_RESTRICTED_DELAUNAY_UPDATE -#include -#endif - #include #include @@ -202,17 +198,8 @@ class Mesher_3 Cells_level, Null_mesh_visitor> Facets_visitor; -#ifndef CGAL_MESH_3_USE_OLD_SURFACE_RESTRICTED_DELAUNAY_UPDATE /// Cells visitor : it just need to know previous level typedef Null_mesh_visitor_level Cells_visitor; -#else - /// Cells visitor : to update surface (restore restricted Delaunay) - /// when refining cells - typedef Surface_mesher::Visitor< - Triangulation, - Facets_level, - Facets_visitor> Cells_visitor; -#endif /// Constructor Mesher_3(C3T3& c3t3, @@ -384,11 +371,7 @@ Mesher_3::Mesher_3(C3T3& c3t3, ) , null_visitor_() , facets_visitor_(&cells_mesher_, &null_visitor_) -#ifndef CGAL_MESH_3_USE_OLD_SURFACE_RESTRICTED_DELAUNAY_UPDATE , cells_visitor_(facets_visitor_) -#else -, cells_visitor_(&facets_mesher_, &facets_visitor_) -#endif , r_c3t3_(c3t3) , maximal_number_of_vertices_(maximal_number_of_vertices) , error_code_(error_code) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index 346ae6e88c13..aebded10c496 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -412,11 +412,7 @@ class Refine_cells_3 // Job to do after insertion void after_insertion_impl(const Vertex_handle& v) -#ifndef CGAL_MESH_3_USE_OLD_SURFACE_RESTRICTED_DELAUNAY_UPDATE { update_star_self(v); } -#else - { update_star(v); } -#endif // Insertion implementation ; returns the inserted vertex Vertex_handle insert_impl(const Weighted_point& p, const Zone& zone); diff --git a/Mesh_3/test/Mesh_3/test_meshing_utilities.h b/Mesh_3/test/Mesh_3/test_meshing_utilities.h index a6fc40318ba4..2c7f06cd1747 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_utilities.h +++ b/Mesh_3/test/Mesh_3/test_meshing_utilities.h @@ -122,7 +122,6 @@ struct Tester CGAL::parameters::no_perturb(), CGAL::parameters::no_reset_c3t3()); -#ifndef CGAL_MESH_3_USE_OLD_SURFACE_RESTRICTED_DELAUNAY_UPDATE // Using adjacencies instead of calling oracle to update restricted // Delaunay of the surface during the refinement of the volume // does not ensure that refinement is idempotent @@ -142,7 +141,6 @@ struct Tester f = c3t3.number_of_facets_in_complex(); c = c3t3.number_of_cells_in_complex(); assert ( n < 11 ); -#endif verify_c3t3(c3t3,domain,domain_type,v,v,f,f,c,c); verify_c3t3_hausdorff_distance(c3t3, domain, domain_type, hdist); From 82457f56429be286e9597b912c3f26bab322aee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 26 Mar 2026 12:00:18 +0100 Subject: [PATCH 071/127] Prefer C3T3 member functions to cell base member functions Easier to switch between implementations that have the info in the C3T3 and implementations that have the info in the cell base. --- Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp | 12 ++++++------ Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 2 +- Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 4 ++-- .../CGAL/Mesh_3/mesh_standard_cell_criteria.h | 2 +- Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp | 4 ++-- Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp | 2 +- Mesh_3/test/Mesh_3/test_meshing_utilities.h | 6 +++--- .../internal/collapse_short_edges.h | 6 +++--- .../internal/split_long_edges.h | 10 +++++----- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp index 89a3e74f8a72..77b0b7110332 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -449,9 +449,9 @@ update_c3t3(C3t3& c3t3) c3t3.rescan_after_load_of_triangulation(); //fix counters for facets and cells for (Cell_handle cit : c3t3.triangulation().finite_cell_handles()) { - CGAL_assertion(cit->subdomain_index() >= 0); - if (cit->subdomain_index() != C3t3::Triangulation::Cell::Subdomain_index()) - c3t3.add_to_complex(cit, cit->subdomain_index()); + CGAL_assertion(c3t3.subdomain_index(cit) >= 0); + if (c3t3.subdomain_index(cit) != C3t3::Triangulation::Cell::Subdomain_index()) + c3t3.add_to_complex(cit, c3t3.subdomain_index(cit)); for (int i = 0; i < 4; ++i) { @@ -469,11 +469,11 @@ update_c3t3(C3t3& c3t3) Cell_handle nc = c->neighbor(fit.second); // By definition, Subdomain_index() is supposed to be the id of the exterior - if (c->subdomain_index() != C3t3::Triangulation::Cell::Subdomain_index() && - nc->subdomain_index() == C3t3::Triangulation::Cell::Subdomain_index()) + if (c3t3.subdomain_index(c) != C3t3::Triangulation::Cell::Subdomain_index() && + c3t3.subdomain_index(nc) == C3t3::Triangulation::Cell::Subdomain_index()) { // Color the border facet with the index of its cell - c3t3.add_to_complex(c, fit.second, c->subdomain_index()); + c3t3.add_to_complex(c, fit.second, c3t3.subdomain_index(c)); } } } diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 0762d423cd9d..2534f8a63966 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1320,7 +1320,7 @@ class C3T3_helpers { sliver_value_ = criterion.is_sliver(c) ? criterion(c) : 0.; - subdomain_index_ = c->subdomain_index(); + subdomain_index_ = c3t3.subdomain_index(c); for(std::size_t i = 0; i < 4; ++i) { const int ii = static_cast(i);//avoid warnings diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index aebded10c496..f416d83bf079 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -388,9 +388,9 @@ class Refine_cells_3 Bare_point refinement_point_impl(const Cell_handle& cell) const { this->set_last_vertex_index( - r_oracle_.index_from_subdomain_index(cell->subdomain_index()) ); + r_oracle_.index_from_subdomain_index(r_c3t3_.subdomain_index(cell)) ); - // last_vertex_index_ = Index(cell->subdomain_index()); + // last_vertex_index_ = Index(r_c3t3_.subdomain_index(cell)); // NB : dual() is optimized when the cell base class has circumcenter() return r_tr_.dual(cell); } diff --git a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_cell_criteria.h b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_cell_criteria.h index 2328ccdfb398..993c1490a18d 100644 --- a/Mesh_3/include/CGAL/Mesh_3/mesh_standard_cell_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/mesh_standard_cell_criteria.h @@ -285,7 +285,7 @@ class Cell_variable_size_criterion const FT size = sq_radius(p, q, r, s); const FT sq_bound = CGAL::square( size_(tr.dual(ch), 3, - Index(ch->subdomain_index())) ); + Index(c3t3.subdomain_index(ch))) ); if ( size > sq_bound ) { diff --git a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp index b0891d3f34c0..e53a3324df57 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp @@ -58,8 +58,8 @@ int main (int argc, char** argv){ cit != c3t3.triangulation().finite_cells_end(); ++cit) { - assert(cit->subdomain_index() >= 0); - c3t3.add_to_complex(cit, cit->subdomain_index()); + assert(c3t3.subdomain_index(cit) >= 0); + c3t3.add_to_complex(cit, c3t3.subdomain_index(cit)); for(int i=0; i < 4; ++i) { if(cit->surface_patch_index(i)>0) diff --git a/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp b/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp index 94d3d35a5a9f..287f93e92acb 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_criteria_creation.cpp @@ -51,7 +51,7 @@ int main() // Init cell tr.dual(ch); - ch->set_subdomain_index(sub_index); + c3t3.set_subdomain_index(ch, sub_index); // Init facet Tr::Bare_point facet_circum = diff --git a/Mesh_3/test/Mesh_3/test_meshing_utilities.h b/Mesh_3/test/Mesh_3/test_meshing_utilities.h index 2c7f06cd1747..9f94e1d27c91 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_utilities.h +++ b/Mesh_3/test/Mesh_3/test_meshing_utilities.h @@ -326,11 +326,11 @@ struct Tester assert(index.first != index.second); Cell_handle c1 = f.first; Cell_handle c2 = f.first->neighbor(f.second); - if( c1->subdomain_index() == c2->subdomain_index() ) + if( c3t3.subdomain_index(c1) == c3t3.subdomain_index(c2) ) { std::cerr << "ERROR:" - << "\nc1->subdomain_index(): " << c1->subdomain_index() - << "\nc2->subdomain_index(): " << c2->subdomain_index() + << "\nc3t3.subdomain_index(c1): " << c3t3.subdomain_index(c1) + << "\nc3t3.subdomain_index(c2): " << c3t3.subdomain_index(c2) << "\nc3t3.surface_patch_index(f).first: " << index.first << "\nc3t3.surface_patch_index(f).second: " << index.second; if(tr.is_infinite(c1)) std::cerr << "\nc1 is infinite"; diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h index d78a3092c1e4..810bea43bdc6 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h @@ -783,12 +783,12 @@ void merge_surface_patch_indices(const typename C3t3::Facet& f1, if (in_cx_f1 && !in_cx_f2) { typename C3t3::Surface_patch_index patch = c3t3.surface_patch_index(f1); - f2.first->set_surface_patch_index(f2.second, patch); + c3t3.set_surface_patch_index(f2, patch); } else if (in_cx_f2 && !in_cx_f1) { typename C3t3::Surface_patch_index patch = c3t3.surface_patch_index(f2); - f1.first->set_surface_patch_index(f1.second, patch); + c3t3.set_surface_patch_index(f1, patch); } else if(in_cx_f1 && in_cx_f2) { @@ -796,7 +796,7 @@ void merge_surface_patch_indices(const typename C3t3::Facet& f1, typename C3t3::Surface_patch_index patch = c3t3.surface_patch_index(f2); c3t3.remove_from_complex(f2); - f2.first->set_surface_patch_index(f2.second, patch); + c3t3.set_surface_patch_index(f2, patch); } } diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h index 8a53ed2ea9e4..36e64155d8bf 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h @@ -254,13 +254,13 @@ typename C3t3::Vertex_handle split_edge(const typename C3t3::Edge& e, const Facet_info v_and_opp_patch = facets_info.at(mfi); // facet opposite to new_v (status wrt c3t3 is unchanged) - new_cell->set_surface_patch_index(new_cell->index(new_v), - mfi.first->surface_patch_index(mfi.second)); + c3t3.set_surface_patch_index(new_cell, new_cell->index(new_v), + c3t3.surface_patch_index(mfi)); // new half-facet (added or not to c3t3 depending on the stored surface patch index) if (Surface_patch_index() == v_and_opp_patch.patch_index_) - new_cell->set_surface_patch_index(new_cell->index(v_and_opp_patch.opp_vertex_), - Surface_patch_index()); + c3t3.set_surface_patch_index(new_cell, new_cell->index(v_and_opp_patch.opp_vertex_), + Surface_patch_index()); else c3t3.add_to_complex(new_cell, new_cell->index(v_and_opp_patch.opp_vertex_), @@ -272,7 +272,7 @@ typename C3t3::Vertex_handle split_edge(const typename C3t3::Edge& e, const Vertex_handle vi = new_cell->vertex(i); if (vi == v1 || vi == v2) { - new_cell->set_surface_patch_index(i, Surface_patch_index()); + c3t3.set_surface_patch_index(new_cell, i, Surface_patch_index()); break; } } From c8c9ed466403b19e3ac7f950e2834201df5f70e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Mar 2026 14:33:19 +0100 Subject: [PATCH 072/127] Use an unordered flat map --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 27317f24cf2a..fe625ea3469f 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -78,7 +79,7 @@ template struct Hash_map_of_pairs_type { - typedef std::unordered_map type; + typedef CGAL::unordered_flat_map type; }; #ifdef CGAL_LINKED_WITH_TBB From 038e3929a0303ed1cb1bf455246ad0a94be42fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Mar 2026 14:33:56 +0100 Subject: [PATCH 073/127] Remove assertion --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 1 - 1 file changed, 1 deletion(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index fe625ea3469f..7d4a6a147c99 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -856,7 +856,6 @@ class Mesh_complex_3_in_triangulation_3 for (const auto& e : boundary_facet_infos) { const Facet& nf = e.first; - CGAL_assertion(is_in_complex(nf)); add_to_complex(nf, e.second.surface_index_); set_surface_info(nf, e.second); } From 1d3f94f91719e50e89b144ea297ca663d5e8b0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Mar 2026 14:34:54 +0100 Subject: [PATCH 074/127] Revert "Halve the memory map footprint by storing only once per facet pair" This reverts commit 3f6894c02cf17daceab3c00b8f48c8b683bdafed. --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 6 + Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h | 59 ++---- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 10 +- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 179 +++++++++--------- 4 files changed, 109 insertions(+), 145 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 2534f8a63966..8bac5600314a 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1177,6 +1177,7 @@ class C3T3_helpers if(update_surface_center) { + Facet facet_m = c3t3_.triangulation().mirror_facet(facet); if(surface) { #ifndef CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 @@ -1186,6 +1187,7 @@ class C3T3_helpers // Update facet surface center const Bare_point& surface_center = std::get<0>(intersection); c3t3_.set_surface_center(facet.first, facet.second, surface_center); + c3t3_.set_surface_center(facet_m.first, facet_m.second, surface_center); } } @@ -1417,6 +1419,8 @@ class C3T3_helpers if(!( Surface_patch_index() == index )) { c3t3.add_to_complex(f, index); c3t3.set_surface_info(f, surface_prop_table_[old_i]); + const Facet mirror = c3t3.triangulation().mirror_facet(f); + c3t3.set_surface_info(mirror, surface_prop_table_[old_i]); } else { c3t3.remove_from_complex(f); } @@ -1435,6 +1439,8 @@ class C3T3_helpers if (!( Surface_patch_index() == index )) { c3t3.add_to_complex(f, index); c3t3.set_surface_info(f, surface_prop_table_[0]); + const Facet mirror = c3t3.triangulation().mirror_facet(f); + c3t3.set_surface_info(mirror, surface_prop_table_[0]); } else { c3t3.remove_from_complex(f); } diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h index f416d83bf079..3af96625b74c 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_cells_3.h @@ -894,27 +894,9 @@ update_star_self(const Vertex_handle& vertex) const int& k = (*cell_it)->index(vertex); const Facet mirror_f = mirror_facet(*cell_it,k); - CGAL_assertion(!r_c3t3_.is_in_complex(Facet(*cell_it, k), false /*do not canonicalize*/)); - - // See also the function insert_impl: if a facet is a surface facet, we mark its opposite facet - // before insertion regardless of canonicality because the boundary facet is destroyed but - // but not the opposite facet. Now, after the insertion, we must restore that the canonical - // facet is marked if the facet is a surface facet. - if ( r_c3t3_.is_in_complex(mirror_f, false /*do not canonicalize*/) ) - { - // Avoid duplicating information. - const Facet canonical_f = r_c3t3_.canonical_facet(*cell_it, k); - if (canonical_f != mirror_f) - { - const auto& sf = r_c3t3_.surface_info(mirror_f, false /*do not canonicalize*/); - r_c3t3_.set_surface_info(canonical_f, sf); - r_c3t3_.set_surface_patch_index(mirror_f, Surface_patch_index(), false /*do not canonicalize*/); - } - CGAL_postcondition(r_c3t3_.is_in_complex(*cell_it,k)); - CGAL_postcondition(r_c3t3_.is_in_complex(mirror_f)); - CGAL_postcondition(r_c3t3_.is_in_complex(canonical_f, false)); - CGAL_postcondition(!r_c3t3_.is_in_complex(r_c3t3_.triangulation().mirror_facet(canonical_f), false)); - } + // @todo here and below is 2 map looks up which could be only one. + if (r_c3t3_.is_in_complex(mirror_f)) + r_c3t3_.set_surface_info(*cell_it, k, r_c3t3_.surface_info(mirror_f)); // Set subdomain index set_cell_in_domain(*cell_it, cells_subdomain); @@ -965,33 +947,14 @@ Refine_cells_3:: insert_impl(const Weighted_point& point, const Zone& zone) { - // The block below shouldn't be needed because it would be an encroachment? - auto ifit = zone.internal_facets.begin(); - for ( ; ifit != zone.internal_facets.end() ; ++ifit ) - r_c3t3_.remove_from_complex(*ifit); - - // Surface facet info must be preserved throughout the insertion of the new vertex, - // but boundary facets of the conflict zone are destroyed. - // So we temporarily mark the opposite facet (which is not destroyed) regardless of canonicality, - // and we will check post-insertion if we have marked twice - auto bfit = zone.boundary_facets.begin(); - for ( ; bfit != zone.boundary_facets.end() ; ++bfit ) - { - // @todo three map accesses for bfit... - if (r_c3t3_.is_in_complex(*bfit)) { - const Facet mirror_f = mirror_facet(*bfit); - CGAL_assertion(*bfit != mirror_f); - - const auto& sf = r_c3t3_.surface_info(*bfit); - - r_c3t3_.set_surface_info(mirror_f, sf, false /*do not canonicalize*/); - CGAL_postcondition(r_c3t3_.is_in_complex(*bfit)); - CGAL_postcondition(r_c3t3_.is_in_complex(mirror_f, false /*do not canonicalize*/)); - - r_c3t3_.set_surface_patch_index(*bfit, Surface_patch_index(), false /*do not canonicalize*/); - CGAL_postcondition(!r_c3t3_.is_in_complex(*bfit, false /*do not canonicalize*/)); - CGAL_postcondition(r_c3t3_.is_in_complex(mirror_f, false /*do not canonicalize*/)); - } + // Remove the cell's facets from the complex (and from the hash map). + // Do *not* call the C3T3's remove_from_complex() because the information + // on the opposite facet must not be cleared for boundary facets. + auto cit = zone.cells.begin(); + for ( ; cit != zone.cells.end() ; ++cit ) + { + for (int i = 0 ; i < 4 ; ++i) + r_c3t3_.set_surface_patch_index(*cit, i, Surface_patch_index()); } // TODO: look at this diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index c6916994a8c2..9014764ede9f 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -468,15 +468,19 @@ class Refine_facets_3_base const Bare_point& center) { r_c3t3_.add_to_complex(f, surface_index); - // a little awkward: this is performed after add_to_complex() because otherwise - // the surface index is set up, and add_to_complex() does nothing... + + const Facet mirror = mirror_facet(f); + + // a little awkward: these are performed after add_to_complex() because otherwise + // the surface index is set up, and add_to_complex() will do nothing... r_c3t3_.set_surface_info(f, {surface_index, center_index, center}); + r_c3t3_.set_surface_info(mirror, {surface_index, center_index, center}); } /// Returns index of facet `f`. Surface_patch_index get_facet_surface_index(const Facet& f) const { - return r_c3t3_.surface_patch_index(f); + return r_c3t3_.surface_patch_index(f.first, f.second); } /// Sets index and dimension of vertex `v`. diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 7d4a6a147c99..bce92973ce14 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -93,7 +93,7 @@ struct Hash_map_of_pairs_type template class C3t3_helper_class { - public: + protected: typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Facet Facet; @@ -117,15 +117,10 @@ struct Hash_map_of_pairs_type return make_ordered_pair(e.first->vertex(e.second), e.first->vertex(e.third)); } - Facet canonical_facet(Cell_handle c, int i) const { Cell_handle c2 = c->neighbor(i); return (c2 < c) ? std::make_pair(c2, c2->index(c)) : std::make_pair(c, i); } - - Facet canonical_facet(const Facet& f) const { - return canonical_facet(f.first, f.second); - } }; // end class template C3t3_helper_class } // namespace details @@ -489,14 +484,13 @@ class Mesh_complex_3_in_triangulation_3 /** sets the surface index of facet \p f to \p index */ void set_surface_patch_index(const Facet& f, - const Surface_patch_index& index, - const bool do_canonicalize = true) const + const Surface_patch_index& index) const { - const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; + // std::cout << "set " << &*(cell) << " " << i << " to " << index << " (new)" << std::endl; if (index == Surface_patch_index()) { - surface_facet_info_.erase(cf); + surface_facet_info_.erase(f); } else { @@ -504,13 +498,13 @@ class Mesh_complex_3_in_triangulation_3 if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, cf); + surface_facet_info_.insert(accessor, f); accessor->second.surface_index_ = index; } else #endif { - surface_facet_info_[cf].surface_index_ = index; + surface_facet_info_[f].surface_index_ = index; } } } @@ -519,28 +513,25 @@ class Mesh_complex_3_in_triangulation_3 */ void set_surface_patch_index(const Cell_handle& cell, const int i, - const Surface_patch_index& index, - const bool do_canonicalize = true) const + const Surface_patch_index& index) const { - return set_surface_patch_index(Facet(cell, i), index, do_canonicalize); + return set_surface_patch_index(Facet(cell, i), index); } void set_surface_center(const Facet& f, - const Bare_point& p, - const bool do_canonicalize = true) const + const Bare_point& p) const { - const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, cf); + surface_facet_info_.insert(accessor, f); accessor->second.center_ = p; } else #endif { - surface_facet_info_[cf].center_ = p; + surface_facet_info_[f].center_ = p; } } @@ -548,28 +539,25 @@ class Mesh_complex_3_in_triangulation_3 */ void set_surface_center(const Cell_handle& cell, const int i, - const Bare_point& p, - const bool do_canonicalize = true) const + const Bare_point& p) const { - return set_surface_center(Facet(cell, i), p, do_canonicalize); + return set_surface_center(Facet(cell, i), p); } void set_surface_center_index(const Facet& f, - const Index& index, - const bool do_canonicalize = true) const + const Index& index) const { - const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, cf); + surface_facet_info_.insert(accessor, f); accessor->second.center_index_ = index; } else #endif { - surface_facet_info_[cf].center_index_ = index; + surface_facet_info_[f].center_index_ = index; } } @@ -577,20 +565,17 @@ class Mesh_complex_3_in_triangulation_3 */ void set_surface_center_index(const Cell_handle& cell, const int i, - const Index& index, - const bool do_canonicalize = true) const + const Index& index) const { - return set_surface_center_index(Facet(cell, i), index, do_canonicalize); + return set_surface_center_index(Facet(cell, i), index); } void set_surface_info(const Facet& f, - const Facet_prop& info, - const bool do_canonicalize = true) const + const Facet_prop& info) const { - const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; if (info.surface_index_ == Surface_patch_index()) { - surface_facet_info_.erase(cf); + surface_facet_info_.erase(f); } else { @@ -598,22 +583,21 @@ class Mesh_complex_3_in_triangulation_3 if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, cf); + surface_facet_info_.insert(accessor, f); accessor->second = info; } else #endif { - surface_facet_info_[cf] = info; + surface_facet_info_[f] = info; } } } void set_surface_info(const Cell_handle& cell, int i, - const Facet_prop& info, - const bool do_canonicalize = true) const + const Facet_prop& info) const { - return set_surface_info(Facet(cell, i), info, do_canonicalize); + return set_surface_info(Facet(cell, i), info); } /** sets the subdomain index of cell \p cell to \p index @@ -645,21 +629,19 @@ class Mesh_complex_3_in_triangulation_3 } /** returns the surface index of facet \p f */ - Surface_patch_index surface_patch_index(const Facet& f, - const bool do_canonicalize = true) const + Surface_patch_index surface_patch_index(const Facet& f) const { - const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; - if (surface_facet_info_.find(accessor, cf)) + if (surface_facet_info_.find(accessor, f)) return accessor->second.surface_index_; } else #endif { - auto it = surface_facet_info_.find(cf); + auto it = surface_facet_info_.find(f); if (it != surface_facet_info_.end()) return it->second.surface_index_; } @@ -669,31 +651,28 @@ class Mesh_complex_3_in_triangulation_3 /** returns the surface index of facet(\p cell, \p i) */ Surface_patch_index surface_patch_index(const Cell_handle& cell, - const int i, - const bool do_canonicalize = true) const + const int i) const { - return surface_patch_index(Facet(cell, i), do_canonicalize); + return surface_patch_index(Facet(cell, i)); } - decltype(auto) surface_center(const Facet& f, - const bool do_canonicalize = true) const + decltype(auto) surface_center(const Facet& f) const { - const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; - CGAL_precondition(is_in_complex(cf)); + CGAL_precondition(is_in_complex(f)); # ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, cf); + surface_facet_info_.find(accessor, f); CGAL_assume(found); return accessor->second.center_; } else #endif { - auto it = surface_facet_info_.find(cf); + auto it = surface_facet_info_.find(f); CGAL_assume(it != surface_facet_info_.end()); return it->second.center_; } @@ -702,31 +681,28 @@ class Mesh_complex_3_in_triangulation_3 /** returns the surface center of facet(\p cell, \p i) */ decltype(auto) surface_center(const Cell_handle& cell, - const int i, - const bool do_canonicalize = true) const + const int i) const { - return surface_center(Facet(cell, i), do_canonicalize); + return surface_center(Facet(cell, i)); } - Index surface_center_index(const Facet& f, - const bool do_canonicalize = true) const + Index surface_center_index(const Facet& f) const { - const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; - CGAL_precondition(is_in_complex(cf)); + CGAL_precondition(is_in_complex(f)); # ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, cf); + surface_facet_info_.find(accessor, f); CGAL_assume(found); return accessor->second.center_index_; } else #endif { - auto it = surface_facet_info_.find(cf); + auto it = surface_facet_info_.find(f); CGAL_assume(it != surface_facet_info_.end()); return it->second.center_index_; } @@ -735,29 +711,26 @@ class Mesh_complex_3_in_triangulation_3 /** returns the surface center index of facet(\p cell, \p i) */ Index surface_center_index(const Cell_handle& cell, - const int i, - const bool do_canonicalize = true) const + const int i) const { - return surface_center_index(Facet(cell, i), do_canonicalize); + return surface_center_index(Facet(cell, i)); } - decltype(auto) surface_info(const Facet& f, - const bool do_canonicalize = true) const + decltype(auto) surface_info(const Facet& f) const { - const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, cf); + surface_facet_info_.find(accessor, f); CGAL_assume(found); return accessor->second; } else #endif { - auto it = surface_facet_info_.find(cf); + auto it = surface_facet_info_.find(f); CGAL_assume(it != surface_facet_info_.end()); return it->second; } @@ -836,28 +809,41 @@ class Mesh_complex_3_in_triangulation_3 old_cells.reserve(32); tr.incident_cells(v, std::back_inserter(old_cells)); - // The vertex 'v' is isolated from the complex, but the facets opposite to it in the incident - // cells may be in the complex and their surface info must be preserved. - std::unordered_map boundary_facet_infos; - for (const Cell_handle& c : old_cells) { - const Facet f(c, c->index(v)); - if (!is_in_complex(f)) - continue; - boundary_facet_infos[tr.mirror_facet(f)] = surface_info(f); - remove_from_complex(f); + remove_from_complex(c); + for (int i = 0; i < 4; ++i) { + // Do *not* call the C3T3's remove_from_complex() because the information + // on the opposite facet must not be cleared for boundary facets. + set_surface_patch_index(c, i, Surface_patch_index()); + } } std::vector new_cells; new_cells.reserve(32); tr.remove_and_give_new_cells(v, std::back_inserter(new_cells)); - for (const auto& e : boundary_facet_infos) + typename std::vector::iterator nc_it = new_cells.begin(); + typename std::vector::iterator nc_it_end = new_cells.end(); + for (; nc_it != nc_it_end; ++nc_it) { - const Facet& nf = e.first; - add_to_complex(nf, e.second.surface_index_); - set_surface_info(nf, e.second); + Cell_handle c = *nc_it; + for (int i = 0; i < 4; ++i) + { + Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i)); + if (is_in_complex(mirror_facet)) + { + set_surface_patch_index(c, i, surface_patch_index(mirror_facet)); + set_surface_center(c, i, surface_center(mirror_facet.first, mirror_facet.second)); + } + } + /*int i_inf; + if (c->has_vertex(tr.infinite_vertex(), i_inf)) + { + Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i_inf)); + if (is_in_complex(mirror_facet)) + set_surface_patch_index(c, i_inf, surface_patch_index(mirror_facet)); + }*/ } } @@ -1002,21 +988,19 @@ class Mesh_complex_3_in_triangulation_3 } /** returns true if facet \p f belongs to the 2D complex */ - bool is_in_complex(const Facet& f, - const bool do_canonicalize = true) const + bool is_in_complex(const Facet& f) const { - const Facet cf = do_canonicalize ? this->canonical_facet(f) : f; #ifdef CGAL_LINKED_WITH_TBB if constexpr (std::is_same_v) { typename Surface_facet_info::const_accessor accessor; - if (surface_facet_info_.find(accessor, cf)) + if (surface_facet_info_.find(accessor, f)) return !(accessor->second.surface_index_ == Surface_patch_index()); } else #endif { - auto it = surface_facet_info_.find(cf); + auto it = surface_facet_info_.find(f); if (it != surface_facet_info_.end()) return !(it->second.surface_index_ == Surface_patch_index()); } @@ -1713,7 +1697,11 @@ class Mesh_complex_3_in_triangulation_3 ++fit) { const auto& facet = *fit; - set_surface_patch_index(facet, Surface_patch_index()); + set_surface_patch_index(facet.first, facet.second, Surface_patch_index()); + if (this->triangulation().dimension() > 2) { + const Facet& mirror = tr_.mirror_facet(facet); + set_surface_patch_index(mirror.first, mirror.second, Surface_patch_index()); + } } this->number_of_facets_ = 0; @@ -2109,7 +2097,6 @@ Mesh_complex_3_in_triangulation_3(const Self& rhs) const int this_opp = this_cell->index(this_n); const Facet this_facet(this_cell, this_opp); - const Facet this_canonical_facet = this->canonical_facet(this_facet); // std::cout << "from rhs:\n"; // std::cout << " facet: " << rhs.triangulation().point(rhs_c, (rhs_i + 1) % 4) << ", " @@ -2124,13 +2111,13 @@ Mesh_complex_3_in_triangulation_3(const Self& rhs) if constexpr (std::is_same_v) { typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, this_canonical_facet); + surface_facet_info_.insert(accessor, this_facet); accessor->second = e.second; } else #endif { - surface_facet_info_[this_canonical_facet] = e.second; + surface_facet_info_[this_facet] = e.second; } } CGAL_postcondition(surface_facet_info_.size() == rhs.surface_facet_info_.size()); @@ -2261,7 +2248,9 @@ add_to_complex(const Cell_handle& cell, if (!is_in_complex(cell, i)) { + Facet mirror = tr_.mirror_facet(std::make_pair(cell, i)); set_surface_patch_index(cell, i, index); + set_surface_patch_index(mirror.first, mirror.second, index); ++number_of_facets_; if (manifold_info_initialized_) { for (int j = 0; j < 3; ++j) @@ -2309,7 +2298,9 @@ remove_from_complex(const Facet& facet) { if (is_in_complex(facet)) { - set_surface_patch_index(facet, Surface_patch_index()); + Facet mirror = tr_.mirror_facet(facet); + set_surface_patch_index(facet.first, facet.second, Surface_patch_index()); + set_surface_patch_index(mirror.first, mirror.second, Surface_patch_index()); --number_of_facets_; if (manifold_info_initialized_) { const Cell_handle cell = facet.first; From 8957c36c71d49ade67c8fa1ab4464262d8a10d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Mar 2026 15:54:52 +0100 Subject: [PATCH 075/127] If the cell provides surface patch storage, use it --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 228 ++++++++++++------ 1 file changed, 148 insertions(+), 80 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index bce92973ce14..d86da0bce630 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -22,13 +22,14 @@ #include #include -#include #include #include -#include +#include #include +#include +#include +#include #include -#include #include #include @@ -238,6 +239,12 @@ class Mesh_complex_3_in_triangulation_3 Bare_point center_; }; + // in the configuration of a cell base still providing surface pathc info storage + // (i.e., index, center, center index), use that instead of the C3T3 hash map + CGAL_GENERATE_MEMBER_DETECTOR(set_surface_patch_index); + static constexpr bool store_surface_patch_info_in_cell = + has_set_surface_patch_index::value; + private: // Type to store the edges: // - a set of std::pair (ordered at insertion) @@ -486,25 +493,32 @@ class Mesh_complex_3_in_triangulation_3 void set_surface_patch_index(const Facet& f, const Surface_patch_index& index) const { - // std::cout << "set " << &*(cell) << " " << i << " to " << index << " (new)" << std::endl; - - if (index == Surface_patch_index()) + if constexpr (store_surface_patch_info_in_cell) { - surface_facet_info_.erase(f); + f.first->set_surface_patch_index(f.second, index); } else { -#ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) + CGAL_assertion(false); + if (index == Surface_patch_index()) { - typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, f); - accessor->second.surface_index_ = index; + // remove from the map as to avoid wasting memory + surface_facet_info_.erase(f); } else -#endif { - surface_facet_info_[f].surface_index_ = index; +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, f); + accessor->second.surface_index_ = index; + } + else +#endif + { + surface_facet_info_[f].surface_index_ = index; + } } } } @@ -521,17 +535,24 @@ class Mesh_complex_3_in_triangulation_3 void set_surface_center(const Facet& f, const Bare_point& p) const { -#ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) + if constexpr (store_surface_patch_info_in_cell) { - typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, f); - accessor->second.center_ = p; + f.first->set_surface_center(f.second, p); } else -#endif { - surface_facet_info_[f].center_ = p; +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, f); + accessor->second.center_ = p; + } + else +#endif + { + surface_facet_info_[f].center_ = p; + } } } @@ -547,17 +568,24 @@ class Mesh_complex_3_in_triangulation_3 void set_surface_center_index(const Facet& f, const Index& index) const { -#ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) + if constexpr (store_surface_patch_info_in_cell) { - typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, f); - accessor->second.center_index_ = index; + f.first->set_surface_center_index(f.second, index); } else -#endif { - surface_facet_info_[f].center_index_ = index; +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, f); + accessor->second.center_index_ = index; + } + else +#endif + { + surface_facet_info_[f].center_index_ = index; + } } } @@ -573,23 +601,33 @@ class Mesh_complex_3_in_triangulation_3 void set_surface_info(const Facet& f, const Facet_prop& info) const { - if (info.surface_index_ == Surface_patch_index()) + CGAL_assertion(false); + if constexpr (store_surface_patch_info_in_cell) { - surface_facet_info_.erase(f); + f.first->set_surface_patch_index(f.second, info.surface_index_); + f.first->set_facet_surface_center(f.second, info.center_); + f.first->set_facet_surface_center_index(f.second, info.center_index_); } else { -#ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) + if (info.surface_index_ == Surface_patch_index()) { - typename Surface_facet_info::accessor accessor; - surface_facet_info_.insert(accessor, f); - accessor->second = info; + surface_facet_info_.erase(f); } else -#endif { - surface_facet_info_[f] = info; +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::accessor accessor; + surface_facet_info_.insert(accessor, f); + accessor->second = info; + } + else +#endif + { + surface_facet_info_[f] = info; + } } } } @@ -631,20 +669,28 @@ class Mesh_complex_3_in_triangulation_3 */ Surface_patch_index surface_patch_index(const Facet& f) const { -#ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) + if constexpr (store_surface_patch_info_in_cell) { - typename Surface_facet_info::const_accessor accessor; - if (surface_facet_info_.find(accessor, f)) - return accessor->second.surface_index_; + return f.first->surface_patch_index(f.second); } else -#endif { - auto it = surface_facet_info_.find(f); - if (it != surface_facet_info_.end()) - return it->second.surface_index_; +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::const_accessor accessor; + if (surface_facet_info_.find(accessor, f)) + return accessor->second.surface_index_; + } + else +#endif + { + auto it = surface_facet_info_.find(f); + if (it != surface_facet_info_.end()) + return it->second.surface_index_; + } } + return Surface_patch_index(); } @@ -660,21 +706,28 @@ class Mesh_complex_3_in_triangulation_3 { CGAL_precondition(is_in_complex(f)); -# ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) + if constexpr (store_surface_patch_info_in_cell) { - typename Surface_facet_info::const_accessor accessor; - CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, f); - CGAL_assume(found); - return accessor->second.center_; + return f.first->get_facet_surface_center(f.second); } else -#endif { - auto it = surface_facet_info_.find(f); - CGAL_assume(it != surface_facet_info_.end()); - return it->second.center_; +# ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::const_accessor accessor; + CGAL_assume_code(bool found =) + surface_facet_info_.find(accessor, f); + CGAL_assume(found); + return accessor->second.center_; + } + else +#endif + { + auto it = surface_facet_info_.find(f); + CGAL_assume(it != surface_facet_info_.end()); + return it->second.center_; + } } } @@ -690,21 +743,28 @@ class Mesh_complex_3_in_triangulation_3 { CGAL_precondition(is_in_complex(f)); -# ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) + if constexpr (store_surface_patch_info_in_cell) { - typename Surface_facet_info::const_accessor accessor; - CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, f); - CGAL_assume(found); - return accessor->second.center_index_; + return f.first->get_facet_surface_center_index(f.second); } else -#endif { - auto it = surface_facet_info_.find(f); - CGAL_assume(it != surface_facet_info_.end()); - return it->second.center_index_; +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::const_accessor accessor; + CGAL_assume_code(bool found =) + surface_facet_info_.find(accessor, f); + CGAL_assume(found); + return accessor->second.center_index_; + } + else +#endif + { + auto it = surface_facet_info_.find(f); + CGAL_assume(it != surface_facet_info_.end()); + return it->second.center_index_; + } } } @@ -718,21 +778,30 @@ class Mesh_complex_3_in_triangulation_3 decltype(auto) surface_info(const Facet& f) const { -#ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) + if constexpr (store_surface_patch_info_in_cell) { - typename Surface_facet_info::const_accessor accessor; - CGAL_assume_code(bool found =) - surface_facet_info_.find(accessor, f); - CGAL_assume(found); - return accessor->second; + return Facet_prop{ f.first->surface_patch_index(f.second), + f.first->get_facet_surface_center_index(f.second), + f.first->get_facet_surface_center(f.second) }; } else -#endif { - auto it = surface_facet_info_.find(f); - CGAL_assume(it != surface_facet_info_.end()); - return it->second; +#ifdef CGAL_LINKED_WITH_TBB + if constexpr (std::is_same_v) + { + typename Surface_facet_info::const_accessor accessor; + CGAL_assume_code(bool found =) + surface_facet_info_.find(accessor, f); + CGAL_assume(found); + return accessor->second; + } + else +#endif + { + auto it = surface_facet_info_.find(f); + CGAL_assume(it != surface_facet_info_.end()); + return it->second; + } } } @@ -800,7 +869,6 @@ class Mesh_complex_3_in_triangulation_3 far_vertices_.push_back(vh); } - void remove_isolated_vertex(Vertex_handle v) { Triangulation& tr = triangulation(); From 1c7556cf977e052a99aec9af39ab8712065d9c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 27 Mar 2026 16:01:31 +0100 Subject: [PATCH 076/127] Simplify is_in_complex(Facet) And fix it for cases where storage is within the hash map --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index d86da0bce630..3927dba737a2 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -1058,21 +1058,7 @@ class Mesh_complex_3_in_triangulation_3 */ bool is_in_complex(const Facet& f) const { -#ifdef CGAL_LINKED_WITH_TBB - if constexpr (std::is_same_v) - { - typename Surface_facet_info::const_accessor accessor; - if (surface_facet_info_.find(accessor, f)) - return !(accessor->second.surface_index_ == Surface_patch_index()); - } - else -#endif - { - auto it = surface_facet_info_.find(f); - if (it != surface_facet_info_.end()) - return !(it->second.surface_index_ == Surface_patch_index()); - } - return false; + return !(surface_patch_index(f) == Surface_patch_index()); } /** returns true if facet (\p cell, \p i) belongs to the 2D complex From c13fbeaeedf0fd57fdb83de7086ffd7fcab35ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 1 Apr 2026 12:24:03 +0200 Subject: [PATCH 077/127] Use actual c3t3 in soup_to_c3t3 I/O functions --- .../Mesh_complex_3_in_triangulation_3_fwd.h | 16 +- .../Mesh_complex_3_in_triangulation_3_fwd.h | 19 +- Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp | 6 +- .../Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp | 4 +- Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp | 2 +- SMDS_3/include/CGAL/IO/File_avizo.h | 14 +- SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h | 201 ++++++++++++------ .../test/SMDS_3/test_c3t3_into_facegraph.cpp | 2 +- .../internal/collapse_short_edges.h | 9 +- 9 files changed, 176 insertions(+), 97 deletions(-) diff --git a/Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h index 6d644faa1ec2..79659554cb2d 100644 --- a/Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -24,14 +24,14 @@ template class Mesh_complex_3_in_triangulation_3; -template -bool build_triangulation_from_file(std::istream& is, - Tr& tr, - bool replace_domain_0); - -template -bool build_triangulation_from_file(std::istream& is, - Tr& tr); +template +bool build_mesh_complex_from_file(std::istream& is, + C3T3& c3t3, + bool replace_domain_0); + +template +bool build_mesh_complex_from_file(std::istream& is, + C3T3& c3t3); } // CGAL #endif diff --git a/Installation/include/CGAL/SMDS_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/SMDS_3/Mesh_complex_3_in_triangulation_3_fwd.h index 9b0c2d1e38eb..7bca8e7af125 100644 --- a/Installation/include/CGAL/SMDS_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/SMDS_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -37,12 +37,19 @@ namespace IO { namespace SMDS_3 { - template - bool build_triangulation_from_file(std::istream& is, - Tr& tr, - bool verbose = false, - bool replace_domain_0 = false, - bool allow_non_manifold = false); +template +bool build_mesh_complex_from_file(std::istream& is, + C3T3& c3t3, + bool verbose = false, + bool replace_domain_0 = false, + bool allow_non_manifold = false); + +template +bool build_triangulation_from_file(std::istream& is, + Tr& tr, + bool verbose = false, + bool replace_domain_0 = false, + bool allow_non_manifold = false); } // namespace SMDS_3 } // namespace CGAL diff --git a/Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp b/Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp index 127f4acbe85c..67070bfd4c3d 100644 --- a/Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp +++ b/Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp @@ -428,7 +428,7 @@ class CGAL_Lab_vtk_plugin : subdomains.push_back(si); } std::map border_facets; - //Preprocessing for build_triangulation + //Preprocessing for build_mesh_complex //check for orientation and swap in cells if not good. for(std::size_t i=0; ic3t3().triangulation(), + CGAL::SMDS_3::build_mesh_complex_with_subdomains_range( + c3t3_item->c3t3(), points, finite_cells, subdomains, border_facets, false, false, true); diff --git a/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp index 77b0b7110332..607a25fb78e0 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -137,7 +137,7 @@ CGAL_Lab_c3t3_binary_io_plugin::load( item->setName(fileinfo.completeBaseName()); item->set_valid(false); - if(CGAL::SMDS_3::build_triangulation_from_file(in, item->c3t3().triangulation(), + if(CGAL::SMDS_3::build_mesh_complex_from_file(in, item->c3t3(), /*verbose = */false, /*replace_subdomain_0 = */false, /*allow_non_manifold = */true)) { update_c3t3(item->c3t3()); @@ -167,7 +167,7 @@ CGAL_Lab_c3t3_binary_io_plugin::load( item->setName(fileinfo.completeBaseName()); - if (CGAL::IO::read_AVIZO_TETRA(in, item->c3t3().triangulation())) + if (CGAL::IO::read_AVIZO_TETRA(in, item->c3t3())) { update_c3t3(item->c3t3()); diff --git a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp index e53a3324df57..66c8e61f68ab 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp @@ -51,7 +51,7 @@ int main (int argc, char** argv){ return 1; } C3t3 c3t3; - if(CGAL::SMDS_3::build_triangulation_from_file(in, c3t3.triangulation())) + if(CGAL::SMDS_3::build_mesh_complex_from_file(in, c3t3)) { for( C3t3::Triangulation::Finite_cells_iterator cit = c3t3.triangulation().finite_cells_begin(); diff --git a/SMDS_3/include/CGAL/IO/File_avizo.h b/SMDS_3/include/CGAL/IO/File_avizo.h index ee2c3a8adf0a..769624a44de7 100644 --- a/SMDS_3/include/CGAL/IO/File_avizo.h +++ b/SMDS_3/include/CGAL/IO/File_avizo.h @@ -386,11 +386,11 @@ namespace internal { return false; } - template - bool read_tetra_am(std::istream& input, Tr& tr) + template + bool read_tetra_am(std::istream& input, C3T3& c3t3) { using Material_type = unsigned char; - using Point_3 = typename Tr::Geom_traits::Point_3; + using Point_3 = typename C3T3::Triangulation::Geom_traits::Point_3; int n_nodes, n_tets, n_edges; std::vector data; @@ -505,7 +505,7 @@ namespace internal { boost::unordered_map, typename Tr::Cell::Surface_patch_index> empty_facets_map; - CGAL::SMDS_3::build_triangulation_with_subdomains_range(tr, + CGAL::SMDS_3::build_mesh_complex_with_subdomains_range(c3t3, points, tetrahedra, labels, @@ -520,15 +520,15 @@ namespace internal { }// end namespace internal - template - bool read_AVIZO_TETRA(std::istream& in, T3& tr) + template + bool read_AVIZO_TETRA(std::istream& in, C3T3& c3t3) { if (!in) { std::cerr << "Cannot open file " << std::endl; return false; } - return CGAL::IO::internal::read_tetra_am(in, tr); + return CGAL::IO::internal::read_tetra_am(in, c3t3); } } // end namespace IO diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index a627a80c7f8f..0c302297b150 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -112,23 +112,29 @@ bool add_facet_to_incident_cells_map(const typename Tr::Cell_handle c, int i, return success; } -template -bool build_finite_cells(Tr& tr, +template +bool build_finite_cells(C3T3& c3t3, const CellRange& finite_cells, const SubdomainsRange& subdomains, - const std::vector& vertex_handle_vector, - boost::unordered_map, - std::vector > >& incident_cells_map, + const std::vector& vertex_handle_vector, + boost::unordered_map, + std::vector > >& incident_cells_map, const FacetPatchMap& border_facets, const bool verbose, const bool replace_domain_0) { + typedef typename C3T3::Surface_patch_index Surface_patch_index; + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; - typedef typename Tr::Cell::Surface_patch_index Surface_patch_index; bool success = true; + Tr& tr = c3t3.triangulation(); + CGAL_assertion_code( typename Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); typename Tr::Geom_traits::Orientation_3 orientation = tr.geom_traits().orientation_3_object(); @@ -237,19 +243,22 @@ bool add_infinite_facets_to_incident_cells_map(typename Tr::Cell_handle c, return b1 && b2 && b3; } -template -bool build_infinite_cells(Tr& tr, - boost::unordered_map, - std::vector > >& incident_cells_map, +template +bool build_infinite_cells(C3T3& c3t3, + boost::unordered_map, + std::vector > >& incident_cells_map, const bool verbose, const bool allow_non_manifold) { + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; typedef std::array Facet_vvv; typedef std::pair Incident_cell; typedef boost::unordered_map > Incident_cells_map; + Tr& tr = c3t3.triangulation(); + bool success = true; std::vector infinite_cells; @@ -392,23 +401,24 @@ bool assign_neighbors(Tr& tr, return success; } -template -bool build_triangulation_impl(Tr& tr, - const PointRange& points, - const CellRange& finite_cells, - const std::vector& subdomains, - const FacetPatchMap& border_facets, - std::vector& vertex_handle_vector, - const bool verbose,// = false, - const bool replace_domain_0,// = false, - const bool allow_non_manifold) // = false +bool build_mesh_complex_impl(C3T3& c3t3, + const PointRange& points, + const CellRange& finite_cells, + const std::vector& subdomains, + const FacetPatchMap& border_facets, + std::vector& vertex_handle_vector, + const bool verbose,// = false, + const bool replace_domain_0,// = false, + const bool allow_non_manifold) // = false { if (verbose) - std::cout << "build_triangulation_impl()..." << std::endl; + std::cout << "build_mesh_complex_impl()..." << std::endl; + typedef typename C3T3::Triangulation Tr; typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; typedef std::array Facet_vvv; @@ -419,7 +429,10 @@ bool build_triangulation_impl(Tr& tr, CGAL_precondition(!points.empty()); + Tr& tr = c3t3.triangulation(); + bool success = true; + Incident_cells_map incident_cells_map; // id to vertex_handle @@ -443,8 +456,8 @@ bool build_triangulation_impl(Tr& tr, if (!finite_cells.empty()) { - if (!CGAL::SMDS_3::build_finite_cells(tr, finite_cells, subdomains, vertex_handle_vector, - incident_cells_map, border_facets, verbose, replace_domain_0)) + if (!CGAL::SMDS_3::build_finite_cells(c3t3, finite_cells, subdomains, vertex_handle_vector, + incident_cells_map, border_facets, verbose, replace_domain_0)) { if (verbose) std::cerr << "Error: build_finite_cells went wrong!" << std::endl; @@ -455,7 +468,7 @@ bool build_triangulation_impl(Tr& tr, std::cout << "build finite cells done (" << tr.tds().cells().size() << " cells)" << std::endl; } - if (!CGAL::SMDS_3::build_infinite_cells(tr, incident_cells_map, verbose, allow_non_manifold)) + if (!CGAL::SMDS_3::build_infinite_cells(c3t3, incident_cells_map, verbose, allow_non_manifold)) { if(verbose) std::cerr << "Error: build_infinite_cells went wrong!" << std::endl; @@ -468,7 +481,7 @@ bool build_triangulation_impl(Tr& tr, tr.tds().set_dimension(3); - if (!CGAL::SMDS_3::assign_neighbors(tr, incident_cells_map, allow_non_manifold)) + if (!CGAL::SMDS_3::assign_neighbors(c3t3.triangulation(), incident_cells_map, allow_non_manifold)) { if(verbose) std::cerr << "Error: assign_neighbors went wrong!" << std::endl; @@ -492,25 +505,46 @@ bool build_triangulation_impl(Tr& tr, } -template -bool build_triangulation_one_subdomain(Tr& tr, - const PointRange& points, - const CellRange& finite_cells, - const typename Tr::Cell::Subdomain_index& subdomain, - const FacetPatchMap& border_facets, - std::vector& vertex_handle_vector, - const bool verbose,// = false, - const bool replace_domain_0,// = false - const bool allow_non_manifold)// = false +bool build_mesh_complex_one_subdomain(C3T3& c3t3, + const PointRange& points, + const CellRange& finite_cells, + const typename C3T3::Subdomain_index& subdomain, + const FacetPatchMap& border_facets, + std::vector& vertex_handle_vector, + const bool verbose,// = false, + const bool replace_domain_0,// = false + const bool allow_non_manifold)// = false { - std::vector subdomains(finite_cells.size(), subdomain); - return build_triangulation_impl(tr, points, finite_cells, subdomains, - border_facets, vertex_handle_vector, - verbose, replace_domain_0, - allow_non_manifold); + std::vector subdomains(finite_cells.size(), subdomain); + return build_mesh_complex_impl(c3t3, points, finite_cells, subdomains, + border_facets, vertex_handle_vector, + verbose, replace_domain_0, + allow_non_manifold); +} + +template +bool build_mesh_complex_one_subdomain(C3T3& c3t3, + const PointRange& points, + const CellRange& finite_cells, + const typename C3T3::Subdomain_index& subdomain, + const FacetPatchMap& border_facets, + const bool verbose,// = false, + const bool replace_domain_0,// = false + const bool allow_non_manifold)//= false +{ + std::vector subdomains(finite_cells.size(), subdomain); + std::vector vertex_handle_vector; + return build_mesh_complex_impl(c3t3, points, finite_cells, subdomains, + border_facets, vertex_handle_vector, + verbose, replace_domain_0, + allow_non_manifold); } template subdomains(finite_cells.size(), subdomain); - std::vector vertex_handle_vector; - return build_triangulation_impl(tr, points, finite_cells, subdomains, - border_facets, vertex_handle_vector, - verbose, replace_domain_0, - allow_non_manifold); + CGAL::Mesh_complex_3_in_triangulation_3 c3t3; // @fixme what if 'tr' wasn't empty... + bool res = build_mesh_complex_one_subdomain(c3t3, points, finite_cells, subdomain, border_facets, + verbose, replace_domain_0, allow_non_manifold); + tr = std::move(c3t3).triangulation(); + return res; +} + +template +bool build_mesh_complex_with_subdomains_range(C3T3& c3t3, + const PointRange& points, + const CellRange& finite_cells, + const SubdomainsRange& subdomains, + const FacetPatchMap& border_facets, + const bool verbose,// = false + const bool replace_domain_0,// = false, + const bool allow_non_manifold) +{ + std::vector vertex_handle_vector; + std::vector subdomains_vector( + subdomains.begin(), subdomains.end()); + return build_mesh_complex_impl(c3t3, points, finite_cells, subdomains_vector, border_facets, + vertex_handle_vector, + verbose, replace_domain_0, + allow_non_manifold); } template vertex_handle_vector; - std::vector subdomains_vector( - subdomains.begin(), subdomains.end()); - return build_triangulation_impl(tr, points, finite_cells, subdomains_vector, border_facets, - vertex_handle_vector, - verbose, replace_domain_0, - allow_non_manifold); + CGAL::Mesh_complex_3_in_triangulation_3 c3t3; // @fixme what if 'tr' wasn't empty... + bool res = build_mesh_complex_with_subdomains_range(c3t3, points, finite_cells, subdomains, border_facets, + verbose, replace_domain_0, allow_non_manifold); + tr = std::move(c3t3).triangulation(); + return res; } -template -bool build_triangulation_from_file(std::istream& is, - Tr& tr, - const bool verbose, - const bool replace_domain_0, - const bool allow_non_manifold) +template +bool build_mesh_complex_from_file(std::istream& is, + C3T3& c3t3, + const bool verbose, + const bool replace_domain_0, + const bool allow_non_manifold) { + using Tr = typename C3T3::Triangulation; using Point_3 = typename Tr::Point; - using Subdomain_index = typename Tr::Cell::Subdomain_index; - using Surface_patch_index = typename Tr::Cell::Surface_patch_index; + using Subdomain_index = typename C3T3::Subdomain_index; + using Surface_patch_index = typename C3T3::Surface_patch_index; using Facet = std::array; // 3 = id using Tet_with_ref = std::array; // 4 = id @@ -740,11 +795,25 @@ bool build_triangulation_from_file(std::istream& is, CGAL_assertion(finite_cells.size() == subdomains.size()); - return build_triangulation_with_subdomains_range(tr, - points, finite_cells, subdomains, border_facets, - verbose, - replace_domain_0 && !is_CGAL_mesh, - allow_non_manifold); + return build_mesh_complex_with_subdomains_range(c3t3, + points, finite_cells, subdomains, border_facets, + verbose, + replace_domain_0 && !is_CGAL_mesh, + allow_non_manifold); +} + + +template +bool build_triangulation_from_file(std::istream& is, + Tr& tr, + const bool verbose, + const bool replace_domain_0, + const bool allow_non_manifold) +{ + CGAL::Mesh_complex_3_in_triangulation_3 c3t3; // @fixme what if 'tr' wasn't empty... + bool res = build_mesh_complex_from_file(is, c3t3, verbose, replace_domain_0, allow_non_manifold); + tr = std::move(c3t3).triangulation(); + return res; } } // namespace SMDS_3 diff --git a/SMDS_3/test/SMDS_3/test_c3t3_into_facegraph.cpp b/SMDS_3/test/SMDS_3/test_c3t3_into_facegraph.cpp index b31fbe22f0aa..19807d154081 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3_into_facegraph.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3_into_facegraph.cpp @@ -43,7 +43,7 @@ int main (int argc, char** argv){ return 1; } C3t3 c3t3; - if(CGAL::SMDS_3::build_triangulation_from_file(in, c3t3.triangulation())) + if(CGAL::SMDS_3::build_mesh_complex_from_file(in, c3t3)) { for( Cell_handle cit : c3t3.triangulation().finite_cell_handles()) { diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h index 810bea43bdc6..1b054dae526e 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h @@ -113,12 +113,13 @@ class CollapseTriangulation // finished std::vector new_vertices; std::map border_facets; - if (CGAL::SMDS_3::build_triangulation_impl( - triangulation, points, finite_cells, subdomains, border_facets, + if (CGAL::SMDS_3::build_mesh_complex_impl( + c3t3, points, finite_cells, subdomains, border_facets, new_vertices, /*verbose*/ false, /*replace_domain_0*/ false, /*allow_non_manifold*/false)) { + const Tr& triangulation = c3t3.triangulation(); CGAL_expensive_assertion(triangulation.tds().is_valid()); CGAL_assertion(triangulation.infinite_vertex() == new_vertices[0]); @@ -145,6 +146,8 @@ class CollapseTriangulation Result_type collapse() { + Tr& triangulation = c3t3.triangulation(); + if (not_an_edge) { #ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE @@ -301,7 +304,7 @@ class CollapseTriangulation } protected: - Tr triangulation; + C3t3 c3t3; const Collapse_type collapse_type; From 48e66647309e2e638ccb6e2fe4e2fe44473a7ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 1 Apr 2026 14:19:23 +0200 Subject: [PATCH 078/127] Split the new lightweight compact cell base into its own class --- Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp | 10 +- .../Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp | 10 +- Lab/demo/Lab/Scene_tetrahedra_item.cpp | 2 +- .../include/CGAL/Compact_mesh_cell_base_3.h | 346 ++++++++++-------- 4 files changed, 211 insertions(+), 157 deletions(-) diff --git a/Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp b/Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp index 67070bfd4c3d..a77a3bfafeae 100644 --- a/Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp +++ b/Lab/demo/Lab/Plugins/IO/VTK_io_plugin.cpp @@ -459,9 +459,9 @@ class CGAL_Lab_vtk_plugin : c3t3_item->c3t3().add_to_complex(cit, cit->info()); for(int i=0; i < 4; ++i) { - if(cit->surface_patch_index(i)>0) + if(c3t3_item->c3t3().surface_patch_index(cit, i) > 0) { - c3t3_item->c3t3().add_to_complex(cit, i, cit->surface_patch_index(i)); + c3t3_item->c3t3().add_to_complex(cit, i, c3t3_item->c3t3().surface_patch_index(cit, i)); } } } @@ -480,11 +480,11 @@ class CGAL_Lab_vtk_plugin : Cell_handle nc = c->neighbor(fit->second); // By definition, Subdomain_index() is supposed to be the id of the exterior - if(c->subdomain_index() != C3t3::Triangulation::Cell::Subdomain_index() && - nc->subdomain_index() == C3t3::Triangulation::Cell::Subdomain_index()) + if(c3t3_item->c3t3().subdomain_index(c) != C3t3::Subdomain_index() && + c3t3_item->c3t3().subdomain_index(nc) == C3t3::Subdomain_index()) { // Color the border facet with the index of its cell - c3t3_item->c3t3().add_to_complex(c, fit->second, c->subdomain_index()); + c3t3_item->c3t3().add_to_complex(c, fit->second, c3t3_item->c3t3().subdomain_index(c)); } } } diff --git a/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp index 607a25fb78e0..d954f6dfbcab 100644 --- a/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -450,13 +450,13 @@ update_c3t3(C3t3& c3t3) for (Cell_handle cit : c3t3.triangulation().finite_cell_handles()) { CGAL_assertion(c3t3.subdomain_index(cit) >= 0); - if (c3t3.subdomain_index(cit) != C3t3::Triangulation::Cell::Subdomain_index()) + if (c3t3.subdomain_index(cit) != C3t3::Subdomain_index()) c3t3.add_to_complex(cit, c3t3.subdomain_index(cit)); for (int i = 0; i < 4; ++i) { - if (cit->surface_patch_index(i) > 0) - c3t3.add_to_complex(cit, i, cit->surface_patch_index(i)); + if (c3t3.surface_patch_index(cit, i) > 0) + c3t3.add_to_complex(cit, i, c3t3.surface_patch_index(cit, i)); } } @@ -469,8 +469,8 @@ update_c3t3(C3t3& c3t3) Cell_handle nc = c->neighbor(fit.second); // By definition, Subdomain_index() is supposed to be the id of the exterior - if (c3t3.subdomain_index(c) != C3t3::Triangulation::Cell::Subdomain_index() && - c3t3.subdomain_index(nc) == C3t3::Triangulation::Cell::Subdomain_index()) + if (c3t3.subdomain_index(c) != C3t3::Subdomain_index() && + c3t3.subdomain_index(nc) == C3t3::Subdomain_index()) { // Color the border facet with the index of its cell c3t3.add_to_complex(c, fit.second, c3t3.subdomain_index(c)); diff --git a/Lab/demo/Lab/Scene_tetrahedra_item.cpp b/Lab/demo/Lab/Scene_tetrahedra_item.cpp index 56d7278ade46..d24be3d13e17 100644 --- a/Lab/demo/Lab/Scene_tetrahedra_item.cpp +++ b/Lab/demo/Lab/Scene_tetrahedra_item.cpp @@ -183,7 +183,7 @@ void Scene_tetrahedra_item::computeElements()const const Tr::Bare_point& pb = wp2p(cit->vertex(1)->point()); const Tr::Bare_point& pc = wp2p(cit->vertex(2)->point()); const Tr::Bare_point& pd = wp2p(cit->vertex(3)->point()); - const QColor color = d->c3t3_item->getSubdomainIndexColor(cit->subdomain_index()); + const QColor color = d->c3t3_item->getSubdomainIndexColor(c3t3.subdomain_index(cit)); //0 - 1 : dihedral angle double min_dihedral_angle = 360.0; double max_dihedral_angle = -360.0; diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 0b3c3a2e2849..174b38e735be 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -268,13 +268,15 @@ class Compact_mesh_cell_base_3_base #endif // CGAL_LINKED_WITH_TBB +namespace experimental { + // Class Compact_mesh_cell_base_3 // Cell base class used in 3D meshing process. // Adds information to Cb about the cell of the input complex containing it template< class Point_3, - class Weighted_point_3, - class Subdomain_index_, - class Surface_patch_index_, + class WeightedPoint_3, + class SubdomainIndex, + class SurfacePatchIndex, class Index_, class TDS> class Compact_mesh_cell_3 @@ -282,26 +284,21 @@ class Compact_mesh_cell_3 { typedef Compact_mesh_cell_base_3_base Base; -#ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE - using Base::weighted_circumcenter_; -#endif - public: - typedef TDS Triangulation_data_structure; - typedef typename TDS::Vertex_handle Vertex_handle; - typedef typename TDS::Cell_handle Cell_handle; - typedef typename TDS::Vertex Vertex; - typedef typename TDS::Cell Cell; - typedef typename TDS::Cell_data TDS_data; + typedef TDS Triangulation_data_structure; + typedef typename TDS::Vertex_handle Vertex_handle; + typedef typename TDS::Cell_handle Cell_handle; + typedef typename TDS::Vertex Vertex; + typedef typename TDS::Cell Cell; + typedef typename TDS::Cell_data TDS_data; // Index Type - typedef Subdomain_index_ Subdomain_index; - typedef Surface_patch_index_ Surface_patch_index; - typedef Index_ Index; - - typedef Weighted_point_3 Point; + typedef SubdomainIndex Subdomain_index; + typedef SurfacePatchIndex Surface_patch_index; + typedef Index_ Index; + typedef WeightedPoint_3 Point; typedef Point* Point_container; typedef Point* Point_iterator; @@ -311,9 +308,9 @@ class Compact_mesh_cell_3 void invalidate_weighted_circumcenter_cache() const { #ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE - if (!internal_tbb::is_null(weighted_circumcenter_)) { - internal_tbb::delete_circumcenter(weighted_circumcenter_); - internal_tbb::set_weighted_circumcenter(weighted_circumcenter_, nullptr); + if (!internal_tbb::is_null(this->weighted_circumcenter_)) { + internal_tbb::delete_circumcenter(this->weighted_circumcenter_); + internal_tbb::set_weighted_circumcenter(this->weighted_circumcenter_, nullptr); } #endif } @@ -332,20 +329,7 @@ class Compact_mesh_cell_3 , previous_intrusive_(rhs.previous_intrusive_) #endif , time_stamp_(rhs.time_stamp_) -#ifndef CGAL_MESH_3_NO_SLIVER_VALUE - , sliver_value_(rhs.sliver_value_) -# ifndef CGAL_MESH_3_NO_SLIVER_CACHE - , sliver_cache_validity_(false) -# endif -#endif { -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL - for(int i=0; i <4; i++){ - surface_index_table_[i] = rhs.surface_index_table_[i]; - surface_center_table_[i]= rhs.surface_center_table_[i]; - surface_center_index_table_[i] = rhs.surface_center_index_table_[i]; - } -#endif } Compact_mesh_cell_3 (Vertex_handle v0, @@ -373,9 +357,9 @@ class Compact_mesh_cell_3 ~Compact_mesh_cell_3() { #ifndef CGAL_MESH_3_NO_CIRCUMCENTER_CACHE - if(!internal_tbb::is_null(weighted_circumcenter_)){ - internal_tbb::delete_circumcenter(weighted_circumcenter_); - internal_tbb::set_weighted_circumcenter(weighted_circumcenter_, nullptr); + if(!internal_tbb::is_null(this->weighted_circumcenter_)){ + internal_tbb::delete_circumcenter(this->weighted_circumcenter_); + internal_tbb::set_weighted_circumcenter(this->weighted_circumcenter_, nullptr); } #endif } @@ -441,8 +425,6 @@ class Compact_mesh_cell_3 } // SETTING - - void set_neighbor(int i, Cell_handle n) { CGAL_precondition( i >= 0 && i <= 3); @@ -485,7 +467,6 @@ class Compact_mesh_cell_3 TDS_data& tds_data() { return _tds_data; } const TDS_data& tds_data() const { return _tds_data; } - Point_iterator hidden_points_begin() const { return hidden_points_end(); } Point_iterator hidden_points_end() const { return nullptr; } void hide_point (const Point&) const { } @@ -528,7 +509,7 @@ class Compact_mesh_cell_3 #else static_assert(std::is_same::value); - if (internal_tbb::is_null(weighted_circumcenter_)) { + if (internal_tbb::is_null(this->weighted_circumcenter_)) { this->try_to_set_circumcenter( new Point_3(gt.construct_weighted_circumcenter_3_object() (this->vertex(0)->point(), @@ -540,9 +521,9 @@ class Compact_mesh_cell_3 (this->vertex(0)->point(), this->vertex(1)->point(), this->vertex(2)->point(), - this->vertex(3)->point()) == *weighted_circumcenter_); + this->vertex(3)->point()) == *(this->weighted_circumcenter_)); } - return *weighted_circumcenter_; + return *(this->weighted_circumcenter_); #endif } @@ -553,31 +534,144 @@ class Compact_mesh_cell_3 void set_subdomain_index(const Subdomain_index& index) { subdomain_index_ = index; } -#ifndef CGAL_MESH_3_NO_SLIVER_VALUE - void set_sliver_value(double value) + static + std::string io_signature() { -#ifndef CGAL_MESH_3_NO_SLIVER_CACHE - sliver_cache_validity_ = true; -#endif - sliver_value_ = value; + using Geom_traits = typename Kernel_traits::type; + return + Get_io_signature()() + "+" + + Get_io_signature >()() + + "+(" + Get_io_signature()() + ")[4]"; } - double sliver_value() const +#ifdef CGAL_INTRUSIVE_LIST +public: + Cell_handle next_intrusive() const { return next_intrusive_; } + void set_next_intrusive(Cell_handle c) { - CGAL_assertion(is_cache_valid()); - return sliver_value_; + next_intrusive_ = c; } -#ifdef CGAL_MESH_3_NO_SLIVER_CACHE - bool is_cache_valid() const { return sliver_value_ >= 0; } - void reset_cache_validity() { sliver_value_ = -2; } -#else - bool is_cache_valid() const { return sliver_cache_validity_; } - void reset_cache_validity() const { sliver_cache_validity_ = false; } + Cell_handle previous_intrusive() const { return previous_intrusive_; } + void set_previous_intrusive(Cell_handle c) + { + previous_intrusive_ = c; + } +#endif // CGAL_INTRUSIVE_LIST + + /// For the determinism of Compact_container iterators + ///@{ + typedef Tag_true Has_timestamp; + + std::size_t time_stamp() const { + return time_stamp_; + } + void set_time_stamp(const std::size_t& ts) { + time_stamp_ = ts; + } + ///@} + +private: + // tds_data (1 byte) and subdomain index (4, usually) are at the top of the class members + // to use the tail padding from the base_base class (usually 8+1, or 8+4+1 with lazy queues) + TDS_data _tds_data; + + // The index of the cell of the input complex that contains me + Subdomain_index subdomain_index_ = {}; + + std::array N; + std::array V; + +#ifdef CGAL_INTRUSIVE_LIST + Cell_handle next_intrusive_ = {}, previous_intrusive_ = {}; #endif -#endif // CGAL_MESH_3_NO_SLIVER_VALUE -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL + std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; + + // Point_container _hidden; + +public: + friend std::istream& operator>>(std::istream &is, Compact_mesh_cell_3 &c) + { + Subdomain_index index; + if(IO::is_ascii(is)) + is >> index; + else + read(is, index); + if(is) { + c.set_subdomain_index(index); + } + return is; + } + + friend + std::ostream& operator<<(std::ostream &os, const Compact_mesh_cell_3 &c) + { + if(IO::is_ascii(os)) + os << c.subdomain_index(); + else + write(os, c.subdomain_index()); + return os; + } + +}; // class Compact_mesh_cell_3 + +} // namespace experimental + +template< class Point_3, + class WeightedPoint_3, + class SubdomainIndex, + class SurfacePatchIndex, + class Index_, + class TDS> +class Compact_mesh_cell_3 + : public experimental::Compact_mesh_cell_3 +{ + typedef CGAL::Compact_mesh_cell_3 Self; + typedef experimental::Compact_mesh_cell_3 Base; + +public: + typedef TDS Triangulation_data_structure; + typedef typename TDS::Vertex_handle Vertex_handle; + typedef typename TDS::Cell_handle Cell_handle; + typedef typename TDS::Vertex Vertex; + typedef typename TDS::Cell Cell; + typedef typename TDS::Cell_data TDS_data; + + + // Index Type + typedef SubdomainIndex Subdomain_index; + typedef SurfacePatchIndex Surface_patch_index; + typedef Index_ Index; + + typedef WeightedPoint_3 Point; + + typedef Point* Point_container; + typedef Point* Point_iterator; + typedef const Point* Point_const_iterator; + +public: + Compact_mesh_cell_3(const Self& rhs) + : Base(static_cast(rhs)) + , sliver_value_(rhs.sliver_value_) + , sliver_cache_validity_(false) + { + for(int i=0; i <4; i++){ + surface_index_table_[i] = rhs.surface_index_table_[i]; + surface_center_table_[i]= rhs.surface_center_table_[i]; + surface_center_index_table_[i] = rhs.surface_center_index_table_[i]; + } + } + + template + Compact_mesh_cell_3(Args&& ... args) + : Base(std::forward(args)...) + { } + +public: /// Set surface index of `facet` to `index` void set_surface_patch_index(const int facet, const Surface_patch_index& index) { @@ -626,7 +720,6 @@ class Compact_mesh_cell_3 CGAL_precondition(facet>=0 && facet<4); return ( !( Surface_patch_index() == surface_index_table_[facet] )); } -#endif // ----------------------------------- // Backward Compatibility @@ -645,86 +738,31 @@ class Compact_mesh_cell_3 // End backward Compatibility // ----------------------------------- - static - std::string io_signature() - { - using Geom_traits = typename Kernel_traits::type; - return - Get_io_signature()() + "+" + - Get_io_signature >()() - + "+(" + Get_io_signature()() + ")[4]"; - } + bool is_cache_valid() const { return sliver_cache_validity_; } + void reset_cache_validity() const { sliver_cache_validity_ = false; } -#ifdef CGAL_INTRUSIVE_LIST -public: - Cell_handle next_intrusive() const { return next_intrusive_; } - void set_next_intrusive(Cell_handle c) + void set_sliver_value(double value) { - next_intrusive_ = c; + sliver_cache_validity_ = true; + sliver_value_ = value; } - Cell_handle previous_intrusive() const { return previous_intrusive_; } - void set_previous_intrusive(Cell_handle c) + double sliver_value() const { - previous_intrusive_ = c; - } -#endif // CGAL_INTRUSIVE_LIST - - /// For the determinism of Compact_container iterators - ///@{ - typedef Tag_true Has_timestamp; - - std::size_t time_stamp() const { - return time_stamp_; - } - void set_time_stamp(const std::size_t& ts) { - time_stamp_ = ts; + CGAL_assertion(is_cache_valid()); + return sliver_value_; } - ///@} private: - // tds_data (1 byte) and subdomain index (4, usually) are at the top of the class members - // to use the tail padding from the base_base class (usually 8+1, or 8+4+1 with lazy queues) - TDS_data _tds_data; - - // The index of the cell of the input complex that contains me - Subdomain_index subdomain_index_ = {}; - - std::array N; - std::array V; - -#ifdef CGAL_INTRUSIVE_LIST - Cell_handle next_intrusive_ = {}, previous_intrusive_ = {}; -#endif - - std::size_t time_stamp_ = Time_stamper::invalid_time_stamp; - -#ifndef CGAL_MESH_3_NO_SLIVER_VALUE -# ifdef CGAL_MESH_3_NO_SLIVER_CACHE - double sliver_value_ = -2.; -# else - double sliver_value_ = 0.; -# endif -#endif - - // -- Below is unused -- - - // Point_container _hidden; - -#ifndef CGAL_MESH_3_DO_NOT_STORE_COMPLEX_INFO_IN_CELL /// Stores surface_index for each facet of the cell std::array surface_index_table_ = {}; /// Stores surface center of each facet of the cell std::array surface_center_table_ = {}; /// Stores surface center index of each facet of the cell std::array surface_center_index_table_ = {}; -#endif -#ifndef CGAL_MESH_3_NO_SLIVER_VALUE -# ifndef CGAL_MESH_3_NO_SLIVER_CACHE + double sliver_value_ = 0.; mutable bool sliver_cache_validity_ = false; -# endif -#endif public: friend std::istream& operator>>(std::istream &is, Compact_mesh_cell_3 &c) @@ -737,38 +775,36 @@ class Compact_mesh_cell_3 if(is) { c.set_subdomain_index(index); for(int i = 0; i < 4; ++i) - { - Surface_patch_index i2; - if(IO::is_ascii(is)) - is >> IO::iformat(i2); - else - { - read(is, i2); - } - // c.set_surface_patch_index(i, i2); // @tmp - } + { + Surface_patch_index i2; + if(IO::is_ascii(is)) + is >> IO::iformat(i2); + else + { + read(is, i2); + } + c.set_surface_patch_index(i, i2); + } } return is; } - friend - std::ostream& operator<<(std::ostream &os, const Compact_mesh_cell_3 &c) + friend std::ostream& operator<<(std::ostream &os, const Compact_mesh_cell_3 &c) { if(IO::is_ascii(os)) os << c.subdomain_index(); else write(os, c.subdomain_index()); - // for(int i = 0; i < 4; ++i) // @tmp - // { - // if(IO::is_ascii(os)) - // os << ' ' << IO::oformat(c.surface_patch_index(i)); - // else - // write(os, c.surface_patch_index(i)); - // } + for(int i = 0; i < 4; ++i) + { + if(IO::is_ascii(os)) + os << ' ' << IO::oformat(c.surface_patch_index(i)); + else + write(os, c.surface_patch_index(i)); + } return os; } - -}; // end class Compact_mesh_cell_3 +}; /*! \ingroup PkgMesh3MeshClasses @@ -815,12 +851,21 @@ class Compact_mesh_cell_base_3 typedef Triangulation_data_structure::Cell_handle Cell_handle; template struct Rebind_TDS { +#ifdef CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 + typedef experimental::Compact_mesh_cell_3 Other; +#else typedef Compact_mesh_cell_3 Other; +#endif }; }; @@ -840,12 +885,21 @@ class Compact_mesh_cell_generator_3 typedef Triangulation_data_structure::Cell_handle Cell_handle; template struct Rebind_TDS { +#ifdef CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 + typedef experimental::Compact_mesh_cell_3 Other; +#else typedef Compact_mesh_cell_3 Other; +#endif }; }; From ccc7a7984e3b2e5aecdf45f5aedcd78ca104ecca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 1 Apr 2026 14:41:20 +0200 Subject: [PATCH 079/127] Sliver caching fixes --- .../include/CGAL/Mesh_3/Sliver_value_cache.h | 86 +++++++++++-------- Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h | 18 ++-- 2 files changed, 63 insertions(+), 41 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h b/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h index 15678848d6f3..1aa1dc89e7ac 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h +++ b/Mesh_3/include/CGAL/Mesh_3/Sliver_value_cache.h @@ -8,7 +8,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : +// Author(s) : Mael Rouxel-Labbé #ifndef CGAL_MESH_3_SLIVER_VALUE_CACHE_H #define CGAL_MESH_3_SLIVER_VALUE_CACHE_H @@ -16,21 +16,18 @@ #include #include +#include +#include #ifdef CGAL_LINKED_WITH_TBB #include #endif #include -#include namespace CGAL { namespace Mesh_3 { -// Cell must provide sliver_value(), set_sliver_value(), invalidate_sliver_value(), and sliver_cache_valid() -// FT is the floating point type, Cell_handle is the cell handle type - -#ifndef CGAL_MESH_3_NO_SLIVER_VALUE template struct Sliver_value_cache_in_cell { @@ -40,19 +37,25 @@ struct Sliver_value_cache_in_cell void invalidate(const Cell_handle& c) const { c->reset_cache_validity(); } void clear() const {} }; -#endif // Non-concurrent map-based cache template struct Sliver_value_cache_map { typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; - mutable std::unordered_map cache; - bool has_value(const Cell_handle& c) const { return cache.find(c) != cache.end(); } - FT get(const Cell_handle& c) const { return cache.at(c); } - void set(const Cell_handle& c, FT v) const { cache[c] = v; } - void invalidate(const Cell_handle& c) const { cache.erase(c); } - void clear() const { cache.clear(); } + + std::shared_ptr > cache = + std::make_shared>(); + + bool has_value(const Cell_handle& c) const { return cache->find(c) != cache->end(); } + FT get(const Cell_handle& c) const { return cache->at(c); } + void set(const Cell_handle& c, FT v) const { (*cache)[c] = v; } + + void invalidate(const Cell_handle& c) const { + cache->erase(c); + } + + void clear() const { cache->clear(); } }; #ifdef CGAL_LINKED_WITH_TBB @@ -60,31 +63,38 @@ struct Sliver_value_cache_map template struct Sliver_value_cache_concurrent_map { - typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; - typedef tbb::concurrent_hash_map ConcurrentMap; - mutable ConcurrentMap cache; + typedef tbb::concurrent_hash_map ConcurrentMap; + + // Shared ownership: all copies reference the same concurrent map + std::shared_ptr cache = std::make_shared(); + bool has_value(const Cell_handle& c) const { typename ConcurrentMap::const_accessor acc; - return cache.find(acc, c); + return cache->find(acc, c); } + FT get(const Cell_handle& c) const { typename ConcurrentMap::const_accessor acc; - if (cache.find(acc, c)) return acc->second; + if (cache->find(acc, c)) return acc->second; throw std::out_of_range("Cell_handle not found in concurrent cache"); } + void set(const Cell_handle& c, FT v) const { typename ConcurrentMap::accessor acc; - cache.insert(acc, c); + cache->insert(acc, c); acc->second = v; } + void invalidate(const Cell_handle& c) const { - cache.erase(c); + cache->erase(c); + } + + void clear() const { + cache->clear(); } - void clear() const { cache.clear(); } }; #endif -#ifndef CGAL_MESH_3_NO_SLIVER_VALUE // Sanity checker cache: combines in-cell and map, checks consistency template struct Sliver_value_cache_sanity_checker @@ -96,7 +106,8 @@ struct Sliver_value_cache_sanity_checker bool a = in_cell.has_value(c); bool b = map.has_value(c); if (a != b) { - std::cerr << "[Sliver_value_cache_sanity_checker] has_value mismatch: in_cell=" << a << ", map=" << b << std::endl; + std::cerr << "[Sliver_value_cache_sanity_checker] has_value mismatch for C#" << c->time_stamp() << " in_cell=" << a << ", map=" << b << std::endl; + std::cerr << "map @ " << &(map.cache) << std::endl; std::abort(); } return a; @@ -105,16 +116,15 @@ struct Sliver_value_cache_sanity_checker FT get(const Cell_handle& c) const { FT a = in_cell.get(c); FT b = map.get(c); - std::cout << "get sliver value of C#" << c->time_stamp() << " = " << a << std::endl; if (a != b) { std::cerr << "[Sliver_value_cache_sanity_checker] get mismatch: in_cell=" << a << ", map=" << b << std::endl; + std::cerr << "map @ " << &(map.cache) << std::endl; std::abort(); } return a; } void set(const Cell_handle& c, FT v) const { - std::cout << "set sliver value of C#" << c->time_stamp() << " to " << v << std::endl; in_cell.set(c, v); map.set(c, v); } @@ -129,23 +139,29 @@ struct Sliver_value_cache_sanity_checker map.clear(); } }; -#endif // Metafunction to select the default sliver cache type for a triangulation template struct Default_sliver_cache { -#ifdef CGAL_MESH_3_NO_SLIVER_VALUE -# ifdef CGAL_LINKED_WITH_TBB + CGAL_GENERATE_MEMBER_DETECTOR(set_sliver_value); + + using Cell_handle = typename Tr::Cell_handle; + using FT = typename Tr::Geom_traits::FT; + using type = std::conditional_t< - std::is_same::value, - Sliver_value_cache_concurrent_map, - Sliver_value_cache_map>; -# else - using type = Sliver_value_cache_map; -# endif + has_set_sliver_value::value, + // if there is storage, use it + // Sliver_value_cache_sanity_checker, + Sliver_value_cache_in_cell, + // otherwise, use a hash map, concurrent or not +#ifdef CGAL_LINKED_WITH_TBB + std::conditional_t< + std::is_same::value, + Sliver_value_cache_concurrent_map, + Sliver_value_cache_map > >; #else - using type = Sliver_value_cache_sanity_checker; + Sliver_value_cache_map >; #endif }; diff --git a/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h b/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h index 91006aaf61f0..0f403c9c3305 100644 --- a/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h @@ -26,6 +26,8 @@ #include #include // for CGAL::IA_force_to_double +#include +#include #include @@ -34,17 +36,25 @@ namespace Mesh_3 { enum class Sliver_caching_policy { - ALWAYS = 0, + DEFAULT = 0, + ALWAYS, NEVER, BELOW_BOUND // Only cache values below the sliver bound }; template::type, - Sliver_caching_policy caching_policy = Sliver_caching_policy::BELOW_BOUND, + Sliver_caching_policy caching_policy_ = Sliver_caching_policy::DEFAULT, typename Cell_vector_ = std::vector > class Sliver_criterion { + CGAL_GENERATE_MEMBER_DETECTOR(set_sliver_value); + Sliver_caching_policy caching_policy = + (caching_policy_ == Sliver_caching_policy::DEFAULT) + ? (has_set_sliver_value::value ? Sliver_caching_policy::ALWAYS + : Sliver_caching_policy::BELOW_BOUND) + : caching_policy_; + public: typedef typename Tr::Geom_traits GT; typedef typename Tr::Cell_handle Cell_handle; @@ -89,7 +99,6 @@ class Sliver_criterion return operator()(tr_.tetrahedron(cell)); } else { if (cache_.has_value(cell)) { - std::cout << "cache hit for C#" << cell->time_stamp() << " (operator())" << std::endl; return cache_.get(cell); } else { // cell->sliver_value() is stored in a plain 64 bits floating point @@ -101,12 +110,9 @@ class Sliver_criterion // (see also the comment below) // IA_force_to_double is available in CGAL/FPU.h const double value = CGAL::IA_force_to_double(operator()(tr_.tetrahedron(cell))); - std::cout << "computed sliver value for C#" << cell->time_stamp() << " = " << value << std::endl; - if (caching_policy == Sliver_caching_policy::BELOW_BOUND && value > this->sliver_bound_) { return value; } else { - std::cout << "cache sliver value for C#" << cell->time_stamp() << " = " << value << std::endl; cache_.set(cell, value); return value; } From e621c7cd92f11f07a7177ee386c3564cf2e601ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 1 Apr 2026 14:42:03 +0200 Subject: [PATCH 080/127] Use C3T3's functions --- .../Facet_topological_criterion_with_adjacency.h | 4 ++-- Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp | 4 ++-- Mesh_3/test/Mesh_3/test_min_size_criteria.cpp | 2 +- SMDS_3/include/CGAL/IO/File_avizo.h | 4 ++-- SMDS_3/include/CGAL/IO/output_to_vtu.h | 2 +- .../include/CGAL/Mesh_complex_3_in_triangulation_3.h | 4 ++-- SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h | 12 ++++++------ .../CGAL/facets_in_complex_3_to_triangle_mesh.h | 2 +- SMDS_3/test/SMDS_3/test_c3t3_into_facegraph.cpp | 10 +++++----- SMDS_3/test/SMDS_3/test_c3t3_io.cpp | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/experimental/Facet_topological_criterion_with_adjacency.h b/Mesh_3/include/CGAL/Mesh_3/experimental/Facet_topological_criterion_with_adjacency.h index bb6011024916..7f65b670dd8d 100644 --- a/Mesh_3/include/CGAL/Mesh_3/experimental/Facet_topological_criterion_with_adjacency.h +++ b/Mesh_3/include/CGAL/Mesh_3/experimental/Facet_topological_criterion_with_adjacency.h @@ -61,7 +61,7 @@ public Mesh_3::Abstract_criterion return new Self(*this); } - virtual Is_bad do_is_bad (const C3T3& /*c3t3*/, const Facet& f) const + virtual Is_bad do_is_bad (const C3T3& c3t3, const Facet& f) const { typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; @@ -71,7 +71,7 @@ public Mesh_3::Abstract_criterion typedef typename MeshDomain::Surface_patch_index Patch_index; - const Patch_index patch_index = ch->surface_patch_index(i); + const Patch_index patch_index = c3t3.surface_patch_index(ch, i); typedef std::vector Index_set; diff --git a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp index 66c8e61f68ab..e128c5c1b836 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp @@ -62,9 +62,9 @@ int main (int argc, char** argv){ c3t3.add_to_complex(cit, c3t3.subdomain_index(cit)); for(int i=0; i < 4; ++i) { - if(cit->surface_patch_index(i)>0) + if(c3t3.surface_patch_index(cit, i) > 0) { - c3t3.add_to_complex(cit, i, cit->surface_patch_index(i)); + c3t3.add_to_complex(cit, i, c3t3.surface_patch_index(cit, i)); } } } diff --git a/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp b/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp index 95865417ae22..1519f36fae08 100644 --- a/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp +++ b/Mesh_3/test/Mesh_3/test_min_size_criteria.cpp @@ -90,7 +90,7 @@ struct Image_tester : public Tester for (auto f : c3t3.facets_in_complex()) { const Bare_point p1 = cp(tr.point(f.first, (f.second + 1) & 3)); - const Bare_point& ball_center = f.first->get_facet_surface_center(f.second); + const Bare_point& ball_center = c3t3.surface_center(f); const FT sqr = Th().min_squared_distance(tr, p1, ball_center); max_sq_facet_radius = (std::max)(max_sq_facet_radius, sqr); diff --git a/SMDS_3/include/CGAL/IO/File_avizo.h b/SMDS_3/include/CGAL/IO/File_avizo.h index 769624a44de7..5b2b6f895dab 100644 --- a/SMDS_3/include/CGAL/IO/File_avizo.h +++ b/SMDS_3/include/CGAL/IO/File_avizo.h @@ -234,7 +234,7 @@ output_to_avizo(std::ostream& os, end = c3t3.cells_in_complex_end(); cit != end; ++cit) { - os << cit->subdomain_index() << "\n"; + os << c3t3.subdomain_index(cit) << "\n"; } } // end output_to_avizo(...) @@ -503,7 +503,7 @@ namespace internal { } boost::unordered_map, - typename Tr::Cell::Surface_patch_index> empty_facets_map; + typename C3T3::Surface_patch_index> empty_facets_map; CGAL::SMDS_3::build_mesh_complex_with_subdomains_range(c3t3, points, diff --git a/SMDS_3/include/CGAL/IO/output_to_vtu.h b/SMDS_3/include/CGAL/IO/output_to_vtu.h index 24506adc687b..da9b6b2308bd 100644 --- a/SMDS_3/include/CGAL/IO/output_to_vtu.h +++ b/SMDS_3/include/CGAL/IO/output_to_vtu.h @@ -388,7 +388,7 @@ void output_to_vtu(std::ostream& os, std::vector mids; for( Cell_handle c : c3t3.cells_in_complex()) { - mids.push_back(c->subdomain_index()); + mids.push_back(c3t3.subdomain_index(c)); } std::vector > atts; diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 3927dba737a2..73b025a80c06 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -537,7 +537,7 @@ class Mesh_complex_3_in_triangulation_3 { if constexpr (store_surface_patch_info_in_cell) { - f.first->set_surface_center(f.second, p); + f.first->set_facet_surface_center(f.second, p); } else { @@ -570,7 +570,7 @@ class Mesh_complex_3_in_triangulation_3 { if constexpr (store_surface_patch_info_in_cell) { - f.first->set_surface_center_index(f.second, index); + f.first->set_facet_surface_center_index(f.second, index); } else { diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index 0c302297b150..fb2872698cda 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -170,9 +170,9 @@ bool build_finite_cells(C3T3& c3t3, cp(tr.point(vs[2])), cp(tr.point(vs[3]))) == POSITIVE); Cell_handle c = tr.tds().create_cell(vs[0], vs[1], vs[2], vs[3]); - c->set_subdomain_index(subdomains[i]); // the cell's info keeps the reference of the tetrahedron + c3t3.set_subdomain_index(c, subdomains[i]); // the cell's info keeps the reference of the tetrahedron if(replace_domain_0 && subdomains[i] == 0) - c->set_subdomain_index(max_domain+1); // the cell's info keeps the reference of the tetrahedron + c3t3.set_subdomain_index(c, max_domain+1); // the cell's info keeps the reference of the tetrahedron // assign cells to vertices for(int j=0; j<4; ++j) @@ -206,7 +206,7 @@ bool build_finite_cells(C3T3& c3t3, typename FacetPatchMap::const_iterator it = border_facets.find(facet); if(it != border_facets.end()) { - c->set_surface_patch_index(j, it->second); + c3t3.set_surface_patch_index(c, j, it->second); } else { @@ -214,9 +214,9 @@ bool build_finite_cells(C3T3& c3t3, it = border_facets.find(facet); if(it != border_facets.end()) - c->set_surface_patch_index(j, it->second); + c3t3.set_surface_patch_index(c, j, it->second); else - c->set_surface_patch_index(j, Surface_patch_index()); + c3t3.set_surface_patch_index(c, j, Surface_patch_index()); } } } @@ -300,7 +300,7 @@ bool build_infinite_cells(C3T3& c3t3, it->second.emplace_back(opp_c, 0); CGAL_assertion(it->second.size() == 2); - opp_c->set_surface_patch_index(0, c->surface_patch_index(i)); + c3t3.set_surface_patch_index(opp_c, 0, c3t3.surface_patch_index(c, i)); } #ifdef CGAL_TET_SOUP_TO_C3T3_DEBUG diff --git a/SMDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h b/SMDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h index d129641ef1a5..7924373de641 100644 --- a/SMDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h +++ b/SMDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h @@ -94,7 +94,7 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, { const Cell_handle c = fit.first; const int s = fit.second; - const Surface_patch_index spi = c->surface_patch_index(s); + const Surface_patch_index spi = c3t3.surface_patch_index(c, s); const typename C3T3::Subdomain_index cell_sdi = c3t3.subdomain_index(c); const typename C3T3::Subdomain_index opp_sdi = c3t3.subdomain_index(c->neighbor(s)); diff --git a/SMDS_3/test/SMDS_3/test_c3t3_into_facegraph.cpp b/SMDS_3/test/SMDS_3/test_c3t3_into_facegraph.cpp index 19807d154081..003e56c4852b 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3_into_facegraph.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3_into_facegraph.cpp @@ -47,14 +47,14 @@ int main (int argc, char** argv){ { for( Cell_handle cit : c3t3.triangulation().finite_cell_handles()) { - assert(cit->subdomain_index() >= 0); - if(cit->subdomain_index() > 0) - c3t3.add_to_complex(cit, cit->subdomain_index()); + assert(c3t3.subdomain_index(cit) >= 0); + if(c3t3.subdomain_index(cit) > 0) + c3t3.add_to_complex(cit, c3t3.subdomain_index(cit)); for(int i=0; i < 4; ++i) { - if(cit->surface_patch_index(i)>0) + if(c3t3.surface_patch_index(cit, i) > 0) { - c3t3.add_to_complex(cit, i, cit->surface_patch_index(i)); + c3t3.add_to_complex(cit, i, c3t3.surface_patch_index(cit, i)); } } } diff --git a/SMDS_3/test/SMDS_3/test_c3t3_io.cpp b/SMDS_3/test/SMDS_3/test_c3t3_io.cpp index cb9e18171511..2a2d1c46c246 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3_io.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3_io.cpp @@ -292,7 +292,7 @@ struct Test_c3t3_io { end1 = t1.finite_cells_end(); cit1 != end1; ++cit1, ++cit2) { - if(cit1->subdomain_index() != cit2->subdomain_index() ) + if(c1.subdomain_index(cit1) != c2.subdomain_index(cit2) ) { std::cerr << "Error: cells are different:\n"; std::cerr << *cit1 << "\n" From ab12973de67e9b4556c0f1d6088be7168a2dbc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 1 Apr 2026 14:46:51 +0200 Subject: [PATCH 081/127] Add a test using the lightweight compact mesh cell base --- Mesh_3/test/Mesh_3/CMakeLists.txt | 3 + ...meshing_experimental_compact_cell_base.cpp | 145 ++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp diff --git a/Mesh_3/test/Mesh_3/CMakeLists.txt b/Mesh_3/test/Mesh_3/CMakeLists.txt index 16d9af5df5a8..4c224aaf9ec5 100644 --- a/Mesh_3/test/Mesh_3/CMakeLists.txt +++ b/Mesh_3/test/Mesh_3/CMakeLists.txt @@ -58,6 +58,7 @@ create_single_source_cgal_program( "test_mesh_cell_base_3.cpp") create_single_source_cgal_program( "test_min_edge_length.cpp") create_single_source_cgal_program( "test_max_edge_distance.cpp") create_single_source_cgal_program( "test_remeshing_polyhedron.cpp" ) +create_single_source_cgal_program( "test_meshing_experimental_compact_cell_base.cpp" ) foreach(target surface_mesh_to_tetrahedral_mesh @@ -92,6 +93,7 @@ foreach(target test_min_size_criteria test_meshing_polyhedral_complex_with_manifold_and_min_size test_remeshing_polyhedron + test_meshing_experimental_compact_cell_base ) if(TARGET ${target}) target_link_libraries(${target} PRIVATE CGAL::Eigen3_support) @@ -119,6 +121,7 @@ if(TARGET CGAL::TBB_support) test_min_edge_length test_max_edge_distance test_min_size_criteria + test_meshing_experimental_compact_cell_base ) if(TARGET ${target}) target_link_libraries(${target} PRIVATE CGAL::TBB_support) diff --git a/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp b/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp new file mode 100644 index 000000000000..8e43a02d904c --- /dev/null +++ b/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp @@ -0,0 +1,145 @@ +#define CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 +#define CGAL_MESH_3_NO_CIRCUMCENTER_CACHE + +#include "test_meshing_utilities.h" +#include +#include +#include +#include +#include +#include + +#include +#include + +static constexpr bool verbose = +#ifdef CGAL_MESH_3_VERBOSE + true; +#else + false; +#endif + + +std::stringstream cerr_output; + +template +struct Polyhedron_with_features_tester + : public Tester +{ + std::streambuf* old_cerr_buf; + std::string tag_name; + + Polyhedron_with_features_tester(std::string tag_name) + : old_cerr_buf(std::cerr.rdbuf(verbose ? cerr_output.rdbuf() : std::cerr.rdbuf())) + , tag_name(tag_name) + { + } + ~Polyhedron_with_features_tester() + { + std::cerr.rdbuf(old_cerr_buf); + if(verbose) { + const auto output = cerr_output.str(); + const auto str_size= output.size(); + const auto str_begin = output.data(); + const auto str_end = str_begin + str_size; + constexpr auto nb = static_cast>(10000); + auto pos1 = str_begin + (std::min)(nb, str_size); + assert(pos1 <= str_end); + const auto pos2 = str_end - (std::min)(nb, str_size); + assert(pos2 >= str_begin); + if(pos2 <= pos1) { + pos1 = str_end; + } + std::cerr << "NOW THE FIRST AND LAST 10k CHARACTERS OF THE CERR OUTPUT:\n"; + std::cerr << "-----\n" << std::string(str_begin, pos1) << "\n-----\n"; + if(pos1 != str_end) { + std::cerr << "[...]\n-----\n" << std::string(pos2, str_end) << "\n-----\n"; + } + const auto file_name = std::string("test_meshing_verbose-") + tag_name + ".txt"; + std::ofstream file_output(file_name); + file_output << output; + std::cerr << "Full log is output to " << file_name << "\n"; + } + } + void operator()() const + { + typedef CGAL::Mesh_3::Robust_intersection_traits_3 GT; + typedef typename CGAL::Mesh_polyhedron_3::type Polyhedron; + typedef CGAL::Polyhedral_mesh_domain_with_features_3 Mesh_domain; + + typedef typename CGAL::Mesh_triangulation_3< + Mesh_domain, + typename CGAL::Kernel_traits::Kernel, + Concurrency_tag>::type Tr; + typedef CGAL::Mesh_complex_3_in_triangulation_3 < + Tr, + typename Mesh_domain::Corner_index, + typename Mesh_domain::Curve_index > C3t3; + + typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef typename Mesh_criteria::Edge_criteria Edge_criteria; + typedef typename Mesh_criteria::Facet_criteria Facet_criteria; + typedef typename Mesh_criteria::Cell_criteria Cell_criteria; + + //------------------------------------------------------- + // Data generation + //------------------------------------------------------- + std::cout << "\tSeed is\t" << CGAL::get_default_random().get_seed() << std::endl; + + std::ifstream input(CGAL::data_file_path("meshes/cube.off")); + Polyhedron polyhedron; + input >> polyhedron; + + Mesh_domain domain(polyhedron, &CGAL::get_default_random()); + domain.detect_features(); + + // Set mesh criteria +#ifndef CGAL_MESH_3_VERBOSE + Edge_criteria edge_criteria(0.2); + Facet_criteria facet_criteria(30, 0.2, 0.02); + Cell_criteria cell_criteria(3, 0.2); +#else // a different set of criteria, for the test of CGAL_MESH_3_VERBOSE + Edge_criteria edge_criteria(0.3); + Facet_criteria facet_criteria(30, 0.3, 0.03); + Cell_criteria cell_criteria(3, 0.4); +#endif + Mesh_criteria criteria(edge_criteria, facet_criteria, cell_criteria); + + namespace params = CGAL::parameters; + + // Mesh generation + std::cout << "sizeof(Vertex) " << sizeof(typename C3t3::Triangulation::Vertex) << std::endl; + std::cout << "sizeof(Cell) " << sizeof(typename C3t3::Triangulation::Cell) << std::endl; + + C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, + params::odt(params::convergence(0.03).freeze_bound(0.02).time_limit(30)), + params::lloyd(params::max_iteration_number(10)), + params::perturb(params::sliver_bound(10).time_limit(30)), + params::exude(params::sliver_bound(10).time_limit(0))); + + CGAL::remove_far_points_in_mesh_3(c3t3); + } +}; + +int main() +{ + { + std::cerr << "Mesh generation from a polyhedron with edges:\n"; + Polyhedron_with_features_tester test_epic("sequential"); + test_epic(); + } +#ifdef CGAL_LINKED_WITH_TBB + { + std::cerr << "\n\nParallel mesh generation from a polyhedron with edges:\n"; + Polyhedron_with_features_tester test_epic_p("parallel"); + test_epic_p(); + } +#endif + + std::cout << "Done" << std::endl; + + return EXIT_SUCCESS; +} From e37b6dc7788ecefbeffd08d04c6cf914ca6fc257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 1 Apr 2026 14:47:13 +0200 Subject: [PATCH 082/127] Clean up --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 73b025a80c06..1d7e50a3d6ce 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -499,7 +499,6 @@ class Mesh_complex_3_in_triangulation_3 } else { - CGAL_assertion(false); if (index == Surface_patch_index()) { // remove from the map as to avoid wasting memory @@ -601,7 +600,6 @@ class Mesh_complex_3_in_triangulation_3 void set_surface_info(const Facet& f, const Facet_prop& info) const { - CGAL_assertion(false); if constexpr (store_surface_patch_info_in_cell) { f.first->set_surface_patch_index(f.second, info.surface_index_); From 4ae91e18f8077304f6d05b46d4472ab89c1bdcfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 8 Apr 2026 09:03:36 +0200 Subject: [PATCH 083/127] Fix template parameter --- .../poisson_reconstruction_test_mesh_3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/poisson_reconstruction_test_mesh_3.cpp b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/poisson_reconstruction_test_mesh_3.cpp index 587fad01d2af..7d5a95f3f781 100644 --- a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/poisson_reconstruction_test_mesh_3.cpp +++ b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/poisson_reconstruction_test_mesh_3.cpp @@ -68,7 +68,7 @@ typedef CGAL::Mesh_criteria_3 Mesh_criteria; typedef CGAL::Poisson_mesh_domain_3 Poisson_mesh_domain; typedef CGAL::Mesh_triangulation_3::type Poisson_Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 Poisson_C3t3; -typedef CGAL::Mesh_criteria_3 Poisson_mesh_criteria; +typedef CGAL::Mesh_criteria_3 Poisson_mesh_criteria; namespace params = CGAL::parameters; From a09d3d9f5cf9a6ee1a1ff394d7b9650020c12821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 8 Apr 2026 09:05:23 +0200 Subject: [PATCH 084/127] Fix indentation --- .../CGAL/SMDS_3/Mesh_complex_3_in_triangulation_3_fwd.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Installation/include/CGAL/SMDS_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/SMDS_3/Mesh_complex_3_in_triangulation_3_fwd.h index 7bca8e7af125..a3d24f14c908 100644 --- a/Installation/include/CGAL/SMDS_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/SMDS_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -39,10 +39,10 @@ namespace SMDS_3 { template bool build_mesh_complex_from_file(std::istream& is, - C3T3& c3t3, - bool verbose = false, - bool replace_domain_0 = false, - bool allow_non_manifold = false); + C3T3& c3t3, + bool verbose = false, + bool replace_domain_0 = false, + bool allow_non_manifold = false); template bool build_triangulation_from_file(std::istream& is, From d085b325f03929ebe2538a3d39971d5675b2cfa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 8 Apr 2026 09:39:36 +0200 Subject: [PATCH 085/127] Fix maybe-uninitialized warning (?) --- Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h | 4 ++-- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h index 8bac5600314a..fe564b02b3a0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h +++ b/Mesh_3/include/CGAL/Mesh_3/C3T3_helpers.h @@ -1329,7 +1329,7 @@ class C3T3_helpers if (c3t3.is_in_complex(Facet(c, ii))) surface_prop_table_[i] = c3t3.surface_info(Facet(c, ii)); else - surface_prop_table_[i] = {}; + surface_prop_table_[i] = Facet_prop(); } //note c->next_intrusive() and c->previous_intrusive() //are lost by 'backup' and 'restore', @@ -1344,7 +1344,7 @@ class C3T3_helpers if (c3t3.is_in_complex(Facet(c, infinite_index))) surface_prop_table_[0] = c3t3.surface_info(Facet(c, infinite_index)); else - surface_prop_table_[0] = {}; + surface_prop_table_[0] = Facet_prop(); } public: diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 9014764ede9f..41a438bc0ab7 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -422,12 +422,7 @@ class Refine_facets_3_base typedef typename MeshDomain::Surface_patch_index Surface_patch_index; typedef typename MeshDomain::Index Index; - struct Facet_prop - { - Surface_patch_index surface_patch_index; - Index index; - Bare_point point; - }; + typedef typename Complex3InTriangulation3::Facet_prop Facet_prop; typedef typename std::optional Facet_properties; /// Returns canonical facet of facet From cb088105ccc956ba16fbc7f765a2c4b9e413cb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 9 Apr 2026 14:34:08 +0200 Subject: [PATCH 086/127] Fix compilation --- .../compare_mesh_3_vs_Poisson_implicit_surface_3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/compare_mesh_3_vs_Poisson_implicit_surface_3.cpp b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/compare_mesh_3_vs_Poisson_implicit_surface_3.cpp index 27a9db80a4f1..1b284cca26e4 100644 --- a/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/compare_mesh_3_vs_Poisson_implicit_surface_3.cpp +++ b/Poisson_surface_reconstruction_3/test/Poisson_surface_reconstruction_3/compare_mesh_3_vs_Poisson_implicit_surface_3.cpp @@ -65,7 +65,7 @@ typedef CGAL::Surface_mesh_complex_2_in_triangulation_3 C2t3; typedef CGAL::Labeled_mesh_domain_3 LMesh_domain; typedef typename CGAL::Mesh_triangulation_3::type LTr; typedef CGAL::Mesh_complex_3_in_triangulation_3 LC3t3; -typedef CGAL::Mesh_criteria_3 LMesh_criteria; +typedef CGAL::Mesh_criteria_3 LMesh_criteria; typedef CGAL::Poisson_mesh_domain_3 Mesh_domain; typedef typename CGAL::Mesh_triangulation_3::type Tr; From 48ef79324c2dd4e1807278edc0f66e88877c1f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 9 Apr 2026 14:38:22 +0200 Subject: [PATCH 087/127] Align concept with similar concepts --- SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h b/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h index 1a2660ccf526..72293e7f90b8 100644 --- a/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h +++ b/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h @@ -68,7 +68,7 @@ bool is_c2t3_cache_valid(); /*! Sets the cache. */ -void set_c2t3_cache(std::size_t i, std::size_t j) +void set_c2t3_cache(int i, int j) /*! Invalidates the cache. From 45c7a06adcdda00c231923f2e81b9020589d102d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 9 Apr 2026 14:38:40 +0200 Subject: [PATCH 088/127] Fix warning --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 1d7e50a3d6ce..6762347040ec 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -1948,7 +1948,7 @@ class Mesh_complex_3_in_triangulation_3 } const int n = v->cached_number_of_incident_facets(); - const int nb_components = facets.number_of_sets(); + const int nb_components = static_cast(facets.number_of_sets()); v->set_c2t3_cache(n, nb_components); return nb_components; From 32671e78b8411f75c776ab9cc683c8a990e4c55a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 9 Apr 2026 17:49:42 +0200 Subject: [PATCH 089/127] Try to please MSVC2017 --- Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h b/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h index 0f403c9c3305..8b53fab542b9 100644 --- a/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h @@ -48,13 +48,6 @@ template > class Sliver_criterion { - CGAL_GENERATE_MEMBER_DETECTOR(set_sliver_value); - Sliver_caching_policy caching_policy = - (caching_policy_ == Sliver_caching_policy::DEFAULT) - ? (has_set_sliver_value::value ? Sliver_caching_policy::ALWAYS - : Sliver_caching_policy::BELOW_BOUND) - : caching_policy_; - public: typedef typename Tr::Geom_traits GT; typedef typename Tr::Cell_handle Cell_handle; @@ -137,13 +130,22 @@ class Sliver_criterion : tr_(tr) , sliver_bound_(bound) , cache_(cache) - {} + { + caching_policy = + (caching_policy_ == Sliver_caching_policy::DEFAULT) + ? (has_set_sliver_value::value ? Sliver_caching_policy::ALWAYS + : Sliver_caching_policy::BELOW_BOUND) + : caching_policy_; + } virtual ~Sliver_criterion(){} protected: const Tr& tr_; double sliver_bound_; + + CGAL_GENERATE_MEMBER_DETECTOR(set_sliver_value); + Sliver_caching_policy caching_policy; mutable Cache cache_; }; From 18731386835ed1435fba1db2a8970421cb52694b Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 21 Apr 2026 16:03:47 +0200 Subject: [PATCH 090/127] try to please msvc2017 with tags instead of enum template parameter --- Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h | 52 ++++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h b/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h index 8b53fab542b9..a6b99cc86d12 100644 --- a/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h +++ b/Mesh_3/include/CGAL/Mesh_3/sliver_criteria.h @@ -34,17 +34,23 @@ namespace CGAL { namespace Mesh_3 { -enum class Sliver_caching_policy +namespace internal { - DEFAULT = 0, - ALWAYS, - NEVER, - BELOW_BOUND // Only cache values below the sliver bound -}; +struct Sliver_caching_policy_tag +{}; // Default tag for the caching policy, used to detect if the user specified a caching policy or not +struct Sliver_caching_always_tag : public Sliver_caching_policy_tag{}; +struct Sliver_caching_never_tag : public Sliver_caching_policy_tag{}; +struct Sliver_caching_below_bound_tag : public Sliver_caching_policy_tag{};// Only cache values below the sliver bound + +CGAL_GENERATE_MEMBER_DETECTOR(set_sliver_value); +} // end namespace internal template::type, - Sliver_caching_policy caching_policy_ = Sliver_caching_policy::DEFAULT, + typename SliverCachingPolicy = + std::conditional_t::value, + internal::Sliver_caching_always_tag, + internal::Sliver_caching_below_bound_tag>, typename Cell_vector_ = std::vector > class Sliver_criterion { @@ -77,7 +83,7 @@ class Sliver_criterion bool is_sliver(Cell_handle cell) const { - if (caching_policy == Sliver_caching_policy::BELOW_BOUND) { + if (std::is_same_v) { return cache_.has_value(cell); } else { // if we cache everything, the operator() will return the cached value @@ -88,7 +94,7 @@ class Sliver_criterion // returns the value of the criterion for t virtual double operator()(Cell_handle cell) const { - if (caching_policy == Sliver_caching_policy::NEVER) { + if (std::is_same_v) { return operator()(tr_.tetrahedron(cell)); } else { if (cache_.has_value(cell)) { @@ -103,7 +109,8 @@ class Sliver_criterion // (see also the comment below) // IA_force_to_double is available in CGAL/FPU.h const double value = CGAL::IA_force_to_double(operator()(tr_.tetrahedron(cell))); - if (caching_policy == Sliver_caching_policy::BELOW_BOUND && value > this->sliver_bound_) { + if (std::is_same_v + && value > this->sliver_bound_) { return value; } else { cache_.set(cell, value); @@ -130,22 +137,13 @@ class Sliver_criterion : tr_(tr) , sliver_bound_(bound) , cache_(cache) - { - caching_policy = - (caching_policy_ == Sliver_caching_policy::DEFAULT) - ? (has_set_sliver_value::value ? Sliver_caching_policy::ALWAYS - : Sliver_caching_policy::BELOW_BOUND) - : caching_policy_; - } + {} virtual ~Sliver_criterion(){} protected: const Tr& tr_; double sliver_bound_; - - CGAL_GENERATE_MEMBER_DETECTOR(set_sliver_value); - Sliver_caching_policy caching_policy; mutable Cache cache_; }; @@ -154,12 +152,12 @@ class Min_value; template ::type, - Sliver_caching_policy caching_policy = Sliver_caching_policy::BELOW_BOUND> + typename SliverCachingPolicy = internal::Sliver_caching_below_bound_tag> class Min_dihedral_angle_criterion - : public Sliver_criterion + : public Sliver_criterion { protected: - typedef Sliver_criterion Base; + typedef Sliver_criterion Base; typedef typename Base::Tetrahedron_3 Tetrahedron_3; typedef typename Base::Cell_vector Cell_vector; typedef typename Base::GT GT; @@ -213,14 +211,14 @@ class Min_dihedral_angle_criterion template ::type, - Sliver_caching_policy caching_policy = Sliver_caching_policy::BELOW_BOUND> + typename SliverCachingPolicy = internal::Sliver_caching_below_bound_tag> class Radius_ratio_criterion - : public Sliver_criterion + : public Sliver_criterion { - typedef Radius_ratio_criterion Self; + typedef Radius_ratio_criterion Self; protected: - typedef Sliver_criterion Base; + typedef Sliver_criterion Base; typedef typename Base::GT GT; typedef typename Base::Tetrahedron_3 Tetrahedron_3; typedef typename Base::Cell_vector Cell_vector; From 486532ab6c0123a65561ca058641101a44775177 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 30 Apr 2026 17:24:21 +0200 Subject: [PATCH 091/127] remove std::array of 4 in cells and move to a map in ccdt to reduce memory footprint issue : pb with ostream of cells, similar to c3t3 --- ...ing_constrained_Delaunay_triangulation_3.h | 176 +++++++++++++++--- ...ained_Delaunay_triangulation_cell_base_3.h | 40 ++-- ...ained_Delaunay_triangulation_cell_data_3.h | 31 --- .../include/CGAL/IO/write_MEDIT.h | 6 +- .../CGAL/draw_constrained_triangulation_3.h | 11 +- 5 files changed, 180 insertions(+), 84 deletions(-) diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h index b38e41414595..d54c91cff61f 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h @@ -603,6 +603,39 @@ struct Output_rep, With_point_and_info_t template class Conforming_constrained_Delaunay_triangulation_3_impl; +namespace internal { +struct Pair_hash +{ + template + std::size_t operator()(const std::pair& p) const { + return boost::hash>()(p); + } + template + std::size_t hash(const Pair& p) const { + return this->operator()(p); + } + template + bool equal(const T& v1, const T& v2) const { + return v1 == v2; + } +}; + +template +struct Hash_map_of_pairs_type +{ + typedef CGAL::unordered_flat_map type; +}; + +#ifdef CGAL_LINKED_WITH_TBB +template +struct Hash_map_of_pairs_type +{ + typedef tbb::concurrent_hash_map type; +}; +#endif +} // namespace internal + + #endif // not DOXYGEN_RUNNING /*! @@ -1102,7 +1135,7 @@ class Conforming_constrained_Delaunay_triangulation_3 */ CDT_3_signed_index face_constraint_index(typename Triangulation::Cell_handle ch, int i) const { - return ch->ccdt_3_data().face_constraint_index(i); + return face_constraint_index(typename Triangulation::Facet(ch, i)); } /*! @@ -1112,7 +1145,7 @@ class Conforming_constrained_Delaunay_triangulation_3 */ CDT_3_signed_index face_constraint_index(const typename Triangulation::Facet& f) const { - return face_constraint_index(f.first, f.second); + return cdt_impl.face_constraint_index(f); } /*! @@ -1265,6 +1298,19 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D Constrained_facets_range constrained_facets() const { return {constrained_facets_begin(), constrained_facets_end()}; } + +public: // @tmp + struct Facet_prop + { + CDT_3_signed_index face_id = -1; + void* facet_2d = nullptr; + }; + using Surface_facet_info = + typename internal::Hash_map_of_pairs_type::type; + mutable Surface_facet_info surface_facet_info_; + private: struct CDT_2_types { @@ -1339,12 +1385,52 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D public: using Constrained_polyline_id = typename Constraint_hierarchy::Constraint_id; +public: + CDT_3_signed_index face_constraint_index(Cell_handle cell, int facet_index) const + { + return surface_facet_info_[Facet{cell, facet_index}].face_id; + } + CDT_3_signed_index face_constraint_index(const Facet& f) const + { + return face_constraint_index(f.first, f.second); + } + protected: + void set_face_constraint_index(Cell_handle cell, int facet_index, CDT_3_signed_index index) + { + surface_facet_info_[Facet{cell, facet_index}].face_id = index; + } + + template + auto face_2(const CDT_2& cdt, Cell_handle cell, int facet_index) const + { + using Face = typename CDT_2::Face; + auto ptr = static_cast(surface_facet_info_[Facet{cell, facet_index}].facet_2d); + return cdt.tds().faces().iterator_to(*ptr); + } + + template + void set_facet_constraint(Cell_handle cell, int facet_index, + CDT_3_signed_index face_id, + Facet_handle facet_2d) + { + const Facet facet{cell, facet_index}; + const auto f2d = static_cast(facet_2d == Facet_handle{} ? nullptr : std::addressof(*facet_2d)); + + auto surface_facet_info_it = surface_facet_info_.find(facet); + if(surface_facet_info_it != surface_facet_info_.end()) { + surface_facet_info_it->second.face_id = face_id; + surface_facet_info_it->second.facet_2d = f2d; + } + else { + surface_facet_info_.emplace(facet, Facet_prop{face_id, f2d}); + } + } void register_facet_to_be_constrained(Cell_handle cell, int facet_index) { - const auto face_id = static_cast(cell->ccdt_3_data().face_constraint_index(facet_index)); + const auto face_id = static_cast(face_constraint_index(cell, facet_index)); this->face_constraint_misses_subfaces_set(face_id); - auto fh_2 = cell->ccdt_3_data().face_2(this->face_cdt_2(face_id), facet_index); + auto fh_2 = face_2(this->face_cdt_2(face_id), cell, facet_index); fh_2->info().facet_3d = {}; fh_2->info().missing_subface = true; this->set_facet_constrained({cell, facet_index}, -1, {}); @@ -1371,7 +1457,7 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D for(auto cell_it = cell_it_begin; cell_it != end; ++cell_it) { auto c = *cell_it; for(int li = first_li; li < 4; ++li) { - if(c->ccdt_3_data().is_facet_constrained(li)) { + if(self->is_facet_constrained(c, li)) { self->register_facet_to_be_constrained(c, li); #if CGAL_CDT_3_DEBUG_MISSING_TRIANGLES std::cerr << "Add missing triangle (from visitor), face F#" << face_id << ": \n"; @@ -1572,10 +1658,10 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D for(auto outside_facet : facets_of_cavity) { const auto [outside_cell, outside_face_index] = outside_facet; const auto mirror_facet = this->mirror_facet(outside_facet); - if(outside_cell->ccdt_3_data().is_facet_constrained(outside_face_index)) { - const auto polygon_id = outside_cell->ccdt_3_data().face_constraint_index(outside_face_index); + if(is_facet_constrained(outside_cell, outside_face_index)) { + const auto polygon_id = face_constraint_index(outside_cell, outside_face_index); const CDT_2& cdt_2 = face_cdt_2(polygon_id); - const auto f2d = outside_cell->ccdt_3_data().face_2(cdt_2, outside_face_index); + const auto f2d = face_2(cdt_2, outside_cell, outside_face_index); set_facet_constrained(mirror_facet, polygon_id, f2d); } } @@ -1761,7 +1847,10 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D } bool is_facet_constrained(Facet f) const { - return f.first->ccdt_3_data().is_facet_constrained(f.second); + return face_constraint_index(f.first, f.second) >= 0; + } + bool is_facet_constrained(Cell_handle c, int facet_index) const { + return face_constraint_index(c, facet_index) >= 0; } auto number_of_constrained_facets() const @@ -1790,10 +1879,11 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D CGAL_assertion(fh == CDT_2_face_handle{} || same_triangle(f, fh)); const auto [c, facet_index] = f; - c->ccdt_3_data().set_facet_constraint(facet_index, polygon_constraint_id, fh); + set_facet_constraint(c, facet_index, polygon_constraint_id, fh); + if(tr().dimension() > 2) { const auto [n, n_index] = tr().mirror_facet({c, facet_index}); - n->ccdt_3_data().set_facet_constraint(n_index, polygon_constraint_id, fh); + set_facet_constraint(n, n_index, polygon_constraint_id, fh); } if(fh == CDT_2_face_handle{}) return; @@ -3563,10 +3653,10 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D auto restore_markers = [&](Facet outside_facet) { const auto [outside_cell, outside_face_index] = outside_facet; const auto mirror_facet = this->mirror_facet(outside_facet); - if(outside_cell->ccdt_3_data().is_facet_constrained(outside_face_index)) { - const auto polygon_id = outside_cell->ccdt_3_data().face_constraint_index(outside_face_index); + if(is_facet_constrained(outside_cell, outside_face_index)) { + const auto polygon_id = face_constraint_index(outside_cell, outside_face_index); const CDT_2& cdt_2 = face_cdt_2(polygon_id); - const auto f2d = outside_cell->ccdt_3_data().face_2(cdt_2, outside_face_index); + const auto f2d = face_2(cdt_2, outside_cell, outside_face_index); set_facet_constrained(mirror_facet, polygon_id, f2d); } }; @@ -3752,7 +3842,7 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D } for(auto [cell, facet_index] : missing_faces) { facets_of_cavity_border.erase({cell, facet_index}); - if(cell->ccdt_3_data().is_facet_constrained(facet_index)) { + if(is_facet_constrained(cell, facet_index)) { result.interior_constrained_faces.emplace_back(cell, facet_index); } auto is_new_cell = cells_of_cavity.insert(cell).second; @@ -4080,7 +4170,7 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D const auto n_index = n->index(it); if(!this->is_infinite(n->vertex(n_index))) { - if(!it->ccdt_3_data().is_facet_constrained(i) && + if(!is_facet_constrained(it, i) && this->side_of_sphere(it, n->vertex(n_index)->point()) == ON_BOUNDED_SIDE) { if(verbose) { @@ -5092,6 +5182,20 @@ auto get_remeshing_triangulation(Conforming_constrained_Delaunay_triangulation_3 } } + boost::unordered_map constraint_index_map; + for(auto [c, index] : ccdt.triangulation().finite_facets()) + { + if(ccdt.is_facet_constrained(c, index)) + { + typename Tr::Facet f(c, index); + + auto findex = ccdt.face_constraint_index(f); + constraint_index_map[f] = findex; + auto mirror_f = ccdt.triangulation().mirror_facet(f); + constraint_index_map[mirror_f] = findex; + } + } + auto tr = std::move(ccdt).triangulation(); using CDT_3 = Conforming_constrained_Delaunay_triangulation_3; @@ -5102,10 +5206,16 @@ auto get_remeshing_triangulation(Conforming_constrained_Delaunay_triangulation_3 for(auto ch : tr.all_cell_handles()) { ch->set_subdomain_index(0); } - for(auto [c, index] : tr.finite_facets()) { - if(c->ccdt_3_data().is_facet_constrained(index)) { - auto patch = c->ccdt_3_data().face_constraint_index(index) + 1; - c->set_surface_patch_index(index, patch); + for(const auto& f : tr.finite_facets()) + { + auto f_patch_it = constraint_index_map.find(f); + if(f_patch_it != constraint_index_map.end()) + { + const auto& patch = f_patch_it->second; + auto mirror_f = ccdt.triangulation().mirror_facet(f); + + f.first->set_surface_patch_index(f.second, patch); + mirror_f.first->set_surface_patch_index(mirror_f.second, patch); } } } else { @@ -5113,6 +5223,19 @@ auto get_remeshing_triangulation(Conforming_constrained_Delaunay_triangulation_3 ch->set_subdomain_index(-1); } + auto is_f_constrained = [&](typename Tr::Cell_handle ch, int index) -> bool + { + typename Tr::Facet f(ch, index); + return constraint_index_map.find(f) != constraint_index_map.end(); + }; + auto f_constraint_index = [&](typename Tr::Cell_handle ch, int index) -> std::size_t + { + typename Tr::Facet f(ch, index); + auto it = constraint_index_map.find(f); + CGAL_assertion(it != constraint_index_map.end()); + return it->second; + }; + // Use a flood algorithm to mark constrained connected components. // The connected component containing the infinite vertex is marked with index 0. // Nested components are marked with increasing indices. @@ -5123,7 +5246,10 @@ auto get_remeshing_triangulation(Conforming_constrained_Delaunay_triangulation_3 int next_odd_subdomain = 1; // Function to flood-fill a connected component with a given subdomain index - auto flood_component = [&border](typename Tr::Cell_handle start, int subdomain_index) { + auto flood_component + = [&border, &is_f_constrained] + (typename Tr::Cell_handle start, int subdomain_index) + { if(start->subdomain_index() != -1) return; @@ -5139,7 +5265,7 @@ auto get_remeshing_triangulation(Conforming_constrained_Delaunay_triangulation_3 typename Tr::Facet f(ch, i); auto n = ch->neighbor(i); if(n->subdomain_index() == -1) { - if(ch->ccdt_3_data().is_facet_constrained(i)) + if(is_f_constrained(ch, i)) border.push(f); else queue.push(n); @@ -5186,10 +5312,10 @@ auto get_remeshing_triangulation(Conforming_constrained_Delaunay_triangulation_3 for(auto f : tr.finite_facets()) { auto mf = tr.mirror_facet(f); - if(f.first->ccdt_3_data().is_facet_constrained(f.second) || - mf.first->ccdt_3_data().is_facet_constrained(mf.second)) + if(is_f_constrained(f.first, f.second) || + is_f_constrained(mf.first, mf.second)) { - auto patch = f.first->ccdt_3_data().face_constraint_index(f.second) + 1; + auto patch = f_constraint_index(f.first, f.second) + 1; f.first->set_surface_patch_index(f.second, patch); mf.first->set_surface_patch_index(mf.second, patch); } diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_cell_base_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_cell_base_3.h index f109feaed163..4bdc31758ff7 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_cell_base_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_cell_base_3.h @@ -70,9 +70,9 @@ class Conforming_constrained_Delaunay_triangulation_cell_base_3 } static std::string io_signature() { - static_assert( - std::is_same_v< - decltype(std::declval().face_constraint_index(0)), int>); +// static_assert( +// std::is_same_v< +// decltype(std::declval().face_constraint_index(0)), int>); return Get_io_signature()() + "+(" + Get_io_signature()() + ")[4]"; } @@ -82,13 +82,13 @@ class Conforming_constrained_Delaunay_triangulation_cell_base_3 const Conforming_constrained_Delaunay_triangulation_cell_base_3& c) { os << static_cast(c); - for( unsigned li = 0; li < 4; ++li ) { - if(IO::is_ascii(os)) { - os << " " << c.ccdt_3_data().face_constraint_index(li); - } else { - CGAL::write(os, c.ccdt_3_data().face_constraint_index(li)); - } - } + //for( unsigned li = 0; li < 4; ++li ) { + // if(IO::is_ascii(os)) { + // os << " " << face_constraint_index(c, li); + // } else { + // CGAL::write(os, face_constraint_index(c, li)); + // } + //} return os; } friend std::istream& @@ -97,16 +97,16 @@ class Conforming_constrained_Delaunay_triangulation_cell_base_3 { is >> static_cast(c); if(!is) return is; - for( int li = 0; li < 4; ++li ) { - int i; - if(IO::is_ascii(is)) { - is >> i; - } else { - CGAL::read(is, i); - } - if(!is) return is; - c->ccdt_3_data().set_face_constraint_index(li, i); - } +// for( int li = 0; li < 4; ++li ) { +// int i; +// if(IO::is_ascii(is)) { +// is >> i; +// } else { +// CGAL::read(is, i); +// } +// if(!is) return is; +// set_face_constraint_index(c, li, i); +// } return is; } }; diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_cell_data_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_cell_data_3.h index 91d9b73044ae..9fb92555211a 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_cell_data_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_cell_data_3.h @@ -42,8 +42,6 @@ class Conforming_constrained_Delaunay_triangulation_cell_data_3 { template friend class Conforming_constrained_Delaunay_triangulation_3_impl; /// @endcond - std::array face_id = { -1, -1, -1, -1 }; - std::array facet_2d = {nullptr, nullptr, nullptr, nullptr}; std::bitset(CDT_3_cell_marker::nb_of_markers)> markers; bool is_marked() const { return markers.any(); } @@ -52,35 +50,6 @@ class Conforming_constrained_Delaunay_triangulation_cell_data_3 { void clear_mark(CDT_3_cell_marker m) { markers.reset(static_cast(m)); } void clear_marks() { markers.reset(); } - static unsigned int uint(int i) { return static_cast(i); } - - template - void set_facet_constraint(int i, CDT_3_signed_index face_id, - Facet_handle facet_2d) - { - this->face_id[uint(i)] = face_id; - this->facet_2d[uint(i)] = static_cast(facet_2d == Facet_handle{} ? nullptr : std::addressof(*facet_2d)); - } - - template - auto face_2 (const CDT_2& cdt, int i) const { - using Face = typename CDT_2::Face; - auto ptr = static_cast(facet_2d[uint(i)]); - return cdt.tds().faces().iterator_to(*ptr); - } -public: - /// @{ - // @cond SKIP_IN_MANUAL - bool is_facet_constrained(int i) const { return face_id[uint(i)] >= 0; } - - CDT_3_signed_index face_constraint_index(int i) const { - return face_id[uint(i)]; - } - - void set_face_constraint_index(int i, CDT_3_signed_index index) { - face_id[uint(i)] = index; - } - /// @endcond }; } // namespace CGAL diff --git a/Constrained_triangulation_3/include/CGAL/IO/write_MEDIT.h b/Constrained_triangulation_3/include/CGAL/IO/write_MEDIT.h index 95d2262ecd06..c2d20fb094af 100644 --- a/Constrained_triangulation_3/include/CGAL/IO/write_MEDIT.h +++ b/Constrained_triangulation_3/include/CGAL/IO/write_MEDIT.h @@ -95,8 +95,10 @@ void write_MEDIT(std::ostream& os, const bool has_plc_face_id = choose_parameter(get_parameter(np, internal_np::with_plc_face_id), false); - auto plc_patch_map = boost::make_function_property_map([&](const Facet& f) - { return has_plc_face_id ? f.first->ccdt_3_data().face_constraint_index(f.second) + 1 : 1; }); + auto plc_patch_map = boost::make_function_property_map([&](const Facet& f) { + return has_plc_face_id + ? ccdt.face_constraint_index(f.first, f.second) + 1 + : 1; }); return SMDS_3::output_to_medit(os, tr, diff --git a/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h index 06787577176e..a9ccbc29ad94 100644 --- a/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h @@ -38,31 +38,30 @@ void draw(const Conforming_constrained_Delaunay_triangulation_3& ccd using Edge_descriptor = typename Tr_::Finite_edges_iterator; using Facet_descriptor = typename Tr_::Finite_facets_iterator; - using Face_index = CGAL::cpp20::remove_cvref_t< - decltype(std::declval()->ccdt_3_data().face_constraint_index(0))>; + using Face_index = CDT_3_signed_index; Face_index nb_colors = 0; std::for_each( ccdt.constrained_facets_begin(), ccdt.constrained_facets_end(), [&](const auto& f) { auto [c, index] = f; - nb_colors = (std::max)(nb_colors, c->ccdt_3_data().face_constraint_index(index) + 1); + nb_colors = (std::max)(nb_colors, ccdt.face_constraint_index(c, index) + 1); }); std::vector colors(nb_colors); std::generate(colors.begin(), colors.end(), []() { return CGAL::get_random_color(CGAL::get_default_random()); }); CGAL::Graphics_scene_options options; - options.draw_face = [](const Tr_&, Facet_descriptor f) { + options.draw_face = [&](const Tr_&, Facet_descriptor f) { auto [c, index] = *f; - return c->ccdt_3_data().is_facet_constrained(index); + return ccdt.is_facet_constrained(c, index); }; options.colored_face = [](const Tr_&, Facet_descriptor) { return true; }; options.face_color = [&](const Tr_&, Facet_descriptor f) { auto [c, index] = *f; - return colors[c->ccdt_3_data().face_constraint_index(index)]; + return colors[ccdt.face_constraint_index(c, index)]; }; draw(ccdt.triangulation(), options, title); } From 92d852088725de1598ea62e49cab5dd17544786f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 4 May 2026 16:34:51 +0200 Subject: [PATCH 092/127] remove facets from the map before deleted them by vertex insertion --- ...ing_constrained_Delaunay_triangulation_3.h | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h index d54c91cff61f..5bf2deecd59b 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h @@ -1419,8 +1419,14 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D auto surface_facet_info_it = surface_facet_info_.find(facet); if(surface_facet_info_it != surface_facet_info_.end()) { - surface_facet_info_it->second.face_id = face_id; - surface_facet_info_it->second.facet_2d = f2d; + if(face_id >= 0) + { + surface_facet_info_it->second.face_id = face_id; + surface_facet_info_it->second.facet_2d = f2d; + } else + { + surface_facet_info_.erase(surface_facet_info_it);//not constrained anymore + } } else { surface_facet_info_.emplace(facet, Facet_prop{face_id, f2d}); @@ -1433,7 +1439,7 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D auto fh_2 = face_2(this->face_cdt_2(face_id), cell, facet_index); fh_2->info().facet_3d = {}; fh_2->info().missing_subface = true; - this->set_facet_constrained({cell, facet_index}, -1, {}); + this->set_facet_unconstrained({cell, facet_index}); } void register_facet_to_be_constrained(Facet f) { @@ -1574,6 +1580,7 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D CGAL_assertion(lt != Locate_type::VERTEX); boost::container::small_vector cells_of_original_cavity; boost::container::small_vector exterior_border_facets_of_original_cavity; + boost::container::small_vector facets_of_original_cavity; auto output_iterator_to_facets = boost::make_function_output_iterator( [&](Facet f) { exterior_border_facets_of_original_cavity.push_back(tr().mirror_facet(f)); }); @@ -1581,7 +1588,7 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D auto triple_of_output_iterators = make_triple( output_iterator_to_facets, std::back_inserter(cells_of_original_cavity), - Emptyset_iterator{}); + std::back_inserter(facets_of_original_cavity)); switch(tr().dimension()) { case 3: { @@ -1604,6 +1611,14 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D for(auto [ch, _] : exterior_border_facets_of_original_cavity) { ch->tds_data().clear(); } + // clear the surface data from facets that are in the cavity + // and will be deleted + for(const auto& f : facets_of_original_cavity) { + this->set_facet_unconstrained(f); + } + for(const auto& f : exterior_border_facets_of_original_cavity) { + this->set_facet_unconstrained(tr().mirror_facet(f)); + } bool the_infinite_vertex_is_in_the_cavity = false; std::set vertices_of_original_cavity; @@ -1892,6 +1907,11 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D } } + void set_facet_unconstrained(Facet f) + { + this->set_facet_constrained(f, -1, {}); + } + template ) Polygon> std::optional register_new_constrained_polygon(Polygon&& polygon) { return insert_constrained_polygon(std::forward(polygon), false); From 50e64fc6283786fdaae143ca870b3c6569a6fa42 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 11 May 2026 10:05:01 +0200 Subject: [PATCH 093/127] add missing include (try to please CI) --- .../include/CGAL/draw_constrained_triangulation_3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h index a9ccbc29ad94..2fafec692ca0 100644 --- a/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include From 7be28cd68425181e67628c20c33f84e503057fde Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 25 Sep 2026 14:23:01 +0200 Subject: [PATCH 094/127] fix I/O of CDT_3 --- ...ing_constrained_Delaunay_triangulation_3.h | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h index 053ef3944e8e..24f2c78a0298 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h @@ -1238,6 +1238,10 @@ class Conforming_constrained_Delaunay_triangulation_3 void write_facets(std::ostream& out, const CDT& cdt, FacetRange&& facets) const { cdt_impl.write_facets(out, cdt, std::forward(facets)); } + + friend std::ostream& operator<<(std::ostream& out, const Conforming_constrained_Delaunay_triangulation_3& ccdt) { + return out << ccdt.cdt_impl; + } }; #ifndef DOXYGEN_RUNNING @@ -2471,7 +2475,8 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D bool search_for_missing_subfaces(CDT_3_signed_index polygon_constraint_id, - Search_for_missing_subfaces_option option = Search_for_missing_subfaces_option::DEFAULT) { + Search_for_missing_subfaces_option option = Search_for_missing_subfaces_option::DEFAULT) + { bool something_has_changed = false; const CDT_2& cdt_2 = face_cdt_2(polygon_constraint_id); @@ -2505,7 +2510,9 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D << this->display_vert(v2) << '\n'; } } - set_facet_constrained({c, facet_index}, polygon_constraint_id, fh); + if(option != Search_for_missing_subfaces_option::SEARCH_FOR_UNCONSTRAINED_FACETS) { + set_facet_constrained({c, facet_index}, polygon_constraint_id, fh); + } } } if(option == Search_for_missing_subfaces_option::SEARCH_FOR_UNCONSTRAINED_FACETS && something_has_changed) { @@ -4850,9 +4857,29 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D write_3d_triangulation_to_OFF(dump, tr); } - void dump_triangulation() const { - std::ofstream dump("dump.binary.cgal", std::ios::binary); - CGAL::IO::save_binary_file(dump, *this); + friend std::ostream& operator<<(std::ostream& out, const Conforming_constrained_Delaunay_triangulation_3_impl& ccdt_impl) { + out << ccdt_impl.tr(); + if(IO::is_ascii(out)) { + for(auto ch : ccdt_impl.tr().all_cell_handles()) { + for(int li = 0; li < 4; ++li) { + if(li > 0) out << " "; + out << ccdt_impl.face_constraint_index(ch, li); + } + out << '\n'; + } + } else { + for(auto ch : ccdt_impl.tr().all_cell_handles()) { + for(int li = 0; li < 4; ++li) { + CGAL::write(out, ccdt_impl.face_constraint_index(ch, li)); + } + } + } + return out; + } + + void dump_triangulation(std::string_view file_name = "dump.binary.cgal", IO::Mode mode = IO::BINARY) const { + std::ofstream dump(file_name.data(), mode == IO::BINARY ? std::ios::binary : std::ios::out); + CGAL::IO::save_binary_file(dump, *this, mode == IO::BINARY); } void dump_triangulation_to_off() const { From f433274369bb37fbaee6743c63a856b3db9be582 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 25 Sep 2026 14:43:37 +0200 Subject: [PATCH 095/127] more debug --- .../CGAL/Conforming_constrained_Delaunay_triangulation_3.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h index 24f2c78a0298..705db5231ff2 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h @@ -4416,7 +4416,11 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D CGAL_assertion_msg( recheck_for_missing_subfaces() && face_constraint_misses_subfaces_find_first() == face_constraint_misses_subfaces_npos, - "All faces have been restored, but the triangulation is still not a CDT. This should not happen."); + std::invoke([&] { + dump_triangulation_to_off(); + dump_triangulation(); + return "All faces have been restored, but the triangulation is still not a CDT. This should not happen."; + })); } void add_bbox_points_if_not_dimension_3() { From ad061cfa8cf72ccf9d037eb46dce322ba5424008 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 30 Sep 2026 10:38:46 +0200 Subject: [PATCH 096/127] fix Mesh_3 I/O --- ...meshing_experimental_compact_cell_base.cpp | 144 +-------------- .../test_meshing_polyhedron_with_features.cpp | 34 ++-- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 171 +++++++++++++++++- 3 files changed, 184 insertions(+), 165 deletions(-) diff --git a/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp b/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp index 8e43a02d904c..2bb7060b93b8 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp @@ -1,145 +1,3 @@ #define CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 #define CGAL_MESH_3_NO_CIRCUMCENTER_CACHE - -#include "test_meshing_utilities.h" -#include -#include -#include -#include -#include -#include - -#include -#include - -static constexpr bool verbose = -#ifdef CGAL_MESH_3_VERBOSE - true; -#else - false; -#endif - - -std::stringstream cerr_output; - -template -struct Polyhedron_with_features_tester - : public Tester -{ - std::streambuf* old_cerr_buf; - std::string tag_name; - - Polyhedron_with_features_tester(std::string tag_name) - : old_cerr_buf(std::cerr.rdbuf(verbose ? cerr_output.rdbuf() : std::cerr.rdbuf())) - , tag_name(tag_name) - { - } - ~Polyhedron_with_features_tester() - { - std::cerr.rdbuf(old_cerr_buf); - if(verbose) { - const auto output = cerr_output.str(); - const auto str_size= output.size(); - const auto str_begin = output.data(); - const auto str_end = str_begin + str_size; - constexpr auto nb = static_cast>(10000); - auto pos1 = str_begin + (std::min)(nb, str_size); - assert(pos1 <= str_end); - const auto pos2 = str_end - (std::min)(nb, str_size); - assert(pos2 >= str_begin); - if(pos2 <= pos1) { - pos1 = str_end; - } - std::cerr << "NOW THE FIRST AND LAST 10k CHARACTERS OF THE CERR OUTPUT:\n"; - std::cerr << "-----\n" << std::string(str_begin, pos1) << "\n-----\n"; - if(pos1 != str_end) { - std::cerr << "[...]\n-----\n" << std::string(pos2, str_end) << "\n-----\n"; - } - const auto file_name = std::string("test_meshing_verbose-") + tag_name + ".txt"; - std::ofstream file_output(file_name); - file_output << output; - std::cerr << "Full log is output to " << file_name << "\n"; - } - } - void operator()() const - { - typedef CGAL::Mesh_3::Robust_intersection_traits_3 GT; - typedef typename CGAL::Mesh_polyhedron_3::type Polyhedron; - typedef CGAL::Polyhedral_mesh_domain_with_features_3 Mesh_domain; - - typedef typename CGAL::Mesh_triangulation_3< - Mesh_domain, - typename CGAL::Kernel_traits::Kernel, - Concurrency_tag>::type Tr; - typedef CGAL::Mesh_complex_3_in_triangulation_3 < - Tr, - typename Mesh_domain::Corner_index, - typename Mesh_domain::Curve_index > C3t3; - - typedef CGAL::Mesh_criteria_3 Mesh_criteria; - typedef typename Mesh_criteria::Edge_criteria Edge_criteria; - typedef typename Mesh_criteria::Facet_criteria Facet_criteria; - typedef typename Mesh_criteria::Cell_criteria Cell_criteria; - - //------------------------------------------------------- - // Data generation - //------------------------------------------------------- - std::cout << "\tSeed is\t" << CGAL::get_default_random().get_seed() << std::endl; - - std::ifstream input(CGAL::data_file_path("meshes/cube.off")); - Polyhedron polyhedron; - input >> polyhedron; - - Mesh_domain domain(polyhedron, &CGAL::get_default_random()); - domain.detect_features(); - - // Set mesh criteria -#ifndef CGAL_MESH_3_VERBOSE - Edge_criteria edge_criteria(0.2); - Facet_criteria facet_criteria(30, 0.2, 0.02); - Cell_criteria cell_criteria(3, 0.2); -#else // a different set of criteria, for the test of CGAL_MESH_3_VERBOSE - Edge_criteria edge_criteria(0.3); - Facet_criteria facet_criteria(30, 0.3, 0.03); - Cell_criteria cell_criteria(3, 0.4); -#endif - Mesh_criteria criteria(edge_criteria, facet_criteria, cell_criteria); - - namespace params = CGAL::parameters; - - // Mesh generation - std::cout << "sizeof(Vertex) " << sizeof(typename C3t3::Triangulation::Vertex) << std::endl; - std::cout << "sizeof(Cell) " << sizeof(typename C3t3::Triangulation::Cell) << std::endl; - - C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, - params::odt(params::convergence(0.03).freeze_bound(0.02).time_limit(30)), - params::lloyd(params::max_iteration_number(10)), - params::perturb(params::sliver_bound(10).time_limit(30)), - params::exude(params::sliver_bound(10).time_limit(0))); - - CGAL::remove_far_points_in_mesh_3(c3t3); - } -}; - -int main() -{ - { - std::cerr << "Mesh generation from a polyhedron with edges:\n"; - Polyhedron_with_features_tester test_epic("sequential"); - test_epic(); - } -#ifdef CGAL_LINKED_WITH_TBB - { - std::cerr << "\n\nParallel mesh generation from a polyhedron with edges:\n"; - Polyhedron_with_features_tester test_epic_p("parallel"); - test_epic_p(); - } -#endif - - std::cout << "Done" << std::endl; - - return EXIT_SUCCESS; -} +#include "test_meshing_polyhedron_with_features.cpp" diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp index f798165b39a2..efd9b74b07d2 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedron_with_features.cpp @@ -1,19 +1,3 @@ -// Copyright (c) 2010 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// -// -// Author(s) : Stephane Tayeb -// -//****************************************************************************** -// File Description : -//****************************************************************************** - #include "test_meshing_utilities.h" #include #include @@ -99,11 +83,12 @@ struct Polyhedron_with_features_tester : public Tester //------------------------------------------------------- // Data generation //------------------------------------------------------- - std::cout << "\tSeed is\t" - << CGAL::get_default_random().get_seed() << std::endl; + std::cout << "\tSeed is\t" << CGAL::get_default_random().get_seed() << std::endl; + std::ifstream input(CGAL::data_file_path("meshes/cube.off")); Polyhedron polyhedron; input >> polyhedron; + Mesh_domain domain(polyhedron, &CGAL::get_default_random()); domain.detect_features(); @@ -123,7 +108,12 @@ struct Polyhedron_with_features_tester : public Tester #endif Mesh_criteria criteria(edge_criteria, facet_criteria, cell_criteria); + namespace params = CGAL::parameters; + // Mesh generation + std::cout << "sizeof(Vertex) " << sizeof(typename C3t3::Triangulation::Vertex) << std::endl; + std::cout << "sizeof(Cell) " << sizeof(typename C3t3::Triangulation::Cell) << std::endl; + C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, CGAL::parameters::manifold(), CGAL::parameters::no_exude(), @@ -138,6 +128,10 @@ struct Polyhedron_with_features_tester : public Tester std::ofstream out_medit("test-medit.mesh"); CGAL::IO::write_MEDIT(out_medit, c3t3); CGAL::IO::output_to_tetgen("test-tetgen", c3t3); + std::ofstream out_ascii("test-ascii.mesh.cgal", + std::ios_base::out|std::ios_base::binary); + CGAL::IO::save_binary_file(out_ascii, c3t3, false); + out_ascii.close(); std::ofstream out_binary("test-binary.mesh.cgal", std::ios_base::out|std::ios_base::binary); CGAL::IO::save_binary_file(out_binary, c3t3); @@ -160,11 +154,13 @@ int main() } #ifdef CGAL_LINKED_WITH_TBB { - std::cerr << "Parallel mesh generation from a polyhedron with edges:\n"; + std::cerr << "\n\nParallel mesh generation from a polyhedron with edges:\n"; Polyhedron_with_features_tester test_epic_p("parallel"); test_epic_p(); } #endif + std::cout << "Done" << std::endl; + return EXIT_SUCCESS; } diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 001f94a45dd3..b809ee1ba1a1 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -27,9 +27,14 @@ #include #include #include +#include +#include #include +#include #include +#include #include +#include #include #include @@ -38,14 +43,23 @@ #include #include #include +#include +#include +#include #include +#include +#include #include #include #include #include +#include #include -#include +#include +#include +#include +#include #ifdef CGAL_LINKED_WITH_TBB #include @@ -2468,7 +2482,87 @@ operator<< (std::ostream& os, const Mesh_complex_3_in_triangulation_3 &c3t3) { // TODO: implement edge saving - return os << c3t3.triangulation(); + if constexpr(c3t3.store_surface_patch_info_in_cell) { + return os << c3t3.triangulation(); + } else { + auto& tr = c3t3.triangulation(); + auto n = tr.number_of_vertices(); + if(IO::is_ascii(os)) { + os << tr.dimension() << std::endl << n << std::endl; + } else { + write(os, tr.dimension()); + write(os, n); + } + + if(n == 0) + return os; + + using Vertex_handle = typename Tr::Vertex_handle; + std::vector TV(n + 1); + auto i = 0u; + + // write the vertices + for(auto it = tr.vertices_begin(), end = tr.vertices_end(); it != end; ++it) + TV[i++] = it; + + CGAL_assertion(i == n + 1); + CGAL_assertion(tr.is_infinite(TV[0])); + + Unique_hash_map V; + V[tr.infinite_vertex()] = 0; + for(i = 1; i <= n; i++) { + os << *TV[i]; + V[TV[i]] = i; + if(IO::is_ascii(os)) + os << std::endl; + } + + // Asks the tds for the combinatorial information + tr.tds().print_cells(os, V); + + auto insert_cell = [&](std::ostream& os, typename Tr::Cell_handle ch) -> auto& { + if(IO::is_ascii(os)) + os << c3t3.subdomain_index(ch); + else + write(os, c3t3.subdomain_index(ch)); + + for(int i = 0; i < 4; ++i) { + if(IO::is_ascii(os)) + os << ' ' << IO::oformat(c3t3.surface_patch_index(ch, i)); + else + write(os, c3t3.surface_patch_index(ch, i)); + } + return os; + }; + + switch(tr.dimension()) { + case 3: { + for(auto it = tr.cells_begin(), end = tr.cells_end(); it != end; ++it) { + insert_cell(os, it); // other information + if(IO::is_ascii(os)) + os << std::endl; + } + break; + } + case 2: { + for(auto it = tr.facets_begin(), end = tr.facets_end(); it != end; ++it) { + insert_cell(os, (*it).first); // other information + if(IO::is_ascii(os)) + os << std::endl; + } + break; + } + case 1: { + for(auto it = tr.edges_begin(), end = tr.edges_end(); it != end; ++it) { + insert_cell(os, (*it).first); // other information + if(IO::is_ascii(os)) + os << std::endl; + } + break; + } + } + return os; + } } @@ -2479,7 +2573,78 @@ operator>> (std::istream& is, { // TODO: implement edge loading c3t3.clear(); - is >> c3t3.triangulation(); + if constexpr(c3t3.store_surface_patch_info_in_cell) { + is >> c3t3.triangulation(); + } else { + auto& tr = c3t3.triangulation(); + using Vertex_handle = typename Tr::Vertex_handle; + using Cell_handle = typename Tr::Cell_handle; + using C3t3 = Mesh_complex_3_in_triangulation_3; + + + tr.tds().clear(); // infinite vertex deleted + tr.set_infinite_vertex(tr.tds().create_vertex()); + std::size_t n; + int d; + if(IO::is_ascii(is)) { + is >> d >> n; + } else { + read(is, d); + read(is, n); + } + if(!is) + return is; + + std::vector V; + if(d > 3 || d < -2 || (n + 1) > V.max_size()) { + is.setstate(std::ios_base::failbit); + return is; + } + tr.tds().set_dimension(d); + V.resize(n + 1); + V[0] = tr.infinite_vertex(); // the infinite vertex is numbered 0 + + for(std::size_t i = 1; i <= n; i++) { + V[i] = tr.tds().create_vertex(); + if(!(is >> *V[i])) + return is; + } + + std::vector C; + + std::size_t m; + tr.tds().read_cells(is, V, m, C); + + auto extract_cell = [&](std::istream& is, Cell_handle ch) -> auto& { + typename C3t3::Subdomain_index index; + if(IO::is_ascii(is)) + is >> index; + else + read(is, index); + if(is) { + c3t3.set_subdomain_index(ch, index); + for(int i = 0; i < 4; ++i) + { + typename C3t3::Surface_patch_index i2; + if(IO::is_ascii(is)) + is >> IO::iformat(i2); + else + { + read(is, i2); + } + c3t3.set_surface_patch_index(ch, i, i2); + } + } + + return is; + }; + + for(std::size_t j = 0; j < m; j++) + { + if(!extract_cell(is, C[j])) + return is; + } + } if (!is) { c3t3.clear(); From d1f6a2d9b379567c113ff660008c3d862d012647 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 30 Sep 2026 12:11:46 +0200 Subject: [PATCH 097/127] fix test_mesh_cell_base_3 --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 11 ++++++++++- Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp | 13 ++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 41a438bc0ab7..bc6a16c94bed 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -1006,7 +1006,16 @@ scan_triangulation_impl() # endif add_to_TLS_lists(true); - // PARALLEL FOR_EACH + // First loop on cells to initialize the possible circumcenter caches + tbb::parallel_for_each( + this->r_tr_.finite_cells_begin(), this->r_tr_.finite_cells_end(), + [&] (auto& cell) + { + static_cast(cell.weighted_circumcenter()); + } + ); + + // then loop on facets. tbb::parallel_for_each( this->r_tr_.finite_facets_begin(), this->r_tr_.finite_facets_end(), typename Rf_base::template Scan_facet(*this) diff --git a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp index e128c5c1b836..d28f87f48d54 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -44,10 +45,10 @@ int main (int argc, char** argv){ // Open file - std::ifstream in (argc > 1 ? argv[1] : "data/elephant.mesh", - std::ios_base::in); + std::string input_file = (argc > 1 ? argv[1] : CGAL::data_file_path("meshes/elephant.mesh")); + std::ifstream in (input_file, std::ios_base::in); if(!in) { - std::cerr << "Error! Cannot open file " << argv[1] << std::endl; + std::cerr << "Error! Cannot open file " << input_file << std::endl; return 1; } C3t3 c3t3; @@ -58,8 +59,10 @@ int main (int argc, char** argv){ cit != c3t3.triangulation().finite_cells_end(); ++cit) { - assert(c3t3.subdomain_index(cit) >= 0); - c3t3.add_to_complex(cit, c3t3.subdomain_index(cit)); + auto subdomain_index = c3t3.subdomain_index(cit); + assert(subdomain_index >= 0); + if(subdomain_index > 0) + c3t3.add_to_complex(cit, subdomain_index); for(int i=0; i < 4; ++i) { if(c3t3.surface_patch_index(cit, i) > 0) From 74ccf6fe01203b143882e4e49e4ff63acd41ea3e Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 30 Sep 2026 13:56:27 +0200 Subject: [PATCH 098/127] initialize `dual(ch)` for all cells because there might be a cache for circumcenters --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index bc6a16c94bed..2603a7c5007c 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -1008,10 +1008,10 @@ scan_triangulation_impl() // First loop on cells to initialize the possible circumcenter caches tbb::parallel_for_each( - this->r_tr_.finite_cells_begin(), this->r_tr_.finite_cells_end(), - [&] (auto& cell) + this->r_tr_.finite_cell_handles().begin(), this->r_tr_.finite_cell_handles().end(), + [&] (Cell_handle ch) { - static_cast(cell.weighted_circumcenter()); + static_cast(this->r_tr_.dual(ch)); } ); From b5d35a9ddcaa6700fa9731a946ef5cfd63411efb Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 13:11:08 +0200 Subject: [PATCH 099/127] enable `-x` when the action is run with debug logging --- .github/workflows/checks.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 4ec639819924..dbeea2263f60 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -26,7 +26,6 @@ jobs: - name: Run checks run: | - zsh Scripts/developer_scripts/test_merge_of_branch HEAD + zsh ${RUNNER_DEBUG:+-x} Scripts/developer_scripts/test_merge_of_branch HEAD >> $GITHUB_STEP_SUMMARY #test dependencies - bash Scripts/developer_scripts/cgal_check_dependencies.sh --check_headers /usr/bin/doxygen - + bash ${RUNNER_DEBUG:+-x} Scripts/developer_scripts/cgal_check_dependencies.sh --check_headers /usr/bin/doxygen From 42bc9c337125bce33072b9ee64879b0fbb9ab8a5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 13:13:39 +0200 Subject: [PATCH 100/127] add missing includes --- SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index ae3453a05d32..6fa2808b1ed1 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -21,14 +21,25 @@ #include #include +#include +#include #include +#include #include #include +#include #include +#include #include +#include +#include +#include +#include +#include #include +#include #include #include #include From d4123f207c721e207c4a85cb2986966a3fffc6f5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 14:02:52 +0200 Subject: [PATCH 101/127] fix the CI --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index dbeea2263f60..f6ccc0e8ad28 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -26,6 +26,6 @@ jobs: - name: Run checks run: | - zsh ${RUNNER_DEBUG:+-x} Scripts/developer_scripts/test_merge_of_branch HEAD >> $GITHUB_STEP_SUMMARY + bash ${RUNNER_DEBUG:+-x} Scripts/developer_scripts/test_merge_of_branch HEAD >> $GITHUB_STEP_SUMMARY #test dependencies bash ${RUNNER_DEBUG:+-x} Scripts/developer_scripts/cgal_check_dependencies.sh --check_headers /usr/bin/doxygen From cabd3b38c0a691bc4e331bbdecf2dfc678332275 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 15:09:01 +0200 Subject: [PATCH 102/127] try to fix the broken pipe `grep | head -n1` --- Scripts/developer_scripts/test_merge_of_branch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/developer_scripts/test_merge_of_branch b/Scripts/developer_scripts/test_merge_of_branch index 6e0c7fcb5de4..5cbb18c88753 100755 --- a/Scripts/developer_scripts/test_merge_of_branch +++ b/Scripts/developer_scripts/test_merge_of_branch @@ -216,7 +216,7 @@ check_cmake_minimum_required() # shellcheck disable=SC2016 heading 'Checking if all CMakeLists.txt starts with `cmake_minimum_required`' - cmr=$(for i in !(build*)/@(test|examples|demo|benchmark*)/*/CMakeLists.txt; do res=$(grep -Ev "^[[:space:]]*(#|$)" "$i" | head -n 1 | grep -v cmake_minimum_required); if [ -n "${res}" ]; then echo "$i"; fi; done) + cmr=$(for i in !(build*)/@(test|examples|demo|benchmark*)/*/CMakeLists.txt; do res=$(grep -m 1 -Ev "^[[:space:]]*(#|$)" "$i" | grep -v cmake_minimum_required); if [ -n "${res}" ]; then echo "$i"; fi; done) report_error_with_list_of_files 'CMakeLists with issues:' "${cmr}" } From 0151fc48fca371bfbad03d6cac4169e5785c4802 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 15:09:13 +0200 Subject: [PATCH 103/127] fix headers --- SMDS_3/include/CGAL/IO/File_medit.h | 7 +++- SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h | 36 +---------------- SMDS_3/include/CGAL/SMDS_3/utilities.h | 39 +++++++++++++++++++ 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/SMDS_3/include/CGAL/IO/File_medit.h b/SMDS_3/include/CGAL/IO/File_medit.h index 8856a6c5812b..8142a9a550db 100644 --- a/SMDS_3/include/CGAL/IO/File_medit.h +++ b/SMDS_3/include/CGAL/IO/File_medit.h @@ -17,28 +17,31 @@ #include #include -#include +#include #include #include #include #include #include +#include #include +#include #include #include +#include #include #include #include #include +#include #include #include #include #include #include -#include //for std::visit namespace CGAL { diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index 6fa2808b1ed1..4ab72ba61c67 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -24,9 +24,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -46,40 +46,6 @@ namespace CGAL { -namespace SMDS_3_internal { -template -struct Has_in_dimension : std::false_type -{}; - -template -struct Has_in_dimension().in_dimension())>> - : std::true_type -{}; - -template -struct Has_is_corner : std::false_type -{}; - -template -struct Has_is_corner().is_corner())>> - : std::true_type -{}; - -template -bool is_corner(const typename Tr::Vertex_handle v, const Tr&) -{ - using V = typename Tr::Triangulation_data_structure::Vertex; - - if constexpr(Has_in_dimension::value) - return v->in_dimension() == 0; - else if constexpr(Has_is_corner::value) - return v->ccdt_3_data().is_corner(); - else - return false; -} - -} // namespace SMDS_3_internal - namespace SMDS_3 { template diff --git a/SMDS_3/include/CGAL/SMDS_3/utilities.h b/SMDS_3/include/CGAL/SMDS_3/utilities.h index 369bfc9df039..469028ab2e98 100644 --- a/SMDS_3/include/CGAL/SMDS_3/utilities.h +++ b/SMDS_3/include/CGAL/SMDS_3/utilities.h @@ -19,10 +19,15 @@ #include +#include #include +#include + #include #include #include +#include +#include namespace CGAL { namespace SMDS_3 { @@ -116,6 +121,40 @@ class Iterator_not_in_complex } // end namespace internal } // end namespace SMDS_3 + +namespace SMDS_3_internal { +template +struct Has_in_dimension : std::false_type +{}; + +template +struct Has_in_dimension().in_dimension())>> + : std::true_type +{}; + +template +struct Has_is_corner : std::false_type +{}; + +template +struct Has_is_corner().is_corner())>> + : std::true_type +{}; + +template +bool is_corner(const typename Tr::Vertex_handle v, const Tr&) +{ + using V = typename Tr::Triangulation_data_structure::Vertex; + + if constexpr(Has_in_dimension::value) + return v->in_dimension() == 0; + else if constexpr(Has_is_corner::value) + return v->ccdt_3_data().is_corner(); + else + return false; +} + +} // namespace SMDS_3_internal } //namespace CGAL #endif // CGAL_SMDS_3_UTILITIES_H From 35b6195e89b3576c0f5f93e42c8060284caa7f5e Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 16:11:33 +0200 Subject: [PATCH 104/127] group the results --- .../cgal_check_dependencies.sh | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/Scripts/developer_scripts/cgal_check_dependencies.sh b/Scripts/developer_scripts/cgal_check_dependencies.sh index a56aad03214a..a888d662d852 100644 --- a/Scripts/developer_scripts/cgal_check_dependencies.sh +++ b/Scripts/developer_scripts/cgal_check_dependencies.sh @@ -1,7 +1,11 @@ #!/bin/bash #This script must be called from the CGAL root. set -e -[ -n "$RUNNER_DEBUG" ] && set -x +if [ -n "$RUNNER_DEBUG" ]; then + set -x + CMAKE_DEBUG_OPT=" -v" +fi + while test $# -gt 0 do case "$1" in @@ -35,24 +39,41 @@ do fi done -cmake -DCGAL_ENABLE_CHECK_HEADERS=TRUE -DDOXYGEN_EXECUTABLE="$DOX_PATH" -DCGAL_COPY_DEPENDENCIES=TRUE -DCMAKE_CXX_FLAGS="-std=c++1y" .. +group() +{ + local title=$1 + shift + if [ "$GITHUB_ACTIONS" = "true" ]; then + echo "::group::$title" + else + printf '\n## %s\n\n' "$title" + fi + local status=0 + "$@" || status=$? + if [ "$GITHUB_ACTIONS" = "true" ]; then + echo "::endgroup::" + fi + return "$status" +} + +group "Configure dependency check" cmake -DCGAL_ENABLE_CHECK_HEADERS=TRUE -DDOXYGEN_EXECUTABLE="$DOX_PATH" -DCGAL_COPY_DEPENDENCIES=TRUE -DCMAKE_CXX_FLAGS="-std=c++1y" .. if [ -n "$DO_CHECK_HEADERS" ]; then - cmake --build . -j"$(nproc --all)" --target check_headers -v -- -k - cmake --build . -j"$(nproc --all)" --target check_headers_linked_twice -v -- -k + group "Check headers" cmake --build . -j"$(nproc --all)" --target check_headers ${CMAKE_DEBUG_OPT:+"$CMAKE_DEBUG_OPT"} -- -k + group "Check headers linked twice" cmake --build . -j"$(nproc --all)" --target check_headers_linked_twice ${CMAKE_DEBUG_OPT:+"$CMAKE_DEBUG_OPT"} -- -k fi -cmake --build . -j"$(nproc --all)" --target packages_dependencies -v -- -k +group "Collect package dependencies" cmake --build . -j"$(nproc --all)" --target packages_dependencies ${CMAKE_DEBUG_OPT:+"$CMAKE_DEBUG_OPT"} -- -k echo " Checks finished" for pkg_path in "$CGAL_ROOT"/* do pkg=$(basename "$pkg_path") if [ -f "$pkg_path/package_info/$pkg/dependencies" ]; then - PKG_DIFF=$(grep -Fxv -f "$pkg_path/package_info/$pkg/dependencies.old" "$pkg_path/package_info/$pkg/dependencies" || true) - if [ -n "$PKG_DIFF" ]; then - TOTAL_RES="Differences in $pkg:\n$PKG_DIFF\nare new and not committed.\n$TOTAL_RES" - fi - PKG_DIFF=$(grep -Fxv -f "$pkg_path/package_info/$pkg/dependencies" "$pkg_path/package_info/$pkg/dependencies.old" || true) - if [ -n "$PKG_DIFF" ]; then - TOTAL_RES="Differences in $pkg:\n$PKG_DIFF\nhave disappeared.\n$TOTAL_RES" + DIFF_STATUS=0 + PKG_DIFF=$(diff -u "$pkg_path/package_info/$pkg/dependencies.old" "$pkg_path/package_info/$pkg/dependencies") || DIFF_STATUS=$? + if [ "$DIFF_STATUS" -eq 1 ]; then + TOTAL_RES="Differences in $pkg:\n$PKG_DIFF\n$TOTAL_RES" + elif [ "$DIFF_STATUS" -ne 0 ]; then + echo "Failed to compare dependencies for $pkg" >&2 + exit "$DIFF_STATUS" fi if [ -f "$pkg_path/package_info/$pkg/dependencies.old" ]; then rm "$pkg_path/package_info/$pkg/dependencies.old" From 7266c3e99b5d10c4d9de6f3aab0e74bacc6b7dde Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 16:20:04 +0200 Subject: [PATCH 105/127] output errors to the job summary --- .../cgal_check_dependencies.sh | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Scripts/developer_scripts/cgal_check_dependencies.sh b/Scripts/developer_scripts/cgal_check_dependencies.sh index a888d662d852..464fe2cab120 100644 --- a/Scripts/developer_scripts/cgal_check_dependencies.sh +++ b/Scripts/developer_scripts/cgal_check_dependencies.sh @@ -43,13 +43,37 @@ group() { local title=$1 shift + local status=0 + local log_file if [ "$GITHUB_ACTIONS" = "true" ]; then echo "::group::$title" else printf '\n## %s\n\n' "$title" fi - local status=0 - "$@" || status=$? + if [ "$GITHUB_ACTIONS" = "true" ] && [ -n "$GITHUB_STEP_SUMMARY" ]; then + log_file=$(mktemp) || return $? + if (set -o pipefail; "$@" 2>&1 | tee "$log_file"); then + status=0 + else + status=$? + fi + if [ "$status" -ne 0 ]; then + local diagnostics + diagnostics=$(grep -E '(^|[[:space:]])(fatal )?error:|undefined reference|collect2: error:|ld: error:' "$log_file" | tail -n 100 || true) + { + printf '## %s failed\n\n' "$title" + if [ -n "$diagnostics" ]; then + # shellcheck disable=SC2016 + printf '```text\n%s\n```\n\n' "$diagnostics" + else + printf 'No compiler or linker diagnostics were found in the command output. See the job log for details.\n\n' + fi + } >> "$GITHUB_STEP_SUMMARY" + fi + rm -f "$log_file" + else + "$@" || status=$? + fi if [ "$GITHUB_ACTIONS" = "true" ]; then echo "::endgroup::" fi From d0dfd2b5189bf2990677f64e6f0cfd36cdcf9bc1 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 17:46:18 +0200 Subject: [PATCH 106/127] fix headers --- Installation/CMakeLists.txt | 2 ++ SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index bca86d5e1dcf..dd0795da1402 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -830,6 +830,7 @@ if(CGAL_BRANCH_BUILD) find_package(GMP REQUIRED) find_package(Doxygen REQUIRED) find_package(Eigen3 REQUIRED) + get_target_property(CGAL_EIGEN_3_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES) find_package(Qt6 COMPONENTS Core Widgets OpenGL Gui REQUIRED) set(CMAKE_POLICY_DEFAULT_CMP0167 NEW) find_package(VTK COMPONENTS ImagingGeneral IOImage NO_MODULE) @@ -918,6 +919,7 @@ You must disable CGAL_ENABLE_CHECK_HEADERS.") endforeach() foreach( incdir + ${CGAL_EIGEN_3_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS} ${LEDA_INCLUDE_DIR} ${OPENMESH_INCLUDE_DIR} diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index 4ab72ba61c67..65158ab8506b 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -24,9 +24,10 @@ #include #include #include +#include +#include #include #include -#include #include #include From c5853cfe3761eefad7bf268a5fb7b3a047c314fa Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 20:46:29 +0200 Subject: [PATCH 107/127] add backward compatibiloty `Mesh_criteria_3` will compile (compute `C3t3` from `Tr`). --- Mesh_3/include/CGAL/Mesh_criteria_3.h | 34 ++++++++++++++++++++------- Mesh_3/test/Mesh_3/test_criteria.cpp | 3 ++- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index 64482c1ce36e..7511ef93c338 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -26,12 +26,29 @@ #include #include #include +#include #include +#include + #include // for the macro DBL_MAX +#include // for std::void_t and std::is_base_of namespace CGAL { namespace internal { +template +struct Get_c3t3 { + using type = CGAL::Mesh_complex_3_in_triangulation_3; +}; + +template +struct Get_c3t3().number_of_cells_in_complex())>> { + using type = C3t3; +}; + +template +using get_c3t3_t = typename Get_c3t3::type; + // Class Mesh_criteria_3_impl template < typename C3T3, typename EdgeCriteria, @@ -172,18 +189,19 @@ Mesh_criteria_3 criteria (parameters::cell_radius_edge_ratio(2). */ template , - typename FacetCriteria = Mesh_facet_criteria_3, - typename CellCriteria = Mesh_cell_criteria_3 > + typename EdgeCriteria = Mesh_edge_criteria_3>, + typename FacetCriteria = Mesh_facet_criteria_3>, + typename CellCriteria = Mesh_cell_criteria_3> > class Mesh_criteria_3 #ifndef DOXYGEN_RUNNING - : public internal::Mesh_criteria_3_impl< C3T3, + : public internal::Mesh_criteria_3_impl< internal::get_c3t3_t, EdgeCriteria, FacetCriteria, CellCriteria > #endif { - typedef internal::Mesh_criteria_3_impl< C3T3, + typedef internal::get_c3t3_t C3t3; + typedef internal::Mesh_criteria_3_impl< C3t3, EdgeCriteria, FacetCriteria, CellCriteria> Base; @@ -196,18 +214,18 @@ class Mesh_criteria_3 /*! The criteria for edges. */ -typedef Mesh_edge_criteria_3 Edge_criteria; +typedef Mesh_edge_criteria_3 Edge_criteria; /*! The criteria for facets. */ -typedef Mesh_facet_criteria_3 Facet_criteria; +typedef Mesh_facet_criteria_3 Facet_criteria; /*! The criteria for cells. */ -typedef Mesh_cell_criteria_3 Cell_criteria; +typedef Mesh_cell_criteria_3 Cell_criteria; /// @} #else diff --git a/Mesh_3/test/Mesh_3/test_criteria.cpp b/Mesh_3/test/Mesh_3/test_criteria.cpp index e29a0f808593..ae8ee8d4466c 100644 --- a/Mesh_3/test/Mesh_3/test_criteria.cpp +++ b/Mesh_3/test/Mesh_3/test_criteria.cpp @@ -38,7 +38,8 @@ struct Tester typedef typename CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; // the template parameter is `Tr` on purpose, + // to test the backward compatibility typedef typename Mesh_criteria::Facet_criteria Facet_criteria; typedef typename Mesh_criteria::Cell_criteria Cell_criteria; From 8bce8eb6075140082f28ffc48c31d3ae3b485ef2 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 20:46:40 +0200 Subject: [PATCH 108/127] fix CI --- Alpha_wrap_2/package_info/Alpha_wrap_2/dependencies | 2 +- Lab/package_info/Lab/dependencies | 2 -- Mesh_smoothing_3/package_info/Mesh_smoothing_3/dependencies | 4 ++-- Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies | 2 +- Snap_rounding_2/package_info/Snap_rounding_2/dependencies | 2 +- .../package_info/Surface_mesh_decomposition/dependencies | 4 ++-- 6 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 Lab/package_info/Lab/dependencies diff --git a/Alpha_wrap_2/package_info/Alpha_wrap_2/dependencies b/Alpha_wrap_2/package_info/Alpha_wrap_2/dependencies index 6a33fc3506b3..3ebcacd05ed5 100644 --- a/Alpha_wrap_2/package_info/Alpha_wrap_2/dependencies +++ b/Alpha_wrap_2/package_info/Alpha_wrap_2/dependencies @@ -28,4 +28,4 @@ Spatial_searching Spatial_sorting Stream_support TDS_2 -Triangulation_2 \ No newline at end of file +Triangulation_2 diff --git a/Lab/package_info/Lab/dependencies b/Lab/package_info/Lab/dependencies deleted file mode 100644 index 76331fefe0d7..000000000000 --- a/Lab/package_info/Lab/dependencies +++ /dev/null @@ -1,2 +0,0 @@ -Installation -STL_Extension diff --git a/Mesh_smoothing_3/package_info/Mesh_smoothing_3/dependencies b/Mesh_smoothing_3/package_info/Mesh_smoothing_3/dependencies index 85bd567ad93d..bc06ccebf45b 100644 --- a/Mesh_smoothing_3/package_info/Mesh_smoothing_3/dependencies +++ b/Mesh_smoothing_3/package_info/Mesh_smoothing_3/dependencies @@ -3,8 +3,8 @@ Algebraic_foundations Arithmetic_kernel CGAL_Core Cartesian_kernel -Combinatorial_map Circulator +Combinatorial_map Distance_2 Distance_3 Filtered_kernel @@ -23,5 +23,5 @@ Profiling_tools Property_map STL_Extension Spatial_searching -Stream_support Spatial_sorting +Stream_support diff --git a/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies b/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies index 73b1a8c7075e..d2d1605a08ce 100644 --- a/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies +++ b/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies @@ -2,8 +2,8 @@ AABB_tree Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 -Boolean_set_operations_2 BGL +Boolean_set_operations_2 CGAL_Core Cartesian_kernel Circulator diff --git a/Snap_rounding_2/package_info/Snap_rounding_2/dependencies b/Snap_rounding_2/package_info/Snap_rounding_2/dependencies index 0f6aa8bd2d87..f3096ddd610c 100644 --- a/Snap_rounding_2/package_info/Snap_rounding_2/dependencies +++ b/Snap_rounding_2/package_info/Snap_rounding_2/dependencies @@ -17,6 +17,7 @@ Kernel_23 Kernel_d Modular_arithmetic Number_types +Polygon Polynomial Profiling_tools Property_map @@ -25,4 +26,3 @@ Snap_rounding_2 Spatial_searching Stream_support Surface_sweep_2 -Polygon \ No newline at end of file diff --git a/Surface_mesh_decomposition/package_info/Surface_mesh_decomposition/dependencies b/Surface_mesh_decomposition/package_info/Surface_mesh_decomposition/dependencies index 652e2ada534b..57054e6676b8 100644 --- a/Surface_mesh_decomposition/package_info/Surface_mesh_decomposition/dependencies +++ b/Surface_mesh_decomposition/package_info/Surface_mesh_decomposition/dependencies @@ -23,8 +23,8 @@ Number_types Polygon_mesh_processing Profiling_tools Property_map -Spatial_searching +Random_numbers STL_Extension +Spatial_searching Stream_support TDS_2 -Random_numbers From 2a366eaa0cf8486cb8321753654bddfed1b34b7e Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 1 Oct 2026 21:55:46 +0200 Subject: [PATCH 109/127] display "Compare dependencies" to job summary --- .../cgal_check_dependencies.sh | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/Scripts/developer_scripts/cgal_check_dependencies.sh b/Scripts/developer_scripts/cgal_check_dependencies.sh index 464fe2cab120..430fed7e93aa 100644 --- a/Scripts/developer_scripts/cgal_check_dependencies.sh +++ b/Scripts/developer_scripts/cgal_check_dependencies.sh @@ -39,17 +39,33 @@ do fi done -group() +start_group() { local title=$1 - shift - local status=0 - local log_file if [ "$GITHUB_ACTIONS" = "true" ]; then echo "::group::$title" else printf '\n## %s\n\n' "$title" fi +} + +end_group() +{ + if [ "$GITHUB_ACTIONS" = "true" ]; then + echo "::endgroup::" + fi +} + +# Runs a command inside a collapsible group. If the command fails while +# running in GitHub Actions, compiler/linker diagnostics from its output +# are also appended to $GITHUB_STEP_SUMMARY. +group() +{ + local title=$1 + shift + local status=0 + local log_file + start_group "$title" if [ "$GITHUB_ACTIONS" = "true" ] && [ -n "$GITHUB_STEP_SUMMARY" ]; then log_file=$(mktemp) || return $? if (set -o pipefail; "$@" 2>&1 | tee "$log_file"); then @@ -74,9 +90,7 @@ group() else "$@" || status=$? fi - if [ "$GITHUB_ACTIONS" = "true" ]; then - echo "::endgroup::" - fi + end_group return "$status" } @@ -87,6 +101,7 @@ if [ -n "$DO_CHECK_HEADERS" ]; then fi group "Collect package dependencies" cmake --build . -j"$(nproc --all)" --target packages_dependencies ${CMAKE_DEBUG_OPT:+"$CMAKE_DEBUG_OPT"} -- -k echo " Checks finished" +start_group "Compare dependencies" for pkg_path in "$CGAL_ROOT"/* do pkg=$(basename "$pkg_path") @@ -97,6 +112,7 @@ do TOTAL_RES="Differences in $pkg:\n$PKG_DIFF\n$TOTAL_RES" elif [ "$DIFF_STATUS" -ne 0 ]; then echo "Failed to compare dependencies for $pkg" >&2 + end_group exit "$DIFF_STATUS" fi if [ -f "$pkg_path/package_info/$pkg/dependencies.old" ]; then @@ -113,8 +129,24 @@ if [ -n "$TOTAL_RES" ]; then echo " You can run cmake with options \`CGAL_ENABLE_CHECK_HEADERS\` and \`CGAL_COPY_DEPENDENCIES\` set to \`ON\`" echo " then build the target \`packages_dependencies\` and commit the new dependencies files," echo " or simply manually edit the problematic files." + if [ -n "$GITHUB_STEP_SUMMARY" ]; then + { + printf 'Dependency check failed\n\n```diff\n' + # shellcheck disable=SC2059 + printf "$TOTAL_RES" + printf '```\n\n' + echo "You can run cmake with options \`CGAL_ENABLE_CHECK_HEADERS\` and \`CGAL_COPY_DEPENDENCIES\` set to \`ON\`," + echo "then build the target \`packages_dependencies\` and commit the new dependencies files," + echo "or simply manually edit the problematic files." + } >> "$GITHUB_STEP_SUMMARY" + fi + end_group exit 1 else echo "The dependencies are up to date." + if [ -n "$GITHUB_STEP_SUMMARY" ]; then + echo "✅ The dependencies are up to date." >> "$GITHUB_STEP_SUMMARY" + fi + end_group exit 0 fi From dfa804e8756deb3e35d94214ecdcf2a6ee36b019 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 2 Oct 2026 08:56:29 +0200 Subject: [PATCH 110/127] fix errors from testsuite --- .../CGAL/Conforming_constrained_Delaunay_triangulation_3.h | 2 +- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 4 ++-- SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h index af107e807ae0..68452fbe32e3 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h @@ -1863,7 +1863,7 @@ class Conforming_constrained_Delaunay_triangulation_3_impl : public Conforming_D auto number_of_constrained_facets() const { return std::count_if(tr().all_facets_begin(), tr().all_facets_end(), - [this](auto f) { return is_facet_constrained(f); }); + [&](auto f) { return is_facet_constrained(f); }); } bool same_triangle(Facet f, CDT_2_face_handle fh) const { diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index b809ee1ba1a1..76cc29c1c9e5 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -56,7 +56,7 @@ #include #include -#include +#include #include #include #include @@ -2482,7 +2482,7 @@ operator<< (std::ostream& os, const Mesh_complex_3_in_triangulation_3 &c3t3) { // TODO: implement edge saving - if constexpr(c3t3.store_surface_patch_info_in_cell) { + if constexpr(Mesh_complex_3_in_triangulation_3::store_surface_patch_info_in_cell) { return os << c3t3.triangulation(); } else { auto& tr = c3t3.triangulation(); diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index 65158ab8506b..4e36a11634f6 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -153,10 +153,8 @@ bool build_finite_cells(C3T3& c3t3, Tr& tr = c3t3.triangulation(); - CGAL_assertion_code( - typename Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); - typename Tr::Geom_traits::Orientation_3 orientation = tr.geom_traits().orientation_3_object(); - ) + typename Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); + typename Tr::Geom_traits::Orientation_3 orientation = tr.geom_traits().orientation_3_object(); typename SubdomainsRange::value_type max_domain = 0; if(replace_domain_0) From 730f8c4b20df28ff677e6024ae8064810a3265d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 5 Oct 2026 15:08:16 +0200 Subject: [PATCH 111/127] fix unused type warning --- .../include/CGAL/draw_constrained_triangulation_3.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h index 2fafec692ca0..4ca6d09908c9 100644 --- a/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/draw_constrained_triangulation_3.h @@ -35,7 +35,6 @@ void draw(const Conforming_constrained_Delaunay_triangulation_3& ccd { using Tr_ = CGAL::cpp20::remove_cvref_t; using Vertex_handle = typename Tr_::Vertex_handle; - using Cell_handle = typename Tr_::Cell_handle; using Edge_descriptor = typename Tr_::Finite_edges_iterator; using Facet_descriptor = typename Tr_::Finite_facets_iterator; From 693122d85c5f5a32018f25731709cdb64dc12464 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 6 Oct 2026 09:39:30 +0200 Subject: [PATCH 112/127] remove erroneous include --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 1 - 1 file changed, 1 deletion(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 76cc29c1c9e5..f4647e8ca205 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -56,7 +56,6 @@ #include #include -#include #include #include #include From 29d96243388ee4f90565ce07248442e5985c1ac4 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 6 Oct 2026 09:42:57 +0200 Subject: [PATCH 113/127] workaround for MSVC --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index f4647e8ca205..339a62dd9cb4 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -2481,7 +2481,8 @@ operator<< (std::ostream& os, const Mesh_complex_3_in_triangulation_3 &c3t3) { // TODO: implement edge saving - if constexpr(Mesh_complex_3_in_triangulation_3::store_surface_patch_info_in_cell) { + using C3t3 = Mesh_complex_3_in_triangulation_3; + if constexpr(C3t3::store_surface_patch_info_in_cell) { return os << c3t3.triangulation(); } else { auto& tr = c3t3.triangulation(); @@ -2571,14 +2572,14 @@ operator>> (std::istream& is, Mesh_complex_3_in_triangulation_3 &c3t3) { // TODO: implement edge loading + using C3t3 = Mesh_complex_3_in_triangulation_3; c3t3.clear(); - if constexpr(c3t3.store_surface_patch_info_in_cell) { + if constexpr(C3t3::store_surface_patch_info_in_cell) { is >> c3t3.triangulation(); } else { auto& tr = c3t3.triangulation(); using Vertex_handle = typename Tr::Vertex_handle; using Cell_handle = typename Tr::Cell_handle; - using C3t3 = Mesh_complex_3_in_triangulation_3; tr.tds().clear(); // infinite vertex deleted From eb80c60080ec6d888ac001d95bcead359317445f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 5 Oct 2026 16:12:12 +0200 Subject: [PATCH 114/127] fix tet remeshing when patch info is not in cells I have added a test as well. --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 2 + .../Remeshing_triangulation_3.h | 2 - .../include/CGAL/tetrahedral_remeshing.h | 45 +++++++++++++++++-- .../test/Tetrahedral_remeshing/CMakeLists.txt | 2 + .../features_and_adaptive_sizing.cpp | 5 +++ ...daptive_sizing_patch_info_not_in_cells.cpp | 2 + 6 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 339a62dd9cb4..e49041ab2964 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -280,6 +280,8 @@ class Mesh_complex_3_in_triangulation_3 typedef std::vector Far_vertices_vec; public: + using Store_surface_patch_info_in_cell = Boolean_tag; + enum Face_status { NOT_IN_COMPLEX = 0, ISOLATED = 1, // - An ISOLATED edge is a marked edge, diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h index f009ad0471cd..bd0cb05e71c3 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h @@ -23,8 +23,6 @@ #include -#include - namespace CGAL { namespace Tetrahedral_remeshing diff --git a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h index da8766f081e2..f100e1f8ca68 100644 --- a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h +++ b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h @@ -15,10 +15,12 @@ #include +#include #include #include #include +#include #include #include @@ -346,8 +348,12 @@ template +#ifdef DOXYGEN_RUNNING CGAL::Triangulation_3 +#else +auto +#endif convert_to_triangulation_3( CGAL::Mesh_complex_3_in_triangulation_3 c3t3, const NamedParameters& np = parameters::default_values()) @@ -355,6 +361,7 @@ convert_to_triangulation_3( using parameters::get_parameter; using parameters::choose_parameter; + using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; using GT = typename Tr::Geom_traits; using TDS = typename Tr::Triangulation_data_structure; using Dummy_sizing = CGAL::Uniform_sizing_field; @@ -385,10 +392,40 @@ convert_to_triangulation_3( put(vcmap, v, true); } } - - CGAL::Triangulation_3 tr; - tr.swap(c3t3.triangulation()); - return tr; + if constexpr (false == C3t3::Store_surface_patch_info_in_cell::value) + { + using Target_triangulation = CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3; + Target_triangulation tr; + const auto& source_tr = c3t3.triangulation(); + auto infinite_vertex = tr.tds().copy_tds( + source_tr.tds(), source_tr.infinite_vertex(), + [&](const auto& source_vertex) { + typename Target_triangulation::Vertex vertex; + vertex.set_point(source_vertex.point()); + return vertex; + }, + [&](const auto& source_cell) { + typename Target_triangulation::Cell cell; + cell.set_surface_patch_index(source_cell.surface_patch_index()); + return cell; + }); + tr.set_infinite_vertex(infinite_vertex); + auto [src_cell_it, src_cell_end] = source_tr.finite_cell_handles(); + auto [tgt_cell_it, tgt_cell_end] = tr.finite_cell_handles(); + for (; src_cell_it != src_cell_end; ++src_cell_it, ++tgt_cell_it) + { + auto subdomain_index = c3t3.subdomain_index(*src_cell_it); + (*tgt_cell_it)->set_subdomain_index(subdomain_index); + for(int i = 0; i < 4; ++i) { + (*tgt_cell_it)->set_surface_patch_index(i, c3t3.surface_patch_index(*src_cell_it, i)); + } + } + return tr; + } else { + CGAL::Triangulation_3 tr; + tr.swap(c3t3.triangulation()); + return tr; + } } /////////////////////////////////////////////////// diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt index fa4dc3d7bbe6..fdce0ce1eaa5 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt @@ -40,6 +40,8 @@ if(TARGET CGAL::Eigen3_support) create_single_source_cgal_program("features_and_adaptive_sizing.cpp") target_link_libraries(features_and_adaptive_sizing PRIVATE CGAL::Eigen3_support) + create_single_source_cgal_program("features_and_adaptive_sizing_patch_info_not_in_cells.cpp") + target_link_libraries(features_and_adaptive_sizing_patch_info_not_in_cells PRIVATE CGAL::Eigen3_support) create_single_source_cgal_program("test_mesh_and_remesh_with_io.cpp") target_link_libraries(test_mesh_and_remesh_with_io PRIVATE CGAL::Eigen3_support) diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp index ab36bc321419..36b66fa75099 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp @@ -90,8 +90,13 @@ int main(int argc, char* argv[]) Constraints_set constraints; Constraints_pmap constraints_pmap(constraints); + const auto src_tr = c3t3.triangulation(); + const auto src_number_of_vertices = src_tr.number_of_vertices(); + const auto src_number_of_cells = src_tr.number_of_cells(); Triangulation_3 tr = CGAL::convert_to_triangulation_3(std::move(c3t3), p::edge_is_constrained_map(constraints_pmap)); + assert(tr.number_of_vertices() == src_number_of_vertices); + assert(tr.number_of_cells() == src_number_of_cells); //note we use the move semantic, with std::move(c3t3), // to avoid a copy of the triangulation by the function diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp new file mode 100644 index 000000000000..5f8dbfc3f0e9 --- /dev/null +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp @@ -0,0 +1,2 @@ +#define CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 +#include "features_and_adaptive_sizing.cpp" From bfa06f6c5a9168c819473f1cc5feb506baa40c5d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 6 Oct 2026 18:06:18 +0200 Subject: [PATCH 115/127] improve the internal named parameters API --- .../include/CGAL/Named_function_parameters.h | 73 ++++++++++++------- .../STL_Extension/test_cgal_named_params.cpp | 4 + 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/STL_Extension/include/CGAL/Named_function_parameters.h b/STL_Extension/include/CGAL/Named_function_parameters.h index 6d29bfc39405..d30713c02a9b 100644 --- a/STL_Extension/include/CGAL/Named_function_parameters.h +++ b/STL_Extension/include/CGAL/Named_function_parameters.h @@ -71,6 +71,10 @@ struct Named_params_impl : Base : Base(b) , v(v) {} + + constexpr decltype(auto) parameter(Tag) const noexcept { return v; } + constexpr bool has_parameter(Tag) const noexcept { return true; } + using Base::parameter; }; // partial specialization for base class of the recursive nesting @@ -79,9 +83,11 @@ struct Named_params_impl { typename std::conditional::value, T, std::reference_wrapper >::type v; // copy of the parameter if copyable - Named_params_impl(const T& v) + constexpr Named_params_impl(const T& v) : v(v) {} + constexpr decltype(auto) parameter(Tag) const noexcept { return v; } + constexpr bool has_parameter(Tag) const noexcept { return true; } }; // Helper class to get the type of a named parameter pack given a query tag @@ -255,15 +261,14 @@ namespace parameters{ typedef Named_function_parameters Default_named_parameters; -Default_named_parameters -inline default_values(); +inline constexpr Default_named_parameters default_values(); // function to extract a parameter template typename internal_np::Get_param, Query_tag>::type get_parameter(const Named_function_parameters& np, Query_tag tag) { - return internal_np::get_parameter_impl(static_cast&>(np), tag); + return np.parameter(tag); } template @@ -366,15 +371,29 @@ struct Named_function_parameters typedef internal_np::Named_params_impl base; typedef Named_function_parameters self; - Named_function_parameters() : base(T()) {} - Named_function_parameters(const T& v) : base(v) {} - Named_function_parameters(const T& v, const Base& b) : base(v, b) {} + using base::parameter; + using base::has_parameter; + constexpr auto parameter(...) const { return internal_np::Param_not_found(); } + constexpr bool has_parameter(...) const { return false; } + + template + constexpr decltype(auto) parameter_or([[maybe_unused]] U&& default_value) const { + if constexpr (has_parameter(Tag2())) { + return parameter(Tag2()); + } else { + return std::forward(default_value); + } + } + + constexpr Named_function_parameters() : base(T()) {} + constexpr Named_function_parameters(const T& v) : base(v) {} + constexpr Named_function_parameters(const T& v, const Base& b) : base(v, b) {} // create the functions for new named parameters and the one imported boost // used to concatenate several parameters #define CGAL_add_named_parameter(X, Y, Z) \ template \ - Named_function_parameters \ + constexpr Named_function_parameters \ Z(const K& k) const \ { \ typedef Named_function_parameters Params;\ @@ -382,7 +401,7 @@ struct Named_function_parameters } #define CGAL_add_named_parameter_with_compatibility(X, Y, Z) \ template \ - Named_function_parameters \ + constexpr Named_function_parameters \ Z(const K& k) const \ { \ typedef Named_function_parameters Params;\ @@ -390,7 +409,7 @@ struct Named_function_parameters } #define CGAL_add_named_parameter_with_compatibility_cref_only(X, Y, Z) \ template \ - Named_function_parameters, \ + constexpr Named_function_parameters, \ internal_np::X, self> \ Z(const K& k) const \ { \ @@ -400,7 +419,7 @@ struct Named_function_parameters } #define CGAL_add_named_parameter_with_compatibility_ref_only(X, Y, Z) \ template \ - Named_function_parameters, \ + constexpr Named_function_parameters, \ internal_np::X, self> \ Z(K& k) const \ { \ @@ -410,7 +429,7 @@ struct Named_function_parameters } #define CGAL_add_extra_named_parameter_with_compatibility(X, Y, Z) \ template \ - Named_function_parameters \ + constexpr Named_function_parameters \ Z(const K& k) const \ { \ typedef Named_function_parameters Params;\ @@ -433,14 +452,14 @@ struct Named_function_parameters #undef CGAL_NP_BUILD template - Named_function_parameters + constexpr Named_function_parameters combine(const Named_function_parameters& np) const { return Named_function_parameters(np.v,*this); } template - auto + constexpr auto combine(const Named_function_parameters& np, const NPS& ... nps) const { return Named_function_parameters(np.v,*this).combine(nps...); @@ -452,8 +471,8 @@ struct Named_function_parameters namespace parameters { -Default_named_parameters -inline default_values() +inline constexpr Default_named_parameters +default_values() { return Default_named_parameters(); } @@ -470,7 +489,7 @@ template struct Boost_parameter_compatibility_wrapper { template - Named_function_parameters + constexpr Named_function_parameters operator()(const K& p) const { typedef Named_function_parameters Params; @@ -478,7 +497,7 @@ struct Boost_parameter_compatibility_wrapper } template - Named_function_parameters + constexpr Named_function_parameters operator=(const K& p) const { typedef Named_function_parameters Params; @@ -490,7 +509,7 @@ template struct Boost_parameter_compatibility_wrapper { template - Named_function_parameters, Tag> + constexpr Named_function_parameters, Tag> operator()(const K& p) const { typedef Named_function_parameters, Tag> Params; @@ -498,7 +517,7 @@ struct Boost_parameter_compatibility_wrapper } template - Named_function_parameters, Tag> + constexpr Named_function_parameters, Tag> operator=(const K& p) const { typedef Named_function_parameters, Tag> Params; @@ -510,7 +529,7 @@ template struct Boost_parameter_compatibility_wrapper { template - Named_function_parameters, Tag> + constexpr Named_function_parameters, Tag> operator()(K& p) const { typedef Named_function_parameters, Tag> Params; @@ -518,7 +537,7 @@ struct Boost_parameter_compatibility_wrapper } template - Named_function_parameters, Tag> + constexpr Named_function_parameters, Tag> operator=(std::reference_wrapper p) const { typedef Named_function_parameters, Tag> Params; @@ -530,20 +549,20 @@ struct Boost_parameter_compatibility_wrapper #define CGAL_add_named_parameter(X, Y, Z) \ template \ Named_function_parameters \ - Z(const K& p) \ + constexpr Z(const K& p) \ { \ typedef Named_function_parameters Params;\ return Params(p); \ } #define CGAL_add_named_parameter_with_compatibility(X, Y, Z) \ - inline const Boost_parameter_compatibility_wrapper Z; + inline constexpr Boost_parameter_compatibility_wrapper Z; #define CGAL_add_named_parameter_with_compatibility_cref_only(X, Y, Z) \ - inline const Boost_parameter_compatibility_wrapper Z; + inline constexpr Boost_parameter_compatibility_wrapper Z; #define CGAL_add_named_parameter_with_compatibility_ref_only(X, Y, Z) \ - inline const Boost_parameter_compatibility_wrapper Z; + inline constexpr Boost_parameter_compatibility_wrapper Z; #define CGAL_add_extra_named_parameter_with_compatibility(X, Y, Z) \ - inline const Boost_parameter_compatibility_wrapper Z; + inline constexpr Boost_parameter_compatibility_wrapper Z; #include #undef CGAL_add_named_parameter #undef CGAL_add_extra_named_parameter_with_compatibility diff --git a/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp b/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp index 4e6b703cb9b5..855a3f09c26c 100644 --- a/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp +++ b/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp @@ -35,11 +35,15 @@ void test_values_and_types(const NamedParameters& np) // test values assert(get_parameter(np, inp::vertex_index).v == 0); + assert(np.parameter(inp::vertex_index).v == 0); assert(get_parameter(np, inp::visitor).v == 1); + assert(np.parameter(inp::visitor).v == 1); // test types check_same_type<0>(get_parameter(np, inp::vertex_index)); + check_same_type<0>(np.parameter(inp::vertex_index)); check_same_type<1>(get_parameter(np, inp::visitor)); + check_same_type<1>(np.parameter(inp::visitor)); } template From 9935e29d322547f2dd6eb70bc48f9943bc971dc4 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 6 Oct 2026 18:12:56 +0200 Subject: [PATCH 116/127] WIP for tet remeshing with a C3t3 that stores facet info in hash map For the moment, Tetrahedral Remeshing does not compile. Disable the test. --- ...meshing_experimental_compact_cell_base.cpp | 2 +- .../include/CGAL/tetrahedral_remeshing.h | 22 ++--- .../test/Tetrahedral_remeshing/CMakeLists.txt | 1 + .../features_and_adaptive_sizing.cpp | 98 ++++++++++++------- ...daptive_sizing_patch_info_not_in_cells.cpp | 6 +- 5 files changed, 74 insertions(+), 55 deletions(-) diff --git a/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp b/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp index 2bb7060b93b8..34d38122809e 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_experimental_compact_cell_base.cpp @@ -1,3 +1,3 @@ -#define CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 +#define CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 1 #define CGAL_MESH_3_NO_CIRCUMCENTER_CACHE #include "test_meshing_polyhedron_with_features.cpp" diff --git a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h index f100e1f8ca68..0915437d60a3 100644 --- a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h +++ b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h @@ -363,18 +363,10 @@ convert_to_triangulation_3( using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; using GT = typename Tr::Geom_traits; - using TDS = typename Tr::Triangulation_data_structure; - using Dummy_sizing = CGAL::Uniform_sizing_field; - using Remesher_types - = typename Tetrahedral_remeshing::internal::Adaptive_remesher_type_generator - ; - - using Default_edge_pmap = typename Remesher_types::Default_ECMap; - using ECMap = typename Remesher_types::ECMap; - if (!std::is_same_v) + if constexpr (np.has_parameter(internal_np::edge_is_constrained)) { - ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained)); + auto ecmap = np.parameter(internal_np::edge_is_constrained); for (auto e : c3t3.edges_in_complex()) { const auto evv = CGAL::Tetrahedral_remeshing::make_vertex_pair(e);//ordered pair @@ -382,16 +374,15 @@ convert_to_triangulation_3( } } - using Default_vertex_pmap = typename Remesher_types::Default_VCMap; - using VCMap = typename Remesher_types::VCMap; - if (!std::is_same_v) + if constexpr (np.has_parameter(internal_np::vertex_is_constrained)) { - VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained)); + auto vcmap = np.parameter(internal_np::vertex_is_constrained); for (auto v : c3t3.vertices_in_complex()) { put(vcmap, v, true); } } + if constexpr (false == C3t3::Store_surface_patch_info_in_cell::value) { using Target_triangulation = CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3; @@ -421,7 +412,8 @@ convert_to_triangulation_3( } } return tr; - } else { + } else { // C3t3::Store_surface_patch_info_in_cell::value == true + using TDS = typename Tr::Triangulation_data_structure; CGAL::Triangulation_3 tr; tr.swap(c3t3.triangulation()); return tr; diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt index fdce0ce1eaa5..a773722e1b87 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt @@ -40,6 +40,7 @@ if(TARGET CGAL::Eigen3_support) create_single_source_cgal_program("features_and_adaptive_sizing.cpp") target_link_libraries(features_and_adaptive_sizing PRIVATE CGAL::Eigen3_support) + create_single_source_cgal_program("features_and_adaptive_sizing_patch_info_not_in_cells.cpp") target_link_libraries(features_and_adaptive_sizing_patch_info_not_in_cells PRIVATE CGAL::Eigen3_support) diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp index 36b66fa75099..0418c7dc3354 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp @@ -15,6 +15,7 @@ #include #include +#include #include // Domain @@ -33,25 +34,32 @@ typedef CGAL::Mesh_triangulation_3: typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index> C3t3; -// Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +template +int go(const std::string& fname) +{ + // Criteria + typedef CGAL::Mesh_criteria_3 Mesh_criteria; -// Triangulation for Remeshing -typedef CGAL::Triangulation_3 Triangulation_3; -using Vertex_handle = Triangulation_3::Vertex_handle; + // Triangulation for Remeshing + typedef CGAL::Triangulation_3 Triangulation_3; + using Vertex_handle = Triangulation_3::Vertex_handle; -using Vertex_pair = std::pair; -using Constraints_set = std::unordered_set>; -using Constraints_pmap = CGAL::Boolean_property_map; + #ifdef CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 + static_assert(!C3t3::Store_surface_patch_info_in_cell::value); + #else + static_assert(C3t3::Store_surface_patch_info_in_cell::value); + #endif + static_assert(std::is_base_of_v); + using Vertex_pair = std::pair; + using Constraints_set = std::unordered_set>; + using Constraints_pmap = CGAL::Boolean_property_map; -// To avoid verbose function and named parameters call -namespace p = CGAL::parameters; -int main(int argc, char* argv[]) -{ - const std::string fname = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cube.off"); + // To avoid verbose function and named parameters call + namespace p = CGAL::parameters; + std::ifstream input(fname); Polyhedron polyhedron; input >> polyhedron; @@ -86,31 +94,40 @@ int main(int argc, char* argv[]) //Remeshing : extract triangulation timer.reset(); timer.start(); - Constraints_set constraints; Constraints_pmap constraints_pmap(constraints); - - const auto src_tr = c3t3.triangulation(); - const auto src_number_of_vertices = src_tr.number_of_vertices(); - const auto src_number_of_cells = src_tr.number_of_cells(); - Triangulation_3 tr = CGAL::convert_to_triangulation_3(std::move(c3t3), - p::edge_is_constrained_map(constraints_pmap)); - assert(tr.number_of_vertices() == src_number_of_vertices); - assert(tr.number_of_cells() == src_number_of_cells); - - //note we use the move semantic, with std::move(c3t3), - // to avoid a copy of the triangulation by the function - // `CGAL::convert_to_triangulation_3()` - // After the call to this function, c3t3 is an empty and valid C3t3. - //It is possible to use : CGAL::convert_to_triangulation_3(c3t3), - // Then the triangulation is copied and duplicated, and c3t3 remains as is. - - CGAL::tetrahedral_isotropic_remeshing(tr, - CGAL::create_adaptive_remeshing_sizing_field(tr, p::edge_is_constrained_map(constraints_pmap)), - p::number_of_iterations(3) - .edge_is_constrained_map(constraints_pmap) - .smooth_constrained_edges(true)); - + auto np = p::number_of_iterations(3).edge_is_constrained_map(constraints_pmap).smooth_constrained_edges(true); + if constexpr(C3t3::Store_surface_patch_info_in_cell::value) { + const auto src_tr = c3t3.triangulation(); + const auto src_number_of_vertices = src_tr.number_of_vertices(); + const auto src_number_of_cells = src_tr.number_of_cells(); + auto tr = CGAL::convert_to_triangulation_3(std::move(c3t3), + p::edge_is_constrained_map(constraints_pmap)); + assert(tr.number_of_vertices() == src_number_of_vertices); + assert(tr.number_of_cells() == src_number_of_cells); + + //note we use the move semantic, with std::move(c3t3), + // to avoid a copy of the triangulation by the function + // `CGAL::convert_to_triangulation_3()` + // After the call to this function, c3t3 is an empty and valid C3t3. + //It is possible to use : CGAL::convert_to_triangulation_3(c3t3), + // Then the triangulation is copied and duplicated, and c3t3 remains as is. + + CGAL::tetrahedral_isotropic_remeshing( + tr, CGAL::create_adaptive_remeshing_sizing_field(tr, p::edge_is_constrained_map(constraints_pmap)), np); + } else { // C3t3::Store_surface_patch_info_in_cell::value == false + for(const auto e : c3t3.triangulation().finite_edges()) { + if(c3t3.is_in_complex(e)) { + Vertex_pair evv = CGAL::Tetrahedral_remeshing::make_vertex_pair(e); + constraints.insert(evv); + } + } + + CGAL::tetrahedral_isotropic_remeshing(c3t3, + CGAL::create_adaptive_remeshing_sizing_field( + c3t3.triangulation(), p::edge_is_constrained_map(constraints_pmap)), + np); + } timer.stop(); std::cout << "Remeshing done (" << timer.time() << " seconds)" << std::endl; @@ -121,3 +138,10 @@ int main(int argc, char* argv[]) return EXIT_SUCCESS; } + +int main(int argc, char* argv[]) +{ + const std::string fname = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cube.off"); + return go(fname); +} + diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp index 5f8dbfc3f0e9..8543027cf8e3 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp @@ -1,2 +1,4 @@ -#define CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 -#include "features_and_adaptive_sizing.cpp" +// #define CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 1 +// #include "features_and_adaptive_sizing.cpp" + +int main() {} From 385e84b13293827fac85ae5ea59a892fc43ceaa1 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 7 Oct 2026 10:05:32 +0200 Subject: [PATCH 117/127] fix NP::has_parameter --- STL_Extension/include/CGAL/Named_function_parameters.h | 6 +++--- Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/STL_Extension/include/CGAL/Named_function_parameters.h b/STL_Extension/include/CGAL/Named_function_parameters.h index d30713c02a9b..111022d50f8b 100644 --- a/STL_Extension/include/CGAL/Named_function_parameters.h +++ b/STL_Extension/include/CGAL/Named_function_parameters.h @@ -73,7 +73,7 @@ struct Named_params_impl : Base {} constexpr decltype(auto) parameter(Tag) const noexcept { return v; } - constexpr bool has_parameter(Tag) const noexcept { return true; } + static constexpr bool has_parameter(Tag) noexcept { return true; } using Base::parameter; }; @@ -87,7 +87,7 @@ struct Named_params_impl : v(v) {} constexpr decltype(auto) parameter(Tag) const noexcept { return v; } - constexpr bool has_parameter(Tag) const noexcept { return true; } + static constexpr bool has_parameter(Tag) noexcept { return true; } }; // Helper class to get the type of a named parameter pack given a query tag @@ -374,7 +374,7 @@ struct Named_function_parameters using base::parameter; using base::has_parameter; constexpr auto parameter(...) const { return internal_np::Param_not_found(); } - constexpr bool has_parameter(...) const { return false; } + static constexpr bool has_parameter(...) { return false; } template constexpr decltype(auto) parameter_or([[maybe_unused]] U&& default_value) const { diff --git a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h index 0915437d60a3..938b6e26f3d4 100644 --- a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h +++ b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h @@ -364,7 +364,7 @@ convert_to_triangulation_3( using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; using GT = typename Tr::Geom_traits; - if constexpr (np.has_parameter(internal_np::edge_is_constrained)) + if constexpr (NamedParameters::has_parameter(internal_np::edge_is_constrained)) { auto ecmap = np.parameter(internal_np::edge_is_constrained); for (auto e : c3t3.edges_in_complex()) @@ -374,7 +374,7 @@ convert_to_triangulation_3( } } - if constexpr (np.has_parameter(internal_np::vertex_is_constrained)) + if constexpr (NamedParameters::has_parameter(internal_np::vertex_is_constrained)) { auto vcmap = np.parameter(internal_np::vertex_is_constrained); for (auto v : c3t3.vertices_in_complex()) From d36b47c0e704eabca1e7bf74b5798a4442865f9a Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 7 Oct 2026 10:05:47 +0200 Subject: [PATCH 118/127] test the backward compatibility --- Mesh_3/test/Mesh_3/test_meshing_3D_image_with_features.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mesh_3/test/Mesh_3/test_meshing_3D_image_with_features.cpp b/Mesh_3/test/Mesh_3/test_meshing_3D_image_with_features.cpp index 7c65e2badd01..cdddc837b7b8 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_3D_image_with_features.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_3D_image_with_features.cpp @@ -60,7 +60,8 @@ struct Image_tester : public Tester Concurrency_tag>::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_criteria_3 Mesh_criteria; + typedef CGAL::Mesh_criteria_3 Mesh_criteria; // the template parameter is `Tr` on purpose, + // to test the backward compatibility void mesh_and_verify(Mesh_domain& domain, const Image& image, const double volume) const { From 570c2a43ad10d0bfeb152bdab7637d627450d639 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 7 Oct 2026 10:12:00 +0200 Subject: [PATCH 119/127] revert the WIP about tet remeshing and named parameters --- .../include/CGAL/Named_function_parameters.h | 73 ++++++--------- .../STL_Extension/test_cgal_named_params.cpp | 4 - .../include/CGAL/tetrahedral_remeshing.h | 63 ++++--------- .../test/Tetrahedral_remeshing/CMakeLists.txt | 3 - .../features_and_adaptive_sizing.cpp | 93 +++++++------------ ...daptive_sizing_patch_info_not_in_cells.cpp | 4 - 6 files changed, 76 insertions(+), 164 deletions(-) delete mode 100644 Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp diff --git a/STL_Extension/include/CGAL/Named_function_parameters.h b/STL_Extension/include/CGAL/Named_function_parameters.h index 111022d50f8b..6d29bfc39405 100644 --- a/STL_Extension/include/CGAL/Named_function_parameters.h +++ b/STL_Extension/include/CGAL/Named_function_parameters.h @@ -71,10 +71,6 @@ struct Named_params_impl : Base : Base(b) , v(v) {} - - constexpr decltype(auto) parameter(Tag) const noexcept { return v; } - static constexpr bool has_parameter(Tag) noexcept { return true; } - using Base::parameter; }; // partial specialization for base class of the recursive nesting @@ -83,11 +79,9 @@ struct Named_params_impl { typename std::conditional::value, T, std::reference_wrapper >::type v; // copy of the parameter if copyable - constexpr Named_params_impl(const T& v) + Named_params_impl(const T& v) : v(v) {} - constexpr decltype(auto) parameter(Tag) const noexcept { return v; } - static constexpr bool has_parameter(Tag) noexcept { return true; } }; // Helper class to get the type of a named parameter pack given a query tag @@ -261,14 +255,15 @@ namespace parameters{ typedef Named_function_parameters Default_named_parameters; -inline constexpr Default_named_parameters default_values(); +Default_named_parameters +inline default_values(); // function to extract a parameter template typename internal_np::Get_param, Query_tag>::type get_parameter(const Named_function_parameters& np, Query_tag tag) { - return np.parameter(tag); + return internal_np::get_parameter_impl(static_cast&>(np), tag); } template @@ -371,29 +366,15 @@ struct Named_function_parameters typedef internal_np::Named_params_impl base; typedef Named_function_parameters self; - using base::parameter; - using base::has_parameter; - constexpr auto parameter(...) const { return internal_np::Param_not_found(); } - static constexpr bool has_parameter(...) { return false; } - - template - constexpr decltype(auto) parameter_or([[maybe_unused]] U&& default_value) const { - if constexpr (has_parameter(Tag2())) { - return parameter(Tag2()); - } else { - return std::forward(default_value); - } - } - - constexpr Named_function_parameters() : base(T()) {} - constexpr Named_function_parameters(const T& v) : base(v) {} - constexpr Named_function_parameters(const T& v, const Base& b) : base(v, b) {} + Named_function_parameters() : base(T()) {} + Named_function_parameters(const T& v) : base(v) {} + Named_function_parameters(const T& v, const Base& b) : base(v, b) {} // create the functions for new named parameters and the one imported boost // used to concatenate several parameters #define CGAL_add_named_parameter(X, Y, Z) \ template \ - constexpr Named_function_parameters \ + Named_function_parameters \ Z(const K& k) const \ { \ typedef Named_function_parameters Params;\ @@ -401,7 +382,7 @@ struct Named_function_parameters } #define CGAL_add_named_parameter_with_compatibility(X, Y, Z) \ template \ - constexpr Named_function_parameters \ + Named_function_parameters \ Z(const K& k) const \ { \ typedef Named_function_parameters Params;\ @@ -409,7 +390,7 @@ struct Named_function_parameters } #define CGAL_add_named_parameter_with_compatibility_cref_only(X, Y, Z) \ template \ - constexpr Named_function_parameters, \ + Named_function_parameters, \ internal_np::X, self> \ Z(const K& k) const \ { \ @@ -419,7 +400,7 @@ struct Named_function_parameters } #define CGAL_add_named_parameter_with_compatibility_ref_only(X, Y, Z) \ template \ - constexpr Named_function_parameters, \ + Named_function_parameters, \ internal_np::X, self> \ Z(K& k) const \ { \ @@ -429,7 +410,7 @@ struct Named_function_parameters } #define CGAL_add_extra_named_parameter_with_compatibility(X, Y, Z) \ template \ - constexpr Named_function_parameters \ + Named_function_parameters \ Z(const K& k) const \ { \ typedef Named_function_parameters Params;\ @@ -452,14 +433,14 @@ struct Named_function_parameters #undef CGAL_NP_BUILD template - constexpr Named_function_parameters + Named_function_parameters combine(const Named_function_parameters& np) const { return Named_function_parameters(np.v,*this); } template - constexpr auto + auto combine(const Named_function_parameters& np, const NPS& ... nps) const { return Named_function_parameters(np.v,*this).combine(nps...); @@ -471,8 +452,8 @@ struct Named_function_parameters namespace parameters { -inline constexpr Default_named_parameters -default_values() +Default_named_parameters +inline default_values() { return Default_named_parameters(); } @@ -489,7 +470,7 @@ template struct Boost_parameter_compatibility_wrapper { template - constexpr Named_function_parameters + Named_function_parameters operator()(const K& p) const { typedef Named_function_parameters Params; @@ -497,7 +478,7 @@ struct Boost_parameter_compatibility_wrapper } template - constexpr Named_function_parameters + Named_function_parameters operator=(const K& p) const { typedef Named_function_parameters Params; @@ -509,7 +490,7 @@ template struct Boost_parameter_compatibility_wrapper { template - constexpr Named_function_parameters, Tag> + Named_function_parameters, Tag> operator()(const K& p) const { typedef Named_function_parameters, Tag> Params; @@ -517,7 +498,7 @@ struct Boost_parameter_compatibility_wrapper } template - constexpr Named_function_parameters, Tag> + Named_function_parameters, Tag> operator=(const K& p) const { typedef Named_function_parameters, Tag> Params; @@ -529,7 +510,7 @@ template struct Boost_parameter_compatibility_wrapper { template - constexpr Named_function_parameters, Tag> + Named_function_parameters, Tag> operator()(K& p) const { typedef Named_function_parameters, Tag> Params; @@ -537,7 +518,7 @@ struct Boost_parameter_compatibility_wrapper } template - constexpr Named_function_parameters, Tag> + Named_function_parameters, Tag> operator=(std::reference_wrapper p) const { typedef Named_function_parameters, Tag> Params; @@ -549,20 +530,20 @@ struct Boost_parameter_compatibility_wrapper #define CGAL_add_named_parameter(X, Y, Z) \ template \ Named_function_parameters \ - constexpr Z(const K& p) \ + Z(const K& p) \ { \ typedef Named_function_parameters Params;\ return Params(p); \ } #define CGAL_add_named_parameter_with_compatibility(X, Y, Z) \ - inline constexpr Boost_parameter_compatibility_wrapper Z; + inline const Boost_parameter_compatibility_wrapper Z; #define CGAL_add_named_parameter_with_compatibility_cref_only(X, Y, Z) \ - inline constexpr Boost_parameter_compatibility_wrapper Z; + inline const Boost_parameter_compatibility_wrapper Z; #define CGAL_add_named_parameter_with_compatibility_ref_only(X, Y, Z) \ - inline constexpr Boost_parameter_compatibility_wrapper Z; + inline const Boost_parameter_compatibility_wrapper Z; #define CGAL_add_extra_named_parameter_with_compatibility(X, Y, Z) \ - inline constexpr Boost_parameter_compatibility_wrapper Z; + inline const Boost_parameter_compatibility_wrapper Z; #include #undef CGAL_add_named_parameter #undef CGAL_add_extra_named_parameter_with_compatibility diff --git a/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp b/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp index 855a3f09c26c..4e6b703cb9b5 100644 --- a/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp +++ b/STL_Extension/test/STL_Extension/test_cgal_named_params.cpp @@ -35,15 +35,11 @@ void test_values_and_types(const NamedParameters& np) // test values assert(get_parameter(np, inp::vertex_index).v == 0); - assert(np.parameter(inp::vertex_index).v == 0); assert(get_parameter(np, inp::visitor).v == 1); - assert(np.parameter(inp::visitor).v == 1); // test types check_same_type<0>(get_parameter(np, inp::vertex_index)); - check_same_type<0>(np.parameter(inp::vertex_index)); check_same_type<1>(get_parameter(np, inp::visitor)); - check_same_type<1>(np.parameter(inp::visitor)); } template diff --git a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h index 938b6e26f3d4..da8766f081e2 100644 --- a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h +++ b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h @@ -15,12 +15,10 @@ #include -#include #include #include #include -#include #include #include @@ -348,12 +346,8 @@ template -#ifdef DOXYGEN_RUNNING CGAL::Triangulation_3 -#else -auto -#endif convert_to_triangulation_3( CGAL::Mesh_complex_3_in_triangulation_3 c3t3, const NamedParameters& np = parameters::default_values()) @@ -361,12 +355,19 @@ convert_to_triangulation_3( using parameters::get_parameter; using parameters::choose_parameter; - using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; using GT = typename Tr::Geom_traits; + using TDS = typename Tr::Triangulation_data_structure; + using Dummy_sizing = CGAL::Uniform_sizing_field; + + using Remesher_types + = typename Tetrahedral_remeshing::internal::Adaptive_remesher_type_generator + ; - if constexpr (NamedParameters::has_parameter(internal_np::edge_is_constrained)) + using Default_edge_pmap = typename Remesher_types::Default_ECMap; + using ECMap = typename Remesher_types::ECMap; + if (!std::is_same_v) { - auto ecmap = np.parameter(internal_np::edge_is_constrained); + ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained)); for (auto e : c3t3.edges_in_complex()) { const auto evv = CGAL::Tetrahedral_remeshing::make_vertex_pair(e);//ordered pair @@ -374,50 +375,20 @@ convert_to_triangulation_3( } } - if constexpr (NamedParameters::has_parameter(internal_np::vertex_is_constrained)) + using Default_vertex_pmap = typename Remesher_types::Default_VCMap; + using VCMap = typename Remesher_types::VCMap; + if (!std::is_same_v) { - auto vcmap = np.parameter(internal_np::vertex_is_constrained); + VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained)); for (auto v : c3t3.vertices_in_complex()) { put(vcmap, v, true); } } - if constexpr (false == C3t3::Store_surface_patch_info_in_cell::value) - { - using Target_triangulation = CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3; - Target_triangulation tr; - const auto& source_tr = c3t3.triangulation(); - auto infinite_vertex = tr.tds().copy_tds( - source_tr.tds(), source_tr.infinite_vertex(), - [&](const auto& source_vertex) { - typename Target_triangulation::Vertex vertex; - vertex.set_point(source_vertex.point()); - return vertex; - }, - [&](const auto& source_cell) { - typename Target_triangulation::Cell cell; - cell.set_surface_patch_index(source_cell.surface_patch_index()); - return cell; - }); - tr.set_infinite_vertex(infinite_vertex); - auto [src_cell_it, src_cell_end] = source_tr.finite_cell_handles(); - auto [tgt_cell_it, tgt_cell_end] = tr.finite_cell_handles(); - for (; src_cell_it != src_cell_end; ++src_cell_it, ++tgt_cell_it) - { - auto subdomain_index = c3t3.subdomain_index(*src_cell_it); - (*tgt_cell_it)->set_subdomain_index(subdomain_index); - for(int i = 0; i < 4; ++i) { - (*tgt_cell_it)->set_surface_patch_index(i, c3t3.surface_patch_index(*src_cell_it, i)); - } - } - return tr; - } else { // C3t3::Store_surface_patch_info_in_cell::value == true - using TDS = typename Tr::Triangulation_data_structure; - CGAL::Triangulation_3 tr; - tr.swap(c3t3.triangulation()); - return tr; - } + CGAL::Triangulation_3 tr; + tr.swap(c3t3.triangulation()); + return tr; } /////////////////////////////////////////////////// diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt index a773722e1b87..fa4dc3d7bbe6 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt @@ -41,9 +41,6 @@ if(TARGET CGAL::Eigen3_support) create_single_source_cgal_program("features_and_adaptive_sizing.cpp") target_link_libraries(features_and_adaptive_sizing PRIVATE CGAL::Eigen3_support) - create_single_source_cgal_program("features_and_adaptive_sizing_patch_info_not_in_cells.cpp") - target_link_libraries(features_and_adaptive_sizing_patch_info_not_in_cells PRIVATE CGAL::Eigen3_support) - create_single_source_cgal_program("test_mesh_and_remesh_with_io.cpp") target_link_libraries(test_mesh_and_remesh_with_io PRIVATE CGAL::Eigen3_support) diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp index 0418c7dc3354..ab36bc321419 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing.cpp @@ -15,7 +15,6 @@ #include #include -#include #include // Domain @@ -34,32 +33,25 @@ typedef CGAL::Mesh_triangulation_3: typedef CGAL::Mesh_complex_3_in_triangulation_3< Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index> C3t3; -template -int go(const std::string& fname) -{ - // Criteria - typedef CGAL::Mesh_criteria_3 Mesh_criteria; - - // Triangulation for Remeshing - typedef CGAL::Triangulation_3 Triangulation_3; - using Vertex_handle = Triangulation_3::Vertex_handle; +// Criteria +typedef CGAL::Mesh_criteria_3 Mesh_criteria; - #ifdef CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 - static_assert(!C3t3::Store_surface_patch_info_in_cell::value); - #else - static_assert(C3t3::Store_surface_patch_info_in_cell::value); - #endif - static_assert(std::is_base_of_v); +// Triangulation for Remeshing +typedef CGAL::Triangulation_3 Triangulation_3; +using Vertex_handle = Triangulation_3::Vertex_handle; - using Vertex_pair = std::pair; - using Constraints_set = std::unordered_set>; - using Constraints_pmap = CGAL::Boolean_property_map; +using Vertex_pair = std::pair; +using Constraints_set = std::unordered_set>; +using Constraints_pmap = CGAL::Boolean_property_map; - // To avoid verbose function and named parameters call - namespace p = CGAL::parameters; +// To avoid verbose function and named parameters call +namespace p = CGAL::parameters; +int main(int argc, char* argv[]) +{ + const std::string fname = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cube.off"); std::ifstream input(fname); Polyhedron polyhedron; input >> polyhedron; @@ -94,40 +86,26 @@ int go(const std::string& fname) //Remeshing : extract triangulation timer.reset(); timer.start(); + Constraints_set constraints; Constraints_pmap constraints_pmap(constraints); - auto np = p::number_of_iterations(3).edge_is_constrained_map(constraints_pmap).smooth_constrained_edges(true); - if constexpr(C3t3::Store_surface_patch_info_in_cell::value) { - const auto src_tr = c3t3.triangulation(); - const auto src_number_of_vertices = src_tr.number_of_vertices(); - const auto src_number_of_cells = src_tr.number_of_cells(); - auto tr = CGAL::convert_to_triangulation_3(std::move(c3t3), - p::edge_is_constrained_map(constraints_pmap)); - assert(tr.number_of_vertices() == src_number_of_vertices); - assert(tr.number_of_cells() == src_number_of_cells); - - //note we use the move semantic, with std::move(c3t3), - // to avoid a copy of the triangulation by the function - // `CGAL::convert_to_triangulation_3()` - // After the call to this function, c3t3 is an empty and valid C3t3. - //It is possible to use : CGAL::convert_to_triangulation_3(c3t3), - // Then the triangulation is copied and duplicated, and c3t3 remains as is. - - CGAL::tetrahedral_isotropic_remeshing( - tr, CGAL::create_adaptive_remeshing_sizing_field(tr, p::edge_is_constrained_map(constraints_pmap)), np); - } else { // C3t3::Store_surface_patch_info_in_cell::value == false - for(const auto e : c3t3.triangulation().finite_edges()) { - if(c3t3.is_in_complex(e)) { - Vertex_pair evv = CGAL::Tetrahedral_remeshing::make_vertex_pair(e); - constraints.insert(evv); - } - } - - CGAL::tetrahedral_isotropic_remeshing(c3t3, - CGAL::create_adaptive_remeshing_sizing_field( - c3t3.triangulation(), p::edge_is_constrained_map(constraints_pmap)), - np); - } + + Triangulation_3 tr = CGAL::convert_to_triangulation_3(std::move(c3t3), + p::edge_is_constrained_map(constraints_pmap)); + + //note we use the move semantic, with std::move(c3t3), + // to avoid a copy of the triangulation by the function + // `CGAL::convert_to_triangulation_3()` + // After the call to this function, c3t3 is an empty and valid C3t3. + //It is possible to use : CGAL::convert_to_triangulation_3(c3t3), + // Then the triangulation is copied and duplicated, and c3t3 remains as is. + + CGAL::tetrahedral_isotropic_remeshing(tr, + CGAL::create_adaptive_remeshing_sizing_field(tr, p::edge_is_constrained_map(constraints_pmap)), + p::number_of_iterations(3) + .edge_is_constrained_map(constraints_pmap) + .smooth_constrained_edges(true)); + timer.stop(); std::cout << "Remeshing done (" << timer.time() << " seconds)" << std::endl; @@ -138,10 +116,3 @@ int go(const std::string& fname) return EXIT_SUCCESS; } - -int main(int argc, char* argv[]) -{ - const std::string fname = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cube.off"); - return go(fname); -} - diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp deleted file mode 100644 index 8543027cf8e3..000000000000 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/features_and_adaptive_sizing_patch_info_not_in_cells.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// #define CGAL_MESH_3_USE_EXPERIMENTAL_COMPACT_MESH_CELL_BASE_3 1 -// #include "features_and_adaptive_sizing.cpp" - -int main() {} From 761cfc492e919868b77ddc405f437437c18e52a7 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 9 Oct 2026 15:38:46 +0200 Subject: [PATCH 120/127] announcement the breaking change for mesh criteria and fix the documentation --- Installation/CHANGES.md | 9 +++++++ .../doc/Mesh_3/Concepts/MeshCellCriteria_3.h | 25 ++++++++----------- .../doc/Mesh_3/Concepts/MeshEdgeCriteria_3.h | 8 +++--- .../doc/Mesh_3/Concepts/MeshFacetCriteria_3.h | 13 +++++----- Mesh_3/include/CGAL/Mesh_cell_criteria_3.h | 4 +-- Mesh_3/include/CGAL/Mesh_criteria_3.h | 13 ++++------ Mesh_3/include/CGAL/Mesh_edge_criteria_3.h | 2 ++ Mesh_3/include/CGAL/Mesh_facet_criteria_3.h | 4 +-- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index f50ad883ade6..fb9a29f03050 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -37,6 +37,15 @@ Release date: December 2026 - Deprecated the existing overload of `snap_rounding_2()`. - Added a new overload of `snap_rounding_2()` that automatically dispatch to either `vertical_slab_snap_rounding_2()` or `hot_pixel_snap_rounding_2()`, depending on the provided traits class. +### [3D Mesh Generation](https://doc.cgal.org/6.3/Manual/packages.html#PkgMesh3) + +- **Breaking change**: The template parameter of `CGAL::Mesh_cell_criteria_3`, + `CGAL::Mesh_edge_criteria_3`, and `CGAL::Mesh_facet_criteria_3` is now the + mesh complex type `C3T3`, rather than its triangulation type. Code that + explicitly instantiates these criteria classes must be updated accordingly. + `CGAL::Mesh_criteria_3` also uses `C3T3` as its template parameter, but + continues to accept the triangulation type for backward compatibility. + ### [Polygon Mesh Processing - Mesh Repair](https://doc.cgal.org/6.3/Manual/packages.html#PkgPMPMeshRepair) - **Breaking change**: Removed the function `CGAL::Polygon_mesh_processing::smooth_mesh()` which was deprecated since CGAL-5.5. - **Breaking change**: Removed the overload of the functions `CGAL::Polygon_mesh_processing::triangulate_hole()`, `CGAL::Polygon_mesh_processing::triangulate_and_refine_hole()`, and `CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole()` having output iterators for vertices and faces as parameter, which were deprecated since CGAL-6.0. diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshCellCriteria_3.h b/Mesh_3/doc/Mesh_3/Concepts/MeshCellCriteria_3.h index 5e7306a55596..da98845b5eac 100644 --- a/Mesh_3/doc/Mesh_3/Concepts/MeshCellCriteria_3.h +++ b/Mesh_3/doc/Mesh_3/Concepts/MeshCellCriteria_3.h @@ -6,11 +6,12 @@ The Delaunay refinement process involved in the template functions `CGAL::make_mesh_3()` and `CGAL::refine_mesh_3()` is guided by a set of elementary refinement criteria that concern either mesh tetrahedra or surface facets. -The concept `MeshCellCriteria_3` describes the types that -handle the refinement criteria for mesh tetrahedra. +The concept `MeshCellCriteria_3` describes criteria for mesh tetrahedra. +For a mesh complex type `C3T3`, the criteria are evaluated on cells of its +nested triangulation. \cgalHasModelsBegin -\cgalHasModels{CGAL::Mesh_cell_criteria_3} +\cgalHasModels{CGAL::Mesh_cell_criteria_3} \cgalHasModelsEnd \sa `MeshEdgeCriteria_3` @@ -27,13 +28,6 @@ class MeshCellCriteria_3 { /// \name Types /// @{ -/*! -%Handle type for the cells of the -triangulation. Must match the `Cell_handle` type in the -triangulation type used by the mesh generation function. -*/ -typedef unspecified_type Cell_handle; - /*! Type representing the quality of a cell. Must be a model of CopyConstructible and @@ -44,8 +38,8 @@ typedef unspecified_type Cell_quality; /*! Type representing if a cell is bad or not. Must -be convertible to `bool`. If it converts to `true` then the cell is bad, otherwise -the cell is good with regard to the criteria. +be contextually convertible to `bool`. If it converts to `true` then the cell +is bad, otherwise the cell is good with regard to the criteria. In addition, an object of this type must contain an object of type `Cell_quality` if it represents @@ -60,10 +54,11 @@ typedef unspecified_type Is_cell_bad; /// @{ /*! -Returns the `Is_cell_bad` value of the cell `c`, which lives in the triangulation `tr`. -The type `Tr` must be identical to the triangulation type used by the mesh generation function. +Returns the `Is_cell_bad` value for the cell `c` of the triangulation nested +in `c3t3`, the mesh complex used by the mesh generation function. */ -Is_cell_bad operator()(const Tr& tr, Cell_handle c); +Is_cell_bad operator()(const C3T3& c3t3, + typename C3T3::Triangulation::Cell_handle c) const; /// @} diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshEdgeCriteria_3.h b/Mesh_3/doc/Mesh_3/Concepts/MeshEdgeCriteria_3.h index 2fad590a78e3..0010633edcc0 100644 --- a/Mesh_3/doc/Mesh_3/Concepts/MeshEdgeCriteria_3.h +++ b/Mesh_3/doc/Mesh_3/Concepts/MeshEdgeCriteria_3.h @@ -8,7 +8,7 @@ It provides an upper bound for the distance between two protecting ball centers that are consecutive on a 1-feature. \cgalHasModelsBegin -\cgalHasModels{CGAL::Mesh_edge_criteria_3} +\cgalHasModels{CGAL::Mesh_edge_criteria_3} \cgalHasModelsEnd \sa `MeshCellCriteria_3` @@ -26,13 +26,13 @@ class MeshEdgeCriteria_3 { /*! Point type. Must match the `Point_3` type in -the triangulation type used by the mesh generation function. +the triangulation nested in the mesh complex type used by the mesh generation function. */ typedef unspecified_type Point_3; /*! -Type for edges of the triangulation. Must match the -`Edge` type in the triangulation type used by the mesh generation function. +Type for edges of the triangulation. Must match the `Edge` type in the triangulation +nested in the mesh complex type used by the mesh generation function. */ typedef unspecified_type Edge; diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshFacetCriteria_3.h b/Mesh_3/doc/Mesh_3/Concepts/MeshFacetCriteria_3.h index 07a6626bb79d..427d9a891f99 100644 --- a/Mesh_3/doc/Mesh_3/Concepts/MeshFacetCriteria_3.h +++ b/Mesh_3/doc/Mesh_3/Concepts/MeshFacetCriteria_3.h @@ -10,7 +10,7 @@ The concept `MeshFacetCriteria_3` describes the types that handle the refinement criteria for surface facets. \cgalHasModelsBegin -\cgalHasModels{CGAL::Mesh_facet_criteria_3} +\cgalHasModels{CGAL::Mesh_facet_criteria_3} \cgalHasModelsEnd \sa `MeshCellCriteria_3` @@ -30,14 +30,14 @@ class MeshFacetCriteria_3 { /*! Type for the facets of the triangulation. Must match the `Facet` type in the -triangulation type used by the mesh generation function. +triangulation nested in the mesh complex type used by the mesh generation function. */ typedef unspecified_type Facet; /*! Handle type for the cells of the triangulation. Must match the `Cell_handle` type in the -triangulation type used by the mesh generation function. +triangulation nested in the mesh complex type used by the mesh generation function. */ typedef unspecified_type Cell_handle; @@ -73,10 +73,11 @@ typedef unspecified_type FT; /// @{ /*! -Returns the `Is_facet_bad` value of the facet `f`, which lives in the triangulation `tr`. -The type `Tr` must be identical to the triangulation type used by the mesh generation function. +Returns the `Is_facet_bad` value of the facet `f`, which belongs to the mesh complex +`c3t3` used by the mesh generation function. +The type `C3T3` must be the mesh complex type used by the mesh generation function. */ -Is_facet_bad operator()(const Tr& tr, Facet f); +Is_facet_bad operator()(const C3T3& c3t3, Facet f); /** * @returns the squared value of minimal radius bound if set, diff --git a/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h b/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h index 786d1c9e9c87..c89a9b5939b5 100644 --- a/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_cell_criteria_3.h @@ -35,9 +35,7 @@ for the mesh tetrahedra, a uniform shape criterion and a sizing field which may be a uniform or variable field. -\tparam Tr must be identical to the nested type -`Triangulation` of the instance used as model of -`MeshComplex_3InTriangulation_3`. +\tparam C3T3 must be a model of `MeshComplex_3InTriangulation_3`. \cgalModels{MeshCellCriteria_3} diff --git a/Mesh_3/include/CGAL/Mesh_criteria_3.h b/Mesh_3/include/CGAL/Mesh_criteria_3.h index 7511ef93c338..3866b56e89f8 100644 --- a/Mesh_3/include/CGAL/Mesh_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_criteria_3.h @@ -150,11 +150,8 @@ the class `Mesh_criteria_3` handles the definition of a sizing field to guide the discretization of 1-dimensional features. -\tparam Tr has to be instantiated with the type used for -`C3T3::Triangulation`, -where `C3T3` is the model of `MeshComplex_3InTriangulation_3` -used in the mesh generation process, -and `C3T3::Triangulation` its nested triangulation type. +\tparam C3T3 is the model of `MeshComplex_3InTriangulation_3` used in the +mesh generation process. \cgalModels{MeshCriteria_3,MeshCriteriaWithFeatures_3} @@ -182,9 +179,9 @@ Mesh_criteria_3 criteria (parameters::cell_radius_edge_ratio(2). \sa `MeshEdgeCriteria_3` \sa `MeshFacetCriteria_3` \sa `MeshDomainField_3` -\sa `CGAL::Mesh_cell_criteria_3` -\sa `CGAL::Mesh_edge_criteria_3` -\sa `CGAL::Mesh_facet_criteria_3` +\sa `CGAL::Mesh_cell_criteria_3` +\sa `CGAL::Mesh_edge_criteria_3` +\sa `CGAL::Mesh_facet_criteria_3` \sa `CGAL::Mesh_facet_topology` */ diff --git a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h index 2c2ed279a3d1..bab336408e66 100644 --- a/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_edge_criteria_3.h @@ -93,6 +93,8 @@ namespace internal { The function object class `Mesh_edge_criteria_3` is a model of `MeshEdgeCriteria_3`. It provides bounds for the size and approximation criteria. +\tparam C3T3 must be a model of `MeshComplex_3InTriangulation_3`. + \cgalModels{MeshEdgeCriteria_3} \sa `MeshCriteriaWithFeatures_3` diff --git a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h index b5af488e2be7..db4dff0610e9 100644 --- a/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h +++ b/Mesh_3/include/CGAL/Mesh_facet_criteria_3.h @@ -39,9 +39,7 @@ namespace CGAL { a uniform or variable distance field for the approximation error criterion. - \tparam Tr must be identical to the nested type - `Triangulation` of the instance used as model of - `MeshComplex_3InTriangulation_3`. + \tparam C3T3 must be a model of `MeshComplex_3InTriangulation_3`. \cgalModels{MeshFacetCriteria_3} From 44a80fb8ebebd583f121732dea584a817358dcef Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 9 Oct 2026 16:13:52 +0200 Subject: [PATCH 121/127] fix links --- Mesh_3/doc/Mesh_3/Concepts/MeshDomainField_3.h | 6 +++--- Mesh_3/doc/Mesh_3/PackageDescription.txt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshDomainField_3.h b/Mesh_3/doc/Mesh_3/Concepts/MeshDomainField_3.h index 3d05823497b8..0ca70fc6158f 100644 --- a/Mesh_3/doc/Mesh_3/Concepts/MeshDomainField_3.h +++ b/Mesh_3/doc/Mesh_3/Concepts/MeshDomainField_3.h @@ -11,9 +11,9 @@ at any point of the space. \sa `MeshDomain_3` \sa `MeshDomainWithFeatures_3` -\sa `CGAL::Mesh_edge_criteria_3` -\sa `CGAL::Mesh_facet_criteria_3` -\sa `CGAL::Mesh_cell_criteria_3` +\sa `CGAL::Mesh_edge_criteria_3` +\sa `CGAL::Mesh_facet_criteria_3` +\sa `CGAL::Mesh_cell_criteria_3` */ diff --git a/Mesh_3/doc/Mesh_3/PackageDescription.txt b/Mesh_3/doc/Mesh_3/PackageDescription.txt index 6ee4c1f9ddd4..662e54a219d0 100644 --- a/Mesh_3/doc/Mesh_3/PackageDescription.txt +++ b/Mesh_3/doc/Mesh_3/PackageDescription.txt @@ -93,9 +93,9 @@ related to the template parameters of some models of the main concepts: - `CGAL::Compact_mesh_cell_base_3` - `CGAL::Mesh_cell_base_3` - `CGAL::Mesh_criteria_3` -- `CGAL::Mesh_cell_criteria_3` -- `CGAL::Mesh_facet_criteria_3` -- `CGAL::Mesh_edge_criteria_3` +- `CGAL::Mesh_cell_criteria_3` +- `CGAL::Mesh_facet_criteria_3` +- `CGAL::Mesh_edge_criteria_3` - `CGAL::Mesh_constant_domain_field_3` The following classes are models of domain concepts From 35c6a690d8e3852e5d81f3de28659317df021b9b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 22 Oct 2026 10:52:28 +0100 Subject: [PATCH 122/127] Use std::filesystem::path --- Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp index d28f87f48d54..4d9463127023 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp @@ -45,7 +45,7 @@ int main (int argc, char** argv){ // Open file - std::string input_file = (argc > 1 ? argv[1] : CGAL::data_file_path("meshes/elephant.mesh")); + std::filesystem::path input_file = (argc > 1 ? argv[1] : CGAL::data_file_path("meshes/elephant.mesh")); std::ifstream in (input_file, std::ios_base::in); if(!in) { std::cerr << "Error! Cannot open file " << input_file << std::endl; From ed8761615eca97d69d78d476e9c89cbcdce2ccb3 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 22 Oct 2026 10:52:53 +0100 Subject: [PATCH 123/127] Repeat constexpr inside the lambda for VC++ --- SMDS_3/include/CGAL/IO/File_medit.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SMDS_3/include/CGAL/IO/File_medit.h b/SMDS_3/include/CGAL/IO/File_medit.h index 451558fca9e7..69e79aa4c137 100644 --- a/SMDS_3/include/CGAL/IO/File_medit.h +++ b/SMDS_3/include/CGAL/IO/File_medit.h @@ -512,6 +512,8 @@ output_to_medit(std::ostream& os, << '\n'; } auto vertex_index = [&](const Vertex_handle& v) { + constexpr bool use_meshing_info = + has_meshing_info())>::type>::value; if constexpr (use_meshing_info) return v->meshing_info(); else From f4c753795137601d93d3df7b2cc444eaaa2f63e1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 26 Oct 2026 12:25:23 +0100 Subject: [PATCH 124/127] Add a function object to replace a lambda with a constexpr in it --- SMDS_3/include/CGAL/IO/File_medit.h | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/SMDS_3/include/CGAL/IO/File_medit.h b/SMDS_3/include/CGAL/IO/File_medit.h index 69e79aa4c137..b5e6aa4592ed 100644 --- a/SMDS_3/include/CGAL/IO/File_medit.h +++ b/SMDS_3/include/CGAL/IO/File_medit.h @@ -440,6 +440,40 @@ struct Medit_pmap_generator +struct Vertex_index_functor +{ + Vertex_index_functor(const std::unordered_map&) + {} + + int operator()(const VertexHandle& v) + { return -1; } +}; + +template +struct Vertex_index_functor +{ + Vertex_index_functor(const std::unordered_map&) + {} + + int operator()(const VertexHandle& v) + { return v->meshing_info(); } +}; + + +template +struct Vertex_index_functor +{ + const std::unordered_map& V; + Vertex_index_functor(const std::unordered_map& V) + : V(V) + {} + + + int operator()(const VertexHandle& v) + { return V.at(v); } +}; + //------------------------------------------------------- // IO functions //------------------------------------------------------- @@ -511,6 +545,7 @@ output_to_medit(std::ostream& os, << get(vertex_pmap, v) << '\n'; } + /* auto vertex_index = [&](const Vertex_handle& v) { constexpr bool use_meshing_info = has_meshing_info())>::type>::value; @@ -519,6 +554,10 @@ output_to_medit(std::ostream& os, else return V.at(v); }; + */ + + Vertex_index_functor vertex_index(V); + os << "Vertices\n" << inum - 1 << "\n"; os << oss.str(); From 150df3e6301372f76ad98424219c656d6bf5fedc Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 26 Oct 2026 17:02:29 +0100 Subject: [PATCH 125/127] fix a warning ``` [...]CGAL/Conforming_constrained_Delaunay_triangulation_3.h(5291,1): warning C4267: 'argument': conversion from 'size_t' to 'const int', [...] ``` --- .../CGAL/Conforming_constrained_Delaunay_triangulation_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h index 68452fbe32e3..bfdc6b7f8b7d 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h @@ -5256,7 +5256,7 @@ auto get_remeshing_triangulation(Conforming_constrained_Delaunay_triangulation_3 } } - boost::unordered_map constraint_index_map; + boost::unordered_map constraint_index_map; for(auto [c, index] : ccdt.triangulation().finite_facets()) { if(ccdt.is_facet_constrained(c, index)) From 17209e000c88415221c65a1ad5f52956a8413015 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 27 Oct 2026 08:22:44 +0100 Subject: [PATCH 126/127] return type must be auto; trailing whitespace --- SMDS_3/include/CGAL/IO/File_medit.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SMDS_3/include/CGAL/IO/File_medit.h b/SMDS_3/include/CGAL/IO/File_medit.h index b5e6aa4592ed..0aaa584680c2 100644 --- a/SMDS_3/include/CGAL/IO/File_medit.h +++ b/SMDS_3/include/CGAL/IO/File_medit.h @@ -440,28 +440,28 @@ struct Medit_pmap_generator +template struct Vertex_index_functor { - Vertex_index_functor(const std::unordered_map&) + Vertex_index_functor(const std::unordered_map&) {} int operator()(const VertexHandle& v) { return -1; } }; -template +template struct Vertex_index_functor { - Vertex_index_functor(const std::unordered_map&) + Vertex_index_functor(const std::unordered_map&) {} - int operator()(const VertexHandle& v) + auto operator()(const VertexHandle& v) { return v->meshing_info(); } }; -template +template struct Vertex_index_functor { const std::unordered_map& V; @@ -470,7 +470,7 @@ struct Vertex_index_functor {} - int operator()(const VertexHandle& v) + int operator()(const VertexHandle& v) { return V.at(v); } }; From adfbe1eec41e29aa0b08b82afd0bb6b97a52ab93 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 27 Oct 2026 08:28:51 +0100 Subject: [PATCH 127/127] No need for three functors --- SMDS_3/include/CGAL/IO/File_medit.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/SMDS_3/include/CGAL/IO/File_medit.h b/SMDS_3/include/CGAL/IO/File_medit.h index 0aaa584680c2..fb49e0e6972d 100644 --- a/SMDS_3/include/CGAL/IO/File_medit.h +++ b/SMDS_3/include/CGAL/IO/File_medit.h @@ -446,16 +446,6 @@ struct Vertex_index_functor Vertex_index_functor(const std::unordered_map&) {} - int operator()(const VertexHandle& v) - { return -1; } -}; - -template -struct Vertex_index_functor -{ - Vertex_index_functor(const std::unordered_map&) - {} - auto operator()(const VertexHandle& v) { return v->meshing_info(); } }; @@ -469,11 +459,11 @@ struct Vertex_index_functor : V(V) {} - int operator()(const VertexHandle& v) { return V.at(v); } }; + //------------------------------------------------------- // IO functions //-------------------------------------------------------