From c0f53c4a3e9916d9b05f3433bcb618e598995080 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 30 May 2024 16:12:23 +0200 Subject: [PATCH 01/11] avoid using the get(tuple) API, hardly readable --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 33 +++++++++++++++----- 1 file changed, 25 insertions(+), 8 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 6c1a43251841..7bf23f1c8e07 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -247,6 +247,10 @@ class Refine_facets_3_base typedef typename GT::Ray_3 Ray_3; typedef typename GT::Line_3 Line_3; + typedef typename MeshDomain::Intersection Intersection; + typedef typename MeshDomain::Index Index; + typedef typename MeshDomain::Point_3 Point_3; + public: Refine_facets_3_base(Tr& tr, Complex3InTriangulation3& c3t3, const MeshDomain& oracle, @@ -356,6 +360,19 @@ class Refine_facets_3_base return sstr.str(); } + int dimension(const Intersection& intersection) const + { + return std::get<2>(intersection); + } + Index index(const Intersection& intersection) const + { + return std::get<1>(intersection); + } + Point_3 point(const Intersection& intersection) const + { + return std::get<0>(intersection); + } + protected: // Functor for scan_triangulation_impl function @@ -1672,14 +1689,14 @@ compute_facet_properties(const Facet& facet, // test "intersect == Intersection()" (aka empty intersection), but // the later does not work. Surface_patch surface = - (std::get<2>(intersect) == 0) ? Surface_patch() : + (dimension(intersect) == 0) ? Surface_patch() : Surface_patch( - r_oracle_.surface_patch_index(std::get<1>(intersect))); + r_oracle_.surface_patch_index(index(intersect))); if(surface) #endif // CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 fp = Facet_properties(std::make_tuple(*surface, - std::get<1>(intersect), - std::get<0>(intersect))); + index(intersect), + point(intersect))); } } // If the dual is a ray @@ -1710,15 +1727,15 @@ compute_facet_properties(const Facet& facet, Intersection intersect = construct_intersection(ray); #ifdef CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 Surface_patch surface = - (std::get<2>(intersect) == 0) ? Surface_patch() : + (dimension(intersect) == 0) ? Surface_patch() : Surface_patch( - r_oracle_.surface_patch_index(std::get<1>(intersect))); + r_oracle_.surface_patch_index(index(intersect))); if(surface) #endif // CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 { fp = Facet_properties(std::make_tuple(*surface, - std::get<1>(intersect), - std::get<0>(intersect))); + index(intersect), + point(intersect))); } } } From fe6e71724bce80848a35e408dca7ac0eaa33a50c Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 30 May 2024 16:27:01 +0200 Subject: [PATCH 02/11] replace tuple with struct to improve readability --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 39 +++++++++++--------- 1 file changed, 21 insertions(+), 18 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 7bf23f1c8e07..bdc8fcf7e13b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -412,9 +412,13 @@ class Refine_facets_3_base typedef typename MeshDomain::Surface_patch_index Surface_patch_index; typedef typename MeshDomain::Index Index; - typedef typename std::optional< - std::tuple > - Facet_properties; + struct Facet_prop + { + Surface_patch_index surface_patch_index; + Index index; + Bare_point point; + }; + typedef typename std::optional Facet_properties; /// Returns canonical facet of facet @@ -1359,9 +1363,10 @@ conflicts_zone_impl(const Weighted_point& point this->compute_facet_properties(facet, properties, /*force_exact=*/true); if ( properties ) { - const Surface_patch_index& surface_index = std::get<0>(*properties); - const Index& surface_center_index = std::get<1>(*properties); - const Bare_point& surface_center = std::get<2>(*properties); + const Facet_prop& prop = *properties; + const Surface_patch_index& surface_index = prop.surface_patch_index; + const Index& surface_center_index = prop.index; + const Bare_point& surface_center = prop.point; // Facet is on surface: set facet properties this->set_facet_surface_center(facet, surface_center, surface_center_index); @@ -1421,9 +1426,10 @@ conflicts_zone_impl(const Weighted_point& point this->compute_facet_properties(facet, properties, /*force_exact=*/true); if ( properties ) { - const Surface_patch_index& surface_index = std::get<0>(*properties); - const Index& surface_center_index = std::get<1>(*properties); - const Bare_point& surface_center = std::get<2>(*properties); + const Facet_prop& prop = *properties; + const Surface_patch_index& surface_index = prop.surface_patch_index; + const Index& surface_center_index = prop.index; + const Bare_point& surface_center = prop.point; // Facet is on surface: set facet properties this->set_facet_surface_center(facet, surface_center, surface_center_index); @@ -1589,9 +1595,10 @@ treat_new_facet(Facet& facet) compute_facet_properties(facet, properties); if ( properties ) { - const Surface_patch_index& surface_index = std::get<0>(*properties); - const Index& surface_center_index = std::get<1>(*properties); - const Bare_point& surface_center = std::get<2>(*properties); + const Facet_prop& prop = *properties; + const Surface_patch_index& surface_index = prop.surface_patch_index; + const Index& surface_center_index = prop.index; + const Bare_point& surface_center = prop.point; // Facet is on surface: set facet properties set_facet_surface_center(facet, surface_center, surface_center_index); @@ -1694,9 +1701,7 @@ compute_facet_properties(const Facet& facet, r_oracle_.surface_patch_index(index(intersect))); if(surface) #endif // CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 - fp = Facet_properties(std::make_tuple(*surface, - index(intersect), - point(intersect))); + fp = Facet_prop{*surface, index(intersect), point(intersect)}; } } // If the dual is a ray @@ -1733,9 +1738,7 @@ compute_facet_properties(const Facet& facet, if(surface) #endif // CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 { - fp = Facet_properties(std::make_tuple(*surface, - index(intersect), - point(intersect))); + fp = Facet_prop{*surface, index(intersect), point(intersect)}; } } } From 5b1a406dcc513d942ff895dff138314e89f47dba Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 31 May 2024 09:38:20 +0200 Subject: [PATCH 03/11] use c++17 to simplify code --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 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 bdc8fcf7e13b..eceb72b6ec99 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -1363,10 +1363,7 @@ conflicts_zone_impl(const Weighted_point& point this->compute_facet_properties(facet, properties, /*force_exact=*/true); if ( properties ) { - const Facet_prop& prop = *properties; - const Surface_patch_index& surface_index = prop.surface_patch_index; - const Index& surface_center_index = prop.index; - const Bare_point& surface_center = prop.point; + 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); @@ -1426,10 +1423,7 @@ conflicts_zone_impl(const Weighted_point& point this->compute_facet_properties(facet, properties, /*force_exact=*/true); if ( properties ) { - const Facet_prop& prop = *properties; - const Surface_patch_index& surface_index = prop.surface_patch_index; - const Index& surface_center_index = prop.index; - const Bare_point& surface_center = prop.point; + 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); @@ -1595,10 +1589,7 @@ treat_new_facet(Facet& facet) compute_facet_properties(facet, properties); if ( properties ) { - const Facet_prop& prop = *properties; - const Surface_patch_index& surface_index = prop.surface_patch_index; - const Index& surface_center_index = prop.index; - const Bare_point& surface_center = prop.point; + 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); From b2a679ee78ab14436feb9a18d8b407e6f2ad7427 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 31 May 2024 19:05:38 +0200 Subject: [PATCH 04/11] typedefs --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 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 eceb72b6ec99..9904680daa8c 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -248,8 +248,6 @@ class Refine_facets_3_base typedef typename GT::Line_3 Line_3; typedef typename MeshDomain::Intersection Intersection; - typedef typename MeshDomain::Index Index; - typedef typename MeshDomain::Point_3 Point_3; public: Refine_facets_3_base(Tr& tr, Complex3InTriangulation3& c3t3, @@ -360,15 +358,15 @@ class Refine_facets_3_base return sstr.str(); } - int dimension(const Intersection& intersection) const + const int dimension(const Intersection& intersection) const { return std::get<2>(intersection); } - Index index(const Intersection& intersection) const + const typename MeshDomain::Index& index(const Intersection& intersection) const { return std::get<1>(intersection); } - Point_3 point(const Intersection& intersection) const + const typename MeshDomain::Point_3& point(const Intersection& intersection) const { return std::get<0>(intersection); } @@ -414,8 +412,8 @@ class Refine_facets_3_base struct Facet_prop { - Surface_patch_index surface_patch_index; - Index index; + typename MeshDomain::Surface_patch_index surface_patch_index; + typename MeshDomain::Index index; Bare_point point; }; typedef typename std::optional Facet_properties; From bb0c3f22f6874047d6439105727f11dbca92eecc Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 4 Jun 2024 08:52:08 +0200 Subject: [PATCH 05/11] use typedefs --- 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 9904680daa8c..1c4255a57661 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -412,8 +412,8 @@ class Refine_facets_3_base struct Facet_prop { - typename MeshDomain::Surface_patch_index surface_patch_index; - typename MeshDomain::Index index; + Surface_patch_index surface_patch_index; + Index index; Bare_point point; }; typedef typename std::optional Facet_properties; From 3cf86606d8db86b1386187cf72a975d2fba268b8 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 4 Jun 2024 08:55:48 +0200 Subject: [PATCH 06/11] avoid compiler warning --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1c4255a57661..60eb8c3cde82 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -358,7 +358,7 @@ class Refine_facets_3_base return sstr.str(); } - const int dimension(const Intersection& intersection) const + int dimension(const Intersection& intersection) const { return std::get<2>(intersection); } From 7be4da73a3ba00f4b65a40fb2a11c6370ada6b16 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 Jun 2024 17:37:34 +0200 Subject: [PATCH 07/11] remove useless tuple --- Mesh_3/include/CGAL/Mesh_3/polylines_to_protect.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/polylines_to_protect.h b/Mesh_3/include/CGAL/Mesh_3/polylines_to_protect.h index 787b443489c4..7b3dde34edcd 100644 --- a/Mesh_3/include/CGAL/Mesh_3/polylines_to_protect.h +++ b/Mesh_3/include/CGAL/Mesh_3/polylines_to_protect.h @@ -20,7 +20,6 @@ #include // std::swap #include // std::min -#include #include #include #include @@ -515,11 +514,7 @@ polylines_to_protect for(int j = 0; j < ydim; j+= (axis == 1 ? (std::max)(1, ydim-1) : 1 ) ) for(int k = 0; k < zdim; k+= (axis == 2 ? (std::max)(1, zdim-1) : 1 ) ) { - using std::array; - using std::tuple; - using std::get; - typedef array Pixel; #ifdef CGAL_MESH_3_DEBUG_POLYLINES_TO_PROTECT From 8e39809c58c14fd949822388b92a0f861a302d0f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 Jun 2024 17:38:02 +0200 Subject: [PATCH 08/11] remove more tuples --- .../CGAL/Mesh_3/Protect_edges_sizing_field.h | 27 +++++++++---------- .../Mesh_domain_with_polyline_features_3.h | 6 ++--- 2 files changed, 16 insertions(+), 17 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 4a0e3f131dee..07a72823042b 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 @@ -54,7 +54,6 @@ # include // for float_prior #endif #include -#include #include #include @@ -1014,30 +1013,30 @@ Protect_edges_sizing_field:: insert_balls_on_edges() { // Get features - typedef std::tuple, - std::pair > Feature_tuple; - typedef std::vector Input_features; - - Input_features input_features; + struct Feature_tuple + { + Curve_index curve_index_; + std::pair point_s_; + std::pair point_t_; + }; + std::vector input_features; domain_.get_curves(std::back_inserter(input_features)); // Iterate on edges - for ( typename Input_features::iterator fit = input_features.begin(), - end = input_features.end() ; fit != end ; ++fit ) + for ( const Feature_tuple& fit : input_features) { if(forced_stop()) break; - const Curve_index& curve_index = std::get<0>(*fit); + const Curve_index& curve_index = fit.curve_index_; if ( ! is_treated(curve_index) ) { #if CGAL_MESH_3_PROTECTION_DEBUG & 1 std::cerr << "\n** treat curve #" << curve_index << std::endl; #endif - const Bare_point& p = std::get<1>(*fit).first; - const Bare_point& q = std::get<2>(*fit).first; + const Bare_point& p = fit.point_s_.first; + const Bare_point& q = fit.point_t_.first; - const Index& p_index = std::get<1>(*fit).second; - const Index& q_index = std::get<2>(*fit).second; + const Index& p_index = fit.point_s_.second; + const Index& q_index = fit.point_t_.second; Vertex_handle vp,vq; if ( ! domain_.is_loop(curve_index) ) diff --git a/Mesh_3/include/CGAL/Mesh_domain_with_polyline_features_3.h b/Mesh_3/include/CGAL/Mesh_domain_with_polyline_features_3.h index 61eb0682d831..af6e1966641a 100644 --- a/Mesh_3/include/CGAL/Mesh_domain_with_polyline_features_3.h +++ b/Mesh_3/include/CGAL/Mesh_domain_with_polyline_features_3.h @@ -961,9 +961,9 @@ get_curves(OutputIterator out) const q_index = p_index; } - *out++ = std::make_tuple(eit->first, - std::make_pair(p,p_index), - std::make_pair(q,q_index)); + *out++ = {eit->first, + std::make_pair(p,p_index), + std::make_pair(q,q_index)}; } return out; From accfc2aa3110b7399ae0516877ca99170c4f6e0a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 10 Jun 2024 12:55:27 +0200 Subject: [PATCH 09/11] convert tuple to struct for Move --- .../CGAL/Mesh_3/Mesh_global_optimizer.h | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) 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 0a3d73f0341e..3b41f515bb5b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_global_optimizer.h @@ -32,7 +32,6 @@ #include #include -#include #include @@ -74,8 +73,13 @@ class Mesh_global_optimizer_base // The sizing field info is stored inside the move vector because it is computed // when the move is computed. This is because the parallel version uses the threadsafe // version of incident_cells (which thus requires points to not be moving yet) - typedef std::vector > - Moves_vector; + struct Move + { + typename Tr::Vertex_handle vertex_; + Vector_3 move_; + FT size_; + }; + typedef std::vector Moves_vector; typedef unsigned int Nb_frozen_points_type; Mesh_global_optimizer_base(const Bbox_3 &, int) @@ -129,8 +133,14 @@ class Mesh_global_optimizer_base typedef typename GT::FT FT; typedef typename GT::Vector_3 Vector_3; typedef typename Tr::Lock_data_structure Lock_data_structure; - typedef tbb::concurrent_vector > - Moves_vector; + + struct Move + { + typename Tr::Vertex_handle vertex_; + Vector_3 move_; + FT size_; + }; + typedef tbb::concurrent_vector Moves_vector; typedef std::atomic Nb_frozen_points_type ; Mesh_global_optimizer_base(const Bbox_3 &bbox, int num_grid_cells_per_axis) @@ -411,6 +421,7 @@ class Mesh_global_optimizer { typename GT::Construct_point_3 cp = m_gt.construct_point_3_object(); typename GT::Construct_translated_point_3 translate = m_gt.construct_translated_point_3_object(); + typedef typename Moves_vector_::value_type Move; Vector_3 move = m_mgo.compute_move(oldv); if ( CGAL::NULL_VECTOR != move ) @@ -429,7 +440,7 @@ class Mesh_global_optimizer //note : this is not happening for Lloyd and ODT so it's commented // maybe for a new global optimizer it should be de-commented - m_moves.push_back(std::make_tuple(oldv, move, size)); + m_moves.push_back(Move{oldv, move, size}); } else // CGAL::NULL_VECTOR == move { @@ -517,13 +528,13 @@ class Mesh_global_optimizer { for( size_t i = r.begin() ; i != r.end() ; ++i) { - const Vertex_handle& v = std::get<0>(m_moves[i]); - const Vector_3& move = std::get<1>(m_moves[i]); + const Vertex_handle& v = m_moves[i].vertex_; + const Vector_3& move = m_moves[i].move_; // Get size at new position if ( MGO::Sizing_field::is_vertex_update_needed ) { - FT size = std::get<2>(m_moves[i]); + const FT size = m_moves[i].size_; // Move point bool could_lock_zone; @@ -846,7 +857,7 @@ compute_moves(Moving_vertices_set& moving_vertices) size = sizing_field_(new_position, oldv); } - moves.push_back(std::make_tuple(oldv, move, size)); + moves.push_back({oldv, move, size}); } else // CGAL::NULL_VECTOR == move { @@ -965,12 +976,12 @@ update_mesh(const Moves_vector& moves, it != moves.end() ; ++it ) { - const Vertex_handle& v = std::get<0>(*it); - const Vector_3& move = std::get<1>(*it); + const Vertex_handle& v = it->vertex_; + const Vector_3& move = it->move_; // Get size at new position if ( Sizing_field::is_vertex_update_needed ) { - FT size = std::get<2>(*it); + const FT size = it->size_; #ifdef CGAL_MESH_3_OPTIMIZER_VERY_VERBOSE std::cerr << "Moving #" << it - moves.begin() From 8d6d934395b9d7c1879e54aa3a7508d140a1b5e5 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 10 Jun 2024 15:52:09 +0200 Subject: [PATCH 10/11] convert tuple to struct for Facets_erase_counters --- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 73 +++++++++++--------- 1 file changed, 39 insertions(+), 34 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 35a1d972d242..2fa7fa7a3847 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -46,7 +46,7 @@ #include #include #include -#include + #include #include @@ -54,30 +54,40 @@ namespace CGAL { namespace Mesh_3 { + template + struct Facets_erase_counters + { + const Facet& f1_; + const unsigned int f1_erase_counter_; + const Facet& f2_; + const unsigned int f2_erase_counter_; + }; + // Predicate to know if a facet in a refinement queue is a zombie // A facet is a pair . // A facet is a "zombie" if at least one of its two adjacent cells // has been erased. We test it thanks to the "erase counter" which // is inside each cell (incremented by the compact container). - // In the refinement queue, we store a tuple + // In the refinement queue, we store a struct // // where facet2 = mirror_facet(facet1) and facetx_erase_counter is // the erase_counter of facetx's cell when added to the queue> template class Facet_to_refine_is_not_zombie { + typedef Facets_erase_counters Facets_ec; + public: Facet_to_refine_is_not_zombie() {} - bool operator()(const std::tuple< - Facet, unsigned int, Facet, unsigned int> &f) const + bool operator()(const Facets_ec& f) const { #ifdef _DEBUG /* - int f1_current_erase_counter = std::get<0>(f).first->erase_counter(); - int f1_saved_erase_counter = std::get<1>(f); - int f2_current_erase_counter = std::get<2>(f).first->erase_counter(); - int f2_saved_erase_counter = std::get<3>(f); + int f1_current_erase_counter = f.f1_.first->erase_counter(); + int f1_saved_erase_counter = f.f1_erase_counter_; + int f2_current_erase_counter = f.f2_.first->erase_counter(); + int f2_saved_erase_counter = f.f2_erase_counter_; */ //f1_current_erase_counter - f1_saved_erase_counter + f2_current_erase_counter - f2_saved_erase_counter == 1 @@ -89,7 +99,7 @@ namespace Mesh_3 { #endif std::stringstream sstr; - Facet facet = std::get<0>(f); + Facet facet = f.f1_; sstr << "Facet 1 { " << std::endl << " - " << *facet.first->vertex((facet.second+1)%4) << std::endl << " - " << *facet.first->vertex((facet.second+2)%4) << std::endl @@ -97,7 +107,7 @@ namespace Mesh_3 { << " - 4th vertex in cell: " << *facet.first->vertex(facet.second) << std::endl << "}" << std::endl; - facet = std::get<2>(f); + facet = f.f2_; sstr << "Facet 2 { " << std::endl << " - " << *facet.first->vertex((facet.second+1)%4) << std::endl << " - " << *facet.first->vertex((facet.second+2)%4) << std::endl @@ -109,8 +119,8 @@ namespace Mesh_3 { std::cerr << s << std::endl; }*/ #endif - return (std::get<0>(f).first->erase_counter() == std::get<1>(f) - && std::get<2>(f).first->erase_counter() == std::get<3>(f) ); + return (f.f1_.first->erase_counter() == f.f1_erase_counter_ + && f.f2_.first->erase_counter() == f.f2_erase_counter_ ); } }; @@ -123,6 +133,8 @@ namespace Mesh_3 { template class Refine_facets_3_handle_queue_base { + typedef Facets_erase_counters Facets_counters; + protected: Refine_facets_3_handle_queue_base() : m_last_vertex_index() {} @@ -139,21 +151,20 @@ class Refine_facets_3_handle_queue_base #if defined(CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE) \ || defined(CGAL_MESH_3_USE_LAZY_UNSORTED_REFINEMENT_QUEUE) - std::tuple + Facets_counters from_facet_to_refinement_queue_element(const Facet &facet, const Facet &mirror) const { - return std::make_tuple( - facet, facet.first->erase_counter(), - mirror, mirror.first->erase_counter()); + return Facets_counters{facet, facet.first->erase_counter(), + mirror, mirror.first->erase_counter()}; } public: template Facet extract_element_from_container_value(const Container_element &e) const { - // We get the first Facet inside the tuple - return std::get<0>(e); + // We get the first Facet inside the struct + return e.f1_; } #else @@ -198,21 +209,20 @@ class Refine_facets_3_handle_queue_base m_last_vertex_index.local() = i; } - std::tuple + Facets_erase_counters from_facet_to_refinement_queue_element(const Facet &facet, const Facet &mirror) const { - return std::make_tuple( - facet, facet.first->erase_counter(), - mirror, mirror.first->erase_counter()); + return Facets_erase_counters{facet, facet.first->erase_counter(), + mirror, mirror.first->erase_counter()}; } public: template Facet extract_element_from_container_value(const Container_element &e) const { - // We get the first Facet inside the tuple - return std::get<0>(e); + // We get the first Facet inside the struct + return e.f1_; } protected: @@ -667,8 +677,7 @@ template, + Facets_erase_counters, typename Criteria::Facet_quality, Facet_to_refine_is_not_zombie, Concurrency_tag @@ -677,8 +686,7 @@ template, + Facets_erase_counters, typename Criteria::Facet_quality, Facet_to_refine_is_not_zombie, Concurrency_tag @@ -686,8 +694,7 @@ template, + Facets_erase_counters, typename Criteria::Facet_quality, Facet_to_refine_is_not_zombie, Concurrency_tag @@ -705,8 +712,7 @@ template, + Facets_erase_counters, typename Criteria::Facet_quality, Facet_to_refine_is_not_zombie, Concurrency_tag @@ -714,8 +720,7 @@ template, + Facets_erase_counters, typename Criteria::Facet_quality, Facet_to_refine_is_not_zombie, Concurrency_tag From 5d814aee2ad4679168128ac9754d28d570853b5e Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 25 Jun 2024 15:16:07 +0200 Subject: [PATCH 11/11] remove ref (can become invalid) --- 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 2fa7fa7a3847..72bc54181d15 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -57,9 +57,9 @@ namespace Mesh_3 { template struct Facets_erase_counters { - const Facet& f1_; + const Facet f1_; const unsigned int f1_erase_counter_; - const Facet& f2_; + const Facet f2_; const unsigned int f2_erase_counter_; };