From b64a1718c454c323c0af907a5a89f1ad420c1503 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 16 Jun 2020 17:47:00 +0200 Subject: [PATCH 1/8] Reduce size of symbols (and debug infos) - one nested struct `Tds` in `Mesh_triangulation_3`, - rework of `Mesh_vertex_base_3` and `Compact_mesh_cell_base_3`. That reduction of debug infos and size of symbols will help the IDE and debuggers. ``` Debug info size (with gcc-9, and `-g`) ORIG AFTER RATIO FILE IN examples/Mesh_3/ 56532 55572 1.01727 mesh_3D_image_with_custom_initialization.debug 64696 63420 1.02012 mesh_cubes_intersection_with_features.debug 56700 55536 1.02096 mesh_3D_image.debug 56488 55324 1.02104 mesh_implicit_sphere.debug 56496 55332 1.02104 mesh_implicit_sphere_variable_size.debug 56776 55604 1.02108 mesh_3D_image_variable_size.debug 56520 55296 1.02214 mesh_cubes_intersection.debug 56684 55428 1.02266 mesh_3D_gray_image.debug 56796 55536 1.02269 mesh_3D_gray_image_multiple_values.debug 56732 55472 1.02271 mesh_3D_gray_vtk_image.debug 57128 55824 1.02336 mesh_optimization_example.debug 57420 56088 1.02375 mesh_optimization_lloyd_example.debug 56948 55560 1.02498 mesh_implicit_domains_2.debug 56932 55544 1.02499 mesh_implicit_domains.debug 69160 63304 1.09251 mesh_hybrid_mesh_domain.debug 72212 66088 1.09266 mesh_3D_image_with_features.debug 70172 63924 1.09774 mesh_two_implicit_spheres_with_balls.debug 75388 66128 1.14003 mesh_polyhedral_domain_sm.debug 75676 64412 1.17487 mesh_polyhedral_complex_sm.debug 81544 67772 1.20321 mesh_polyhedral_domain.debug 87456 71672 1.22023 mesh_polyhedral_domain_with_features_sm.debug 87524 71600 1.2224 remesh_polyhedral_surface_sm.debug 92332 74528 1.23889 mesh_polyhedral_complex.debug 98640 77448 1.27363 mesh_polyhedral_domain_with_lipschitz_sizing.debug 95640 74456 1.28452 mesh_polyhedral_domain_with_features.debug 95132 74000 1.28557 mesh_polyhedral_domain_with_surface_inside.debug 95724 74388 1.28682 remesh_polyhedral_surface.debug 1899448 1695256 1.12045 total ``` --- .../include/CGAL/Compact_mesh_cell_base_3.h | 241 ++++++++---------- Mesh_3/include/CGAL/Mesh_3/io_signature.h | 6 +- Mesh_3/include/CGAL/Mesh_triangulation_3.h | 41 +-- Mesh_3/include/CGAL/Mesh_vertex_base_3.h | 119 +++++---- .../CGAL/internal/Mesh_3/indices_management.h | 55 +++- 5 files changed, 239 insertions(+), 223 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 f1414264ca1..233860e9e3a 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -98,12 +98,9 @@ namespace CGAL { // Base for Compact_mesh_cell_base_3, with specializations // for different values of Concurrency_tag // Sequential -template +template class Compact_mesh_cell_base_3_base { - typedef typename GT::Point_3 Point_3; - typedef typename GT::Weighted_point_3 Point; - protected: Compact_mesh_cell_base_3_base() : bits_(0) @@ -176,11 +173,9 @@ protected: #ifdef CGAL_LINKED_WITH_TBB // Class Compact_mesh_cell_base_3_base // Specialization for parallel -template -class Compact_mesh_cell_base_3_base +template +class Compact_mesh_cell_base_3_base { - typedef typename GT::Point_3 Point_3; - protected: Compact_mesh_cell_base_3_base() { @@ -260,14 +255,16 @@ protected: // 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 GT, - class MD, - class TDS = void > -class Compact_mesh_cell_base_3 - : public Compact_mesh_cell_base_3_base +template< class Point_3, + class Weighted_point_3, + class Subdomain_index_, + class Surface_patch_index_, + class Index_, + class TDS> +class Compact_mesh_cell_3 + : public Compact_mesh_cell_base_3_base { - typedef typename GT::FT FT; - typedef Compact_mesh_cell_base_3_base Base; + typedef Compact_mesh_cell_base_3_base Base; using Base::weighted_circumcenter_; public: @@ -279,20 +276,12 @@ public: typedef typename TDS::Cell_data TDS_data; - template - struct Rebind_TDS { - typedef Compact_mesh_cell_base_3 Other; - }; - - // Index Type - typedef typename MD::Subdomain_index Subdomain_index; - typedef typename MD::Surface_patch_index Surface_patch_index; - typedef typename MD::Index Index; + typedef Subdomain_index_ Subdomain_index; + typedef Surface_patch_index_ Surface_patch_index; + typedef Index_ Index; - typedef GT Geom_traits; - typedef typename GT::Point_3 Point_3; - typedef typename GT::Weighted_point_3 Point; + typedef Weighted_point_3 Point; typedef Point* Point_container; @@ -310,20 +299,10 @@ public: public: // Constructors - Compact_mesh_cell_base_3() - : surface_index_table_() - , surface_center_table_() -#ifdef CGAL_INTRUSIVE_LIST - , next_intrusive_() - , previous_intrusive_() -#endif - , surface_center_index_table_() - , sliver_value_(FT(0.)) - , subdomain_index_() - , sliver_cache_validity_(false) + Compact_mesh_cell_3() {} - Compact_mesh_cell_base_3(const Compact_mesh_cell_base_3& rhs) + Compact_mesh_cell_3(const Compact_mesh_cell_3& rhs) : N(rhs.N) , V(rhs.V) #ifdef CGAL_INTRUSIVE_LIST @@ -342,49 +321,29 @@ public: } } - Compact_mesh_cell_base_3 (Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3) - : surface_index_table_() - , surface_center_table_() - , V(CGAL::make_array(v0, v1, v2, v3)) -#ifdef CGAL_INTRUSIVE_LIST - , next_intrusive_() - , previous_intrusive_() -#endif - , surface_center_index_table_() - , sliver_value_(FT(0.)) - , subdomain_index_() - , sliver_cache_validity_(false) + Compact_mesh_cell_3 (Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3) + : V(CGAL::make_array(v0, v1, v2, v3)) { } - Compact_mesh_cell_base_3 (Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3, - Cell_handle n0, - Cell_handle n1, - Cell_handle n2, - Cell_handle n3) - : surface_index_table_() - , surface_center_table_() - , N(CGAL::make_array(n0, n1, n2, n3)) + Compact_mesh_cell_3 (Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3, + Cell_handle n0, + Cell_handle n1, + Cell_handle n2, + Cell_handle n3) + : N(CGAL::make_array(n0, n1, n2, n3)) , V(CGAL::make_array(v0, v1, v2, v3)) -#ifdef CGAL_INTRUSIVE_LIST - , next_intrusive_() - , previous_intrusive_() -#endif - , surface_center_index_table_() - , sliver_value_(FT(0.)) - , subdomain_index_() - , sliver_cache_validity_(false) { } - ~Compact_mesh_cell_base_3() + ~Compact_mesh_cell_3() { if(!internal_tbb::compare_weighted_circumcenter(weighted_circumcenter_)){ internal_tbb::delete_circumcenter(weighted_circumcenter_); @@ -550,11 +509,6 @@ public: return *weighted_circumcenter_; } - const Point_3& weighted_circumcenter() const - { - return weighted_circumcenter(Geom_traits()); - } - // Returns the index of the cell of the input complex that contains the cell Subdomain_index subdomain_index() const { return subdomain_index_; } @@ -562,13 +516,13 @@ public: void set_subdomain_index(const Subdomain_index& index) { subdomain_index_ = index; } - void set_sliver_value(const FT& value) + void set_sliver_value(double value) { sliver_cache_validity_ = true; sliver_value_ = value; } - const FT& sliver_value() const + double sliver_value() const { CGAL_assertion(is_cache_valid()); return sliver_value_; @@ -646,6 +600,7 @@ public: static std::string io_signature() { + using Geom_traits = typename Kernel_traits::type; return Get_io_signature()() + "+" + Get_io_signature >()() @@ -683,81 +638,81 @@ private: /// Stores surface_index for each facet of the cell - std::array surface_index_table_; + std::array surface_index_table_ = {}; /// Stores surface center of each facet of the cell - std::array surface_center_table_; + std::array surface_center_table_ = {}; /// Stores surface center index of each facet of the cell std::array N; std::array V; #ifdef CGAL_INTRUSIVE_LIST - Cell_handle next_intrusive_, previous_intrusive_; + Cell_handle next_intrusive_ = {}, previous_intrusive_ = {}; #endif std::size_t time_stamp_; - std::array surface_center_index_table_; + std::array surface_center_index_table_ = {}; /// Stores visited facets (4 first bits) // Point_container _hidden; - FT sliver_value_; + double sliver_value_ = 0.; // The index of the cell of the input complex that contains me - Subdomain_index subdomain_index_; + Subdomain_index subdomain_index_ = {}; TDS_data _tds_data; - mutable bool sliver_cache_validity_; + mutable bool sliver_cache_validity_ = false; +public: -}; // end class Compact_mesh_cell_base_3 - -template < class GT, class MT, class Cb > -std::istream& -operator>>(std::istream &is, - Compact_mesh_cell_base_3 &c) -{ - typename Compact_mesh_cell_base_3::Subdomain_index index; - if(is_ascii(is)) - is >> index; - else - read(is, index); - if(is) { - c.set_subdomain_index(index); - for(int i = 0; i < 4; ++i) - { - typename Compact_mesh_cell_base_3::Surface_patch_index i2; - if(is_ascii(is)) - is >> iformat(i2); - else - { - read(is, i2); - } - c.set_surface_patch_index(i, i2); + friend std::istream& operator>>(std::istream &is, Compact_mesh_cell_3 &c) + { + Subdomain_index index; + if(is_ascii(is)) + is >> index; + else + read(is, index); + if(is) { + c.set_subdomain_index(index); + for(int i = 0; i < 4; ++i) + { + Surface_patch_index i2; + if(is_ascii(is)) + is >> iformat(i2); + else + { + read(is, i2); + } + c.set_surface_patch_index(i, i2); + } } + return is; } - return is; -} -template < class GT, class MT, class Cb > -std::ostream& -operator<<(std::ostream &os, - const Compact_mesh_cell_base_3 &c) -{ - if(is_ascii(os)) - os << c.subdomain_index(); - else - write(os, c.subdomain_index()); - for(int i = 0; i < 4; ++i) + friend + std::ostream& operator<<(std::ostream &os, const Compact_mesh_cell_3 &c) { if(is_ascii(os)) - os << ' ' << oformat(c.surface_patch_index(i)); + os << c.subdomain_index(); else - write(os, c.surface_patch_index(i)); + write(os, c.subdomain_index()); + for(int i = 0; i < 4; ++i) + { + if(is_ascii(os)) + os << ' ' << oformat(c.surface_patch_index(i)); + else + write(os, c.surface_patch_index(i)); + } + return os; } - return os; -} +}; // end class Compact_mesh_cell_3 + +template< class GT, + class MD, + class TDS = void > +class Compact_mesh_cell_base_3; // Specialization for void. template @@ -768,7 +723,35 @@ public: typedef Triangulation_data_structure::Vertex_handle Vertex_handle; typedef Triangulation_data_structure::Cell_handle Cell_handle; template - struct Rebind_TDS { typedef Compact_mesh_cell_base_3 Other; }; + struct Rebind_TDS { + typedef Compact_mesh_cell_3 Other; + }; +}; + +template +class Compact_mesh_cell_generator_3 +{ +public: + typedef internal::Dummy_tds_3 Triangulation_data_structure; + typedef Triangulation_data_structure::Vertex_handle Vertex_handle; + typedef Triangulation_data_structure::Cell_handle Cell_handle; + template + struct Rebind_TDS { + typedef Compact_mesh_cell_3 Other; + }; }; } // end namespace CGAL diff --git a/Mesh_3/include/CGAL/Mesh_3/io_signature.h b/Mesh_3/include/CGAL/Mesh_3/io_signature.h index d871b8ffe7d..2c0f02ab3b0 100644 --- a/Mesh_3/include/CGAL/Mesh_3/io_signature.h +++ b/Mesh_3/include/CGAL/Mesh_3/io_signature.h @@ -219,12 +219,10 @@ struct Get_io_signature > }; #ifdef CGAL_TRIANGULATION_3_H -template +template struct -Get_io_signature > > +Get_io_signature > { - typedef Triangulation_data_structure_3 Tds; - std::string operator()() { return std::string("Triangulation_3(") + Get_io_signature()() + diff --git a/Mesh_3/include/CGAL/Mesh_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_triangulation_3.h index 8d5373b1bd7..3e2deb00d10 100644 --- a/Mesh_3/include/CGAL/Mesh_triangulation_3.h +++ b/Mesh_3/include/CGAL/Mesh_triangulation_3.h @@ -133,52 +133,25 @@ struct Mesh_triangulation_3 private: typedef typename Default::Lazy_get >::type K; - typedef typename details::Mesh_geom_traits_generator::type Geom_traits; + typedef typename details::Mesh_geom_traits_generator::type Geom_traits; typedef typename Default::Get< Vertex_base_, - Mesh_vertex_base_3 >::type Vertex_base; + Mesh_vertex_generator_3 >::type Vertex_base; typedef typename Default::Get< Cell_base_, - Compact_mesh_cell_base_3 >::type Cell_base; + Compact_mesh_cell_generator_3 >::type Cell_base; - typedef Triangulation_data_structure_3 Tds; + struct Tds : public Triangulation_data_structure_3 {}; typedef Mesh_3_regular_triangulation_3_wrapper Triangulation; public: typedef Triangulation type; typedef type Type; }; // end struct Mesh_triangulation_3 - -#ifdef CGAL_LINKED_WITH_TBB -// Parallel version (specialization) -// -template -struct Mesh_triangulation_3 -{ -private: - typedef typename Default::Get::Kernel>::type K; - - typedef typename details::Mesh_geom_traits_generator::type Geom_traits; - - typedef typename Default::Get< - Vertex_base_, - Mesh_vertex_base_3 >::type Vertex_base; - typedef typename Default::Get< - Cell_base_, - Compact_mesh_cell_base_3 >::type Cell_base; - - typedef Triangulation_data_structure_3< - Vertex_base, Cell_base, Parallel_tag> Tds; - typedef Mesh_3_regular_triangulation_3_wrapper Triangulation; - -public: - typedef Triangulation type; - typedef type Type; -}; // end struct Mesh_triangulation_3 -#endif // CGAL_LINKED_WITH_TBB - } // end namespace CGAL #include diff --git a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h index aeb3411a1e1..ffadc01ff66 100644 --- a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h @@ -92,9 +92,9 @@ protected: // Adds information to Vb about the localization of the vertex in regards // to the 3D input complex. template > -class Mesh_vertex_base_3 +class Mesh_vertex_3 : public Vb, public Mesh_vertex_base_3_base< typename Vb::Triangulation_data_structure::Concurrency_tag> @@ -103,19 +103,12 @@ public: typedef Vb Cmvb3_base; typedef typename Vb::Vertex_handle Vertex_handle; - // To get correct vertex type in TDS - template < class TDS3 > - struct Rebind_TDS { - typedef typename Vb::template Rebind_TDS::Other Vb3; - typedef Mesh_vertex_base_3 Other; - }; - // Types - typedef typename MD::Index Index; - typedef typename GT::FT FT; + typedef Index_ Index; + typedef typename GT::FT FT; // Constructor - Mesh_vertex_base_3() + Mesh_vertex_3() : Vb() , number_of_incident_facets_(0) , number_of_components_(0) @@ -248,56 +241,72 @@ private: Vertex_handle previous_intrusive_; #endif std::size_t time_stamp_; +public: -}; // end class Mesh_vertex_base_3 + friend std::istream& operator>>(std::istream &is, Mesh_vertex_3& v) + { + is >> static_cast(v); + int dimension; + if(is_ascii(is)) { + is >> dimension; + + } else { + CGAL::read(is, dimension); + } + v.set_dimension(dimension); + CGAL_assertion(v.in_dimension() >= -1); + CGAL_assertion(v.in_dimension() < 4); + Index index = + Mesh_3::internal::Read_write_index()(is, v.in_dimension()); + v.set_index(index); + return is; + } + + friend std::ostream& operator<<(std::ostream &os, const Mesh_vertex_3& v) + { + os << static_cast(v); + if(is_ascii(os)) { + os << " " << v.in_dimension() + << " "; + } else { + CGAL::write(os, v.in_dimension()); + } + Mesh_3::internal::Read_write_index()(os, + v.in_dimension(), + v.index()); + return os; + } +}; // end class Mesh_vertex_3 template -inline -std::istream& -operator>>(std::istream &is, Mesh_vertex_base_3& v) -{ - typedef Mesh_vertex_base_3 Vertex; - typedef typename Vertex::Cmvb3_base Cmvb3_base; - is >> static_cast(v); - int dimension; - if(is_ascii(is)) { - is >> dimension; + class Vb = Regular_triangulation_vertex_base_3 > +struct Mesh_vertex_base_3 { + typedef internal::Dummy_tds_3 Triangulation_data_structure; + typedef Triangulation_data_structure::Vertex_handle Vertex_handle; + typedef Triangulation_data_structure::Cell_handle Cell_handle; - } else { - CGAL::read(is, dimension); - } - v.set_dimension(dimension); - CGAL_assertion(v.in_dimension() >= -1); - CGAL_assertion(v.in_dimension() < 4); - typename Vertex::Index index = - Mesh_3::internal::Read_mesh_domain_index()(v.in_dimension(), is); - v.set_index(index); - return is; -} + template < class TDS3 > + struct Rebind_TDS { + typedef typename Vb::template Rebind_TDS::Other Vb3; + typedef Mesh_vertex_3 Other; + }; +}; template -inline -std::ostream& -operator<<(std::ostream &os, const Mesh_vertex_base_3& v) -{ - typedef Mesh_vertex_base_3 Vertex; - typedef typename Vertex::Cmvb3_base Cmvb3_base; - os << static_cast(v); - if(is_ascii(os)) { - os << " " << v.in_dimension() - << " "; - } else { - CGAL::write(os, v.in_dimension()); - } - Mesh_3::internal::Write_mesh_domain_index()(os, - v.in_dimension(), - v.index()); - return os; -} + class Index, + class Vb = Regular_triangulation_vertex_base_3 > +struct Mesh_vertex_generator_3 { + typedef internal::Dummy_tds_3 Triangulation_data_structure; + typedef Triangulation_data_structure::Vertex_handle Vertex_handle; + typedef Triangulation_data_structure::Cell_handle Cell_handle; + + template < class TDS3 > + struct Rebind_TDS { + typedef typename Vb::template Rebind_TDS::Other Vb3; + typedef Mesh_vertex_3 Other; + }; +}; } // end namespace CGAL diff --git a/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h b/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h index 62bde6e2135..adb52c0ef69 100644 --- a/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h +++ b/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h @@ -23,7 +23,9 @@ #include #include -#include +#include +#include +#include #include #include @@ -245,6 +247,57 @@ struct Write_mesh_domain_index { }; // end template partial specialization // Write_mesh_domain_index +template +struct Read_write_index { + void operator()(std::ostream& os, int, Index index) const { + if(is_ascii(os)) os << oformat(index); + else CGAL::write(os, index); + } + Index operator()(std::istream& is, int) const { + Index index; + if(is_ascii(is)) is >> iformat(index); + else CGAL::read(is, index); + return index; + } +}; + +struct Variant_write_visitor { + std::ostream& os; + template + void operator()(T v) const { + if(is_ascii(os)) os << CGAL::oformat(v); + else CGAL::write(os, v); + } +}; + +template +struct Variant_read_visitor { + std::istream& is; + boost::variant& variant; + template + void operator()(T) const { + T v; + if(is_ascii(is)) is >> CGAL::iformat(v); + else CGAL::read(is, v); + variant = v; + } +}; +template +struct Read_write_index> { + using Index = boost::variant; + void operator()(std::ostream& os, int, Index index) const { + Variant_write_visitor visitor{os}; + apply_visitor(visitor, index); + } + Index operator()(std::istream& is, int dimension) const { + static const Index variants[] = { Args{}... }; + Index index = variants[dimension]; + Variant_read_visitor visitor{is, index}; + apply_visitor(visitor, index); + return index; + } +}; + } // end namespace internal } // end namespace Mesh_3 } // end namespace CGAL From 86496e469eafceacb2a8163f5ec1d57422ddc541 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 16 Jun 2020 21:56:07 +0200 Subject: [PATCH 2/8] Repair the I/O of Mesh_vertex_3 --- Mesh_3/include/CGAL/Mesh_triangulation_3.h | 21 +++++---- Mesh_3/include/CGAL/Mesh_vertex_base_3.h | 32 +++++++------ .../CGAL/internal/Mesh_3/indices_management.h | 46 +++++++++++++++---- 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_triangulation_3.h index 3e2deb00d10..28c880c8005 100644 --- a/Mesh_3/include/CGAL/Mesh_triangulation_3.h +++ b/Mesh_3/include/CGAL/Mesh_triangulation_3.h @@ -131,26 +131,29 @@ template >::type K; + using K = typename Default::Lazy_get >::type; - typedef typename details::Mesh_geom_traits_generator::type Geom_traits; + using Geom_traits = typename details::Mesh_geom_traits_generator::type; - typedef typename Default::Get< + using Indices_tuple = Mesh_3::internal::Indices_tuple_t; + using Vertex_base = typename Default::Get< Vertex_base_, - Mesh_vertex_generator_3 >::type Vertex_base; - typedef typename Default::Get< + Mesh_vertex_generator_3 >::type; + using Cell_base = typename Default::Get< Cell_base_, Compact_mesh_cell_generator_3 >::type Cell_base; + typename MD::Index> >::type; struct Tds : public Triangulation_data_structure_3 {}; - typedef Mesh_3_regular_triangulation_3_wrapper Triangulation; + using Triangulation = Mesh_3_regular_triangulation_3_wrapper;; public: - typedef Triangulation type; - typedef type Type; + using type = Triangulation; + using Type = type;; }; // end struct Mesh_triangulation_3 } // end namespace CGAL diff --git a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h index ffadc01ff66..ecb1f9464c5 100644 --- a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h @@ -24,7 +24,7 @@ #include -#include +#include #include #include #include @@ -92,8 +92,9 @@ protected: // Adds information to Vb about the localization of the vertex in regards // to the 3D input complex. template > + class Vb> class Mesh_vertex_3 : public Vb, public Mesh_vertex_base_3_base< @@ -257,7 +258,8 @@ public: CGAL_assertion(v.in_dimension() >= -1); CGAL_assertion(v.in_dimension() < 4); Index index = - Mesh_3::internal::Read_write_index()(is, v.in_dimension()); + Mesh_3::internal::Read_write_index()(is, v.in_dimension()); v.set_index(index); return is; } @@ -271,7 +273,8 @@ public: } else { CGAL::write(os, v.in_dimension()); } - Mesh_3::internal::Read_write_index()(os, + Mesh_3::internal::Read_write_index()(os, v.in_dimension(), v.index()); return os; @@ -282,29 +285,32 @@ template > struct Mesh_vertex_base_3 { - typedef internal::Dummy_tds_3 Triangulation_data_structure; - typedef Triangulation_data_structure::Vertex_handle Vertex_handle; - typedef Triangulation_data_structure::Cell_handle Cell_handle; + using Triangulation_data_structure = internal::Dummy_tds_3; + using Vertex_handle = typename Triangulation_data_structure::Vertex_handle; + using Cell_handle = typename Triangulation_data_structure::Cell_handle; template < class TDS3 > struct Rebind_TDS { - typedef typename Vb::template Rebind_TDS::Other Vb3; - typedef Mesh_vertex_3 Other; + using Vb3 = typename Vb::template Rebind_TDS::Other; + using Other = Mesh_vertex_3 , + typename MD::Index, Vb3>; }; }; template > struct Mesh_vertex_generator_3 { - typedef internal::Dummy_tds_3 Triangulation_data_structure; - typedef Triangulation_data_structure::Vertex_handle Vertex_handle; - typedef Triangulation_data_structure::Cell_handle Cell_handle; + using Triangulation_data_structure = internal::Dummy_tds_3; + using Vertex_handle = typename Triangulation_data_structure::Vertex_handle; + using Cell_handle = typename Triangulation_data_structure::Cell_handle; template < class TDS3 > struct Rebind_TDS { typedef typename Vb::template Rebind_TDS::Other Vb3; - typedef Mesh_vertex_3 Other; + typedef Mesh_vertex_3 Other; }; }; diff --git a/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h b/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h index adb52c0ef69..a8b9d25da4d 100644 --- a/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h +++ b/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h @@ -29,6 +29,8 @@ #include #include +#include + namespace CGAL { namespace Mesh_3 { namespace internal { @@ -51,6 +53,26 @@ struct Index_generator typedef Index type; }; +template ::value> +struct Indices_tuple_generator +{ + using type = std::tuple; +}; + +template +struct Indices_tuple_generator +{ + using type = std::tuple; +}; + +template +using Indices_tuple_t = typename Indices_tuple_generator::type; + // Nasty meta-programming to get a boost::variant of four types that // may not be all different. template struct seq1 { @@ -247,7 +269,7 @@ struct Write_mesh_domain_index { }; // end template partial specialization // Write_mesh_domain_index -template +template struct Read_write_index { void operator()(std::ostream& os, int, Index index) const { if(is_ascii(os)) os << oformat(index); @@ -270,10 +292,10 @@ struct Variant_write_visitor { } }; -template +template struct Variant_read_visitor { std::istream& is; - boost::variant& variant; + Index& variant; template void operator()(T) const { T v; @@ -282,17 +304,25 @@ struct Variant_read_visitor { variant = v; } }; -template -struct Read_write_index> { + +template +struct Read_write_index> { using Index = boost::variant; + using index_seq = std::make_index_sequence; + + template + Index get_index(int dimension, std::index_sequence) const{ + static const Index variants[] = { std::tuple_element_t{}... }; + return variants[3-dimension]; + } + void operator()(std::ostream& os, int, Index index) const { Variant_write_visitor visitor{os}; apply_visitor(visitor, index); } Index operator()(std::istream& is, int dimension) const { - static const Index variants[] = { Args{}... }; - Index index = variants[dimension]; - Variant_read_visitor visitor{is, index}; + Index index = get_index(dimension, index_seq{}); + Variant_read_visitor visitor{is, index}; apply_visitor(visitor, index); return index; } From e44d58a49c15c1e4fa676a57b256bebdc891d237 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 17 Jun 2020 10:22:51 +0200 Subject: [PATCH 3/8] Fix a bug in this PR The number of type in `Indices_tuple` and `Index` may differ: one is a list of types, and the other one is more like a set of types. --- Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h b/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h index a8b9d25da4d..06333638445 100644 --- a/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h +++ b/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h @@ -308,7 +308,7 @@ struct Variant_read_visitor { template struct Read_write_index> { using Index = boost::variant; - using index_seq = std::make_index_sequence; + using index_seq = std::make_index_sequence::value>; template Index get_index(int dimension, std::index_sequence) const{ From 3895932005790e69122ecdf06ce4ea561478b064 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 25 Jun 2020 16:56:37 +0200 Subject: [PATCH 4/8] Fix the TDS: restore the concurrency tag --- Mesh_3/include/CGAL/Mesh_triangulation_3.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_triangulation_3.h index 28c880c8005..44414b7d487 100644 --- a/Mesh_3/include/CGAL/Mesh_triangulation_3.h +++ b/Mesh_3/include/CGAL/Mesh_triangulation_3.h @@ -148,8 +148,11 @@ private: typename MD::Surface_patch_index, typename MD::Index> >::type; - struct Tds : public Triangulation_data_structure_3 {}; - using Triangulation = Mesh_3_regular_triangulation_3_wrapper;; + struct Tds : public Triangulation_data_structure_3 {}; + using Triangulation = + Mesh_3_regular_triangulation_3_wrapper; + ; public: using type = Triangulation; From 9a0f310e6bd008a6ec8852047b96d1bb75681c96 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 29 Jul 2020 16:40:48 +0200 Subject: [PATCH 5/8] Fix IO of Mesh_vertex_3: case of dimension -1 I forgot that dimension() can be -1, for far points. It has to be dealt with in I/O. --- Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h b/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h index 06333638445..fdb84a6c82b 100644 --- a/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h +++ b/Mesh_3/include/CGAL/internal/Mesh_3/indices_management.h @@ -313,7 +313,7 @@ struct Read_write_index> { template Index get_index(int dimension, std::index_sequence) const{ static const Index variants[] = { std::tuple_element_t{}... }; - return variants[3-dimension]; + return variants[dimension < 0 ? 0 : 3-dimension]; } void operator()(std::ostream& os, int, Index index) const { From 40a0a1bf49074677ad15750fa1a25af041e8d45f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 29 Jul 2020 16:41:37 +0200 Subject: [PATCH 6/8] Allow the use of Default as concurrency tag in Mesh_triangulation_3 That is used in Tetrahedral_remeshing. --- Mesh_3/include/CGAL/Mesh_triangulation_3.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_triangulation_3.h index 44414b7d487..7bc643f4444 100644 --- a/Mesh_3/include/CGAL/Mesh_triangulation_3.h +++ b/Mesh_3/include/CGAL/Mesh_triangulation_3.h @@ -120,14 +120,9 @@ public: // template -struct Mesh_triangulation_3; - -// Sequential version (default) -template struct Mesh_triangulation_3 { private: @@ -147,7 +142,8 @@ private: typename MD::Subdomain_index, typename MD::Surface_patch_index, typename MD::Index> >::type; - + using Concurrency_tag = + typename Default::Get::type; struct Tds : public Triangulation_data_structure_3 {}; using Triangulation = @@ -156,7 +152,7 @@ private: public: using type = Triangulation; - using Type = type;; + using Type = type; }; // end struct Mesh_triangulation_3 } // end namespace CGAL From dd383217f2bd86ff38d8b83b417a064f9e3e150c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 29 Jul 2020 16:42:10 +0200 Subject: [PATCH 7/8] Avoid a race-condition between two tests using the same I/O file --- Mesh_3/test/Mesh_3/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Mesh_3/test/Mesh_3/CMakeLists.txt b/Mesh_3/test/Mesh_3/CMakeLists.txt index d731e12d4e4..98cfb1e2b23 100644 --- a/Mesh_3/test/Mesh_3/CMakeLists.txt +++ b/Mesh_3/test/Mesh_3/CMakeLists.txt @@ -118,6 +118,12 @@ if ( CGAL_FOUND ) endforeach() endif() + if(BUILD_TESTING) + set_tests_properties( + execution___of__test_meshing_polyhedron_with_features + execution___of__test_meshing_verbose + PROPERTIES RESOURCE_LOCK Mesh_3_Tests_IO) + endif() else() message(STATUS "This program requires the CGAL library, and will not be compiled.") From 1b2f4398be21ff1fe923c35ca08956a636aaf6c2 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 30 Jul 2020 10:37:39 +0200 Subject: [PATCH 8/8] Fix C3t3 RIB exporter @maxGimeno Should not we remove that plugin, by the way? Why do we have an exporter of c3t3 for RenderMan? --- .../Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp index f622cfa4862..795f6a247f9 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp @@ -732,8 +732,8 @@ void C3t3_rib_exporter_plugin:: write_surface_cells(const C3t3& c3t3, const Plane& /* plane */, std::ofstream& out) { - Geom_traits::Construct_point_3 wp2p - = c3t3.triangulation().geom_traits().construct_point_3_object(); + const Geom_traits& gt = c3t3.triangulation().geom_traits(); + Geom_traits::Construct_point_3 wp2p = gt.construct_point_3_object(); for ( C3t3::Cells_in_complex_iterator it_cell = c3t3.cells_in_complex_begin(), end = c3t3.cells_in_complex_end() ; it_cell != end ; ++it_cell ) @@ -755,7 +755,7 @@ write_surface_cells(const C3t3& c3t3, const Plane& /* plane */, std::ofstream& o //const int TRANSPARENCY_ALPHA_VALUE = 100; CGAL::Bbox_3 bbox = c3t3.bbox(); - float relPos = static_cast((c->weighted_circumcenter().x() - bbox.xmin()) + float relPos = static_cast((c->weighted_circumcenter(gt).x() - bbox.xmin()) / (bbox.xmax() - bbox.xmin())); float TRANSPARENCY_ALPHA_VALUE = 1.f -