From 4f0d883b27d299a1454775429b0af8c0083cfb9d Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 16 Aug 2019 16:01:26 +0200 Subject: [PATCH 01/86] WIP map_getter helper --- .../CGAL/boost/graph/named_params_helper.h | 73 +++++++++++++++++++ .../connected_components.h | 16 +++- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index bf8c2c606da..b1c96ab8127 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -112,8 +113,80 @@ namespace CGAL { typedef typename boost::property_traits::value_type type; }; + namespace internal_np + { + //overloads used to select a default map: + // use the one passed in the named parameters (user must have initialized it) + template + MapFromNP + get_map(MapFromNP m, Default_tag, Dynamic_tag, const Mesh&) + { + return m; + } + + // use the one internal to the mesh (user must have initialized it) + template + typename boost::property_map::const_type + get_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m) + { + return get(t,m); + } + + // create a dynamic property and initialize it + template + typename boost::property_map::const_type + get_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m) + { + return get(t,m); + } + + }//end of internal_np + namespace Polygon_mesh_processing { + template + class GetMapFromNP { + private : + const Tag tag; + const Dynamic_tag dtag; + const Mesh& m; + const NamedParameters& np; + const Parameter p; + + public: + //get the Default tag : + //if Mesh has an internal property map for Tag, use Tag, else use the Dynamic_tag. + typedef typename boost::mpl::if_c::value + , Tag + , Dynamic_tag + >::type Final_tag; + + //If Parameter is in NamedParameters, take the NP map. + //Else, take the default map. + typedef typename internal_np::Lookup_named_param_def< + Parameter, + NamedParameters, + typename boost::property_map::const_type + > ::type PropertyMapType; + + + GetMapFromNP(const Tag tag, + const Dynamic_tag dtag, + const Mesh& m, + const NamedParameters& np, + const Parameter p) + : tag(tag), dtag(dtag), m(m), np(np), p(p) {} + + + PropertyMapType property_map() + { + return internal_np::get_map( + parameters::get_parameter(np, p), + tag, + dtag, + m); + } + }; template class GetVertexPointMap diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 16375ee9673..78a08d36689 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -232,9 +232,19 @@ connected_components(const PolygonMesh& pmesh, FiniteDual finite_dual(dual, internal::No_border(pmesh, ecmap)); - typename GetFaceIndexMap::const_type - fimap = choose_parameter(get_parameter(np, internal_np::face_index), - get_const_property_map(boost::face_index, pmesh)); + typedef CGAL::Polygon_mesh_processing::GetMapFromNP, + PolygonMesh, NamedParameters, internal_np::face_index_t> MapGetter; + + MapGetter get_map(boost::face_index_t(), + CGAL::dynamic_face_property_t(), + pmesh, np, internal_np::face_index); + + typename MapGetter::PropertyMapType fimap = get_map.property_map(); + + //typename GetFaceIndexMap::const_type + // fimap = choose_parameter(get_parameter(np, internal_np::face_index), + // get_const_property_map(boost::face_index, pmesh)); return boost::connected_components(finite_dual, fcm, From a8bccc6e414f5995ae26e2e54ae56c51656ba730 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 19 Aug 2019 12:55:17 +0200 Subject: [PATCH 02/86] restore the bool parameter and use ittogether with the `init_XXX_indices` helper functions. --- BGL/include/CGAL/boost/graph/named_params_helper.h | 13 ++++++++----- .../Polygon_mesh_processing/connected_components.h | 9 ++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index b1c96ab8127..772ff39e31f 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -119,24 +119,27 @@ namespace CGAL { // use the one passed in the named parameters (user must have initialized it) template MapFromNP - get_map(MapFromNP m, Default_tag, Dynamic_tag, const Mesh&) + get_map(MapFromNP m, Default_tag, Dynamic_tag, const Mesh&, bool& need_init) { + need_init = false; return m; } // use the one internal to the mesh (user must have initialized it) template typename boost::property_map::const_type - get_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m) + get_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m, bool& need_init) { + need_init = false; return get(t,m); } // create a dynamic property and initialize it template typename boost::property_map::const_type - get_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m) + get_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m, bool& need_init) { + need_init = true; return get(t,m); } @@ -178,13 +181,13 @@ namespace CGAL { : tag(tag), dtag(dtag), m(m), np(np), p(p) {} - PropertyMapType property_map() + PropertyMapType property_map(bool& need_init) { return internal_np::get_map( parameters::get_parameter(np, p), tag, dtag, - m); + m, need_init); } }; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 78a08d36689..6b57ae7bf62 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -240,11 +240,10 @@ connected_components(const PolygonMesh& pmesh, CGAL::dynamic_face_property_t(), pmesh, np, internal_np::face_index); - typename MapGetter::PropertyMapType fimap = get_map.property_map(); - - //typename GetFaceIndexMap::const_type - // fimap = choose_parameter(get_parameter(np, internal_np::face_index), - // get_const_property_map(boost::face_index, pmesh)); + bool need_init = false; + typename MapGetter::PropertyMapType fimap = get_map.property_map(need_init); + if(need_init) + CGAL::helpers::init_face_indices(pmesh, fimap); return boost::connected_components(finite_dual, fcm, From d285d4aae26ca669bffd0066084227cbf1fa3182 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 4 Sep 2019 13:47:35 +0200 Subject: [PATCH 03/86] Fix mechanism and adapt cc test for polyhedron with no id --- .../CGAL/boost/graph/named_params_helper.h | 7 +++---- .../connected_components.h | 17 ++++++++++++++--- .../connected_component_polyhedron.cpp | 9 ++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 772ff39e31f..c5714f0d7d6 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -150,7 +150,6 @@ namespace CGAL { template class GetMapFromNP { private : - const Tag tag; const Dynamic_tag dtag; const Mesh& m; const NamedParameters& np; @@ -173,19 +172,19 @@ namespace CGAL { > ::type PropertyMapType; - GetMapFromNP(const Tag tag, + GetMapFromNP(const Tag, const Dynamic_tag dtag, const Mesh& m, const NamedParameters& np, const Parameter p) - : tag(tag), dtag(dtag), m(m), np(np), p(p) {} + : dtag(dtag), m(m), np(np), p(p) {} PropertyMapType property_map(bool& need_init) { return internal_np::get_map( parameters::get_parameter(np, p), - tag, + Final_tag(), dtag, m, need_init); } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 6b57ae7bf62..e75506d4b55 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -317,9 +317,20 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, using parameters::get_parameter; // FaceIndexMap - typedef typename GetFaceIndexMap::type FaceIndexMap; - FaceIndexMap fimap = choose_parameter(get_parameter(np, internal_np::face_index), - get_property_map(boost::face_index, pmesh)); + typedef CGAL::Polygon_mesh_processing::GetMapFromNP, + PolygonMesh, NamedParameters, internal_np::face_index_t> MapGetter; + + typedef typename MapGetter::PropertyMapType FaceIndexMap; + + MapGetter get_map(boost::face_index_t(), + CGAL::dynamic_face_property_t(), + pmesh, np, internal_np::face_index); + + bool need_init = false; + FaceIndexMap fimap = get_map.property_map(need_init); + if(need_init) + CGAL::helpers::init_face_indices(pmesh, fimap); // FaceSizeMap typedef typename internal_np::Lookup_named_param_def::type vim + boost::property_map::type vim = get(boost::vertex_external_index,sm); - boost::property_map::type fim + boost::property_map::type fim = get(boost::face_external_index,sm); boost::vector_property_map::type> fccmap(fim); - std::size_t num = PMP::connected_components(sm, fccmap, PMP::parameters::face_index_map(fim)); + std::size_t num = PMP::connected_components(sm, fccmap); if (strcmp(argv1, "data/blobby_3cc.off") == 0) assert(num == 3); @@ -91,8 +91,7 @@ void mesh_no_id(const char* argv1, const bool save_output) // std::cout << &*f << " in connected component " << fccmap[f] << std::endl; //} - PMP::keep_largest_connected_components(sm, 2, PMP::parameters::vertex_index_map(vim) - .face_index_map(fim)); + PMP::keep_largest_connected_components(sm, 2, PMP::parameters::vertex_index_map(vim)); if (save_output) return; From d18191db46b1ebd9151020ef6bd1c926a7801396 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 24 Sep 2019 14:15:01 +0200 Subject: [PATCH 04/86] rename helper and add detect if map is writable (need_init is true in that case) --- .../CGAL/boost/graph/named_params_helper.h | 23 ++++++++++++++++--- .../connected_components.h | 6 ++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index c5714f0d7d6..1a1639f0209 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -115,6 +115,22 @@ namespace CGAL { namespace internal_np { + + template + bool is_pmap_writable(PMapCategory) + { + return false; + } + template<> + bool is_pmap_writable(boost::read_write_property_map_tag) + { + return true; + } + template<> + bool is_pmap_writable(boost::writable_property_map_tag) + { + return true; + } //overloads used to select a default map: // use the one passed in the named parameters (user must have initialized it) template @@ -130,7 +146,7 @@ namespace CGAL { typename boost::property_map::const_type get_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m, bool& need_init) { - need_init = false; + need_init = is_pmap_writable(typename boost::property_traits::const_type>::category()); return get(t,m); } @@ -139,6 +155,7 @@ namespace CGAL { typename boost::property_map::const_type get_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m, bool& need_init) { + need_init = true; return get(t,m); } @@ -148,7 +165,7 @@ namespace CGAL { namespace Polygon_mesh_processing { template - class GetMapFromNP { + class Get_index_map_from_NP { private : const Dynamic_tag dtag; const Mesh& m; @@ -172,7 +189,7 @@ namespace CGAL { > ::type PropertyMapType; - GetMapFromNP(const Tag, + Get_index_map_from_NP(const Tag, const Dynamic_tag dtag, const Mesh& m, const NamedParameters& np, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index e75506d4b55..5f4b00a7c62 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -232,7 +232,7 @@ connected_components(const PolygonMesh& pmesh, FiniteDual finite_dual(dual, internal::No_border(pmesh, ecmap)); - typedef CGAL::Polygon_mesh_processing::GetMapFromNP, PolygonMesh, NamedParameters, internal_np::face_index_t> MapGetter; @@ -240,7 +240,7 @@ connected_components(const PolygonMesh& pmesh, CGAL::dynamic_face_property_t(), pmesh, np, internal_np::face_index); - bool need_init = false; + bool need_init; typename MapGetter::PropertyMapType fimap = get_map.property_map(need_init); if(need_init) CGAL::helpers::init_face_indices(pmesh, fimap); @@ -317,7 +317,7 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, using parameters::get_parameter; // FaceIndexMap - typedef CGAL::Polygon_mesh_processing::GetMapFromNP, PolygonMesh, NamedParameters, internal_np::face_index_t> MapGetter; From 5a4dc7733c2492c020a253efd91df3ab96ded5e3 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 24 Sep 2019 15:39:01 +0200 Subject: [PATCH 05/86] blah --- .../include/CGAL/Polygon_mesh_processing/connected_components.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 5f4b00a7c62..72c9c708dc0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -327,7 +327,7 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, CGAL::dynamic_face_property_t(), pmesh, np, internal_np::face_index); - bool need_init = false; + bool need_init; FaceIndexMap fimap = get_map.property_map(need_init); if(need_init) CGAL::helpers::init_face_indices(pmesh, fimap); From bf0e52cf6e73cd5fb89b17b57d162cff9cf383da Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 24 Sep 2019 16:36:57 +0200 Subject: [PATCH 06/86] Incorporate the initialization of the map to the helpers. --- .../CGAL/boost/graph/named_params_helper.h | 103 ++++++++++++++---- .../connected_components.h | 12 +- 2 files changed, 82 insertions(+), 33 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 1a1639f0209..37f8a1f0b78 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -115,49 +115,106 @@ namespace CGAL { namespace internal_np { + template + struct MapInitializer{ + void operator()(PMap, const Graph& ) + {} + }; + + template + struct MapInitializer{ + void operator()( PMap, const Graph& ) + { + //do nothing. + } + }; + + template< class PMap, class Graph> + struct MapInitializer< + typename boost::graph_traits::vertex_descriptor, + PMap, Graph, + CGAL::Tag_true>{ + void operator()(PMap map, const Graph& g) + { + CGAL::helpers::init_vertex_indices(g, map); + } + }; + + template< class PMap, class Graph> + struct MapInitializer< + typename boost::graph_traits::halfedge_descriptor, + PMap, Graph, + CGAL::Tag_true>{ + void operator()(PMap map, const Graph& g) + { + CGAL::helpers::init_halfedge_indices(g, map); + } + }; + + template< class PMap, class Graph> + struct MapInitializer< + typename boost::graph_traits::face_descriptor, + PMap, Graph, + CGAL::Tag_true>{ + void operator()(PMap map,const Graph& g) + { + CGAL::helpers::init_face_indices(g, map); + } + }; template - bool is_pmap_writable(PMapCategory) - { - return false; - } + struct Is_pmap_writable{ + typedef CGAL::Tag_false result; + }; + template<> - bool is_pmap_writable(boost::read_write_property_map_tag) - { - return true; - } + struct Is_pmap_writable{ + typedef CGAL::Tag_true result; + }; + template<> - bool is_pmap_writable(boost::writable_property_map_tag) - { - return true; - } + struct Is_pmap_writable{ + typedef CGAL::Tag_true result; + }; //overloads used to select a default map: // use the one passed in the named parameters (user must have initialized it) template MapFromNP - get_map(MapFromNP m, Default_tag, Dynamic_tag, const Mesh&, bool& need_init) + get_map(MapFromNP m, Default_tag, Dynamic_tag, const Mesh&) { - need_init = false; return m; } // use the one internal to the mesh (user must have initialized it) template typename boost::property_map::const_type - get_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m, bool& need_init) + get_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m) { - need_init = is_pmap_writable(typename boost::property_traits::const_type>::category()); - return get(t,m); + typename boost::property_map::const_type map = get(t, m); + MapInitializer< + typename boost::property_traits::const_type>::key_type, + typename boost::property_map::const_type, + Mesh, + typename Is_pmap_writable< + typename boost::property_traits + + ::const_type>::category>::result> + ()(map, m); + return map; } // create a dynamic property and initialize it template typename boost::property_map::const_type - get_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m, bool& need_init) + get_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m) { - - need_init = true; - return get(t,m); + typename boost::property_map::const_type map = get(t,m); + MapInitializer< + typename boost::property_traits::const_type>::key_type, + typename boost::property_map::const_type, + Mesh, + CGAL::Tag_true>()(map, m); + return map; } }//end of internal_np @@ -197,13 +254,13 @@ namespace CGAL { : dtag(dtag), m(m), np(np), p(p) {} - PropertyMapType property_map(bool& need_init) + PropertyMapType property_map() { return internal_np::get_map( parameters::get_parameter(np, p), Final_tag(), dtag, - m, need_init); + m); } }; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 72c9c708dc0..d80320ce963 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -240,11 +240,7 @@ connected_components(const PolygonMesh& pmesh, CGAL::dynamic_face_property_t(), pmesh, np, internal_np::face_index); - bool need_init; - typename MapGetter::PropertyMapType fimap = get_map.property_map(need_init); - if(need_init) - CGAL::helpers::init_face_indices(pmesh, fimap); - + typename MapGetter::PropertyMapType fimap = get_map.property_map(); return boost::connected_components(finite_dual, fcm, boost::vertex_index_map(fimap) @@ -327,11 +323,7 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, CGAL::dynamic_face_property_t(), pmesh, np, internal_np::face_index); - bool need_init; - FaceIndexMap fimap = get_map.property_map(need_init); - if(need_init) - CGAL::helpers::init_face_indices(pmesh, fimap); - + FaceIndexMap fimap = get_map.property_map(); // FaceSizeMap typedef typename internal_np::Lookup_named_param_def Date: Thu, 26 Sep 2019 11:56:19 +0200 Subject: [PATCH 07/86] Wrap the mechanism in 3 functions with 3 types to reduce the number of template parameters to 2. --- .../CGAL/boost/graph/named_params_helper.h | 93 +++++++++++++------ .../connected_components.h | 23 +---- 2 files changed, 71 insertions(+), 45 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 37f8a1f0b78..c4b932aea9b 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -116,21 +116,13 @@ namespace CGAL { namespace internal_np { template - struct MapInitializer{ + struct Index_map_initializer{ void operator()(PMap, const Graph& ) {} }; - template - struct MapInitializer{ - void operator()( PMap, const Graph& ) - { - //do nothing. - } - }; - template< class PMap, class Graph> - struct MapInitializer< + struct Index_map_initializer< typename boost::graph_traits::vertex_descriptor, PMap, Graph, CGAL::Tag_true>{ @@ -141,7 +133,7 @@ namespace CGAL { }; template< class PMap, class Graph> - struct MapInitializer< + struct Index_map_initializer< typename boost::graph_traits::halfedge_descriptor, PMap, Graph, CGAL::Tag_true>{ @@ -152,7 +144,7 @@ namespace CGAL { }; template< class PMap, class Graph> - struct MapInitializer< + struct Index_map_initializer< typename boost::graph_traits::face_descriptor, PMap, Graph, CGAL::Tag_true>{ @@ -162,25 +154,24 @@ namespace CGAL { } }; +#define CGAL_IS_PMAP_WRITABLE(TAG) template<> \ + struct Is_pmap_writable{ typedef CGAL::Tag_true result; }; + template struct Is_pmap_writable{ typedef CGAL::Tag_false result; }; - template<> - struct Is_pmap_writable{ - typedef CGAL::Tag_true result; - }; + CGAL_IS_PMAP_WRITABLE(boost::read_write_property_map_tag) + CGAL_IS_PMAP_WRITABLE(boost::writable_property_map_tag) + CGAL_IS_PMAP_WRITABLE(boost::lvalue_property_map_tag) +#undef CGAL_IS_PMAP_WRITABLE - template<> - struct Is_pmap_writable{ - typedef CGAL::Tag_true result; - }; //overloads used to select a default map: // use the one passed in the named parameters (user must have initialized it) template MapFromNP - get_map(MapFromNP m, Default_tag, Dynamic_tag, const Mesh&) + get_ndi_map(MapFromNP m, Default_tag, Dynamic_tag, const Mesh&) { return m; } @@ -188,10 +179,10 @@ namespace CGAL { // use the one internal to the mesh (user must have initialized it) template typename boost::property_map::const_type - get_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m) + get_ndi_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m) { typename boost::property_map::const_type map = get(t, m); - MapInitializer< + Index_map_initializer< typename boost::property_traits::const_type>::key_type, typename boost::property_map::const_type, Mesh, @@ -206,10 +197,10 @@ namespace CGAL { // create a dynamic property and initialize it template typename boost::property_map::const_type - get_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m) + get_ndi_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m) { typename boost::property_map::const_type map = get(t,m); - MapInitializer< + Index_map_initializer< typename boost::property_traits::const_type>::key_type, typename boost::property_map::const_type, Mesh, @@ -221,7 +212,34 @@ namespace CGAL { namespace Polygon_mesh_processing { - template + + //define types for maps : + //struct Default_face_index_map + //struct Default_vertex_index_map + //struct Default_halfedge_index_map +#define CGAL_DEF_MAP_TYPE(TYPE) \ + template \ + struct Default_##TYPE##_index_map{ \ + typedef typename boost::mpl::if_c< \ + CGAL::graph_has_property::value \ + , boost::TYPE##_index_t \ + , CGAL::dynamic_##TYPE##_property_t \ + >::type Final_tag; \ + typedef typename internal_np::Lookup_named_param_def< \ + internal_np::TYPE##_index_t, \ + NP, \ + typename boost::property_map::const_type \ + > ::type type; \ + }; + + CGAL_DEF_MAP_TYPE(face) + CGAL_DEF_MAP_TYPE(vertex) + CGAL_DEF_MAP_TYPE(halfedge) +#undef CGAL_DEF_MAP_TYPE + + + template class Get_index_map_from_NP { private : const Dynamic_tag dtag; @@ -256,7 +274,7 @@ namespace CGAL { PropertyMapType property_map() { - return internal_np::get_map( + return internal_np::get_ndi_map( parameters::get_parameter(np, p), Final_tag(), dtag, @@ -264,6 +282,27 @@ namespace CGAL { } }; + //define the + // get_initialized_face_index_map(), get_initialized_vertex_index_map(), get_initialized_halfedge_index_map() + // functions. + //This comment is here to make it easier to find the definition of the functions with a grep. + +#define CGAL_DEF_GET_INIT_ID_MAP(TYPE) template \ + typename Default_##TYPE##_index_map::type \ + get_initialized_##TYPE##_index_map(const PolygonMesh& pmesh, const NamedParameters& np){ \ + typedef Get_index_map_from_NP, \ + PolygonMesh, NamedParameters, internal_np::TYPE##_index_t> MapGetter; \ + MapGetter get_map(boost::TYPE##_index_t(), \ + CGAL::dynamic_##TYPE##_property_t(), \ + pmesh, np, internal_np::TYPE##_index); \ + return get_map.property_map(); \ + } + CGAL_DEF_GET_INIT_ID_MAP(face) + CGAL_DEF_GET_INIT_ID_MAP(vertex) + CGAL_DEF_GET_INIT_ID_MAP(halfedge) + +#undef CGAL_DEF_GET_INIT_ID_MAP template class GetVertexPointMap { diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index d80320ce963..2ad208e24d9 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -232,15 +232,11 @@ connected_components(const PolygonMesh& pmesh, FiniteDual finite_dual(dual, internal::No_border(pmesh, ecmap)); - typedef CGAL::Polygon_mesh_processing::Get_index_map_from_NP, - PolygonMesh, NamedParameters, internal_np::face_index_t> MapGetter; +//#define old_one 1 - MapGetter get_map(boost::face_index_t(), - CGAL::dynamic_face_property_t(), - pmesh, np, internal_np::face_index); + typename Default_face_index_map::type fimap + = get_initialized_face_index_map(pmesh, np); - typename MapGetter::PropertyMapType fimap = get_map.property_map(); return boost::connected_components(finite_dual, fcm, boost::vertex_index_map(fimap) @@ -312,18 +308,9 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, using parameters::choose_parameter; using parameters::get_parameter; - // FaceIndexMap - typedef CGAL::Polygon_mesh_processing::Get_index_map_from_NP, - PolygonMesh, NamedParameters, internal_np::face_index_t> MapGetter; + typedef typename Default_face_index_map::type FaceIndexMap; - typedef typename MapGetter::PropertyMapType FaceIndexMap; - - MapGetter get_map(boost::face_index_t(), - CGAL::dynamic_face_property_t(), - pmesh, np, internal_np::face_index); - - FaceIndexMap fimap = get_map.property_map(); + FaceIndexMap fimap = get_initialized_face_index_map(pmesh, np); // FaceSizeMap typedef typename internal_np::Lookup_named_param_def Date: Fri, 27 Sep 2019 08:52:59 +0200 Subject: [PATCH 08/86] Update comment --- BGL/include/CGAL/boost/graph/named_params_helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index c4b932aea9b..6dbe98ffe63 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -176,7 +176,7 @@ namespace CGAL { return m; } - // use the one internal to the mesh (user must have initialized it) + // use the one internal to the mesh (it will be init if writable) template typename boost::property_map::const_type get_ndi_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m) From 8583935ae8c358e211628e57f2999fca3b42182c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 27 Sep 2019 11:50:55 +0200 Subject: [PATCH 09/86] Use the functions where possible --- .../CGAL/Polygon_mesh_processing/border.h | 15 ++------- .../connected_components.h | 24 +++++++------- .../Polygon_mesh_processing/corefinement.h | 31 +++++++++---------- .../Polygon_mesh_processing/detect_features.h | 5 ++- .../Polygon_mesh_processing/orientation.h | 12 +++---- .../CGAL/Polygon_mesh_processing/remesh.h | 13 ++++---- .../Polygon_mesh_processing/stitch_borders.h | 6 ++-- .../Rigid_triangle_mesh_collision_detection.h | 7 ++--- 8 files changed, 44 insertions(+), 69 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index ec6bf344009..5c4df3f8ed0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -187,20 +187,9 @@ namespace Polygon_mesh_processing { { if (faces.empty()) return out; - typedef PolygonMesh PM; - typedef typename GetFaceIndexMap::const_type FIMap; - typedef typename boost::property_map::type Unset_FIMap; - if (boost::is_same::value || faces.size() == 1) - { - //face index map is not given in named parameters, nor as an internal property map - return internal::border_halfedges_impl(faces, out, pmesh); - } - - //face index map given as a named parameter, or as an internal property map - FIMap fim = parameters::choose_parameter(parameters::get_parameter(np, internal_np::face_index), - get_const_property_map(CGAL::face_index, pmesh)); + auto fim = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); return internal::border_halfedges_impl(faces, fim, out, pmesh, np); } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 2ad208e24d9..b05b4063b74 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -413,10 +413,9 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh, using parameters::choose_parameter; using parameters::get_parameter; - // FaceIndexMap - typedef typename GetFaceIndexMap::type FaceIndexMap; - FaceIndexMap fim = choose_parameter(get_parameter(np, internal_np::face_index), - get_property_map(boost::face_index, pmesh)); + typedef typename Default_face_index_map::type FaceIndexMap; + FaceIndexMap fim = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def::edge_iterator edge_iterator; //VertexIndexMap - typedef typename GetVertexIndexMap::type VertexIndexMap; - VertexIndexMap vim = choose_parameter(get_parameter(np, internal_np::vertex_index), - get_const_property_map(boost::vertex_index, pmesh)); + typedef typename Default_vertex_index_map::type VertexIndexMap; + VertexIndexMap vim = get_initialized_vertex_index_map(pmesh, np); std::set cc_to_keep; for(std::size_t i : components_to_keep) @@ -730,9 +728,9 @@ void remove_connected_components(PolygonMesh& pmesh using parameters::get_parameter; //FaceIndexMap - typedef typename GetFaceIndexMap::type FaceIndexMap; - FaceIndexMap fim = choose_parameter(get_parameter(np, internal_np::face_index), - get_property_map(boost::face_index, pmesh)); + typedef typename Default_face_index_map::type FaceIndexMap; + FaceIndexMap fim = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); //vector_property_map boost::vector_property_map face_cc(fim); @@ -788,9 +786,9 @@ void keep_connected_components(PolygonMesh& pmesh using parameters::get_parameter; //FaceIndexMap - typedef typename GetFaceIndexMap::type FaceIndexMap; - FaceIndexMap fim = choose_parameter(get_parameter(np, internal_np::face_index), - get_property_map(boost::face_index, pmesh)); + typedef typename Default_face_index_map::type FaceIndexMap; + FaceIndexMap fim = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); //vector_property_map boost::vector_property_map face_cc(fim); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h index 53264e1dc5e..4743a283b58 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h @@ -185,8 +185,6 @@ bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) typedef typename GT::vertex_descriptor vertex_descriptor; typedef typename GetVertexPointMap::const_type Vpm; - typedef typename GetFaceIndexMap::const_type Fid_map; typedef typename Kernel_traits< typename boost::property_traits::value_type >::Kernel Kernel; @@ -196,8 +194,8 @@ bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) Vpm vpm = parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm)); - Fid_map fid_map = parameters::choose_parameter(parameters::get_parameter(np, internal_np::face_index), - get_const_property_map(boost::face_index, tm)); + auto fid_map = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); @@ -524,19 +522,18 @@ corefine_and_compute_boolean_operations( Edge_mark_map_tuple; // Face index point maps - typedef typename GetFaceIndexMap::type Fid_map; - typedef typename GetFaceIndexMap::type Fid_map2; + + typedef typename CGAL::Polygon_mesh_processing:: + Default_face_index_map::type Fid_map; + typedef typename CGAL::Polygon_mesh_processing:: + Default_face_index_map::type Fid_map2; + CGAL_USE_TYPE(Fid_map2); CGAL_assertion_code( static const bool same_fidmap = (boost::is_same::value);) CGAL_static_assertion(same_fidmap); - - Fid_map fid_map1 = parameters::choose_parameter(parameters::get_parameter(np1, internal_np::face_index), - get_property_map(boost::face_index, tm1)); - Fid_map fid_map2 = parameters::choose_parameter(parameters::get_parameter(np2, internal_np::face_index), - get_property_map(boost::face_index, tm2)); + Fid_map fid_map1 = get_initialized_face_index_map(tm1, np1); + Fid_map fid_map2 = get_initialized_face_index_map(tm2, np2); // User visitor typedef typename internal_np::Lookup_named_param_def < internal_np::graph_visitor_t, @@ -1023,10 +1020,10 @@ namespace experimental { Vpm vpm = parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), get_property_map(boost::vertex_point, tm)); // Face index map - typedef typename GetFaceIndexMap::type Fid_map; - Fid_map fid_map = parameters::choose_parameter(parameters::get_parameter(np, internal_np::face_index), - get_property_map(boost::face_index, tm)); + typedef typename Default_face_index_map::type Fid_map; + Fid_map fid_map = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); + // Edge is-constrained maps typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h index 371f21a5f97..da7490e35b7 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h @@ -148,9 +148,8 @@ detect_surface_patches(PolygonMesh& p, const NamedParameters& np) { //extract types from NPs - typename GetFaceIndexMap::const_type - fimap = parameters::choose_parameter(parameters::get_parameter(np, internal_np::face_index), - get_const_property_map(boost::face_index, p)); + auto fimap = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(p, np); int offset = static_cast( parameters::choose_parameter(parameters::get_parameter(np, internal_np::first_index), diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index f13fdb9bbc5..86fdefb1380 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -475,8 +475,6 @@ void orient(TriangleMesh& tm, const NamedParameters& np) typedef typename Graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename GetVertexPointMap::const_type Vpm; - typedef typename GetFaceIndexMap::const_type Fid_map; CGAL_assertion(is_triangle_mesh(tm)); CGAL_assertion(is_valid_polygon_mesh(tm)); @@ -491,8 +489,8 @@ void orient(TriangleMesh& tm, const NamedParameters& np) Vpm vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm)); - Fid_map fid_map = choose_parameter(get_parameter(np, internal_np::face_index), - get_const_property_map(boost::face_index, tm)); + auto fid_map = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); @@ -582,8 +580,6 @@ void orient_to_bound_a_volume(TriangleMesh& tm, typedef typename Graph_traits::vertex_descriptor vertex_descriptor; typedef typename GetVertexPointMap::const_type Vpm; - typedef typename GetFaceIndexMap::const_type Fid_map; typedef typename Kernel_traits< typename boost::property_traits::value_type >::Kernel Kernel; if (!is_closed(tm)) return; @@ -598,8 +594,8 @@ void orient_to_bound_a_volume(TriangleMesh& tm, Vpm vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm)); - Fid_map fid_map = choose_parameter(get_parameter(np, internal_np::face_index), - get_const_property_map(boost::face_index, tm)); + auto fid_map = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index 62479ad4912..66327d23eca 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -168,10 +168,9 @@ void isotropic_remeshing(const FaceRange& faces typedef typename GetVertexPointMap::type VPMap; VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)); - - typedef typename GetFaceIndexMap::type FIMap; - FIMap fimap = choose_parameter(get_parameter(np, internal_np::face_index), - get_property_map(face_index, pmesh)); +typedef typename Default_face_index_map::type FIMap; + FIMap fimap = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, @@ -347,9 +346,9 @@ void split_long_edges(const EdgeRange& edges VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)); - typedef typename GetFaceIndexMap::type FIMap; - FIMap fimap = choose_parameter(get_parameter(np, internal_np::face_index), - get_property_map(face_index, pmesh)); + typedef typename Default_face_index_map::type FIMap; + FIMap fimap = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h index f9491528d53..4b39bc69807 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h @@ -186,9 +186,9 @@ collect_duplicated_stitchable_boundary_edges if(per_cc) { cc = get(Face_property_tag(), pmesh); - typedef typename GetFaceIndexMap::const_type FIMap; - FIMap fim = parameters::choose_parameter(parameters::get_parameter(np, internal_np::face_index), - get_const_property_map(face_index, pmesh)); + + auto fim = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); num_component = num_component_wrapper(pmesh, cc, fim); border_edges_per_cc.resize(num_component); } diff --git a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h index 32449ddebc2..591d72e9728 100644 --- a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h +++ b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h @@ -551,12 +551,9 @@ public: std::vector cc_ids(num_faces(tm)); // face index map - typedef typename GetFaceIndexMap::type Fid_map; - Fid_map fid_map = - parameters::choose_parameter(parameters::get_parameter(np, internal_np::face_index), - get_const_property_map(boost::face_index, tm)); + auto fid_map = + CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); std::size_t nb_cc = Polygon_mesh_processing::connected_components( From 3bcd8810e5a51e213a6ed4780125628a64d6ce38 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 27 Sep 2019 14:24:31 +0200 Subject: [PATCH 10/86] update doc --- .../CGAL/Polygon_mesh_processing/border.h | 4 +- .../CGAL/Polygon_mesh_processing/clip.h | 10 ++-- .../connected_components.h | 50 +++++++++++-------- .../Polygon_mesh_processing/detect_features.h | 6 ++- .../Polygon_mesh_processing/orientation.h | 12 +++-- .../CGAL/Polygon_mesh_processing/remesh.h | 8 +-- .../Polygon_mesh_processing/stitch_borders.h | 2 +- 7 files changed, 54 insertions(+), 38 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index 5c4df3f8ed0..a6a30be67c0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -152,9 +152,9 @@ namespace Polygon_mesh_processing { * but `face(h, pmesh)` does not belong to the patch. * * @tparam PolygonMesh model of `HalfedgeGraph`. If `PolygonMesh` - * has an internal property map + * has an internal not writable property map * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized + * as a named parameter, then the internal one must be initialized; else, it will be. * @tparam FaceRange range of `boost::graph_traits::%face_descriptor`, model of `Range`. Its iterator type is `InputIterator`. diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h index 1a85761f3f8..38fe07b384f 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -283,8 +283,9 @@ clip_to_bbox(const Plane_3& plane, * \pre \link CGAL::Polygon_mesh_processing::does_bound_a_volume() `CGAL::Polygon_mesh_processing::does_bound_a_volume(clipper)` \endlink * * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. - * If `TriangleMesh` has an internal property map for `CGAL::face_index_t`, - * as a named parameter, then it must be initialized. + * If `TriangleMesh` * has an internal not writable property map + * for `CGAL::face_index_t` and no `face_index_map` is given + * as a named parameter, then the internal one must be initialized; else, it will be. * * @tparam NamedParameters1 a sequence of \ref pmp_namedparameters "Named Parameters" * @tparam NamedParameters2 a sequence of \ref pmp_namedparameters "Named Parameters" @@ -373,8 +374,9 @@ bool dispatch_clip_call(TriangleMesh& tm, TriangleMesh& clipper, * \pre \link CGAL::Polygon_mesh_processing::does_self_intersect() `!CGAL::Polygon_mesh_processing::does_self_intersect(tm)` \endlink * * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. - * If `TriangleMesh` has an internal property map for `CGAL::face_index_t`, - * as a named parameter, then it must be initialized. + * If `TriangleMesh` has an internal not writable property map + * for `CGAL::face_index_t` and no `face_index_map` is given + * as a named parameter, then the internal one must be initialized; else, it will be. * An internal property map for `CGAL::vertex_point_t` must be available. * * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index b05b4063b74..0da4b69131e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -182,8 +182,10 @@ connected_component(typename boost::graph_traits::face_descriptor s * \ingroup keep_connected_components_grp * computes for each face the index of the corresponding connected component. * - * A property map for `CGAL::face_index_t` must be either available as an internal property map - * to `pmesh` or provided as one of the \ref pmp_namedparameters "Named Parameters". + * If `PolygonMesh` + * has an internal not writable property map + * for `CGAL::face_index_t` and no `face_index_map` is given + * as a named parameter, then the internal one must be initialized; else, it will be. * * \tparam PolygonMesh a model of `FaceListGraph` * \tparam FaceComponentMap a model of `WritablePropertyMap` with @@ -232,8 +234,6 @@ connected_components(const PolygonMesh& pmesh, FiniteDual finite_dual(dual, internal::No_border(pmesh, ecmap)); -//#define old_one 1 - typename Default_face_index_map::type fimap = get_initialized_face_index_map(pmesh, np); @@ -272,9 +272,10 @@ void keep_connected_components(PolygonMesh& pmesh * By default, the size of a face is `1` (and thus the size of a connected component is the number * of faces it contains), but it is also possible to pass custom sizes, such as the area of the face. * - * Property maps for `CGAL::face_index_t` and `CGAL::vertex_index_t` - * must be either available as internal property maps - * to `pmesh` or provided as \ref pmp_namedparameters "Named Parameters". +* If `PolygonMesh` +* has a not writable internal property map +* for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given +* as a named parameter, then the internal one(s) must be initialized. Else, it will be. * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" @@ -372,9 +373,10 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, * the size of a connected component is the number of faces it contains), but it is also possible * to pass custom sizes, such as the area of the face. * - * Property maps for `CGAL::face_index_t` and `CGAL::vertex_index_t` - * must be either available as internal property maps - * to `pmesh` or provided as \ref pmp_namedparameters "Named Parameters". +* If `PolygonMesh` +* has a not writable internal property map +* for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given +* as a named parameter, then the internal one(s) must be initialized. Else, it will be. * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam ThresholdValueType the type of the threshold value @@ -607,9 +609,10 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh * \note If the removal of the connected components makes `pmesh` a non-manifold surface, * then the behavior of this function is undefined. * -* Property maps for `CGAL::vertex_index_t` -* must be either available as internal property map -* to `pmesh` or provided as \ref pmp_namedparameters "Named Parameters". +* If `PolygonMesh` +* has a not writable internal property map +* for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given +* as a named parameter, then the internal one(s) must be initialized. Else, it will be. * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" @@ -650,9 +653,10 @@ void keep_connected_components(PolygonMesh& pmesh * \note If the removal of the connected components makes `pmesh` a non-manifold surface, * then the behavior of this function is undefined. * -* Property maps for `CGAL::vertex_index_t` -* must be either available as internal property map -* to `pmesh` or provided as \ref pmp_namedparameters "Named Parameters". +* If `PolygonMesh` +* has a not writable internal property map +* for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given +* as a named parameter, then the internal one(s) must be initialized. Else, it will be. * * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` @@ -691,9 +695,10 @@ void remove_connected_components(PolygonMesh& pmesh * keeps the connected components not designated by the faces in `components_to_remove`, * and removes the other connected components and all isolated vertices. * -* Property maps for `CGAL::face_index_t` and `CGAL::vertex_index_t` -* must be either available as internal property maps -* to `pmesh` or provided as \ref pmp_namedparameters "Named Parameters". +* If `PolygonMesh` +* has a not writable internal property map +* for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given +* as a named parameter, then the internal one(s) must be initialized. Else, it will be. * * \note If the removal of the connected components makes `pmesh` a non-manifold surface, * then the behavior of this function is undefined. @@ -749,9 +754,10 @@ void remove_connected_components(PolygonMesh& pmesh * keeps the connected components designated by the faces in `components_to_keep`, * and removes the other connected components and all isolated vertices. * -* Property maps for `CGAL::face_index_t` and `CGAL::vertex_index_t` -* must be either available as internal property maps -* to `pmesh` or provided as \ref pmp_namedparameters "Named Parameters". +* If `PolygonMesh` +* has a not writable internal property map +* for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given +* as a named parameter, then the internal one(s) must be initialized. Else, it will be. * * \note If the removal of the connected components makes `pmesh` a non-manifold surface, * then the behavior of this function is undefined. diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h index da7490e35b7..f8e07bab8a2 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h @@ -381,8 +381,10 @@ namespace internal * computing a * surface patch id for each face. * - * A property map for `CGAL::face_index_t` must be either available - * as an internal property map to `pmesh` or provided as one of the Named Parameters. + * If `PolygonMesh` + * has an internal not writable property map + * for `CGAL::face_index_t` and no `face_index_map` is given + * as a named parameter, then the internal one must be initialized; else, it will be. * * \tparam PolygonMesh a model of `FaceGraph` * \tparam FT a number type. It is diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index 86fdefb1380..f2cc05d1279 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -444,8 +444,10 @@ void recursive_orient_volume_ccs( TriangleMesh& tm, * inward or outward oriented. * * @tparam TriangleMesh a model of `FaceListGraph` and `MutableFaceGraph` . -* If `TriangleMesh` has an internal property map for `CGAL::face_index_t`, -* as a named parameter, then it must be initialized. +* If `TriangleMesh` + * has an internal not writable property map + * for `CGAL::face_index_t` and no `face_index_map` is given + * as a named parameter, then the internal one must be initialized; else, it will be. * @tparam NamedParameters a sequence of \ref pmp_namedparameters * * @param tm a closed triangulated surface mesh @@ -547,8 +549,10 @@ void orient(TriangleMesh& tm) * See \ref coref_def_subsec for a precise definition. * * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. - * If `TriangleMesh` has an internal property map for `CGAL::face_index_t`, - * as a named parameter, then it must be initialized. + * If `TriangleMesh` + * has an internal not writable property map + * for `CGAL::face_index_t` and no `face_index_map` is given + * as a named parameter, then the internal one must be initialized; else, it will be. * @tparam NamedParameters a sequence of \ref pmp_namedparameters * * @param tm a closed triangulated surface mesh diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index 66327d23eca..098d6c14a7c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -50,9 +50,11 @@ namespace Polygon_mesh_processing { * The descriptor types `boost::graph_traits::%face_descriptor` * and `boost::graph_traits::%halfedge_descriptor` must be * models of `Hashable`. -* If `PolygonMesh` has an internal property map for `CGAL::face_index_t`, -* and no `face_index_map` is given -* as a named parameter, then the internal one must be initialized +* If `PolygonMesh` + * has an internal not writable property map + * for `CGAL::face_index_t` and no `face_index_map` is given + * as a named parameter, then the internal one must be initialized; else, it will be. + * * @tparam FaceRange range of `boost::graph_traits::%face_descriptor`, model of `Range`. Its iterator type is `ForwardIterator`. * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h index 4b39bc69807..ca8355a7553 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h @@ -745,7 +745,7 @@ void stitch_borders(PolygonMesh& pmesh, /// `CGAL::vertex_point_t` must be available in `PolygonMesh`.\cgalParamEnd /// \cgalParamBegin{apply_per_connected_component} /// specifies if the borders should only be stitched inside their own connected component. -/// In that case, a property map for `CGAL::face_index_t` should be either available as an internal property map +/// In that case, an initialized property map for `CGAL::face_index_t` should be either available as an internal property map /// to `pmesh` or provided as the \ref pmp_namedparameters "Named Parameter" `face_index_map`. If this is not the case, /// a default map will be created on the fly. /// Default value is `false`.\cgalParamEnd From 002a3ac218616673084006b96250ca64e6e12070 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 14 Feb 2020 13:40:57 +0100 Subject: [PATCH 11/86] refines the Is_pmap_writable to take the reference constness into account --- .../CGAL/boost/graph/named_params_helper.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 6dbe98ffe63..1344be31b71 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -32,6 +32,7 @@ #include +#include namespace CGAL { @@ -154,10 +155,12 @@ namespace CGAL { } }; -#define CGAL_IS_PMAP_WRITABLE(TAG) template<> \ - struct Is_pmap_writable{ typedef CGAL::Tag_true result; }; +#define CGAL_IS_PMAP_WRITABLE(TAG) template \ + struct Is_pmap_writable{ typedef CGAL::Tag_true result; }; \ + template<> \ + struct Is_pmap_writable >{ typedef CGAL::Tag_false result; }; - template + template struct Is_pmap_writable{ typedef CGAL::Tag_false result; }; @@ -189,7 +192,11 @@ namespace CGAL { typename Is_pmap_writable< typename boost::property_traits - ::const_type>::category>::result> + ::const_type>::category, + typename boost::property_traits + + ::const_type>::reference + >::result> ()(map, m); return map; } From 249eb85060e1e94f2d7b09a7aa1a15314ea4f410 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 14 Feb 2020 14:25:28 +0100 Subject: [PATCH 12/86] fixes --- BGL/include/CGAL/boost/graph/properties.h | 64 +++++++++++++++++++ .../CGAL/Polygon_mesh_processing/border.h | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index f9a915dba68..5bb232048ca 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -123,6 +123,64 @@ using boost::face_external_index; namespace CGAL{ namespace helpers { +//check that an existing map is initialized/valid +template +bool is_face_index_map_valid(PolygonMesh& pm, + FaceIndexMap& fid) +{ + typedef typename boost::property_traits::value_type Id_type; + const std::size_t num_f = num_faces(pm); + std::set indices; + for(typename boost::graph_traits::face_descriptor fd : + faces(pm)) + { + Id_type id = get(fid, fd); + if(static_cast(id) >=static_cast(num_f)) //also covers the case where the id is < 0 as size_t(-1) = max_int or smthg. + return false; + if(!indices.insert(id).second) + return false; + } + return true; +} + +template +bool is_halfedge_index_map_valid(PolygonMesh& pm, + HalfedgeIndexMap& fid) +{ + typedef typename boost::property_traits::value_type Id_type; + const std::size_t num_hd = num_halfedges(pm); + std::set indices; + for(typename boost::graph_traits::halfedge_descriptor hd : + halfedges(pm)) + { + Id_type id = get(fid, hd); + if(static_cast(id) >=static_cast(num_hd)) //also covers the case where the id is < 0 as size_t(-1) = max_int or smthg. + return false; + if(!indices.insert(id).second) + return false; + } + return true; +} + +template +bool is_vertex_index_map_valid(PolygonMesh& pm, + VertexIndexMap& fid) +{ + typedef typename boost::property_traits::value_type Id_type; + const std::size_t num_v= num_vertices(pm); + std::set indices; + for(typename boost::graph_traits::vertex_descriptor vd : + vertices(pm)) + { + Id_type id = get(fid, vd); + if(static_cast(id) >=static_cast(num_v)) //also covers the case where the id is < 0 as size_t(-1) = max_int or smthg. + return false; + if(!indices.insert(id).second) + return false; + } + return true; +} + // matches read-write property maps template void init_face_indices(PolygonMesh& pm, @@ -130,6 +188,8 @@ void init_face_indices(PolygonMesh& pm, boost::read_write_property_map_tag, Tag) { + if(is_face_index_map_valid(pm, fid)) + return; typename boost::property_traits::value_type i = 0; for(typename boost::graph_traits::face_descriptor fd : faces(pm)) @@ -144,6 +204,8 @@ void init_vertex_indices(PolygonMesh& pm, boost::read_write_property_map_tag, Tag) { + if(is_vertex_index_map_valid(pm, vid)) + return; typename boost::property_traits::value_type i = 0; for(typename boost::graph_traits::vertex_descriptor vd : vertices(pm)) @@ -158,6 +220,8 @@ void init_halfedge_indices(PolygonMesh& pm, boost::read_write_property_map_tag, Tag) { + if(is_halfedge_index_map_valid(pm, hid)) + return; typename boost::property_traits::value_type i = 0; for(typename boost::graph_traits::halfedge_descriptor hd : halfedges(pm)) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index a6a30be67c0..9f31c1d5de7 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -152,7 +152,7 @@ namespace Polygon_mesh_processing { * but `face(h, pmesh)` does not belong to the patch. * * @tparam PolygonMesh model of `HalfedgeGraph`. If `PolygonMesh` - * has an internal not writable property map + * has an internal non mutable property map * for `CGAL::face_index_t` and no `face_index_map` is given * as a named parameter, then the internal one must be initialized; else, it will be. * @tparam FaceRange range of From b9a8d50b664890b4e67894f6946edf3cc424c643 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 17 Feb 2020 11:18:42 +0100 Subject: [PATCH 13/86] add missing include --- BGL/include/CGAL/boost/graph/properties.h | 1 + 1 file changed, 1 insertion(+) diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index 5d91a397e16..49b88c9f221 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -22,6 +22,7 @@ #include #include +#include namespace CGAL{ /// \ingroup PkgBGLProperties From 9459df666d339017d72f573a270f6b1cd4741757 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 18 Feb 2020 11:26:09 +0100 Subject: [PATCH 14/86] fix after review --- .../CGAL/boost/graph/named_params_helper.h | 8 ++- BGL/include/CGAL/boost/graph/properties.h | 68 ++++--------------- 2 files changed, 21 insertions(+), 55 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 34e3496ca65..1d1b4599677 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -155,16 +155,19 @@ namespace CGAL { } }; + #define CGAL_IS_PMAP_WRITABLE(TAG) template \ struct Is_pmap_writable{ typedef CGAL::Tag_true result; }; \ - template<> \ + template<> \ //if ref is const, then return false struct Is_pmap_writable >{ typedef CGAL::Tag_false result; }; + //Default is false template struct Is_pmap_writable{ typedef CGAL::Tag_false result; }; + //Pmaps with these tags will be considered writabl, unless their reference is const CGAL_IS_PMAP_WRITABLE(boost::read_write_property_map_tag) CGAL_IS_PMAP_WRITABLE(boost::writable_property_map_tag) CGAL_IS_PMAP_WRITABLE(boost::lvalue_property_map_tag) @@ -193,9 +196,10 @@ namespace CGAL { typename boost::property_traits ::const_type>::category, + std::is_const< typename boost::property_traits - ::const_type>::reference + ::const_type>::reference> >::result> ()(map, m); return map; diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index 49b88c9f221..2ce2efa3108 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -22,7 +22,7 @@ #include #include -#include +#include namespace CGAL{ /// \ingroup PkgBGLProperties @@ -116,62 +116,24 @@ namespace CGAL{ namespace helpers { //check that an existing map is initialized/valid -template -bool is_face_index_map_valid(PolygonMesh& pm, - FaceIndexMap& fid) +template +bool is_index_map_valid(typename boost::property_traits::value_type max_id, + const SimplexRange& range, + const IndexMap& idmap) { - typedef typename boost::property_traits::value_type Id_type; - const std::size_t num_f = num_faces(pm); - std::set indices; - for(typename boost::graph_traits::face_descriptor fd : - faces(pm)) + typedef typename boost::property_traits::value_type Id_type; + std::vector indices(max_id + 1); + for(const auto& simplex : range) { - Id_type id = get(fid, fd); - if(static_cast(id) >=static_cast(num_f)) //also covers the case where the id is < 0 as size_t(-1) = max_int or smthg. - return false; - if(!indices.insert(id).second) + Id_type id = get(idmap, simplex); + if( id >= 0 && id <= max_id && ! indices[id]) + indices[id] = true; + else return false; } return true; } -template -bool is_halfedge_index_map_valid(PolygonMesh& pm, - HalfedgeIndexMap& fid) -{ - typedef typename boost::property_traits::value_type Id_type; - const std::size_t num_hd = num_halfedges(pm); - std::set indices; - for(typename boost::graph_traits::halfedge_descriptor hd : - halfedges(pm)) - { - Id_type id = get(fid, hd); - if(static_cast(id) >=static_cast(num_hd)) //also covers the case where the id is < 0 as size_t(-1) = max_int or smthg. - return false; - if(!indices.insert(id).second) - return false; - } - return true; -} - -template -bool is_vertex_index_map_valid(PolygonMesh& pm, - VertexIndexMap& fid) -{ - typedef typename boost::property_traits::value_type Id_type; - const std::size_t num_v= num_vertices(pm); - std::set indices; - for(typename boost::graph_traits::vertex_descriptor vd : - vertices(pm)) - { - Id_type id = get(fid, vd); - if(static_cast(id) >=static_cast(num_v)) //also covers the case where the id is < 0 as size_t(-1) = max_int or smthg. - return false; - if(!indices.insert(id).second) - return false; - } - return true; -} // matches read-write property maps template @@ -180,7 +142,7 @@ void init_face_indices(PolygonMesh& pm, boost::read_write_property_map_tag, Tag) { - if(is_face_index_map_valid(pm, fid)) + if(is_index_map_valid(num_faces(pm), faces(pm), fid)) return; typename boost::property_traits::value_type i = 0; for(typename boost::graph_traits::face_descriptor fd : @@ -196,7 +158,7 @@ void init_vertex_indices(PolygonMesh& pm, boost::read_write_property_map_tag, Tag) { - if(is_vertex_index_map_valid(pm, vid)) + if(is_index_map_valid(num_vertices(pm), vertices(pm), vid)) return; typename boost::property_traits::value_type i = 0; for(typename boost::graph_traits::vertex_descriptor vd : @@ -212,7 +174,7 @@ void init_halfedge_indices(PolygonMesh& pm, boost::read_write_property_map_tag, Tag) { - if(is_halfedge_index_map_valid(pm, hid)) + if(is_index_map_valid(num_halfedges(pm), halfedges(pm), hid)) return; typename boost::property_traits::value_type i = 0; for(typename boost::graph_traits::halfedge_descriptor hd : From 7d11c830e4eae59178c7eede0d214ed7a08f46a3 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 18 Feb 2020 11:38:08 +0100 Subject: [PATCH 15/86] add some typedefs to get_ndi_map --- .../CGAL/boost/graph/named_params_helper.h | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 1d1b4599677..9ee21a3d796 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -158,7 +158,7 @@ namespace CGAL { #define CGAL_IS_PMAP_WRITABLE(TAG) template \ struct Is_pmap_writable{ typedef CGAL::Tag_true result; }; \ - template<> \ //if ref is const, then return false + template<> \ struct Is_pmap_writable >{ typedef CGAL::Tag_false result; }; //Default is false @@ -167,7 +167,7 @@ namespace CGAL { typedef CGAL::Tag_false result; }; - //Pmaps with these tags will be considered writabl, unless their reference is const + //Pmaps with these tags will be considered writable, unless their reference is const CGAL_IS_PMAP_WRITABLE(boost::read_write_property_map_tag) CGAL_IS_PMAP_WRITABLE(boost::writable_property_map_tag) CGAL_IS_PMAP_WRITABLE(boost::lvalue_property_map_tag) @@ -187,20 +187,23 @@ namespace CGAL { typename boost::property_map::const_type get_ndi_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m) { - typename boost::property_map::const_type map = get(t, m); + typedef typename boost::property_map::const_type Map_const_type; + typedef typename boost::property_traits::key_type Key_type; + typedef typename boost::property_traits + + ::const_type>::category Category; + typedef typename boost::property_traits + ::const_type>::reference Reference; + + Map_const_type map = get(t, m); Index_map_initializer< - typename boost::property_traits::const_type>::key_type, - typename boost::property_map::const_type, + Key_type, + Map_const_type, Mesh, typename Is_pmap_writable< - typename boost::property_traits - - ::const_type>::category, - std::is_const< - typename boost::property_traits - - ::const_type>::reference> - >::result> + Category, + std::is_const >::result + > ()(map, m); return map; } @@ -210,12 +213,11 @@ namespace CGAL { typename boost::property_map::const_type get_ndi_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m) { - typename boost::property_map::const_type map = get(t,m); + typedef typename boost::property_map::const_type Map_const_type; + Map_const_type map = get(t,m); Index_map_initializer< - typename boost::property_traits::const_type>::key_type, - typename boost::property_map::const_type, - Mesh, - CGAL::Tag_true>()(map, m); + typename boost::property_traits::key_type, + Map_const_type, Mesh, CGAL::Tag_true>()(map, m); return map; } From 7ec84ae69c0a74f8eb69604d9ee11224b0fc2957 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 18 Feb 2020 14:42:53 +0100 Subject: [PATCH 16/86] replace the functor by overloads of a free function --- .../CGAL/boost/graph/named_params_helper.h | 88 +++++++++---------- .../connected_component_polyhedron.cpp | 4 +- 2 files changed, 44 insertions(+), 48 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 9ee21a3d796..21e7e51287d 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -116,44 +116,48 @@ namespace CGAL { namespace internal_np { - template - struct Index_map_initializer{ - void operator()(PMap, const Graph& ) - {} - }; + //cases the map is writable for vertices template< class PMap, class Graph> - struct Index_map_initializer< - typename boost::graph_traits::vertex_descriptor, - PMap, Graph, - CGAL::Tag_true>{ - void operator()(PMap map, const Graph& g) - { - CGAL::helpers::init_vertex_indices(g, map); - } - }; - + void initialize_index_map(PMap map, const Graph& g, const boost::vertex_index_t&, const CGAL::Tag_true&) + { + CGAL::helpers::init_vertex_indices(g, map); + } + + template< class PMap, class Graph, typename T> + void initialize_index_map(PMap map, const Graph& g, const CGAL::dynamic_vertex_property_t&, const CGAL::Tag_true&) + { + CGAL::helpers::init_vertex_indices(g, map); + } + + //cases the map is writable for halfedges template< class PMap, class Graph> - struct Index_map_initializer< - typename boost::graph_traits::halfedge_descriptor, - PMap, Graph, - CGAL::Tag_true>{ - void operator()(PMap map, const Graph& g) - { - CGAL::helpers::init_halfedge_indices(g, map); - } - }; - + void initialize_index_map(PMap map, const Graph& g, const boost::halfedge_index_t&, const CGAL::Tag_true&) + { + CGAL::helpers::init_halfedge_indices(g, map); + } + + template< class PMap, class Graph, typename T> + void initialize_index_map(PMap map, const Graph& g, const CGAL::dynamic_halfedge_property_t&&, const CGAL::Tag_true&) + { + CGAL::helpers::init_halfedge_indices(g, map); + } + //cases the map is writable for faces template< class PMap, class Graph> - struct Index_map_initializer< - typename boost::graph_traits::face_descriptor, - PMap, Graph, - CGAL::Tag_true>{ - void operator()(PMap map,const Graph& g) - { - CGAL::helpers::init_face_indices(g, map); - } - }; + void initialize_index_map(PMap map, const Graph& g, const boost::face_index_t&, const CGAL::Tag_true&) + { + CGAL::helpers::init_face_indices(g, map); + } + template< class PMap, class Graph, typename T> + void initialize_index_map(PMap map, const Graph& g, const CGAL::dynamic_face_property_t&, const CGAL::Tag_true&) + { + CGAL::helpers::init_face_indices(g, map); + } + + //default case : don't do anything + template + void initialize_index_map(PMap, const Graph&, const SimplexTag& t, const IsWritableTag& w) + {} #define CGAL_IS_PMAP_WRITABLE(TAG) template \ @@ -196,15 +200,9 @@ namespace CGAL { ::const_type>::reference Reference; Map_const_type map = get(t, m); - Index_map_initializer< - Key_type, - Map_const_type, - Mesh, - typename Is_pmap_writable< - Category, - std::is_const >::result - > - ()(map, m); + typename Is_pmap_writable >::result is_writable; + initialize_index_map(map, m, t,is_writable); return map; } @@ -215,9 +213,7 @@ namespace CGAL { { typedef typename boost::property_map::const_type Map_const_type; Map_const_type map = get(t,m); - Index_map_initializer< - typename boost::property_traits::key_type, - Map_const_type, Mesh, CGAL::Tag_true>()(map, m); + initialize_index_map(map, m, t, CGAL::Tag_true()); return map; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp index df29479d83e..35a7e3a75f0 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/connected_component_polyhedron.cpp @@ -37,8 +37,8 @@ void mesh_with_id(const char* argv1, const bool save_output) std::cerr << cc.size() << " faces in the CC of " << &*fd << std::endl; boost::vector_property_map::type> - fccmap(get(boost::face_index,sm)); + boost::property_map::type> + fccmap(get(CGAL::face_index,sm)); std::size_t num = PMP::connected_components(sm, fccmap); if (strcmp(argv1, "data/blobby_3cc.off") == 0) From aeb44510f1d33de79d5926377c66eb31d89b6681 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 18 Feb 2020 15:27:34 +0100 Subject: [PATCH 17/86] Fix doc about boost/CGAL property tags --- BGL/doc/BGL/CGAL/boost/graph/properties.h | 13 ++----------- BGL/include/CGAL/boost/graph/properties.h | 4 ++++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/BGL/doc/BGL/CGAL/boost/graph/properties.h b/BGL/doc/BGL/CGAL/boost/graph/properties.h index cbd4d4f960f..7613e7cb8d9 100644 --- a/BGL/doc/BGL/CGAL/boost/graph/properties.h +++ b/BGL/doc/BGL/CGAL/boost/graph/properties.h @@ -1,5 +1,5 @@ -/// Boost Namespace -namespace boost { +/// CGAL Namespace +namespace CGAL { /// \ingroup PkgBGLProperties /// @{ @@ -34,15 +34,6 @@ enum face_index_t { face_index }; /// \cgalModels PropertyTag enum vertex_point_t { vertex_point }; - -/// @} -} // namespace boost - -namespace CGAL { - - -/// @{ - /// \ingroup PkgBGLPropertiesDynamic /// Dynamic vertex property tag /// \tparam T the value type of the vertex property diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index 2ce2efa3108..cbb74b59e98 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -100,6 +100,10 @@ using boost::vertex_point_t; using boost::vertex_point; using boost::vertex_external_index_t; using boost::vertex_external_index; +using boost::vertex_index_t; +using boost::vertex_index; +using boost::edge_index_t; +using boost::edge_index; using boost::halfedge_index_t; using boost::halfedge_index; using boost::halfedge_external_index_t; From cf6fec2bbbdb89843fadf603362f9cc67c1ef3c5 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 18 Feb 2020 15:45:29 +0100 Subject: [PATCH 18/86] move using --- BGL/doc/BGL/CGAL/boost/graph/properties.h | 1 + BGL/include/CGAL/boost/graph/properties.h | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/BGL/doc/BGL/CGAL/boost/graph/properties.h b/BGL/doc/BGL/CGAL/boost/graph/properties.h index 7613e7cb8d9..6afe91335e3 100644 --- a/BGL/doc/BGL/CGAL/boost/graph/properties.h +++ b/BGL/doc/BGL/CGAL/boost/graph/properties.h @@ -34,6 +34,7 @@ enum face_index_t { face_index }; /// \cgalModels PropertyTag enum vertex_point_t { vertex_point }; +/// @} /// \ingroup PkgBGLPropertiesDynamic /// Dynamic vertex property tag /// \tparam T the value type of the vertex property diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index cbb74b59e98..0b8fe0ae4ab 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -98,16 +98,16 @@ BOOST_INSTALL_PROPERTY(face, external_index); namespace CGAL { using boost::vertex_point_t; using boost::vertex_point; -using boost::vertex_external_index_t; -using boost::vertex_external_index; using boost::vertex_index_t; using boost::vertex_index; -using boost::edge_index_t; -using boost::edge_index; +using boost::vertex_external_index_t; +using boost::vertex_external_index; using boost::halfedge_index_t; using boost::halfedge_index; using boost::halfedge_external_index_t; using boost::halfedge_external_index; +using boost::edge_index_t; +using boost::edge_index; using boost::edge_external_index_t; using boost::edge_external_index; using boost::face_index_t; From 928f2bd2bb3d6aa3cf7abb2703d8d807a4b03746 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 19 Feb 2020 09:16:55 +0100 Subject: [PATCH 19/86] Remove unused typedef --- BGL/include/CGAL/boost/graph/named_params_helper.h | 1 - 1 file changed, 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 21e7e51287d..22e6819beb5 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -192,7 +192,6 @@ namespace CGAL { get_ndi_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m) { typedef typename boost::property_map::const_type Map_const_type; - typedef typename boost::property_traits::key_type Key_type; typedef typename boost::property_traits ::const_type>::category Category; From c999ce144feac7daf4865a739ec1c1d25fcc414d Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 19 Feb 2020 10:07:53 +0100 Subject: [PATCH 20/86] Add the missing spe for Seam_mesh and dynamic_property_map --- .../CGAL/boost/graph/named_params_helper.h | 4 +-- .../CGAL/boost/graph/properties_Seam_mesh.h | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 22e6819beb5..2e57a80fa57 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -225,7 +225,7 @@ namespace CGAL { //struct Default_face_index_map //struct Default_vertex_index_map //struct Default_halfedge_index_map -#define CGAL_DEF_MAP_TYPE(TYPE) \ +#define CGAL_DEF_MAP_TYPE(TYPE) \ template \ struct Default_##TYPE##_index_map{ \ typedef typename boost::mpl::if_c< \ @@ -234,7 +234,7 @@ namespace CGAL { , CGAL::dynamic_##TYPE##_property_t \ >::type Final_tag; \ typedef typename internal_np::Lookup_named_param_def< \ - internal_np::TYPE##_index_t, \ + internal_np::TYPE##_index_t, \ NP, \ typename boost::property_map::const_type \ > ::type type; \ diff --git a/BGL/include/CGAL/boost/graph/properties_Seam_mesh.h b/BGL/include/CGAL/boost/graph/properties_Seam_mesh.h index 96bf18fa8ab..53acfbce101 100644 --- a/BGL/include/CGAL/boost/graph/properties_Seam_mesh.h +++ b/BGL/include/CGAL/boost/graph/properties_Seam_mesh.h @@ -112,6 +112,39 @@ struct property_map, CGAL::vertex_point_t> typedef CGAL::Seam_mesh_point_map type; typedef type const_type; }; + +template +struct property_map, CGAL::dynamic_vertex_property_t > +{ + typedef typename boost::graph_traits >::vertex_descriptor vertex_descriptor; + typedef CGAL::internal::Dynamic_property_map type; + typedef type const_type; +}; + +template +struct property_map, CGAL::dynamic_halfedge_property_t > +{ + typedef typename boost::graph_traits >::halfedge_descriptor halfedge_descriptor; + typedef CGAL::internal::Dynamic_property_map type; + typedef type const_type; +}; + + +template +struct property_map, CGAL::dynamic_edge_property_t > +{ + typedef typename boost::graph_traits >::edge_descriptor edge_descriptor; + typedef CGAL::internal::Dynamic_property_map type; + typedef type const_type; +}; + +template +struct property_map, CGAL::dynamic_face_property_t > +{ + typedef typename boost::graph_traits >::face_descriptor face_descriptor; + typedef CGAL::internal::Dynamic_property_map type; + typedef type const_type; +}; } // namespace boost namespace CGAL { From 195d43bc5e6b16eb89f1fd2073abd223d2e8f2b2 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 20 Feb 2020 16:49:54 +0100 Subject: [PATCH 21/86] Fix conversion warning --- BGL/include/CGAL/boost/graph/properties.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index 0b8fe0ae4ab..52e22a0dcba 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -121,11 +121,13 @@ namespace helpers { //check that an existing map is initialized/valid template -bool is_index_map_valid(typename boost::property_traits::value_type max_id, +bool is_index_map_valid( std::size_t num_simplices, const SimplexRange& range, const IndexMap& idmap) { + typedef typename boost::property_traits::value_type Id_type; + Id_type max_id = static_cast(num_simplices); std::vector indices(max_id + 1); for(const auto& simplex : range) { From 9a454ca7e207f93ed86638240b09b5bf44f413c5 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 21 Feb 2020 11:43:08 +0100 Subject: [PATCH 22/86] Changes after review --- .../CGAL/boost/graph/named_params_helper.h | 62 ++++++++----------- BGL/include/CGAL/boost/graph/properties.h | 4 +- .../CGAL/Polygon_mesh_processing/border.h | 2 +- .../connected_components.h | 41 ++++++------ .../Polygon_mesh_processing/corefinement.h | 8 +-- .../Polygon_mesh_processing/detect_features.h | 2 +- .../Polygon_mesh_processing/orientation.h | 4 +- .../CGAL/Polygon_mesh_processing/remesh.h | 4 +- .../Polygon_mesh_processing/stitch_borders.h | 2 +- .../Rigid_triangle_mesh_collision_detection.h | 2 +- 10 files changed, 60 insertions(+), 71 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 2e57a80fa57..de23c405db3 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -195,8 +195,7 @@ namespace CGAL { typedef typename boost::property_traits ::const_type>::category Category; - typedef typename boost::property_traits - ::const_type>::reference Reference; + typedef typename boost::property_traits::reference Reference; Map_const_type map = get(t, m); typename Is_pmap_writable::const_type \ > ::type type; \ - }; - +}; + CGAL_DEF_MAP_TYPE(face) CGAL_DEF_MAP_TYPE(vertex) CGAL_DEF_MAP_TYPE(halfedge) #undef CGAL_DEF_MAP_TYPE - - + + template class Get_index_map_from_NP { - private : + private : const Dynamic_tag dtag; const Mesh& m; const NamedParameters& np; const Parameter p; - - public: + + public: //get the Default tag : //if Mesh has an internal property map for Tag, use Tag, else use the Dynamic_tag. typedef typename boost::mpl::if_c::value - , Tag - , Dynamic_tag - >::type Final_tag; - + , Tag, Dynamic_tag>::type Final_tag; + //If Parameter is in NamedParameters, take the NP map. //Else, take the default map. typedef typename internal_np::Lookup_named_param_def< - Parameter, - NamedParameters, - typename boost::property_map::const_type - > ::type PropertyMapType; - - + Parameter, + NamedParameters, + typename boost::property_map::const_type + > ::type PropertyMapType; + + Get_index_map_from_NP(const Tag, - const Dynamic_tag dtag, - const Mesh& m, - const NamedParameters& np, - const Parameter p) + const Dynamic_tag dtag, + const Mesh& m, + const NamedParameters& np, + const Parameter p) : dtag(dtag), m(m), np(np), p(p) {} - - + + PropertyMapType property_map() { - return internal_np::get_ndi_map( - parameters::get_parameter(np, p), - Final_tag(), - dtag, - m); + return internal_np::get_ndi_map(parameters::get_parameter(np, p), + Final_tag(), dtag, m); } }; - + //define the // get_initialized_face_index_map(), get_initialized_vertex_index_map(), get_initialized_halfedge_index_map() // functions. @@ -311,7 +302,6 @@ namespace CGAL { CGAL_DEF_GET_INIT_ID_MAP(halfedge) #undef CGAL_DEF_GET_INIT_ID_MAP -} //end Polygon_mesh_processing template > diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index 27e7fcac574..7915d818048 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -100,11 +100,11 @@ bool is_index_map_valid( std::size_t num_simplices, typedef typename boost::property_traits::value_type Id_type; Id_type max_id = static_cast(num_simplices); - std::vector indices(max_id + 1); + std::vector indices(max_id); for(const auto& simplex : range) { Id_type id = get(idmap, simplex); - if( id >= 0 && id <= max_id && ! indices[id]) + if( id >= 0 && id < max_id && ! indices[id]) indices[id] = true; else return false; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index e4ffca1cc0c..a7704f6f9ca 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -180,7 +180,7 @@ namespace Polygon_mesh_processing { auto fim = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); + CGAL::get_initialized_face_index_map(pmesh, np); return internal::border_halfedges_impl(faces, fim, out, pmesh, np); } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 39884206f1b..cef16f633ca 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -172,9 +172,9 @@ connected_component(typename boost::graph_traits::face_descriptor s * computes for each face the index of the corresponding connected component. * * If `PolygonMesh` - * has an internal not writable property map - * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; else, it will be. + * has an internal non writable property map + * for `CGAL::face_index_t` and no `face_index_map` is given + * as a named parameter, then the internal one must be initialized; otherwise, it will be. * * \tparam PolygonMesh a model of `FaceListGraph` * \tparam FaceComponentMap a model of `WritablePropertyMap` with @@ -222,9 +222,8 @@ connected_components(const PolygonMesh& pmesh, typedef typename Default_face_index_map::type FaceIndexMap; - FaceIndexMap fimap - = get_initialized_face_index_map(pmesh, np); - + FaceIndexMap fimap = get_initialized_face_index_map(pmesh, np); + typename boost::property_traits::value_type i=0; std::vector handled(num_faces(pmesh), false); for (face_descriptor f : faces(pmesh)) @@ -328,9 +327,9 @@ std::size_t number_of_connected_components(const PolygonMesh& pmesh) * of faces it contains), but it is also possible to pass custom sizes, such as the area of the face. * * If `PolygonMesh` -* has a not writable internal property map +* has a non writable internal property map * for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given -* as a named parameter, then the internal one(s) must be initialized. Else, it will be. +* as a named parameter, then the internal one(s) must be initialized. Otherwise, it will be. * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" @@ -460,9 +459,9 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, * to pass custom sizes, such as the area of the face. * * If `PolygonMesh` -* has a not writable internal property map +* has a non writable internal property map * for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given -* as a named parameter, then the internal one(s) must be initialized. Else, it will be. +* as a named parameter, then the internal one(s) must be initialized. Otherwise, it will be. * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam ThresholdValueType the type of the threshold value @@ -511,7 +510,7 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh, typedef typename Default_face_index_map::type FaceIndexMap; FaceIndexMap fim = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); + CGAL::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def::type FaceIndexMap; FaceIndexMap fim = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); + CGAL::get_initialized_face_index_map(pmesh, np); //vector_property_map boost::vector_property_map face_cc(fim); @@ -869,9 +868,9 @@ void remove_connected_components(PolygonMesh& pmesh * and removes the other connected components and all isolated vertices. * * If `PolygonMesh` -* has a not writable internal property map +* has a non writable internal property map * for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given -* as a named parameter, then the internal one(s) must be initialized. Else, it will be. +* as a named parameter, then the internal one(s) must be initialized. Otherwise, it will be. * * \note If the removal of the connected components makes `pmesh` a non-manifold surface, * then the behavior of this function is undefined. @@ -908,7 +907,7 @@ void keep_connected_components(PolygonMesh& pmesh //FaceIndexMap typedef typename Default_face_index_map::type FaceIndexMap; FaceIndexMap fim = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); + CGAL::get_initialized_face_index_map(pmesh, np); //vector_property_map boost::vector_property_map face_cc(fim); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h index 18d6452de0c..b579e484ccc 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h @@ -186,7 +186,7 @@ bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) get_const_property_map(boost::vertex_point, tm)); auto fid_map = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); + CGAL::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); @@ -514,9 +514,9 @@ corefine_and_compute_boolean_operations( // Face index point maps - typedef typename CGAL::Polygon_mesh_processing:: + typedef typename CGAL:: Default_face_index_map::type Fid_map; - typedef typename CGAL::Polygon_mesh_processing:: + typedef typename CGAL:: Default_face_index_map::type Fid_map2; CGAL_USE_TYPE(Fid_map2); @@ -1013,7 +1013,7 @@ namespace experimental { // Face index map typedef typename Default_face_index_map::type Fid_map; Fid_map fid_map = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); + CGAL::get_initialized_face_index_map(tm, np); // Edge is-constrained maps typedef typename internal_np::Lookup_named_param_def < diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h index fd05b161107..05f629f127c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h @@ -140,7 +140,7 @@ detect_surface_patches(PolygonMesh& p, { //extract types from NPs auto fimap = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(p, np); + CGAL::get_initialized_face_index_map(p, np); int offset = static_cast( parameters::choose_parameter(parameters::get_parameter(np, internal_np::first_index), diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index 85a17efa933..2e9618d8188 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -485,7 +485,7 @@ void orient(TriangleMesh& tm, const NamedParameters& np) get_const_property_map(boost::vertex_point, tm)); auto fid_map = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); + CGAL::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); @@ -592,7 +592,7 @@ void orient_to_bound_a_volume(TriangleMesh& tm, get_const_property_map(boost::vertex_point, tm)); auto fid_map = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); + CGAL::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index a840ede9623..83042336813 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -163,7 +163,7 @@ void isotropic_remeshing(const FaceRange& faces get_property_map(vertex_point, pmesh)); typedef typename Default_face_index_map::type FIMap; FIMap fimap = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); + CGAL::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, @@ -341,7 +341,7 @@ void split_long_edges(const EdgeRange& edges typedef typename Default_face_index_map::type FIMap; FIMap fimap = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); + CGAL::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h index ac8333f2e59..9391cfc71a7 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h @@ -187,7 +187,7 @@ collect_duplicated_stitchable_boundary_edges cc = get(Face_property_tag(), pmesh); auto fim = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(pmesh, np); + CGAL::get_initialized_face_index_map(pmesh, np); num_component = num_component_wrapper(pmesh, cc, fim); border_edges_per_cc.resize(num_component); } diff --git a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h index 642373f491e..c9018e89a96 100644 --- a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h +++ b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h @@ -539,7 +539,7 @@ public: // face index map auto fid_map = - CGAL::Polygon_mesh_processing::get_initialized_face_index_map(tm, np); + CGAL::get_initialized_face_index_map(tm, np); std::size_t nb_cc = Polygon_mesh_processing::connected_components( From 79c390eb6d4dfcc8c6085b0838431c07780c457e Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 26 Feb 2020 16:17:17 +0100 Subject: [PATCH 23/86] fix warning --- BGL/include/CGAL/boost/graph/named_params_helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index de23c405db3..5d801b3e261 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -156,7 +156,7 @@ namespace CGAL { //default case : don't do anything template - void initialize_index_map(PMap, const Graph&, const SimplexTag& t, const IsWritableTag& w) + void initialize_index_map(PMap, const Graph&, const SimplexTag&, const IsWritableTag&) {} From 733fd95df7dca62b9c7cf1242e3236dc04940279 Mon Sep 17 00:00:00 2001 From: Mael Date: Fri, 28 Feb 2020 13:58:19 +0100 Subject: [PATCH 24/86] Misc cleaning --- .../include/CGAL/Polygon_mesh_processing/border.h | 3 +-- .../Polygon_mesh_processing/connected_components.h | 10 +++------- .../CGAL/Polygon_mesh_processing/corefinement.h | 6 ++---- .../CGAL/Polygon_mesh_processing/detect_features.h | 3 +-- .../include/CGAL/Polygon_mesh_processing/orientation.h | 6 ++---- .../include/CGAL/Polygon_mesh_processing/remesh.h | 6 ++---- .../CGAL/Polygon_mesh_processing/stitch_borders.h | 3 +-- .../CGAL/Rigid_triangle_mesh_collision_detection.h | 3 +-- 8 files changed, 13 insertions(+), 27 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index a7704f6f9ca..b6b28f8aa23 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -179,8 +179,7 @@ namespace Polygon_mesh_processing { if (faces.empty()) return out; - auto fim = - CGAL::get_initialized_face_index_map(pmesh, np); + auto fim = CGAL::get_initialized_face_index_map(pmesh, np); return internal::border_halfedges_impl(faces, fim, out, pmesh, np); } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index cef16f633ca..70ed0334a6b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -221,7 +221,6 @@ connected_components(const PolygonMesh& pmesh, internal::No_constraint()); typedef typename Default_face_index_map::type FaceIndexMap; - FaceIndexMap fimap = get_initialized_face_index_map(pmesh, np); typename boost::property_traits::value_type i=0; @@ -509,8 +508,7 @@ std::size_t keep_large_connected_components(PolygonMesh& pmesh, using parameters::get_parameter; typedef typename Default_face_index_map::type FaceIndexMap; - FaceIndexMap fim = - CGAL::get_initialized_face_index_map(pmesh, np); + FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def::type FaceIndexMap; - FaceIndexMap fim = - CGAL::get_initialized_face_index_map(pmesh, np); + FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); //vector_property_map boost::vector_property_map face_cc(fim); @@ -906,8 +903,7 @@ void keep_connected_components(PolygonMesh& pmesh //FaceIndexMap typedef typename Default_face_index_map::type FaceIndexMap; - FaceIndexMap fim = - CGAL::get_initialized_face_index_map(pmesh, np); + FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); //vector_property_map boost::vector_property_map face_cc(fim); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h index b579e484ccc..3d1b4e88bbe 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h @@ -185,8 +185,7 @@ bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) Vpm vpm = parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm)); - auto fid_map = - CGAL::get_initialized_face_index_map(tm, np); + auto fid_map = CGAL::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); @@ -1012,8 +1011,7 @@ namespace experimental { get_property_map(boost::vertex_point, tm)); // Face index map typedef typename Default_face_index_map::type Fid_map; - Fid_map fid_map = - CGAL::get_initialized_face_index_map(tm, np); + Fid_map fid_map = CGAL::get_initialized_face_index_map(tm, np); // Edge is-constrained maps typedef typename internal_np::Lookup_named_param_def < diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h index 05f629f127c..c6b5149946e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h @@ -139,8 +139,7 @@ detect_surface_patches(PolygonMesh& p, const NamedParameters& np) { //extract types from NPs - auto fimap = - CGAL::get_initialized_face_index_map(p, np); + auto fimap = CGAL::get_initialized_face_index_map(p, np); int offset = static_cast( parameters::choose_parameter(parameters::get_parameter(np, internal_np::first_index), diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index 2e9618d8188..d3cde0501e8 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -484,8 +484,7 @@ void orient(TriangleMesh& tm, const NamedParameters& np) Vpm vpm = CGAL::parameters::choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm)); - auto fid_map = - CGAL::get_initialized_face_index_map(tm, np); + auto fid_map = CGAL::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); @@ -591,8 +590,7 @@ void orient_to_bound_a_volume(TriangleMesh& tm, Vpm vpm = CGAL::parameters::choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm)); - auto fid_map = - CGAL::get_initialized_face_index_map(tm, np); + auto fid_map = CGAL::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index 83042336813..42d5b8bcbec 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -162,8 +162,7 @@ void isotropic_remeshing(const FaceRange& faces VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)); typedef typename Default_face_index_map::type FIMap; - FIMap fimap = - CGAL::get_initialized_face_index_map(pmesh, np); + FIMap fimap = CGAL::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, @@ -340,8 +339,7 @@ void split_long_edges(const EdgeRange& edges get_property_map(vertex_point, pmesh)); typedef typename Default_face_index_map::type FIMap; - FIMap fimap = - CGAL::get_initialized_face_index_map(pmesh, np); + FIMap fimap = CGAL::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h index 9391cfc71a7..36e2fef9bb6 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h @@ -186,8 +186,7 @@ collect_duplicated_stitchable_boundary_edges { cc = get(Face_property_tag(), pmesh); - auto fim = - CGAL::get_initialized_face_index_map(pmesh, np); + auto fim = CGAL::get_initialized_face_index_map(pmesh, np); num_component = num_component_wrapper(pmesh, cc, fim); border_edges_per_cc.resize(num_component); } diff --git a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h index c9018e89a96..53d20d4fc3b 100644 --- a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h +++ b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h @@ -538,8 +538,7 @@ public: // face index map - auto fid_map = - CGAL::get_initialized_face_index_map(tm, np); + auto fid_map = CGAL::get_initialized_face_index_map(tm, np); std::size_t nb_cc = Polygon_mesh_processing::connected_components( From 6b147c89a02894bbf3f04e73c4abc269b75c4be8 Mon Sep 17 00:00:00 2001 From: Mael Date: Fri, 28 Feb 2020 13:59:42 +0100 Subject: [PATCH 25/86] Fix doc --- .../CGAL/Polygon_mesh_processing/clip.h | 8 ++-- .../connected_components.h | 45 ++++++++----------- .../Polygon_mesh_processing/detect_features.h | 5 +-- .../Polygon_mesh_processing/orientation.h | 14 +++--- .../CGAL/Polygon_mesh_processing/remesh.h | 7 ++- 5 files changed, 34 insertions(+), 45 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h index 151e743d509..5b914813af2 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -274,9 +274,9 @@ clip_to_bbox(const Plane_3& plane, * \pre \link CGAL::Polygon_mesh_processing::does_bound_a_volume() `CGAL::Polygon_mesh_processing::does_bound_a_volume(clipper)` \endlink * * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. - * If `TriangleMesh` * has an internal not writable property map + * If `TriangleMesh` has an internal not modifiable property map * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; else, it will be. + * as a named parameter, then the internal one must be initialized; otherwise, it will be. * * @tparam NamedParameters1 a sequence of \ref pmp_namedparameters "Named Parameters" * @tparam NamedParameters2 a sequence of \ref pmp_namedparameters "Named Parameters" @@ -366,9 +366,9 @@ bool dispatch_clip_call(TriangleMesh& tm, TriangleMesh& clipper, * \pre \link CGAL::Polygon_mesh_processing::does_self_intersect() `!CGAL::Polygon_mesh_processing::does_self_intersect(tm)` \endlink * * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. - * If `TriangleMesh` has an internal not writable property map + * If `TriangleMesh` has an internal non modifiable property map * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; else, it will be. + * as a named parameter, then the internal one must be initialized; otherwise, it will be. * An internal property map for `CGAL::vertex_point_t` must be available. * * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 70ed0334a6b..0c97c86d56f 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -171,8 +171,7 @@ connected_component(typename boost::graph_traits::face_descriptor s * \ingroup keep_connected_components_grp * computes for each face the index of the corresponding connected component. * - * If `PolygonMesh` - * has an internal non writable property map + * If `PolygonMesh` has an internal non modifiable property map * for `CGAL::face_index_t` and no `face_index_map` is given * as a named parameter, then the internal one must be initialized; otherwise, it will be. * @@ -325,10 +324,9 @@ std::size_t number_of_connected_components(const PolygonMesh& pmesh) * By default, the size of a face is `1` (and thus the size of a connected component is the number * of faces it contains), but it is also possible to pass custom sizes, such as the area of the face. * -* If `PolygonMesh` -* has a non writable internal property map -* for `CGAL::face_index_t` or `CGAL::vertex_index_t` and no `face_index_map` (respectively `vertex_index_map`) is given -* as a named parameter, then the internal one(s) must be initialized. Otherwise, it will be. +* If `PolygonMesh` has a non modifiable internal property map +* for `CGAL::face_index_t` (resp. `CGAL::vertex_index_t`) and no `face_index_map` (resp. `vertex_index_map`) is given +* as a named parameter, then the internal one must be initialized. Otherwise, it will be. * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" @@ -372,8 +370,8 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, using parameters::get_parameter; typedef typename Default_face_index_map::type FaceIndexMap; - FaceIndexMap fimap = get_initialized_face_index_map(pmesh, np); + // FaceSizeMap typedef typename internal_np::Lookup_named_param_def::%face_descriptor` * and `boost::graph_traits::%halfedge_descriptor` must be * models of `Hashable`. -* If `PolygonMesh` - * has an internal not writable property map - * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; else, it will be. +* If `PolygonMesh` has a non modifiable internal property map +* for `CGAL::face_index_t` and no `face_index_map` is given +* as a named parameter, then the internal one must be initialized; otherwise, it will be. * * @tparam FaceRange range of `boost::graph_traits::%face_descriptor`, model of `Range`. Its iterator type is `ForwardIterator`. From e94da7c669ffd2a625b2eedcc877de77eff536e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 2 Mar 2020 14:00:11 +0100 Subject: [PATCH 26/86] Remove trailing whitespace --- .../CGAL/boost/graph/named_params_helper.h | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 5d801b3e261..6863ca4564b 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -42,8 +42,8 @@ namespace CGAL { class Eigen_svd; class Lapack_svd; // - - + + //helper classes template class property_map_selector @@ -123,20 +123,20 @@ namespace CGAL { { CGAL::helpers::init_vertex_indices(g, map); } - + template< class PMap, class Graph, typename T> void initialize_index_map(PMap map, const Graph& g, const CGAL::dynamic_vertex_property_t&, const CGAL::Tag_true&) { CGAL::helpers::init_vertex_indices(g, map); } - + //cases the map is writable for halfedges template< class PMap, class Graph> void initialize_index_map(PMap map, const Graph& g, const boost::halfedge_index_t&, const CGAL::Tag_true&) { CGAL::helpers::init_halfedge_indices(g, map); } - + template< class PMap, class Graph, typename T> void initialize_index_map(PMap map, const Graph& g, const CGAL::dynamic_halfedge_property_t&&, const CGAL::Tag_true&) { @@ -153,13 +153,13 @@ namespace CGAL { { CGAL::helpers::init_face_indices(g, map); } - + //default case : don't do anything template void initialize_index_map(PMap, const Graph&, const SimplexTag&, const IsWritableTag&) {} - + #define CGAL_IS_PMAP_WRITABLE(TAG) template \ struct Is_pmap_writable{ typedef CGAL::Tag_true result; }; \ template<> \ @@ -196,7 +196,7 @@ namespace CGAL { ::const_type>::category Category; typedef typename boost::property_traits::reference Reference; - + Map_const_type map = get(t, m); typename Is_pmap_writable >::result is_writable; @@ -216,7 +216,7 @@ namespace CGAL { } }//end of internal_np - + //define types for maps : //struct Default_face_index_map //struct Default_vertex_index_map @@ -235,13 +235,13 @@ namespace CGAL { typename boost::property_map::const_type \ > ::type type; \ }; - + CGAL_DEF_MAP_TYPE(face) CGAL_DEF_MAP_TYPE(vertex) CGAL_DEF_MAP_TYPE(halfedge) #undef CGAL_DEF_MAP_TYPE - - + + template class Get_index_map_from_NP { @@ -250,13 +250,13 @@ namespace CGAL { const Mesh& m; const NamedParameters& np; const Parameter p; - + public: //get the Default tag : //if Mesh has an internal property map for Tag, use Tag, else use the Dynamic_tag. typedef typename boost::mpl::if_c::value , Tag, Dynamic_tag>::type Final_tag; - + //If Parameter is in NamedParameters, take the NP map. //Else, take the default map. typedef typename internal_np::Lookup_named_param_def< @@ -264,23 +264,23 @@ namespace CGAL { NamedParameters, typename boost::property_map::const_type > ::type PropertyMapType; - - + + Get_index_map_from_NP(const Tag, const Dynamic_tag dtag, const Mesh& m, const NamedParameters& np, const Parameter p) : dtag(dtag), m(m), np(np), p(p) {} - - + + PropertyMapType property_map() { return internal_np::get_ndi_map(parameters::get_parameter(np, p), Final_tag(), dtag, m); } }; - + //define the // get_initialized_face_index_map(), get_initialized_vertex_index_map(), get_initialized_halfedge_index_map() // functions. @@ -302,7 +302,7 @@ namespace CGAL { CGAL_DEF_GET_INIT_ID_MAP(halfedge) #undef CGAL_DEF_GET_INIT_ID_MAP - + template > class GetVertexPointMap @@ -420,7 +420,7 @@ namespace CGAL { DummyNormalPmap//default > ::type type; }; - + namespace Point_set_processing_3 { @@ -436,7 +436,7 @@ namespace CGAL { typedef std::random_access_iterator_tag iterator_category; }; }; - + namespace parameters { template @@ -450,7 +450,7 @@ namespace CGAL { namespace internal{ BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_nested_type_iterator, iterator, false) } - + template::value> class GetPointMap @@ -572,7 +572,7 @@ namespace CGAL { DefaultPMap > ::type const_type; }; - + template class GetPlaneIndexMap { @@ -620,7 +620,7 @@ namespace CGAL { }; } // namespace Point_set_processing_3 - + template class GetSolver { @@ -653,10 +653,10 @@ namespace CGAL { typedef int Matrix; static FT solve (const Matrix&, Vector&) { return 0.; } }; - + public: typedef DummySvdTraits NoTraits; - + typedef typename internal_np::Lookup_named_param_def < internal_np::svd_traits_t, NamedParameters, @@ -669,7 +669,7 @@ namespace CGAL { #endif > ::type type; }; - + } //namespace CGAL From 7e303f421f14bec51b5f9fa089bb85675862afa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 09:02:13 +0100 Subject: [PATCH 27/86] Add 'Is_writable_property_map' Note the following: 'lvalue_pmap_tag' is annoying, because the property map is allowed to be non-mutable, but boost::lvalue_property_map_tag is !always! defined as: struct lvalue_property_map_tag : public read_write_property_map_tag so we can't just check that 'writable_property_map_tag' is a base of the the pmap's category. Instead, this struct checks if the reference is non-const, which is not completely correct: map[key] returning a non-const reference doesn't mean that 'put(map, key, val)' exists, which is what a writable property map must define. --- BGL/include/CGAL/boost/graph/properties.h | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index 7915d818048..fc3a315861c 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -298,6 +298,33 @@ struct Point_accessor reference operator[](Handle h) const { return h->point(); } }; +// @todo test this +// this one is basically 'readable_property_map_tag' +template ::category> +struct Is_writable_property_map : CGAL::Tag_false { }; + +template +struct Is_writable_property_map : CGAL::Tag_true { }; + +template +struct Is_writable_property_map : CGAL::Tag_true { }; + +// 'lvalue_pmap_tag' is annoying, because the property map is allowed to be non-mutable, +// but boost::lvalue_property_map_tag is defined as: +// struct lvalue_property_map_tag : public read_write_property_map_tag +// so we can't just check that 'writable_property_map_tag' is a base of the the lvalue tag. +// +// This checks if the reference is non-const, which is not completely correct: map[key] returning +// a non-const reference doesn't mean that 'put(map, key, val)' exists, which is what a writable +// property map must define. +template +struct Is_writable_property_map + : boost::mpl::if_c::reference>::type>::value, + CGAL::Tag_false, CGAL::Tag_true>::type +{ }; + } // namespace internal // Needed by PMP::detec_features and Mesh_3 From d6bbf2bb5f7038bed51f973f554fc92ec52f9f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 11:56:50 +0100 Subject: [PATCH 28/86] Fix implementation of initialized index map getters --- .../internal/initialized_index_maps_helpers.h | 318 ++++++++++++++++++ .../CGAL/boost/graph/named_params_helper.h | 201 +---------- BGL/include/CGAL/boost/graph/properties.h | 167 +-------- .../include/CGAL/Dynamic_property_map.h | 4 +- 4 files changed, 336 insertions(+), 354 deletions(-) create mode 100644 BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h new file mode 100644 index 00000000000..e939a99e97b --- /dev/null +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -0,0 +1,318 @@ +// Copyright (c) 2020 GeometryFactory (France). All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Mael Rouxel-Labbé +// Maxime Gimeno + +#ifndef CGAL_BOOST_GRAPH_INITIALIZED_INTERNAL_INDEX_MAPS_HELPERS +#define CGAL_BOOST_GRAPH_INITIALIZED_INTERNAL_INDEX_MAPS_HELPERS + +#include +#include +#include +#include +#include + +#include + +namespace CGAL { +namespace BGL { +namespace internal { + +// Check that an index map has been correctly initialized +template +bool is_index_map_valid(const IndexMap idmap, + const std::size_t num_simplices, + const DescriptorRange& range) +{ + typedef typename boost::property_traits::value_type Id_type; + + Id_type max_id = static_cast(num_simplices); + std::vector indices(max_id); + for(const auto& d : range) + { + const Id_type id = get(idmap, d); + if(id >= 0 && id < max_id && !indices[id]) + { + indices[id] = true; + } + else + { + std::cerr << "Invalid ID: " << id << " num_simplices: " << num_simplices << std::endl; + return false; + } + } + + return true; +} + +template +bool is_index_map_valid(const CGAL::internal_np::vertex_index_t, VertexIndexPropertyMap vertex_index_map, const Graph& g) +{ + return is_index_map_valid(vertex_index_map, num_vertices(g), vertices(g)); +} + +template +bool is_index_map_valid(const CGAL::internal_np::halfedge_index_t, HalfedgeIndexPropertyMap halfedge_index_map, const Graph& g) +{ + return is_index_map_valid(halfedge_index_map, num_halfedges(g), halfedges(g)); +} + +template +bool is_index_map_valid(const CGAL::internal_np::edge_index_t, EdgeIndexPropertyMap edge_index_map, const Graph& g) +{ + return is_index_map_valid(edge_index_map, num_edges(g), edges(g)); +} + +template +bool is_index_map_valid(const CGAL::internal_np::face_index_t, FaceIndexPropertyMap face_index_map, const Graph& g) +{ + return is_index_map_valid(face_index_map, num_faces(g), faces(g)); +} + +template +void initialize_index_map(const Parameter, IndexPropertyMap, const Graph&) +{ + // Unknown parameter; should never be here. + CGAL_assertion(false); +} + +template ::value> +struct Index_map_initializer +{ + void operator()(const CGAL::internal_np::vertex_index_t, IndexPropertyMap vertex_index_map, const Graph& g) + { + typename boost::property_traits::value_type i = 0; + for(typename boost::graph_traits::vertex_descriptor vd : vertices(g)) + put(vertex_index_map, vd, i++); + } + + void operator()(const CGAL::internal_np::halfedge_index_t, IndexPropertyMap halfedge_index_map, const Graph& g) + { + typename boost::property_traits::value_type i = 0; + for(typename boost::graph_traits::halfedge_descriptor hd : halfedges(g)) + put(halfedge_index_map, hd, i++); + } + + void operator()(const CGAL::internal_np::edge_index_t, IndexPropertyMap edge_index_map, const Graph& g) + { + typename boost::property_traits::value_type i = 0; + for(typename boost::graph_traits::edge_descriptor ed : edges(g)) + put(edge_index_map, ed, i++); + } + + void operator()(const CGAL::internal_np::face_index_t, IndexPropertyMap face_index_map, const Graph& g) + { + typename boost::property_traits::value_type i = 0; + for(typename boost::graph_traits::face_descriptor fd : faces(g)) + put(face_index_map, fd, i++); + } + + template + void operator()(const Parameter, IndexPropertyMap, const Graph&) + { + // Unknown parameter; should never be here. + CGAL_assertion(false); + } +}; + +template +struct Index_map_initializer +{ + template + void operator()(const Parameter, IndexPropertyMap, const Graph&) + { + // The property map is not writable; should never be here. + CGAL_assertion(false); + } +}; + +// Just for convenience, define the following functions: +// +// BGL::internal::initialize_vertex_index_map() +// BGL::internal::initialize_halfedge_index_map() +// BGL::internal::initialize_edge_index_map() +// BGL::internal::initialize_face_index_map() + +#define CGAL_DEF_INITIALIZE_ID_MAP_FUNCTION(TYPE) \ +template \ +void initialize_##TYPE##_index_map(WritableIndexPropertyMap index_map, \ + const Graph& g) \ +{ \ + Index_map_initializer initializer; \ + initializer(CGAL::internal_np::TYPE##_index_t(), index_map, g); \ +} + +CGAL_DEF_INITIALIZE_ID_MAP_FUNCTION(vertex) +CGAL_DEF_INITIALIZE_ID_MAP_FUNCTION(halfedge) +CGAL_DEF_INITIALIZE_ID_MAP_FUNCTION(edge) +CGAL_DEF_INITIALIZE_ID_MAP_FUNCTION(face) + +#undef CGAL_DEF_INITIALIZE_ID_FUCNTION + +// Using the pmap passed in named parameters +template +IndexMap get_initialized_index_map(const IndexMap index_map, + const Parameter p, Tag, DynamicTag, + const Graph& g) +{ + CGAL_USE(g); + CGAL_USE(p); + CGAL_assertion(is_index_map_valid(p, index_map, g)); + + return index_map; +} + +// Using the internal to the mesh +template +typename boost::property_map::const_type +get_initialized_index_map(CGAL::internal_np::Param_not_found, + const Parameter p, const Tag tag, DynamicTag, + const Graph& g) // @todo non-const +{ + typedef typename boost::property_map::const_type Index_map; + Index_map index_map = get(tag, g); + + if(CGAL::internal::Is_writable_property_map::value) + { + if(!is_index_map_valid(p, index_map, g)) + Index_map_initializer{}(p, index_map, g); + } + else // not writable + { + CGAL_assertion(is_index_map_valid(p, index_map, g)); + } + + return index_map; +} + +// Create a dynamic property and initialize it +template +typename boost::property_map::const_type +get_initialized_index_map(CGAL::internal_np::Param_not_found, + const Parameter p, const DynamicTag tag, DynamicTag, + const Graph& g) +{ + typedef typename boost::property_map::const_type Index_map; + + Index_map index_map = get(tag, g); + Index_map_initializer{}(p, index_map, g); + + return index_map; +} + +template > +class GetInitializedIndexMap +{ +public: + // Definition of the Tag that will be used if there is no named parameter + typedef typename boost::mpl::if_c< + CGAL::graph_has_property::value, Tag, DynamicTag>::type Final_tag; + + typedef typename internal_np::Lookup_named_param_def< + Parameter, + NamedParameters, + typename boost::property_map::type>::type type; + + typedef typename internal_np::Lookup_named_param_def< + Parameter, + NamedParameters, + typename boost::property_map::const_type>::type const_type; + + static const_type get(const Parameter p, const Graph& g, const NamedParameters& np) + { + return BGL::internal::get_initialized_index_map(parameters::get_parameter(np, p), + p, Final_tag(), DynamicTag(), g); + } + + static type get(const Parameter p, Graph& g, const NamedParameters& np) + { + return BGL::internal::get_initialized_index_map(parameters::get_parameter(np, p), + p, Final_tag(), DynamicTag(), g); + } +}; + +} // namespace internal +} // namespace BGL + +// @todo move below to named_params_... + +#define CGAL_DEF_GET_INDEX_TYPE(CTYPE, TYPE) \ +template > \ +struct GetInitialized##CTYPE##IndexMap \ + : public BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters> \ +{ }; + +CGAL_DEF_GET_INDEX_TYPE(Vertex, vertex) +CGAL_DEF_GET_INDEX_TYPE(Halfedge, halfedge) +CGAL_DEF_GET_INDEX_TYPE(Edge, edge) +CGAL_DEF_GET_INDEX_TYPE(Face, face) + +#undef CGAL_DEF_GET_INDEX_TYPE + +// @todo move below to properties.h + +// Define the following functions: +// +// get_initialized_vertex_index_map(); +// get_initialized_halfedge_index_map(); +// get_initialized_edge_index_map(); +// get_initialized_face_index_map() +// +// The function returns: +// - the index property map passed in the NPs, if passed in the NPs; it must be initialized by the user; +// - the internal index property map if it is the graph has one. It is initialized if needed and possible; +// - an initialized dynamic pmap otherwise. + +#define CGAL_DEF_GET_INITIALIZED_INDEX_MAP(TYPE) \ +template \ +typename BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters>::const_type \ +get_initialized_##TYPE##_index_map(const Graph& g, \ + const NamedParameters& np) \ +{ \ + typedef BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters> Index_map_getter; \ + return Index_map_getter::get(CGAL::internal_np::TYPE##_index_t(), g, np); \ +} \ +template \ +typename BGL::internal::GetInitializedIndexMap, \ + Graph>::const_type \ +get_initialized_##TYPE##_index_map(const Graph& g) \ +{ \ + return get_initialized_##TYPE##_index_map(g, CGAL::parameters::all_default()); \ +} + +// @todo add the non-const Graph& version + +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(vertex) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(halfedge) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(edge) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face) + +#undef CGAL_DEF_GET_INITIALIZED_INDEX_MAP + +} // namespace CGAL + +#endif // CGAL_BOOST_GRAPH_INITIALIZED_INTERNAL_INDEX_MAPS_HELPERS diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 6863ca4564b..68a79777a2d 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -19,17 +19,16 @@ #ifndef CGAL_BOOST_GRAPH_NAMED_PARAMETERS_HELPERS_H #define CGAL_BOOST_GRAPH_NAMED_PARAMETERS_HELPERS_H +#include #include - +#include +#include #include #include - #include -#include + #include #include -#include - #include #include @@ -106,7 +105,8 @@ namespace CGAL { property_map_selector pms; return pms.get_const_pmap(p, pmesh); } -// shortcut for accessing the value type of the property map + + // Shortcut for accessing the value type of the property map template class property_map_value { typedef typename boost::property_map::const_type PMap; @@ -114,195 +114,6 @@ namespace CGAL { typedef typename boost::property_traits::value_type type; }; - namespace internal_np - { - - //cases the map is writable for vertices - template< class PMap, class Graph> - void initialize_index_map(PMap map, const Graph& g, const boost::vertex_index_t&, const CGAL::Tag_true&) - { - CGAL::helpers::init_vertex_indices(g, map); - } - - template< class PMap, class Graph, typename T> - void initialize_index_map(PMap map, const Graph& g, const CGAL::dynamic_vertex_property_t&, const CGAL::Tag_true&) - { - CGAL::helpers::init_vertex_indices(g, map); - } - - //cases the map is writable for halfedges - template< class PMap, class Graph> - void initialize_index_map(PMap map, const Graph& g, const boost::halfedge_index_t&, const CGAL::Tag_true&) - { - CGAL::helpers::init_halfedge_indices(g, map); - } - - template< class PMap, class Graph, typename T> - void initialize_index_map(PMap map, const Graph& g, const CGAL::dynamic_halfedge_property_t&&, const CGAL::Tag_true&) - { - CGAL::helpers::init_halfedge_indices(g, map); - } - //cases the map is writable for faces - template< class PMap, class Graph> - void initialize_index_map(PMap map, const Graph& g, const boost::face_index_t&, const CGAL::Tag_true&) - { - CGAL::helpers::init_face_indices(g, map); - } - template< class PMap, class Graph, typename T> - void initialize_index_map(PMap map, const Graph& g, const CGAL::dynamic_face_property_t&, const CGAL::Tag_true&) - { - CGAL::helpers::init_face_indices(g, map); - } - - //default case : don't do anything - template - void initialize_index_map(PMap, const Graph&, const SimplexTag&, const IsWritableTag&) - {} - - -#define CGAL_IS_PMAP_WRITABLE(TAG) template \ - struct Is_pmap_writable{ typedef CGAL::Tag_true result; }; \ - template<> \ - struct Is_pmap_writable >{ typedef CGAL::Tag_false result; }; - - //Default is false - template - struct Is_pmap_writable{ - typedef CGAL::Tag_false result; - }; - - //Pmaps with these tags will be considered writable, unless their reference is const - CGAL_IS_PMAP_WRITABLE(boost::read_write_property_map_tag) - CGAL_IS_PMAP_WRITABLE(boost::writable_property_map_tag) - CGAL_IS_PMAP_WRITABLE(boost::lvalue_property_map_tag) -#undef CGAL_IS_PMAP_WRITABLE - - //overloads used to select a default map: - // use the one passed in the named parameters (user must have initialized it) - template - MapFromNP - get_ndi_map(MapFromNP m, Default_tag, Dynamic_tag, const Mesh&) - { - return m; - } - - // use the one internal to the mesh (it will be init if writable) - template - typename boost::property_map::const_type - get_ndi_map(CGAL::internal_np::Param_not_found, Default_tag t, Dynamic_tag , const Mesh& m) - { - typedef typename boost::property_map::const_type Map_const_type; - typedef typename boost::property_traits - - ::const_type>::category Category; - typedef typename boost::property_traits::reference Reference; - - Map_const_type map = get(t, m); - typename Is_pmap_writable >::result is_writable; - initialize_index_map(map, m, t,is_writable); - return map; - } - - // create a dynamic property and initialize it - template - typename boost::property_map::const_type - get_ndi_map(CGAL::internal_np::Param_not_found, Dynamic_tag t, Dynamic_tag , const Mesh& m) - { - typedef typename boost::property_map::const_type Map_const_type; - Map_const_type map = get(t,m); - initialize_index_map(map, m, t, CGAL::Tag_true()); - return map; - } - - }//end of internal_np - - //define types for maps : - //struct Default_face_index_map - //struct Default_vertex_index_map - //struct Default_halfedge_index_map -#define CGAL_DEF_MAP_TYPE(TYPE) \ - template \ - struct Default_##TYPE##_index_map{ \ - typedef typename boost::mpl::if_c< \ - CGAL::graph_has_property::value \ - , boost::TYPE##_index_t \ - , CGAL::dynamic_##TYPE##_property_t \ - >::type Final_tag; \ - typedef typename internal_np::Lookup_named_param_def< \ - internal_np::TYPE##_index_t, \ - NP, \ - typename boost::property_map::const_type \ - > ::type type; \ -}; - - CGAL_DEF_MAP_TYPE(face) - CGAL_DEF_MAP_TYPE(vertex) - CGAL_DEF_MAP_TYPE(halfedge) -#undef CGAL_DEF_MAP_TYPE - - - template - class Get_index_map_from_NP { - private : - const Dynamic_tag dtag; - const Mesh& m; - const NamedParameters& np; - const Parameter p; - - public: - //get the Default tag : - //if Mesh has an internal property map for Tag, use Tag, else use the Dynamic_tag. - typedef typename boost::mpl::if_c::value - , Tag, Dynamic_tag>::type Final_tag; - - //If Parameter is in NamedParameters, take the NP map. - //Else, take the default map. - typedef typename internal_np::Lookup_named_param_def< - Parameter, - NamedParameters, - typename boost::property_map::const_type - > ::type PropertyMapType; - - - Get_index_map_from_NP(const Tag, - const Dynamic_tag dtag, - const Mesh& m, - const NamedParameters& np, - const Parameter p) - : dtag(dtag), m(m), np(np), p(p) {} - - - PropertyMapType property_map() - { - return internal_np::get_ndi_map(parameters::get_parameter(np, p), - Final_tag(), dtag, m); - } - }; - - //define the - // get_initialized_face_index_map(), get_initialized_vertex_index_map(), get_initialized_halfedge_index_map() - // functions. - //This comment is here to make it easier to find the definition of the functions with a grep. - -#define CGAL_DEF_GET_INIT_ID_MAP(TYPE) template \ - typename Default_##TYPE##_index_map::type \ - get_initialized_##TYPE##_index_map(const PolygonMesh& pmesh, const NamedParameters& np){ \ - typedef Get_index_map_from_NP, \ - PolygonMesh, NamedParameters, internal_np::TYPE##_index_t> MapGetter; \ - MapGetter get_map(boost::TYPE##_index_t(), \ - CGAL::dynamic_##TYPE##_property_t(), \ - pmesh, np, internal_np::TYPE##_index); \ - return get_map.property_map(); \ - } - CGAL_DEF_GET_INIT_ID_MAP(face) - CGAL_DEF_GET_INIT_ID_MAP(vertex) - CGAL_DEF_GET_INIT_ID_MAP(halfedge) - -#undef CGAL_DEF_GET_INIT_ID_MAP - template > class GetVertexPointMap diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index fc3a315861c..1f28aac582d 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -14,15 +14,15 @@ #define CGAL_BOOST_GRAPH_BGL_PROPERTIES_H #include +#include +#include + #include #include -#include -#include -#include -#include #include #include +#include namespace CGAL { @@ -88,156 +88,7 @@ using boost::face_external_index_t; using boost::face_external_index; } // CGAL -namespace CGAL{ -namespace helpers { - -//check that an existing map is initialized/valid -template -bool is_index_map_valid( std::size_t num_simplices, - const SimplexRange& range, - const IndexMap& idmap) -{ - - typedef typename boost::property_traits::value_type Id_type; - Id_type max_id = static_cast(num_simplices); - std::vector indices(max_id); - for(const auto& simplex : range) - { - Id_type id = get(idmap, simplex); - if( id >= 0 && id < max_id && ! indices[id]) - indices[id] = true; - else - return false; - } - return true; -} - - -// matches read-write property maps -template -void init_face_indices(PolygonMesh& pm, - FaceIndexMap& fid, - boost::read_write_property_map_tag, - Tag) -{ - if(is_index_map_valid(num_faces(pm), faces(pm), fid)) - return; - typename boost::property_traits::value_type i = 0; - for(typename boost::graph_traits::face_descriptor fd : - faces(pm)) - { - put(fid, fd, i); - ++i; - } -} -template -void init_vertex_indices(PolygonMesh& pm, - VertexIndexMap& vid, - boost::read_write_property_map_tag, - Tag) -{ - if(is_index_map_valid(num_vertices(pm), vertices(pm), vid)) - return; - typename boost::property_traits::value_type i = 0; - for(typename boost::graph_traits::vertex_descriptor vd : - vertices(pm)) - { - put(vid, vd, i); - ++i; - } -} -template -void init_halfedge_indices(PolygonMesh& pm, - HalfedgeIndexMap& hid, - boost::read_write_property_map_tag, - Tag) -{ - if(is_index_map_valid(num_halfedges(pm), halfedges(pm), hid)) - return; - typename boost::property_traits::value_type i = 0; - for(typename boost::graph_traits::halfedge_descriptor hd : - halfedges(pm)) - { - put(hid, hd, i); - ++i; - } -} - -// matches mutable Lvalue property maps -template -void init_face_indices(PolygonMesh& pm, - FaceIndexMap& fid, - boost::lvalue_property_map_tag, - boost::false_type) -{ - init_face_indices(pm, fid, - boost::read_write_property_map_tag(), boost::false_type()); -} -template -void init_vertex_indices(PolygonMesh& pm, - VertexIndexMap& vid, - boost::lvalue_property_map_tag, - boost::false_type) -{ - init_vertex_indices(pm, vid, - boost::read_write_property_map_tag(), boost::false_type()); -} -template -void init_halfedge_indices(PolygonMesh& pm, - HalfedgeIndexMap& hid, - boost::lvalue_property_map_tag, - boost::false_type) -{ - init_halfedge_indices(pm, hid, - boost::read_write_property_map_tag(), boost::false_type()); -} - -// matches all other types of property map -template -void init_face_indices(PolygonMesh&, FaceIndexMap, MapTag, Tag) -{} -template -void init_vertex_indices(PolygonMesh&, VertexIndexMap, MapTag, Tag) -{} -template -void init_halfedge_indices(PolygonMesh&, HalfedgeIndexMap, MapTag, Tag) -{} - -template -void init_face_indices(PolygonMesh& pm, FaceIndexMap fid) -{ - init_face_indices(pm, fid, - typename boost::property_traits::category(), - typename boost::is_const< - typename boost::remove_reference< - typename boost::property_traits::reference - >::type >::type() ); -} - -template -void init_vertex_indices(PolygonMesh& pm, VertexIndexMap vid) -{ - init_vertex_indices(pm, vid, - typename boost::property_traits::category(), - typename boost::is_const< - typename boost::remove_reference< - typename boost::property_traits::reference - >::type >::type() ); -} - -template -void init_halfedge_indices(PolygonMesh& pm, HalfedgeIndexMap hid) -{ - init_halfedge_indices(pm, hid, - typename boost::property_traits::category(), - typename boost::is_const< - typename boost::remove_reference< - typename boost::property_traits::reference - >::type >::type() ); -} - -} //namespace helpers - +namespace CGAL { namespace internal { template @@ -265,8 +116,8 @@ struct Edge_index_accessor }; template::type >::value> + bool is_const = std::is_const< + typename std::remove_reference::type >::value> struct Point_accessor : boost::put_get_helper< Reference, Point_accessor > { @@ -335,12 +186,12 @@ enum vertex_time_stamp_t { vertex_time_stamp}; enum halfedge_time_stamp_t { halfedge_time_stamp}; enum face_time_stamp_t { face_time_stamp}; -template +template struct vertex_incident_patches_t { typedef ID type; }; -template +template struct face_patch_id_t { typedef ID type; }; diff --git a/Property_map/include/CGAL/Dynamic_property_map.h b/Property_map/include/CGAL/Dynamic_property_map.h index 35cdcd5f4db..2300b4b5efe 100644 --- a/Property_map/include/CGAL/Dynamic_property_map.h +++ b/Property_map/include/CGAL/Dynamic_property_map.h @@ -13,11 +13,13 @@ #define CGAL_DYNAMIC_PROPERTY_MAP_H #include +#include + #include #include + #include #include - #include #include From a449948588846c26c1c5bd1ccfac00ce07527504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 11:57:23 +0100 Subject: [PATCH 29/86] Add (undocumented) edge_ids to T2_face_base_with_id_2.h This is done because the previous edge IDs can range from 0 to 3*num_faces(tr) + 2, which is greater than num_edges(tr) and is therefore not very rational. --- .../include/CGAL/Triangulation_face_base_with_id_2.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Triangulation_2/include/CGAL/Triangulation_face_base_with_id_2.h b/Triangulation_2/include/CGAL/Triangulation_face_base_with_id_2.h index d47a256a245..8d5a54281e1 100644 --- a/Triangulation_2/include/CGAL/Triangulation_face_base_with_id_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_face_base_with_id_2.h @@ -42,11 +42,15 @@ public: : Fb(v0, v1, v2, n0, n1, n2) { } - int& id() { return _id; } - int id() const { return _id; } + int& id() { return face_id; } + int id() const { return face_id; } + + int& edge_id(const std::size_t i) { return edge_ids[i]; } + int edge_id(const std::size_t i) const { return edge_ids[i]; } private: - int _id; + int face_id; + std::array edge_ids; }; } //namespace CGAL From 17f97fc460e353fa89cf49da9aacbd1df00db23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 11:59:01 +0100 Subject: [PATCH 30/86] Add a function to initialize triangulation IDs --- .../internal/properties_2D_triangulation.h | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h b/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h index 6bad3c9aa0c..cb308276022 100644 --- a/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h +++ b/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h @@ -368,6 +368,39 @@ put(PropertyTag p, CGAL_2D_TRIANGULATION& g, const Key& key, const Value& value) put(pmap, key, value); } +template < CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS > +void initialize_triangulation_IDs(CGAL_2D_TRIANGULATION& g) +{ + typedef typename boost::graph_traits< CGAL_2D_TRIANGULATION >::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits< CGAL_2D_TRIANGULATION >::halfedge_descriptor halfedge_descriptor; + typedef typename boost::graph_traits< CGAL_2D_TRIANGULATION >::edge_descriptor edge_descriptor; + typedef typename boost::graph_traits< CGAL_2D_TRIANGULATION >::face_descriptor face_descriptor; + + int vid = 0; + for(vertex_descriptor vd : vertices(g)) + vd->id() = vid++; + + int eid = 0; + for(edge_descriptor ed : edges(g)) + { + halfedge_descriptor hd = halfedge(ed, g); + face_descriptor fd = face(hd, g); + if(fd != boost::graph_traits< CGAL_2D_TRIANGULATION >::null_face()) + fd->edge_id(hd.second) = eid; + + halfedge_descriptor opp_hd = opposite(hd, g); + face_descriptor opp_fd = face(opp_hd, g); + if(opp_fd != boost::graph_traits< CGAL_2D_TRIANGULATION >::null_face()) + opp_fd->edge_id(opp_hd.second) = eid; + + ++eid; + } + + int fid = 0; + for(face_descriptor fd : faces(g)) + fd->id() = fid++; +} + } // namespace CGAL #undef CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS From d3feda16505c06a5366af2e0465bda25d6605a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 12:06:29 +0100 Subject: [PATCH 31/86] Update IDs getter for triangulation edge / halfedges --- .../internal/properties_2D_triangulation.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h b/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h index cb308276022..6f3423f2952 100644 --- a/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h +++ b/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h @@ -111,7 +111,7 @@ public: T2_halfedge_id_map(const Tr& tr) : tr(tr) { } // Halfedge id is twice the edge id, and +0/+1 depending whether - // h.first is such that h.first < opposite(h).first --> different ids + // h.first is such that h.first < opposite(h).first value_type operator[](key_type h) const { const Face_handle f1 = h.first; @@ -119,13 +119,13 @@ public: CGAL_assertion(!tr.is_infinite(f1) || !tr.is_infinite(f2)); if(tr.is_infinite(f1)) - return 2*(3 * f2->id() + f2->index(f1)); + return 2*(f2->edge_id(f2->index(f1))); else if(tr.is_infinite(f2)) - return 2*(3 * f1->id() + h.second) + 1; + return 2*(f1->edge_id(h.second)) + 1; else if(f1->id() < f2->id()) - return 2*(3 * f1->id() + h.second); + return 2*(f1->edge_id(h.second)); else - return 2*(3 * f2->id() + f2->index(f1)) + 1; + return 2*(f1->edge_id(h.second)) + 1; } private: @@ -152,13 +152,9 @@ public: CGAL_assertion(!tr.is_infinite(f1) || !tr.is_infinite(f2)); if(tr.is_infinite(f1)) - return 3 * f2->id() + f2->index(f1); - else if(tr.is_infinite(f2)) - return 3 * f1->id() + e.second; - else if(f1->id() < f2->id()) - return 3 * f1->id() + e.second; + return f2->edge_id(f2->index(f1)); else - return 3 * f2->id() + f2->index(f1); + return f1->edge_id(e.second); } private: From 529fc71dea9e186738572a38ed51bafba8ca355c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 12:31:44 +0100 Subject: [PATCH 32/86] Document initialize_triangulation_IDs --- .../BGL/CGAL/Triangulation_face_base_with_id_2.h | 14 ++++++++++++-- .../BGL/CGAL/Triangulation_vertex_base_with_id_2.h | 3 ++- BGL/doc/BGL/PackageDescription.txt | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h b/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h index 83e14e58af7..ebb5603be9d 100644 --- a/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h +++ b/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h @@ -5,11 +5,12 @@ namespace CGAL { The class `Triangulation_face_base_with_id_2` is a model of the concept `TriangulationFaceBase_2`, the base face of a -2D-triangulation. It provides an integer field that can be used to +2D-triangulation. It provides an integer field that can be used to index faces for \sc{Bgl} algorithms. Note that the user is in charge of setting indices correctly before -running a graph algorithm. +running a graph algorithm, by calling the function +`CGAL::initialize_triangulation_IDs(Triangulation&)`. \tparam TriangulationTraits_2 is the geometric traits class and must be a model of `TriangulationTraits_2`. @@ -42,4 +43,13 @@ int& id(); /// @} }; /* end Triangulation_face_base_with_id_2 */ + +/// \ingroup PkgBGLHelper +/// +/// This function initializes vertex, edge, and face indices of the triangulation `tr` and must +/// be called prior to using `tr` as a BGL graph in an algorithm that requires +/// vertex, halfedge, edge, or face indices. +template +void initialize_triangulation_IDs(Triangulation& tr); + } /* end namespace CGAL */ diff --git a/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h b/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h index a93691aa0b4..9937c6d59d0 100644 --- a/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h +++ b/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h @@ -9,7 +9,8 @@ concept `TriangulationVertexBase_2`, the base vertex of a index vertices for \sc{Bgl} algorithms. Note that the user is in charge of setting indices correctly before -running a graph algorithm. +running a graph algorithm, by calling the function +`CGAL::initialize_triangulation_IDs(Triangulation&)`. \tparam TriangulationTraits_2 is the geometric traits class and must be a model of `TriangulationTraits_2`. diff --git a/BGL/doc/BGL/PackageDescription.txt b/BGL/doc/BGL/PackageDescription.txt index 287b2662399..99fc1a01169 100644 --- a/BGL/doc/BGL/PackageDescription.txt +++ b/BGL/doc/BGL/PackageDescription.txt @@ -642,6 +642,8 @@ user might encounter. - `CGAL::clear()` - `CGAL::copy_face_graph()` +- `CGAL::initialize_triangulation_IDs()` + \cgalCRPSection{Iterators} - `CGAL::Halfedge_around_source_iterator` - `CGAL::Halfedge_around_target_iterator` From 1e91b35575f7e784e30bb805133bd8ddcc68974f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 12:31:55 +0100 Subject: [PATCH 33/86] Fix namespace of boost::***_index_t (should be CGAL::) --- BGL/doc/BGL/PackageDescription.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BGL/doc/BGL/PackageDescription.txt b/BGL/doc/BGL/PackageDescription.txt index 99fc1a01169..6d8678df6d2 100644 --- a/BGL/doc/BGL/PackageDescription.txt +++ b/BGL/doc/BGL/PackageDescription.txt @@ -574,11 +574,11 @@ Methods to read and write graphs. - `MutableFaceGraph` \cgalCRPSection{Properties} -- `boost::vertex_index_t` -- `boost::halfedge_index_t` -- `boost::edge_index_t` -- `boost::face_index_t` -- `boost::vertex_point_t` +- `CGAL::vertex_index_t` +- `CGAL::halfedge_index_t` +- `CGAL::edge_index_t` +- `CGAL::face_index_t` +- `CGAL::vertex_point_t` \cgalCRPSection{%CGAL Classes Adapted for the Graph API} From 839dcf71f558f1c8bf5e3119a1e20f9004b5ab39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 12:53:49 +0100 Subject: [PATCH 34/86] Improve section tag and description (BGL doc) --- BGL/doc/BGL/CGAL/HalfedgeDS_face_max_base_with_id.h | 2 +- .../BGL/CGAL/HalfedgeDS_halfedge_max_base_with_id.h | 2 +- BGL/doc/BGL/CGAL/HalfedgeDS_vertex_max_base_with_id.h | 2 +- BGL/doc/BGL/CGAL/Linear_cell_complex_bgl_min_items.h | 2 +- ...ear_cell_complex_for_bgl_combinatorial_map_helper.h | 2 +- BGL/doc/BGL/CGAL/Polyhedron_items_with_id_3.h | 4 ++-- BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h | 4 ++-- BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h | 2 +- BGL/doc/BGL/PackageDescription.txt | 9 ++++++--- BGL/test/BGL/test_Prefix.h | 10 +--------- 10 files changed, 17 insertions(+), 22 deletions(-) diff --git a/BGL/doc/BGL/CGAL/HalfedgeDS_face_max_base_with_id.h b/BGL/doc/BGL/CGAL/HalfedgeDS_face_max_base_with_id.h index 446481b9fc4..0006a4332e8 100644 --- a/BGL/doc/BGL/CGAL/HalfedgeDS_face_max_base_with_id.h +++ b/BGL/doc/BGL/CGAL/HalfedgeDS_face_max_base_with_id.h @@ -2,7 +2,7 @@ namespace CGAL { /*! -\ingroup PkgBGLHelper +\ingroup BGLGraphExternalIndices The class `HalfedgeDS_face_max_base_with_id` is a model of the `HalfedgeDSFace` concept. diff --git a/BGL/doc/BGL/CGAL/HalfedgeDS_halfedge_max_base_with_id.h b/BGL/doc/BGL/CGAL/HalfedgeDS_halfedge_max_base_with_id.h index 6e597c7d346..b9d7f4142eb 100644 --- a/BGL/doc/BGL/CGAL/HalfedgeDS_halfedge_max_base_with_id.h +++ b/BGL/doc/BGL/CGAL/HalfedgeDS_halfedge_max_base_with_id.h @@ -2,7 +2,7 @@ namespace CGAL { /*! -\ingroup PkgBGLHelper +\ingroup BGLGraphExternalIndices The class `HalfedgeDS_halfedge_max_base_with_id` is a model of the `HalfedgeDSHalfedge` concept. diff --git a/BGL/doc/BGL/CGAL/HalfedgeDS_vertex_max_base_with_id.h b/BGL/doc/BGL/CGAL/HalfedgeDS_vertex_max_base_with_id.h index 0839d254c8f..565236d880e 100644 --- a/BGL/doc/BGL/CGAL/HalfedgeDS_vertex_max_base_with_id.h +++ b/BGL/doc/BGL/CGAL/HalfedgeDS_vertex_max_base_with_id.h @@ -2,7 +2,7 @@ namespace CGAL { /*! -\ingroup PkgBGLHelper +\ingroup BGLGraphExternalIndices The class `HalfedgeDS_vertex_max_base_with_id` is a model of the `HalfedgeDSVertex` concept. It is diff --git a/BGL/doc/BGL/CGAL/Linear_cell_complex_bgl_min_items.h b/BGL/doc/BGL/CGAL/Linear_cell_complex_bgl_min_items.h index 0c9ab30a613..611ff3cd88b 100644 --- a/BGL/doc/BGL/CGAL/Linear_cell_complex_bgl_min_items.h +++ b/BGL/doc/BGL/CGAL/Linear_cell_complex_bgl_min_items.h @@ -2,7 +2,7 @@ namespace CGAL { /*! -\ingroup PkgBGLHelper +\ingroup BGLGraphExternalIndices The class `Linear_cell_complex_bgl_min_items` defines `void` as the information associated with darts, darts have ids and 0- and 2-attributes are enabled and have ids. diff --git a/BGL/doc/BGL/CGAL/Linear_cell_complex_for_bgl_combinatorial_map_helper.h b/BGL/doc/BGL/CGAL/Linear_cell_complex_for_bgl_combinatorial_map_helper.h index 72ba704077c..8bebd8f9e53 100644 --- a/BGL/doc/BGL/CGAL/Linear_cell_complex_for_bgl_combinatorial_map_helper.h +++ b/BGL/doc/BGL/CGAL/Linear_cell_complex_for_bgl_combinatorial_map_helper.h @@ -2,7 +2,7 @@ namespace CGAL { /*! -\ingroup PkgBGLHelper +\ingroup BGLGraphExternalIndices The class `Linear_cell_complex_for_bgl_combinatorial_map_helper` defines a `CGAL::Linear_cell_complex_for_combinatorial_map` as inner type, named `type`, having `CGAL::Linear_cell_complex_bgl_min_items` as items class. With this item class, no information are associated with darts, darts have ids and 0- and 2-attributes are enabled and have ids. diff --git a/BGL/doc/BGL/CGAL/Polyhedron_items_with_id_3.h b/BGL/doc/BGL/CGAL/Polyhedron_items_with_id_3.h index fdfee46c400..a64795aaa74 100644 --- a/BGL/doc/BGL/CGAL/Polyhedron_items_with_id_3.h +++ b/BGL/doc/BGL/CGAL/Polyhedron_items_with_id_3.h @@ -2,7 +2,7 @@ namespace CGAL { /*! -\ingroup PkgBGLHelper +\ingroup BGLGraphExternalIndices The class `Polyhedron_items_with_id_3` is a model of the `PolyhedronItems_3` concept. It provides definitions for vertices with points, halfedges, @@ -63,7 +63,7 @@ public: /*! -\ingroup PkgBGLHelper +\ingroup BGLGraphExternalIndices Given a `CGAL::Polyhedron_3`, for each simplex type (vertex, halfedge, facet) associates an index from diff --git a/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h b/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h index ebb5603be9d..46d790045d3 100644 --- a/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h +++ b/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h @@ -1,7 +1,7 @@ namespace CGAL { /*! -\ingroup PkgBGLHelper +\ingroup BGLGraphExternalIndices The class `Triangulation_face_base_with_id_2` is a model of the concept `TriangulationFaceBase_2`, the base face of a @@ -44,7 +44,7 @@ int& id(); }; /* end Triangulation_face_base_with_id_2 */ -/// \ingroup PkgBGLHelper +/// \ingroup BGLGraphExternalIndices /// /// This function initializes vertex, edge, and face indices of the triangulation `tr` and must /// be called prior to using `tr` as a BGL graph in an algorithm that requires diff --git a/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h b/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h index 9937c6d59d0..3a6145548fc 100644 --- a/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h +++ b/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h @@ -1,7 +1,7 @@ namespace CGAL { /*! -\ingroup PkgBGLHelper +\ingroup BGLGraphExternalIndices The class `Triangulation_vertex_base_with_id_2` is a model of the concept `TriangulationVertexBase_2`, the base vertex of a diff --git a/BGL/doc/BGL/PackageDescription.txt b/BGL/doc/BGL/PackageDescription.txt index 6d8678df6d2..185a6a76e1c 100644 --- a/BGL/doc/BGL/PackageDescription.txt +++ b/BGL/doc/BGL/PackageDescription.txt @@ -443,7 +443,7 @@ the requirement for traversal of all faces in a graph. /// \defgroup PkgBGLPropertiesDynamic Dynamic Properties /// \ingroup PkgBGLRef -/// \defgroup PkgBGLHelper Helper Classes +/// \defgroup PkgBGLGraphExternalIndices External Indices /// \ingroup PkgBGLRef /// \defgroup PkgBGLHelperFct Helper Functions @@ -473,8 +473,11 @@ The dynamic property tags enable to associate information to simplices of a `Fac */ /*! -\addtogroup PkgBGLHelper -Several classes that enable to store ids in vertices/halfedges/faces of a `CGAL::Polyhedron_3`, as well as adapters such as `CGAL::Dual`. +\addtogroup BGLGraphExternalIndices +A number of BGL and \cgal algorithms require the graph to have (initialized) integer-like indices +for its vertices, edges, or faces. However, not all graphs intrinsically offer a natural way +to attach a unique ID to each element. The following classes and functions paliate this +by attaching and initializing external IDs to the elements of the graph. */ /*! diff --git a/BGL/test/BGL/test_Prefix.h b/BGL/test/BGL/test_Prefix.h index e5343a10659..4c383517d26 100644 --- a/BGL/test/BGL/test_Prefix.h +++ b/BGL/test/BGL/test_Prefix.h @@ -189,8 +189,6 @@ template Tr build_dummy_triangulation() { typedef typename Tr::Point Point; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; Tr t; t.insert(Point(0.1,0)); @@ -199,13 +197,7 @@ Tr build_dummy_triangulation() t.insert(Point(0,1)); t.insert(Point(0,2)); - int id = 0; - for(vertex_descriptor vd : vertices(t)) - vd->id() = id++; - - id = 0; - for(face_descriptor fd : faces(t)) - fd->id() = id++; + CGAL::initialize_triangulation_IDs(t); return t; } From 3667550e7552b71b3fba337aa8b900b8d56acc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 12:54:56 +0100 Subject: [PATCH 35/86] Rename new triangulation IDs initializing functions To look more like the existing function set_halfedgeDS_items_id() --- BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h | 4 ++-- BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h | 2 +- BGL/doc/BGL/PackageDescription.txt | 2 +- BGL/test/BGL/test_Prefix.h | 2 +- .../Surface_mesh_shortest_path/Surface_mesh_shortest_path.h | 4 ++-- .../CGAL/boost/graph/internal/properties_2D_triangulation.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h b/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h index 46d790045d3..503e24967e3 100644 --- a/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h +++ b/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h @@ -10,7 +10,7 @@ index faces for \sc{Bgl} algorithms. Note that the user is in charge of setting indices correctly before running a graph algorithm, by calling the function -`CGAL::initialize_triangulation_IDs(Triangulation&)`. +`CGAL::set_triangulation_ids(Triangulation&)`. \tparam TriangulationTraits_2 is the geometric traits class and must be a model of `TriangulationTraits_2`. @@ -50,6 +50,6 @@ int& id(); /// be called prior to using `tr` as a BGL graph in an algorithm that requires /// vertex, halfedge, edge, or face indices. template -void initialize_triangulation_IDs(Triangulation& tr); +void set_triangulation_ids(Triangulation& tr); } /* end namespace CGAL */ diff --git a/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h b/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h index 3a6145548fc..bc156657b30 100644 --- a/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h +++ b/BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h @@ -10,7 +10,7 @@ index vertices for \sc{Bgl} algorithms. Note that the user is in charge of setting indices correctly before running a graph algorithm, by calling the function -`CGAL::initialize_triangulation_IDs(Triangulation&)`. +`CGAL::set_triangulation_ids(Triangulation&)`. \tparam TriangulationTraits_2 is the geometric traits class and must be a model of `TriangulationTraits_2`. diff --git a/BGL/doc/BGL/PackageDescription.txt b/BGL/doc/BGL/PackageDescription.txt index 185a6a76e1c..975b8e5eeb5 100644 --- a/BGL/doc/BGL/PackageDescription.txt +++ b/BGL/doc/BGL/PackageDescription.txt @@ -645,7 +645,7 @@ user might encounter. - `CGAL::clear()` - `CGAL::copy_face_graph()` -- `CGAL::initialize_triangulation_IDs()` +- `CGAL::set_triangulation_ids()` \cgalCRPSection{Iterators} - `CGAL::Halfedge_around_source_iterator` diff --git a/BGL/test/BGL/test_Prefix.h b/BGL/test/BGL/test_Prefix.h index 4c383517d26..afe23ed2744 100644 --- a/BGL/test/BGL/test_Prefix.h +++ b/BGL/test/BGL/test_Prefix.h @@ -197,7 +197,7 @@ Tr build_dummy_triangulation() t.insert(Point(0,1)); t.insert(Point(0,2)); - CGAL::initialize_triangulation_IDs(t); + CGAL::set_triangulation_ids(t); return t; } diff --git a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h index a54781c1ae1..01057be54ca 100644 --- a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h +++ b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h @@ -67,7 +67,7 @@ Refer to those respective papers for the details of the implementation. If index property maps are not provided through the constructor of the class, internal property maps must be available and initialized. -\sa \link PkgBGLHelper `CGAL::set_halfedgeds_items_id()`\endlink +\sa \link BGLGraphExternalIndices `CGAL::set_halfedgeds_items_id()`\endlink */ template -void initialize_triangulation_IDs(CGAL_2D_TRIANGULATION& g) +void set_triangulation_ids(CGAL_2D_TRIANGULATION& g) { typedef typename boost::graph_traits< CGAL_2D_TRIANGULATION >::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits< CGAL_2D_TRIANGULATION >::halfedge_descriptor halfedge_descriptor; From 2b25a664d31d3c10d2ac3d40cdd6e74f2290842c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 12:55:40 +0100 Subject: [PATCH 36/86] Precise that other 2D triangulations also have BGL interfaces --- BGL/doc/BGL/PackageDescription.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/BGL/doc/BGL/PackageDescription.txt b/BGL/doc/BGL/PackageDescription.txt index 975b8e5eeb5..6f85bafbf06 100644 --- a/BGL/doc/BGL/PackageDescription.txt +++ b/BGL/doc/BGL/PackageDescription.txt @@ -585,17 +585,17 @@ Methods to read and write graphs. \cgalCRPSection{%CGAL Classes Adapted for the Graph API} -Different \cgal types have been adapted as graphs for the \sc{Bgl}. All +A number of \cgal structures have been adapted as graphs for the \sc{Bgl}. All adapted types are listed here. The pages document which concepts they model, the properties they support, and any possible caveats that a user might encounter. -- \link BGLSMGT `boost::graph_traits< CGAL::Surface_mesh

>` \endlink -- \link BGLPolyGT `boost::graph_traits< CGAL::Polyhedron_3 >` \endlink -- \link BGLLCCGT `boost::graph_traits< CGAL::Linear_cell_complex_for_combinatorial_map<...> >` \endlink -- \link BGLSeam_meshGT `boost::graph_traits< CGAL::Seam_mesh >` \endlink -- \link BGLT2GT `boost::graph_traits< CGAL::Triangulation_2 >` \endlink -- \link BGLArgtGT `boost::graph_traits< CGAL::Arrangement_2 >` \endlink +- \link BGLSMGT `boost::graph_traits >` \endlink +- \link BGLPolyGT `boost::graph_traits >` \endlink +- \link BGLLCCGT `boost::graph_traits >` \endlink +- \link BGLSeam_meshGT `boost::graph_traits >` \endlink +- \link BGLT2GT `boost::graph_traits >` \endlink and other 2D triangulations +- \link BGLArgtGT `boost::graph_traits >` \endlink - \link BGLOMPAK `boost::graph_traits >` \endlink - \link BGLOMTMAK `boost::graph_traits >` \endlink From 461e3fab00538649b23e10ff54ca3fb8703c6706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 12:57:52 +0100 Subject: [PATCH 37/86] Improve index pmap tests / Add tests with the new get_initiliazed_ipmap() --- BGL/test/BGL/test_Properties.cpp | 105 +++++++++++++------------------ 1 file changed, 44 insertions(+), 61 deletions(-) diff --git a/BGL/test/BGL/test_Properties.cpp b/BGL/test/BGL/test_Properties.cpp index 3ffd9d1720e..aef8981d529 100644 --- a/BGL/test/BGL/test_Properties.cpp +++ b/BGL/test/BGL/test_Properties.cpp @@ -2,16 +2,17 @@ #include -template< typename G, - typename ForwardRange, - typename IndexPropertyMap - > -void index_uniqueness(const G&, +template +void index_uniqueness(const G&, ForwardRange range, IndexPropertyMap pm) { + std::cout << "index_uniqueness" << std::endl; + typename boost::range_iterator::type - begin = boost::begin(range), + begin = boost::begin(range), begin2 = boost::begin(range), end = boost::end(range); @@ -28,13 +29,29 @@ void index_uniqueness(const G&, assert(std::distance(begin2, end) == static_cast(m.size())); } +template +void index_uniqueness(const Graph& g) +{ + std::cout << "Graph has:" << std::endl + << "\t" << num_vertices(g) << " vertices" << std::endl + << "\t" << num_halfedges(g) << " halfedges" << std::endl + << "\t" << num_edges(g) << " edges" << std::endl + << "\t" << num_faces(g) << " faces" << std::endl; + + index_uniqueness(g, vertices(g), get(boost::vertex_index, g)); + index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g)); + index_uniqueness(g, edges(g) , get(boost::edge_index, g)); + index_uniqueness(g, faces(g), get(boost::face_index, g)); + + index_uniqueness(g, vertices(g), CGAL::get_initialized_vertex_index_map(g)); + index_uniqueness(g, halfedges(g), CGAL::get_initialized_halfedge_index_map(g)); + index_uniqueness(g, edges(g) , CGAL::get_initialized_edge_index_map(g)); + index_uniqueness(g, faces(g), CGAL::get_initialized_face_index_map(g)); +} void index_uniqueness_poly(const Polyhedron& g) { - index_uniqueness(g, edges(g) , get(boost::edge_index, g)); - index_uniqueness(g, vertices(g), get(boost::vertex_index, g)); - index_uniqueness(g, faces(g), get(boost::face_index, g)); - index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g)); + index_uniqueness(g); index_uniqueness(g, edges(g) , get(boost::edge_external_index, g)); index_uniqueness(g, vertices(g), get(boost::vertex_external_index, g)); @@ -42,73 +59,39 @@ void index_uniqueness_poly(const Polyhedron& g) index_uniqueness(g, halfedges(g), get(boost::halfedge_external_index, g)); } -void index_uniqueness_lcc(const LCC& g) -{ - index_uniqueness(g, edges(g) , get(boost::edge_index, g)); - index_uniqueness(g, vertices(g), get(boost::vertex_index, g)); - index_uniqueness(g, faces(g), get(boost::face_index, g)); - index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g)); -} - -void index_uniqueness_sm(const SM& g) -{ - index_uniqueness(g, edges(g) , get(boost::edge_index, g)); - index_uniqueness(g, vertices(g), get(boost::vertex_index, g)); - index_uniqueness(g, faces(g), get(boost::face_index, g)); - index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g)); -} - -#if defined(CGAL_USE_OPENMESH) -void index_uniqueness_omesh(const OMesh& g) -{ - index_uniqueness(g, edges(g) , get(boost::edge_index, g)); - index_uniqueness(g, vertices(g), get(boost::vertex_index, g)); - index_uniqueness(g, faces(g), get(boost::face_index, g)); - index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g)); -} -#endif - -template -void index_uniqueness_tr(const Triangulation& g) -{ - index_uniqueness(g, edges(g) , get(boost::edge_index, g)); - index_uniqueness(g, vertices(g), get(boost::vertex_index, g)); - index_uniqueness(g, faces(g), get(boost::face_index, g)); - index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g)); -} - -int main() +// @todo test non-const +int main(int, char**) { std::cout << "testing Polyhedron\n"; - std::vector polys = poly_data(); - for(Polyhedron p : polys) + std::vector polys = poly_data(); // @tmp + for(const Polyhedron& p : polys) index_uniqueness_poly(p); std::cout << "testing Linear_cell_complex\n"; std::vector lccs = lcc_data(); - for(LCC p : lccs) - index_uniqueness_lcc(p); + for(const LCC& p : lccs) + index_uniqueness(p); std::cout << "testing Surface_mesh\n"; std::vector sms = sm_data(); - for(SM p : sms) - index_uniqueness_sm(p); + for(const SM& p : sms) + index_uniqueness(p); #if defined(CGAL_USE_OPENMESH) std::cout << "testing OpenMesh\n"; std::vector omeshs = omesh_data(); - for(OMesh p : omeshs) - index_uniqueness_omesh(p); + for(const OMesh& p : omeshs) + index_uniqueness(p); #endif std::cout << "testing Triangulations\n"; - index_uniqueness_tr(t2_data()); - index_uniqueness_tr(dt2_data()); - index_uniqueness_tr(rt2_data()); - index_uniqueness_tr(ct2_data()); - index_uniqueness_tr(cdt2_data()); - index_uniqueness_tr(cdtp2_data()); - index_uniqueness_tr(t2h_data()); + index_uniqueness(t2_data()); + index_uniqueness(dt2_data()); + index_uniqueness(rt2_data()); + index_uniqueness(ct2_data()); + index_uniqueness(cdt2_data()); + index_uniqueness(cdtp2_data()); + index_uniqueness(t2h_data()); std::cerr << "done\n"; return 0; From 889108e253b78963a73abb4f7166c51927eeee9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 12:58:42 +0100 Subject: [PATCH 38/86] Update get_initialize_xxx_index_map usages to new API --- BGL/include/CGAL/boost/graph/copy_face_graph.h | 3 +-- .../include/CGAL/Polygon_mesh_processing/border.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/copy_face_graph.h b/BGL/include/CGAL/boost/graph/copy_face_graph.h index 5eafa161533..9f6ae2925c7 100644 --- a/BGL/include/CGAL/boost/graph/copy_face_graph.h +++ b/BGL/include/CGAL/boost/graph/copy_face_graph.h @@ -201,8 +201,7 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, // init halfedge index map /// \TODO shall we keep that? - helpers::init_halfedge_indices(const_cast(sm), - get(boost::halfedge_index, sm)); + BGL::internal::initialize_halfedge_index_map(get(boost::halfedge_index, sm), const_cast(sm)); copy_face_graph_impl(sm, tm, bind_property_maps(get(boost::halfedge_index, sm), diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index b6b28f8aa23..4622c12f626 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -178,8 +178,8 @@ namespace Polygon_mesh_processing { { if (faces.empty()) return out; - - auto fim = CGAL::get_initialized_face_index_map(pmesh, np); + typedef typename CGAL::GetInitializedFaceIndexMap::const_type FIMap; + FIMap fim = CGAL::get_initialized_face_index_map(pmesh, np); return internal::border_halfedges_impl(faces, fim, out, pmesh, np); } From 432d5c724a167b72ad028e71dcd5c5bb8b3a7e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 13:37:09 +0100 Subject: [PATCH 39/86] Improve usages of get_initialized_xxx_index_map --- .../CGAL/boost/graph/named_params_helper.h | 1 - .../connected_components.h | 43 +++++++------- .../Polygon_mesh_processing/corefinement.h | 56 +++++++++---------- .../Polygon_mesh_processing/detect_features.h | 8 +-- .../Polygon_mesh_processing/orientation.h | 37 ++++++------ .../CGAL/Polygon_mesh_processing/remesh.h | 5 +- .../Polygon_mesh_processing/stitch_borders.h | 3 +- .../Rigid_triangle_mesh_collision_detection.h | 4 +- 8 files changed, 75 insertions(+), 82 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 68a79777a2d..ab10db10ef2 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -232,7 +232,6 @@ namespace CGAL { > ::type type; }; - namespace Point_set_processing_3 { template diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 0c97c86d56f..c072237ec9d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -219,9 +219,9 @@ connected_components(const PolygonMesh& pmesh, = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), internal::No_constraint()); - typedef typename Default_face_index_map::type FaceIndexMap; - FaceIndexMap fimap = get_initialized_face_index_map(pmesh, np); - + typedef typename GetInitializedFaceIndexMap::const_type FaceIndexMap; + FaceIndexMap fimap = get_initialized_face_index_map(pmesh, np); + typename boost::property_traits::value_type i=0; std::vector handled(num_faces(pmesh), false); for (face_descriptor f : faces(pmesh)) @@ -369,8 +369,8 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, using parameters::choose_parameter; using parameters::get_parameter; - typedef typename Default_face_index_map::type FaceIndexMap; - FaceIndexMap fimap = get_initialized_face_index_map(pmesh, np); + typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; + FaceIndexMap fimap = CGAL::get_initialized_face_index_map(pmesh, np); // FaceSizeMap typedef typename internal_np::Lookup_named_param_def::type FaceIndexMap; + typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def // default - >::type FaceSizeMap; + NamedParameters, + Constant_property_map // default + >::type FaceSizeMap; typedef typename boost::property_traits::value_type Face_size; CGAL_static_assertion((std::is_convertible::value)); @@ -584,7 +584,6 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh , bool keep , const NamedParameters& np) { - typedef PolygonMesh PM; using parameters::choose_parameter; using parameters::get_parameter; @@ -596,9 +595,8 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh typedef typename boost::graph_traits::edge_descriptor edge_descriptor; typedef typename boost::graph_traits::edge_iterator edge_iterator; - //VertexIndexMap - typedef typename Default_vertex_index_map::type VertexIndexMap; - VertexIndexMap vim = get_initialized_vertex_index_map(pmesh, np); + typedef typename GetInitializedVertexIndexMap::type VertexIndexMap; + VertexIndexMap vim = get_initialized_vertex_index_map(pmesh, np); std::set cc_to_keep; for(std::size_t i : components_to_keep) @@ -831,19 +829,19 @@ void remove_connected_components(PolygonMesh& pmesh , const FaceRange& components_to_remove , const CGAL_PMP_NP_CLASS& np) { - if (components_to_remove.empty()) return; - typedef PolygonMesh PM; - typedef typename boost::graph_traits::face_descriptor face_descriptor; using parameters::choose_parameter; using parameters::get_parameter; - //FaceIndexMap - typedef typename Default_face_index_map::type FaceIndexMap; + if (components_to_remove.empty()) + return; + + typedef PolygonMesh PM; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + + typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); - //vector_property_map boost::vector_property_map face_cc(fim); - connected_components(pmesh, face_cc, np); std::vector cc_to_remove; @@ -894,13 +892,10 @@ void keep_connected_components(PolygonMesh& pmesh using parameters::choose_parameter; using parameters::get_parameter; - //FaceIndexMap - typedef typename Default_face_index_map::type FaceIndexMap; + typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; FaceIndexMap fim = CGAL::get_initialized_face_index_map(pmesh, np); - //vector_property_map boost::vector_property_map face_cc(fim); - connected_components(pmesh, face_cc, np); std::vector cc_to_keep; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h index 3d1b4e88bbe..ed2461228a0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h @@ -46,9 +46,10 @@ bool recursive_does_bound_a_volume(const TriangleMesh& tm, std::size_t xtrm_cc_id, bool is_parent_outward_oriented) { - typedef boost::graph_traits GT; - typedef typename GT::face_descriptor face_descriptor; - typedef Side_of_triangle_mesh Side_of_tm; + typedef boost::graph_traits Graph_traits; + typedef typename Graph_traits::face_descriptor face_descriptor; + typedef Side_of_triangle_mesh Side_of_tm; + // first check that the orientation of the current cc is consistant with its // parent cc containing it bool new_is_parent_outward_oriented = internal::is_outward_oriented( @@ -170,22 +171,23 @@ enum Boolean_operation_type {UNION = 0, INTERSECTION=1, * \see `CGAL::Polygon_mesh_processing::orient_to_bound_a_volume()` */ template -bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) +bool does_bound_a_volume(const TriangleMesh& tm, + const NamedParameters& np) { - typedef boost::graph_traits GT; - typedef typename GT::vertex_descriptor vertex_descriptor; - typedef typename GetVertexPointMap::const_type Vpm; - typedef typename Kernel_traits< - typename boost::property_traits::value_type >::Kernel Kernel; + typedef boost::graph_traits Graph_traits; + typedef typename Graph_traits::vertex_descriptor vertex_descriptor; + typedef typename GetVertexPointMap::const_type Vpm; + typedef typename boost::property_traits::value_type Point; + typedef typename Kernel_traits::Kernel Kernel; if (!is_closed(tm)) return false; if (!is_triangle_mesh(tm)) return false; Vpm vpm = parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), - get_const_property_map(boost::vertex_point, tm)); + get_const_property_map(boost::vertex_point, tm)); - auto fid_map = CGAL::get_initialized_face_index_map(tm, np); + typedef typename GetInitializedFaceIndexMap::const_type Fid_map; + Fid_map fid_map = get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); @@ -200,11 +202,11 @@ bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) boost::dynamic_bitset<> cc_handled(nb_cc, 0); // extract a vertex with max z coordinate for each connected component - std::vector xtrm_vertices(nb_cc, GT::null_vertex()); + std::vector xtrm_vertices(nb_cc, Graph_traits::null_vertex()); for(vertex_descriptor vd : vertices(tm)) { std::size_t cc_id = face_cc[get(fid_map, face(halfedge(vd, tm), tm))]; - if (xtrm_vertices[cc_id]==GT::null_vertex()) + if (xtrm_vertices[cc_id] == Graph_traits::null_vertex()) xtrm_vertices[cc_id]=vd; else if (get(vpm, vd).z()>get(vpm,xtrm_vertices[cc_id]).z()) @@ -511,20 +513,16 @@ corefine_and_compute_boolean_operations( typedef std::tuple Edge_mark_map_tuple; -// Face index point maps + // Face index point maps + typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; + typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap2; - typedef typename CGAL:: - Default_face_index_map::type Fid_map; - typedef typename CGAL:: - Default_face_index_map::type Fid_map2; + CGAL_static_assertion((std::is_same::value)); - CGAL_USE_TYPE(Fid_map2); - CGAL_assertion_code( - static const bool same_fidmap = (boost::is_same::value);) - CGAL_static_assertion(same_fidmap); - Fid_map fid_map1 = get_initialized_face_index_map(tm1, np1); - Fid_map fid_map2 = get_initialized_face_index_map(tm2, np2); -// User visitor + FaceIndexMap fid_map1 = get_initialized_face_index_map(tm1, np1); + FaceIndexMap fid_map2 = get_initialized_face_index_map(tm2, np2); + + // User visitor typedef typename internal_np::Lookup_named_param_def < internal_np::graph_visitor_t, NamedParameters1, @@ -537,7 +535,7 @@ corefine_and_compute_boolean_operations( typedef Corefinement::Face_graph_output_builder::type Fid_map; - Fid_map fid_map = CGAL::get_initialized_face_index_map(tm, np); + typedef typename GetInitializedFaceIndexMap::type Fid_map; + Fid_map fid_map = get_initialized_face_index_map(tm, np); // Edge is-constrained maps typedef typename internal_np::Lookup_named_param_def < diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h index 293eb677ab9..34346781eca 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h @@ -138,9 +138,6 @@ detect_surface_patches(PolygonMesh& p, EdgeIsFeatureMap eif, const NamedParameters& np) { - //extract types from NPs - auto fimap = CGAL::get_initialized_face_index_map(p, np); - int offset = static_cast( parameters::choose_parameter(parameters::get_parameter(np, internal_np::first_index), 1)); @@ -148,11 +145,12 @@ detect_surface_patches(PolygonMesh& p, internal::PatchIdMapWrapper::value_type> wrapmap(patch_id_map, offset); + return connected_components(p, wrapmap, parameters::edge_is_constrained_map(eif) - .face_index_map(fimap)); - + .face_index_map(CGAL::get_initialized_face_index_map(p, np))); } + template typename boost::graph_traits::faces_size_type detect_surface_patches(PolygonMesh& p, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index 55a2c625ee9..7991ad88b88 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -462,14 +462,15 @@ void recursive_orient_volume_ccs( TriangleMesh& tm, * \cgalNamedParamsEnd */ template -void orient(TriangleMesh& tm, const NamedParameters& np) +void orient(TriangleMesh& tm, + const NamedParameters& np) { - typedef boost::graph_traits Graph_traits; - typedef typename Graph_traits::vertex_descriptor vertex_descriptor; - typedef typename Graph_traits::face_descriptor face_descriptor; - typedef typename Graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename GetVertexPointMap::const_type Vpm; + typedef boost::graph_traits Graph_traits; + typedef typename Graph_traits::vertex_descriptor vertex_descriptor; + typedef typename Graph_traits::face_descriptor face_descriptor; + typedef typename Graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename GetVertexPointMap::const_type Vpm; + typedef typename GetInitializedFaceIndexMap::type FaceIndexMap; CGAL_assertion(is_triangle_mesh(tm)); CGAL_assertion(is_valid_polygon_mesh(tm)); @@ -483,7 +484,7 @@ void orient(TriangleMesh& tm, const NamedParameters& np) Vpm vpm = CGAL::parameters::choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm)); - auto fid_map = CGAL::get_initialized_face_index_map(tm, np); + FaceIndexMap fid_map = CGAL::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); @@ -568,18 +569,20 @@ void orient(TriangleMesh& tm) */ template void orient_to_bound_a_volume(TriangleMesh& tm, - const NamedParameters& np) + const NamedParameters& np) { - typedef boost::graph_traits Graph_traits; - typedef typename Graph_traits::vertex_descriptor vertex_descriptor; - typedef typename GetVertexPointMap::const_type Vpm; - typedef typename Kernel_traits< - typename boost::property_traits::value_type >::Kernel Kernel; + typedef boost::graph_traits Graph_traits; + typedef typename Graph_traits::vertex_descriptor vertex_descriptor; + + typedef typename GetVertexPointMap::const_type Vpm; + typedef typename boost::property_traits::value_type Point; + typedef typename Kernel_traits::Kernel Kernel; + + typedef typename GetInitializedFaceIndexMap::type FaceIndexMap; + if (!is_closed(tm)) return; if (!is_triangle_mesh(tm)) return; - using parameters::get_parameter; bool orient_outward = CGAL::parameters::choose_parameter( @@ -588,7 +591,7 @@ void orient_to_bound_a_volume(TriangleMesh& tm, Vpm vpm = CGAL::parameters::choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(boost::vertex_point, tm)); - auto fid_map = CGAL::get_initialized_face_index_map(tm, np); + FaceIndexMap fid_map = CGAL::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index 397ee733850..4ab09ae8efc 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -160,7 +160,8 @@ void isotropic_remeshing(const FaceRange& faces typedef typename GetVertexPointMap::type VPMap; VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)); -typedef typename Default_face_index_map::type FIMap; + + typedef typename GetInitializedFaceIndexMap::type FIMap; FIMap fimap = CGAL::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def < @@ -337,7 +338,7 @@ void split_long_edges(const EdgeRange& edges VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)); - typedef typename Default_face_index_map::type FIMap; + typedef typename GetInitializedFaceIndexMap::type FIMap; FIMap fimap = CGAL::get_initialized_face_index_map(pmesh, np); typedef typename internal_np::Lookup_named_param_def < diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h index 36e2fef9bb6..c7c3e604bcf 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h @@ -186,8 +186,7 @@ collect_duplicated_stitchable_boundary_edges { cc = get(Face_property_tag(), pmesh); - auto fim = CGAL::get_initialized_face_index_map(pmesh, np); - num_component = num_component_wrapper(pmesh, cc, fim); + num_component = num_component_wrapper(pmesh, cc, CGAL::get_initialized_face_index_map(pmesh, np)); border_edges_per_cc.resize(num_component); } diff --git a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h index 53d20d4fc3b..b739d68e443 100644 --- a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h +++ b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h @@ -537,8 +537,8 @@ public: std::vector cc_ids(num_faces(tm)); // face index map - - auto fid_map = CGAL::get_initialized_face_index_map(tm, np); + typedef typename GetInitializedFaceIndexMap::const_type FaceIndexMap; + FaceIndexMap fid_map = CGAL::get_initialized_face_index_map(tm, np); std::size_t nb_cc = Polygon_mesh_processing::connected_components( From 6ada1e8d168a4747ef0c00a61371cc2fcfcefbf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 14:20:41 +0100 Subject: [PATCH 40/86] Clean useless and talkative output --- BGL/test/BGL/test_Properties.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/BGL/test/BGL/test_Properties.cpp b/BGL/test/BGL/test_Properties.cpp index aef8981d529..6128a846d95 100644 --- a/BGL/test/BGL/test_Properties.cpp +++ b/BGL/test/BGL/test_Properties.cpp @@ -9,8 +9,6 @@ void index_uniqueness(const G&, ForwardRange range, IndexPropertyMap pm) { - std::cout << "index_uniqueness" << std::endl; - typename boost::range_iterator::type begin = boost::begin(range), begin2 = boost::begin(range), From ca68f22f8d4988e271972d50f7becc536042f456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 14:20:56 +0100 Subject: [PATCH 41/86] Update usage of internal index map initializer to new API --- .../internal/Corefinement/Face_graph_output_builder.h | 4 ++-- .../Corefinement/Output_builder_for_autorefinement.h | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index 2f93d176784..d854eec8a37 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -461,8 +461,8 @@ public: Intersection_edge_map& intersection_edges2 = mesh_to_intersection_edges[&tm2]; // this will initialize face indices if the face index map is writable. - helpers::init_face_indices(tm1, fids1); - helpers::init_face_indices(tm2, fids2); + BGL::internal::initialize_face_index_map(fids1, tm1); + BGL::internal::initialize_face_index_map(fids2, tm2); // bitset to identify coplanar faces boost::dynamic_bitset<> tm1_coplanar_faces(num_faces(tm1), 0); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h index 3656f46aea3..33db7adf4da 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h @@ -214,9 +214,6 @@ public: const boost::dynamic_bitset<>& is_node_of_degree_one, const Mesh_to_map_node&) { - // this will initialize face indices if the face index map is writable. - helpers::init_face_indices(tm, fids); - // first build an unordered_map mapping a vertex to its node id + a set // of all intersection edges typedef boost::unordered_set Intersection_edge_map; @@ -240,7 +237,7 @@ public: } // this will initialize face indices if the face index map is writable. - helpers::init_face_indices(tm, fids); + BGL::internal::initialize_face_index_map(fids, tm); // bitset to identify coplanar faces boost::dynamic_bitset<> tm_coplanar_faces(num_faces(tm), 0); From 2d1f3266ea9fd31ce5f6dc4a368ae38891fdd62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 4 Mar 2020 14:35:20 +0100 Subject: [PATCH 42/86] Hide error message behind debug macro --- .../CGAL/boost/graph/internal/initialized_index_maps_helpers.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h index e939a99e97b..d98eb313bf6 100644 --- a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -43,7 +43,9 @@ bool is_index_map_valid(const IndexMap idmap, } else { +#ifdef CGAL_BGL_INDEX_MAP_DEBUG std::cerr << "Invalid ID: " << id << " num_simplices: " << num_simplices << std::endl; +#endif return false; } } From aa331c0f146aed14d3c1c2f82bfb45faac0acc9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 11:30:29 +0100 Subject: [PATCH 43/86] Add missing hash value function for Seam_mesh's edges --- BGL/include/CGAL/boost/graph/Seam_mesh.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BGL/include/CGAL/boost/graph/Seam_mesh.h b/BGL/include/CGAL/boost/graph/Seam_mesh.h index 33a995dba43..d4fdd9e4b22 100644 --- a/BGL/include/CGAL/boost/graph/Seam_mesh.h +++ b/BGL/include/CGAL/boost/graph/Seam_mesh.h @@ -439,6 +439,11 @@ public: { return ! (e1 == e2); } + + friend std::size_t hash_value(const edge_descriptor ed) + { + return hash_value((std::min)(ed.hd, ed.mesh_->opposite(ed.hd))); + } }; #ifndef DOXYGEN_RUNNING From 1f7c96a6600257117ea542d0437980b74a2e65bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 11:42:30 +0100 Subject: [PATCH 44/86] Some constructors from () to {} for clarity --- .../boost/graph/internal/initialized_index_maps_helpers.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h index d98eb313bf6..10e0343ee7c 100644 --- a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -149,7 +149,7 @@ void initialize_##TYPE##_index_map(WritableIndexPropertyMap index_map, const Graph& g) \ { \ Index_map_initializer initializer; \ - initializer(CGAL::internal_np::TYPE##_index_t(), index_map, g); \ + initializer(CGAL::internal_np::TYPE##_index_t{}, index_map, g); \ } CGAL_DEF_INITIALIZE_ID_MAP_FUNCTION(vertex) @@ -232,14 +232,14 @@ public: static const_type get(const Parameter p, const Graph& g, const NamedParameters& np) { - return BGL::internal::get_initialized_index_map(parameters::get_parameter(np, p), - p, Final_tag(), DynamicTag(), g); + return BGL::internal::get_initialized_index_map_const(parameters::get_parameter(np, p), + p, Final_tag{}, DynamicTag{}, g); } static type get(const Parameter p, Graph& g, const NamedParameters& np) { return BGL::internal::get_initialized_index_map(parameters::get_parameter(np, p), - p, Final_tag(), DynamicTag(), g); + p, Final_tag{}, DynamicTag{}, g); } }; From 14582b1be912092b7fa7c5f5ff65cc6438945c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 11:42:54 +0100 Subject: [PATCH 45/86] Fix compilation (wrong mesh type) --- .../include/CGAL/Rigid_triangle_mesh_collision_detection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h index b739d68e443..2ce1278e7ae 100644 --- a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h +++ b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h @@ -537,7 +537,7 @@ public: std::vector cc_ids(num_faces(tm)); // face index map - typedef typename GetInitializedFaceIndexMap::const_type FaceIndexMap; + typedef typename GetInitializedFaceIndexMap::const_type FaceIndexMap; FaceIndexMap fid_map = CGAL::get_initialized_face_index_map(tm, np); std::size_t nb_cc = From af47c608fcd1f2cd07a93738a7329240010209a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 13:23:34 +0100 Subject: [PATCH 46/86] Add missing & --- BGL/include/CGAL/boost/graph/Seam_mesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/Seam_mesh.h b/BGL/include/CGAL/boost/graph/Seam_mesh.h index d4fdd9e4b22..4e78a264798 100644 --- a/BGL/include/CGAL/boost/graph/Seam_mesh.h +++ b/BGL/include/CGAL/boost/graph/Seam_mesh.h @@ -440,7 +440,7 @@ public: return ! (e1 == e2); } - friend std::size_t hash_value(const edge_descriptor ed) + friend std::size_t hash_value(const edge_descriptor& ed) { return hash_value((std::min)(ed.hd, ed.mesh_->opposite(ed.hd))); } From 18a7c6900ff6d77e60fefd01308beb4f2f9c3149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 13:23:41 +0100 Subject: [PATCH 47/86] Tiny alignment change --- BGL/include/CGAL/boost/graph/Seam_mesh.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/Seam_mesh.h b/BGL/include/CGAL/boost/graph/Seam_mesh.h index 4e78a264798..07ed312307f 100644 --- a/BGL/include/CGAL/boost/graph/Seam_mesh.h +++ b/BGL/include/CGAL/boost/graph/Seam_mesh.h @@ -124,8 +124,8 @@ public: /// The type for the objects used to identify halfedges in the underlying mesh. typedef typename boost::graph_traits::halfedge_descriptor TM_halfedge_descriptor; - /// The type for the iterators that traverse through the complete halfedge set of the underlying mesh. - typedef typename boost::graph_traits::halfedge_iterator TM_halfedge_iterator; + /// The type for the iterators that traverse through the complete halfedge set of the underlying mesh. + typedef typename boost::graph_traits::halfedge_iterator TM_halfedge_iterator; /// The type for the objects used to identify edges in the underlying mesh. typedef typename boost::graph_traits::edge_descriptor TM_edge_descriptor; From e6584bd17658ea42cbcfbd9e46e583a2b9996610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 14:26:20 +0100 Subject: [PATCH 48/86] Implement initialized_index_map getter with non-const graph --- .../internal/initialized_index_maps_helpers.h | 146 +++++++++++++----- 1 file changed, 111 insertions(+), 35 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h index 10e0343ee7c..1205072fa5e 100644 --- a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -19,6 +19,7 @@ #include #include +#include namespace CGAL { namespace BGL { @@ -26,7 +27,7 @@ namespace internal { // Check that an index map has been correctly initialized template -bool is_index_map_valid(const IndexMap idmap, +bool is_index_map_valid(IndexMap idmap, const std::size_t num_simplices, const DescriptorRange& range) { @@ -132,7 +133,7 @@ struct Index_map_initializer void operator()(const Parameter, IndexPropertyMap, const Graph&) { // The property map is not writable; should never be here. - CGAL_assertion(false); + CGAL_assertion_msg(false, "You are trying to initialize a non-writable property map"); } }; @@ -159,11 +160,11 @@ CGAL_DEF_INITIALIZE_ID_MAP_FUNCTION(face) #undef CGAL_DEF_INITIALIZE_ID_FUCNTION -// Using the pmap passed in named parameters +// Using the pmap passed in named parameters ------------------------------------------------------- template -IndexMap get_initialized_index_map(const IndexMap index_map, - const Parameter p, Tag, DynamicTag, - const Graph& g) +IndexMap get_initialized_index_map_const(const IndexMap index_map, + const Parameter p, Tag, DynamicTag, + const Graph& g) { CGAL_USE(g); CGAL_USE(p); @@ -172,20 +173,29 @@ IndexMap get_initialized_index_map(const IndexMap index_map, return index_map; } -// Using the internal to the mesh -template -typename boost::property_map::const_type -get_initialized_index_map(CGAL::internal_np::Param_not_found, - const Parameter p, const Tag tag, DynamicTag, - const Graph& g) // @todo non-const +template +IndexMap get_initialized_index_map(const IndexMap index_map, + const Parameter p, Tag, DynamicTag, + Graph& g) { - typedef typename boost::property_map::const_type Index_map; - Index_map index_map = get(tag, g); + CGAL_USE(g); + CGAL_USE(p); + CGAL_assertion(is_index_map_valid(p, index_map, g)); - if(CGAL::internal::Is_writable_property_map::value) + return index_map; +} + +// Using the internal to the mesh ------------------------------------------------------------------ +template +InternalIndexMap +get_initialized_internal_index_map(InternalIndexMap index_map, + const Parameter p, + const Graph& g) +{ + if(CGAL::internal::Is_writable_property_map::value) { if(!is_index_map_valid(p, index_map, g)) - Index_map_initializer{}(p, index_map, g); + Index_map_initializer{}(p, index_map, g); } else // not writable { @@ -195,42 +205,80 @@ get_initialized_index_map(CGAL::internal_np::Param_not_found, return index_map; } -// Create a dynamic property and initialize it -template -typename boost::property_map::const_type -get_initialized_index_map(CGAL::internal_np::Param_not_found, - const Parameter p, const DynamicTag tag, DynamicTag, - const Graph& g) +template +typename boost::property_map::const_type +get_initialized_index_map_const(CGAL::internal_np::Param_not_found, + const Parameter p, const Tag tag, DynamicTag, + const Graph& g) { - typedef typename boost::property_map::const_type Index_map; + return get_initialized_internal_index_map(get(tag, g), p, g); +} - Index_map index_map = get(tag, g); - Index_map_initializer{}(p, index_map, g); +// same as above, non-const graph overload +template +typename boost::property_map::type +get_initialized_index_map(CGAL::internal_np::Param_not_found, + const Parameter p, const Tag tag, DynamicTag, + Graph& g) +{ + // From now on the correct property map has been acquired + // and there is no need to distinguish between const and non-const mesh + return get_initialized_internal_index_map(get(tag, g), p, g); +} +// Create a dynamic property and initialize it ----------------------------------------------------- +template +DynamicIndexMap +get_initialized_dynamic_index_map(DynamicIndexMap index_map, + const Parameter p, + const Graph& g) +{ + Index_map_initializer{}(p, index_map, g); return index_map; } +template +typename boost::property_map::const_type +get_initialized_index_map_const(CGAL::internal_np::Param_not_found, + const Parameter p, const DynamicTag dtag, DynamicTag, + const Graph& g) +{ + return get_initialized_dynamic_index_map(get(dtag, g), p, g); +} + +// same as above, non-const graph overload +template +typename boost::property_map::type +get_initialized_index_map(CGAL::internal_np::Param_not_found, + const Parameter p, const DynamicTag dtag, DynamicTag, + Graph& g) +{ + // From now on the correct property map has been acquired + // and there is no need to distinguish between const and non-const mesh + return get_initialized_dynamic_index_map(get(dtag, g), p, g); +} + template > + typename Graph, + typename NamedParameters = Named_function_parameters > class GetInitializedIndexMap { public: - // Definition of the Tag that will be used if there is no named parameter + // Check if there is an internal property map; if not, we must a dynamic property map typedef typename boost::mpl::if_c< CGAL::graph_has_property::value, Tag, DynamicTag>::type Final_tag; typedef typename internal_np::Lookup_named_param_def< Parameter, NamedParameters, - typename boost::property_map::type>::type type; + typename boost::property_map::const_type>::type const_type; typedef typename internal_np::Lookup_named_param_def< Parameter, NamedParameters, - typename boost::property_map::const_type>::type const_type; + typename boost::property_map::type>::type type; - static const_type get(const Parameter p, const Graph& g, const NamedParameters& np) + static const_type get_const(const Parameter p, const Graph& g, const NamedParameters& np) { return BGL::internal::get_initialized_index_map_const(parameters::get_parameter(np, p), p, Final_tag{}, DynamicTag{}, g); @@ -246,7 +294,7 @@ public: } // namespace internal } // namespace BGL -// @todo move below to named_params_... +// @todo move below to named_params_helper.h #define CGAL_DEF_GET_INDEX_TYPE(CTYPE, TYPE) \ template , \ Graph, NamedParameters> Index_map_getter; \ - return Index_map_getter::get(CGAL::internal_np::TYPE##_index_t(), g, np); \ + return Index_map_getter::get_const(CGAL::internal_np::TYPE##_index_t{}, g, np); \ } \ template \ typename BGL::internal::GetInitializedIndexMap, \ Graph>::const_type \ get_initialized_##TYPE##_index_map(const Graph& g) \ +{ \ + return get_initialized_##TYPE##_index_map(g, CGAL::parameters::all_default()); \ +} \ +/* same as above, non-const version*/ \ +template ::type>::value, int> = 0> \ +typename BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters>::type \ +get_initialized_##TYPE##_index_map(Graph& g, \ + const NamedParameters& np) \ +{ \ + typedef BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters> Index_map_getter; \ + return Index_map_getter::get(CGAL::internal_np::TYPE##_index_t{}, g, np); \ +} \ +template ::type>::value, int> = 0> \ +typename BGL::internal::GetInitializedIndexMap, \ + Graph>::type \ +get_initialized_##TYPE##_index_map(Graph& g) \ { \ return get_initialized_##TYPE##_index_map(g, CGAL::parameters::all_default()); \ } -// @todo add the non-const Graph& version - CGAL_DEF_GET_INITIALIZED_INDEX_MAP(vertex) CGAL_DEF_GET_INITIALIZED_INDEX_MAP(halfedge) CGAL_DEF_GET_INITIALIZED_INDEX_MAP(edge) From 7bd79230bdae4185f277f446b6fe1c9bff9cb5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 14:27:00 +0100 Subject: [PATCH 49/86] Test the initialized_index_map getter mechanisms --- BGL/test/BGL/test_Prefix.h | 5 + BGL/test/BGL/test_Properties.cpp | 454 +++++++++++++++++++++++++++---- 2 files changed, 411 insertions(+), 48 deletions(-) diff --git a/BGL/test/BGL/test_Prefix.h b/BGL/test/BGL/test_Prefix.h index afe23ed2744..396b0f9408d 100644 --- a/BGL/test/BGL/test_Prefix.h +++ b/BGL/test/BGL/test_Prefix.h @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -57,6 +58,10 @@ typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper typedef CGAL::Surface_mesh SM; +typedef SM::Property_map Seam_edge_pmap; +typedef SM::Property_map Seam_vertex_pmap; +typedef CGAL::Seam_mesh Seam_mesh; + #if defined(CGAL_USE_OPENMESH) #include diff --git a/BGL/test/BGL/test_Properties.cpp b/BGL/test/BGL/test_Properties.cpp index 6128a846d95..9f3cbe32136 100644 --- a/BGL/test/BGL/test_Properties.cpp +++ b/BGL/test/BGL/test_Properties.cpp @@ -1,14 +1,72 @@ #include "test_Prefix.h" +#include + #include -template +struct Non_mutable_property_map +{ + typedef Key key_type; + typedef Value value_type; + typedef value_type reference; + typedef boost::readable_property_map_tag category; + + Non_mutable_property_map(const Container& c) : m_c(c) { } + + friend reference get(const Non_mutable_property_map& pmap, key_type k) + { + return pmap.m_c.at(k); + } + +private: + const Container& m_c; +}; + +template +struct RW_property_map +{ + typedef Key key_type; + typedef Value value_type; + typedef value_type& reference; + typedef boost::read_write_property_map_tag category; + + RW_property_map(Container& c) : m_c(c) { } + + friend void put(RW_property_map& pmap, const key_type& k, const value_type& val) + { + pmap.m_c[k] = val; + } + + friend reference get(RW_property_map& pmap, const key_type& k) + { + return pmap.m_c[k]; + } + +private: + Container& m_c; +}; + +} // namespace CGAL + +template -void index_uniqueness(const G&, - ForwardRange range, - IndexPropertyMap pm) +void test_uniqueness(const Graph&, + const ForwardRange& range, + IndexPropertyMap index_map) { +#ifdef CGAL_TEST_PROPERTIES_DEBUG + std::cout << std::endl + << "Checking the uniqueness of the property map of type: " + << typeid(IndexPropertyMap).name() << std::endl; + std::cout << "Element type: " << typeid(typename boost::range_value::type).name() << std::endl; +#endif + typename boost::range_iterator::type begin = boost::begin(range), begin2 = boost::begin(range), @@ -16,81 +74,381 @@ void index_uniqueness(const G&, typedef boost::unordered_set id_map; typedef std::pair resultp; - id_map m; - while(begin != end) { - resultp r = m.insert(get(pm, *begin)); + id_map m; + while(begin != end) + { + resultp r = m.insert(get(index_map, *begin)); +#ifdef CGAL_TEST_PROPERTIES_DEBUG + std::cout << "id: " << get(index_map, *begin) << std::endl; +#endif ++begin; - assert(r.second); + assert(r.second); // already seen that id } assert(std::distance(begin2, end) == static_cast(m.size())); } +template +void test_vertex_index_map_uniqueness(const Graph& g, + const NamedParameters& np) +{ + typedef typename CGAL::GetInitializedVertexIndexMap::type VIM; + typedef typename CGAL::GetInitializedVertexIndexMap::const_type CVIM; + + // in the case where the map is passed by NP, its type doesn't depend on whether the mesh is const or not + static_assert((std::is_same::value), "VIM, CVIM must be the same type"); + + VIM ivim = CGAL::get_initialized_vertex_index_map(g, np); + + return test_uniqueness(g, vertices(g), ivim); +} + +template +void test_halfedge_index_map_uniqueness(const Graph& g, + const NamedParameters& np) +{ + typedef typename CGAL::GetInitializedHalfedgeIndexMap::type HIM; + typedef typename CGAL::GetInitializedHalfedgeIndexMap::const_type CHIM; + + // in the case where the map is passed by NP, its type doesn't depend on whether the mesh is const or not + static_assert((std::is_same::value), "HIM, CHIM must be the same type"); + + HIM ihim = CGAL::get_initialized_halfedge_index_map(g, np); + + return test_uniqueness(g, halfedges(g), ihim); +} + +template +void test_edge_index_map_uniqueness(const Graph& g, + const NamedParameters& np) +{ + typedef typename CGAL::GetInitializedEdgeIndexMap::type EIM; + typedef typename CGAL::GetInitializedEdgeIndexMap::const_type CEIM; + + // in the case where the map is passed by NP, its type doesn't depend on whether the mesh is const or not + static_assert((std::is_same::value), "EIM, CEIM must be the same type"); + + EIM ieim = CGAL::get_initialized_edge_index_map(g, np); + + return test_uniqueness(g, edges(g), ieim); +} + +template +void test_face_index_map_uniqueness(const Graph& g, + const NamedParameters& np) +{ + typedef typename CGAL::GetInitializedFaceIndexMap::type FIM; + typedef typename CGAL::GetInitializedFaceIndexMap::const_type CFIM; + + // in the case where the map is passed by NP, its type doesn't depend on whether the mesh is const or not + static_assert((std::is_same::value), "FIM, CFIM must be the same type"); + + FIM ifim = CGAL::get_initialized_face_index_map(g, np); + + return test_uniqueness(g, faces(g), ifim); +} + +////////////////////////////////////////// const /////////////////////////////////////////////////// + template -void index_uniqueness(const Graph& g) +void test_internal_index_maps_const(const Graph& g) { + test_uniqueness(g, vertices(g), get(boost::vertex_index, g)); + test_uniqueness(g, halfedges(g), get(boost::halfedge_index, g)); + test_uniqueness(g, edges(g) , get(boost::edge_index, g)); + test_uniqueness(g, faces(g), get(boost::face_index, g)); +} + +template +void test_initialized_index_maps_const(const Graph& g) +{ + typedef typename CGAL::GetInitializedVertexIndexMap::const_type VIM; + VIM ivim = CGAL::get_initialized_vertex_index_map(g); + test_uniqueness(g, vertices(g), ivim); + + typedef typename CGAL::GetInitializedHalfedgeIndexMap::const_type HIM; + HIM ihim = CGAL::get_initialized_halfedge_index_map(g); + test_uniqueness(g, halfedges(g), ihim); + + typedef typename CGAL::GetInitializedEdgeIndexMap::const_type EIM; + EIM ieim = CGAL::get_initialized_edge_index_map(g); + test_uniqueness(g, edges(g), ieim); + + typedef typename CGAL::GetInitializedFaceIndexMap::const_type FIM; + FIM ifim = CGAL::get_initialized_face_index_map(g); + test_uniqueness(g, faces(g), ifim); + + // Passing an index map via NP + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef std::map VertexIndexMap; + typedef boost::associative_property_map VertexIdPropertyMap; // lvalue_pmap + + int vi = static_cast(num_vertices(g)); + VertexIndexMap vim; + VertexIdPropertyMap external_vertex_index_map(vim); + for(vertex_descriptor v : vertices(g)) + put(external_vertex_index_map, v, --vi); + + test_vertex_index_map_uniqueness(g, CGAL::parameters::vertex_index_map(external_vertex_index_map)); + + // Read-only pmap + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef std::map HalfedgeIndexMap; + typedef CGAL::Non_mutable_property_map HalfedgeIdPropertyMap; + + int hi = 0; + HalfedgeIndexMap him; + HalfedgeIdPropertyMap external_halfedge_index_map(him); + + // this should complain that the map is not writable (commented because it does assert) +// CGAL::BGL::internal::initialize_halfedge_index_map(external_halfedge_index_map, g); + + // forced to initialize the underlying map + for(halfedge_descriptor h : halfedges(g)) + him[h] = hi++; + + test_halfedge_index_map_uniqueness(g, CGAL::parameters::halfedge_index_map(external_halfedge_index_map)); + + // Writable pmap + typedef typename boost::graph_traits::edge_descriptor edge_descriptor; + typedef boost::unordered_map EdgeIndexMap; + typedef CGAL::RW_property_map EdgeIdPropertyMap; + + EdgeIndexMap eim; + EdgeIdPropertyMap external_edge_index_map(eim); + CGAL::BGL::internal::initialize_edge_index_map(external_edge_index_map, g); + + test_edge_index_map_uniqueness(g, CGAL::parameters::edge_index_map(external_edge_index_map)); + + // Just so face_index_map don't feel excluded + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef std::map FaceIndexMap; + typedef boost::const_associative_property_map FaceIdPropertyMap; + + FaceIndexMap fim; + FaceIdPropertyMap external_face_index_map(fim); + + // 'const_associative_pmap' has category 'lvalue_property_map_tag' but it's not writable + // so below should complain (commented because it does assert) +// CGAL::BGL::internal::initialize_face_index_map(external_face_index_map, g); + + // gotta initialize the underlying map + int fi = 0; + for(face_descriptor f : faces(g)) + fim[f] = fi++; + + test_face_index_map_uniqueness(g, CGAL::parameters::face_index_map(external_face_index_map)); +} + +template +void test_all_index_maps_const(const Graph& g) +{ +#ifdef CGAL_TEST_PROPERTIES_DEBUG + std::cout << " ---------------------------- Const graph tests" << std::endl; +#endif + + test_internal_index_maps_const(g); + test_initialized_index_maps_const(g); +} + +///////////////////////////////////// non-const //////////////////////////////////////////////////// + +template +void test_internal_index_maps(Graph& g) +{ + test_uniqueness(g, vertices(g), get(boost::vertex_index, g)); + test_uniqueness(g, halfedges(g), get(boost::halfedge_index, g)); + test_uniqueness(g, edges(g) , get(boost::edge_index, g)); + test_uniqueness(g, faces(g), get(boost::face_index, g)); +} + +template +void test_initialized_index_maps(Graph& g) +{ + typedef typename CGAL::GetInitializedVertexIndexMap::type VIM; + VIM ivim = CGAL::get_initialized_vertex_index_map(g); + test_uniqueness(g, vertices(g), ivim); + + typedef typename CGAL::GetInitializedHalfedgeIndexMap::type HIM; + HIM ihim = CGAL::get_initialized_halfedge_index_map(g); + test_uniqueness(g, halfedges(g), ihim); + + typedef typename CGAL::GetInitializedEdgeIndexMap::type EIM; + EIM ieim = CGAL::get_initialized_edge_index_map(g); + test_uniqueness(g, edges(g), ieim); + + typedef typename CGAL::GetInitializedFaceIndexMap::type FIM; + FIM ifim = CGAL::get_initialized_face_index_map(g); + test_uniqueness(g, faces(g), ifim); + + // Passing an index map via NP + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef std::map VertexIndexMap; + typedef boost::associative_property_map VertexIdPropertyMap; // lvalue_pmap + + int vi = static_cast(num_vertices(g)); + VertexIndexMap vim; + VertexIdPropertyMap external_vertex_index_map(vim); + for(vertex_descriptor v : vertices(g)) + put(external_vertex_index_map, v, --vi); + + test_vertex_index_map_uniqueness(g, CGAL::parameters::vertex_index_map(external_vertex_index_map)); + + // Read-only pmap + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef std::map HalfedgeIndexMap; + typedef CGAL::Non_mutable_property_map HalfedgeIdPropertyMap; + + int hi = 0; + HalfedgeIndexMap him; + HalfedgeIdPropertyMap external_halfedge_index_map(him); + + // this should complain that the map is not writable (commented because it does assert) +// CGAL::BGL::internal::initialize_halfedge_index_map(external_halfedge_index_map, g); + + // forced to initialize the underlying map + for(halfedge_descriptor h : halfedges(g)) + him[h] = hi++; + + test_halfedge_index_map_uniqueness(g, CGAL::parameters::halfedge_index_map(external_halfedge_index_map)); + + // Writable pmap + typedef typename boost::graph_traits::edge_descriptor edge_descriptor; + typedef boost::unordered_map EdgeIndexMap; + typedef CGAL::RW_property_map EdgeIdPropertyMap; + + EdgeIndexMap eim; + EdgeIdPropertyMap external_edge_index_map(eim); + CGAL::BGL::internal::initialize_edge_index_map(external_edge_index_map, g); + + test_edge_index_map_uniqueness(g, CGAL::parameters::edge_index_map(external_edge_index_map)); + + // Just so face_index_map don't feel excluded + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef std::map FaceIndexMap; + typedef boost::const_associative_property_map FaceIdPropertyMap; + + FaceIndexMap fim; + FaceIdPropertyMap external_face_index_map(fim); + + // 'const_associative_pmap' has category 'lvalue_property_map_tag' but it's not writable + // so below should complain (commented because it does assert) +// CGAL::BGL::internal::initialize_face_index_map(external_face_index_map, g); + + // gotta initialize the underlying map + int fi = 0; + for(face_descriptor f : faces(g)) + fim[f] = fi++; + + test_face_index_map_uniqueness(g, CGAL::parameters::face_index_map(external_face_index_map)); +} + +template +void test_all_index_maps(Graph& g) +{ +#ifdef CGAL_TEST_PROPERTIES_DEBUG + std::cout << " ---------------------------- Non-const graph tests" << std::endl; +#endif + + test_internal_index_maps(g); + test_initialized_index_maps(g); +} + +template +void test_graph(Graph& g) +{ + assert(!CGAL::is_empty(g)); + + // Add some garbage + CGAL::Euler::join_vertex(*(halfedges(g).begin()), g); + +#ifdef CGAL_TEST_PROPERTIES_DEBUG std::cout << "Graph has:" << std::endl - << "\t" << num_vertices(g) << " vertices" << std::endl - << "\t" << num_halfedges(g) << " halfedges" << std::endl - << "\t" << num_edges(g) << " edges" << std::endl - << "\t" << num_faces(g) << " faces" << std::endl; + << "\t" << num_vertices(g) << " vertices (actual: " << vertices(g).size() << ")" << std::endl + << "\t" << num_halfedges(g) << " halfedges (actual: " << halfedges(g).size() << ")" << std::endl + << "\t" << num_edges(g) << " edges (actual: " << edges(g).size() << ")" << std::endl + << "\t" << num_faces(g) << " faces (actual: " << faces(g).size() << ")" << std::endl; +#endif - index_uniqueness(g, vertices(g), get(boost::vertex_index, g)); - index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g)); - index_uniqueness(g, edges(g) , get(boost::edge_index, g)); - index_uniqueness(g, faces(g), get(boost::face_index, g)); - - index_uniqueness(g, vertices(g), CGAL::get_initialized_vertex_index_map(g)); - index_uniqueness(g, halfedges(g), CGAL::get_initialized_halfedge_index_map(g)); - index_uniqueness(g, edges(g) , CGAL::get_initialized_edge_index_map(g)); - index_uniqueness(g, faces(g), CGAL::get_initialized_face_index_map(g)); + test_all_index_maps(g); + test_all_index_maps_const(g); } -void index_uniqueness_poly(const Polyhedron& g) +void test_poly(Polyhedron& g) { - index_uniqueness(g); + test_graph(g); - index_uniqueness(g, edges(g) , get(boost::edge_external_index, g)); - index_uniqueness(g, vertices(g), get(boost::vertex_external_index, g)); - index_uniqueness(g, faces(g), get(boost::face_external_index, g)); - index_uniqueness(g, halfedges(g), get(boost::halfedge_external_index, g)); + test_uniqueness(g, edges(g) , get(boost::edge_external_index, g)); + test_uniqueness(g, vertices(g), get(boost::vertex_external_index, g)); + test_uniqueness(g, faces(g), get(boost::face_external_index, g)); + test_uniqueness(g, halfedges(g), get(boost::halfedge_external_index, g)); } -// @todo test non-const int main(int, char**) { std::cout << "testing Polyhedron\n"; - std::vector polys = poly_data(); // @tmp - for(const Polyhedron& p : polys) - index_uniqueness_poly(p); + std::vector polys = poly_data(); + for(Polyhedron& p : polys) + test_poly(p); std::cout << "testing Linear_cell_complex\n"; std::vector lccs = lcc_data(); - for(const LCC& p : lccs) - index_uniqueness(p); + for(LCC& p : lccs) + test_graph(p); std::cout << "testing Surface_mesh\n"; std::vector sms = sm_data(); - for(const SM& p : sms) - index_uniqueness(p); + for(SM& sm : sms) + { + test_graph(sm); + + // Test on a mesh with no internal index maps + Seam_edge_pmap seam_edges = sm.add_property_map("e:on_seam", false).first; + Seam_vertex_pmap seam_vertices = sm.add_property_map("v:on_seam", false).first; + Seam_mesh seam_mesh(sm, seam_edges, seam_vertices); + + test_initialized_index_maps(seam_mesh); + test_initialized_index_maps_const(seam_mesh); + } #if defined(CGAL_USE_OPENMESH) std::cout << "testing OpenMesh\n"; std::vector omeshs = omesh_data(); - for(const OMesh& p : omeshs) - index_uniqueness(p); + for(OMesh& p : omeshs) + test_graph(p); #endif - std::cout << "testing Triangulations\n"; - index_uniqueness(t2_data()); - index_uniqueness(dt2_data()); - index_uniqueness(rt2_data()); - index_uniqueness(ct2_data()); - index_uniqueness(cdt2_data()); - index_uniqueness(cdtp2_data()); - index_uniqueness(t2h_data()); +// std::cout << "testing Triangulations\n"; - std::cerr << "done\n"; - return 0; +// Triangulation_2 t2 = t2_data(); +// test_graph(t2); + +// Delaunay_triangulatiotest_initialized_index_mapsn_2 dt2 = dt2_data(); +// test_graph(dt2); + +// Regular_triangulation_2 rt2 = rt2_data(); +// test_graph(rt2); + +// Constrained_triangulation_2 ct2 = ct2_data(); +// test_graph(ct2); + +// Constrained_Delaunay_triangulation_2 cdt2 = cdt2_data(); +// test_graph(cdt2); + +// CDT_P2 cdtp2 = cdtp2_data(); +// test_graph(cdtp2); + +// Triangulation_hierarchy_2 t2h = t2h_data(); +// test_graph(t2h); + + std::cout << "Done!" << std::endl; + + return EXIT_SUCCESS; } From 9d4b0a7543992d1ab5f70002e2f0789468a0fd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 14:40:14 +0100 Subject: [PATCH 50/86] Also test initialized_pmaps for 2D triangulations --- BGL/test/BGL/test_Prefix.h | 27 ++++++++++++------ BGL/test/BGL/test_Properties.cpp | 47 ++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/BGL/test/BGL/test_Prefix.h b/BGL/test/BGL/test_Prefix.h index 396b0f9408d..4ca383561f1 100644 --- a/BGL/test/BGL/test_Prefix.h +++ b/BGL/test/BGL/test_Prefix.h @@ -78,6 +78,8 @@ typedef OpenMesh::PolyMesh_ArrayKernelT OMesh; typedef CGAL::Triangulation_vertex_base_with_id_2 Vbb; typedef CGAL::Triangulation_face_base_with_id_2 Fbb; +typedef CGAL::Triangulation_2 Triangulation_no_id_2; + typedef CGAL::Triangulation_2 > Triangulation_2; typedef CGAL::Delaunay_triangulation_2(); } -Delaunay_triangulation_2 dt2_data() { return build_dummy_triangulation(); } -Regular_triangulation_2 rt2_data() { return build_dummy_triangulation(); } -Constrained_triangulation_2 ct2_data() { return build_dummy_triangulation(); } -Constrained_Delaunay_triangulation_2 cdt2_data() { return build_dummy_triangulation(); } -CDT_P2 cdtp2_data() { return build_dummy_triangulation(); } -Triangulation_hierarchy_2 t2h_data() { return build_dummy_triangulation(); } +template +Tr build_dummy_triangulation_with_ids() +{ + Tr t = build_dummy_triangulation(); + CGAL::set_triangulation_ids(t); + return t; +} + +Triangulation_no_id_2 t2_no_id_data() { return build_dummy_triangulation(); } +Triangulation_2 t2_data() { return build_dummy_triangulation_with_ids(); } +Delaunay_triangulation_2 dt2_data() { return build_dummy_triangulation_with_ids(); } +Regular_triangulation_2 rt2_data() { return build_dummy_triangulation_with_ids(); } +Constrained_triangulation_2 ct2_data() { return build_dummy_triangulation_with_ids(); } +Constrained_Delaunay_triangulation_2 cdt2_data() { return build_dummy_triangulation_with_ids(); } +CDT_P2 cdtp2_data() { return build_dummy_triangulation_with_ids(); } +Triangulation_hierarchy_2 t2h_data() { return build_dummy_triangulation_with_ids(); } template struct Surface_fixture_1 { diff --git a/BGL/test/BGL/test_Properties.cpp b/BGL/test/BGL/test_Properties.cpp index 9f3cbe32136..984891b4ca9 100644 --- a/BGL/test/BGL/test_Properties.cpp +++ b/BGL/test/BGL/test_Properties.cpp @@ -4,7 +4,7 @@ #include -#define CGAL_TEST_PROPERTIES_DEBUG +// #define CGAL_TEST_PROPERTIES_DEBUG namespace CGAL { @@ -364,11 +364,6 @@ void test_all_index_maps(Graph& g) template void test_graph(Graph& g) { - assert(!CGAL::is_empty(g)); - - // Add some garbage - CGAL::Euler::join_vertex(*(halfedges(g).begin()), g); - #ifdef CGAL_TEST_PROPERTIES_DEBUG std::cout << "Graph has:" << std::endl << "\t" << num_vertices(g) << " vertices (actual: " << vertices(g).size() << ")" << std::endl @@ -407,6 +402,11 @@ int main(int, char**) std::vector sms = sm_data(); for(SM& sm : sms) { + assert(!CGAL::is_empty(sm)); + + // Add some garbage + CGAL::Euler::join_vertex(*(halfedges(sm).begin()), sm); + test_graph(sm); // Test on a mesh with no internal index maps @@ -425,28 +425,33 @@ int main(int, char**) test_graph(p); #endif -// std::cout << "testing Triangulations\n"; + std::cout << "testing Triangulations\n"; -// Triangulation_2 t2 = t2_data(); -// test_graph(t2); + Triangulation_2 t2 = t2_data(); + test_graph(t2); -// Delaunay_triangulatiotest_initialized_index_mapsn_2 dt2 = dt2_data(); -// test_graph(dt2); + Delaunay_triangulation_2 dt2 = dt2_data(); + test_graph(dt2); -// Regular_triangulation_2 rt2 = rt2_data(); -// test_graph(rt2); + Regular_triangulation_2 rt2 = rt2_data(); + test_graph(rt2); -// Constrained_triangulation_2 ct2 = ct2_data(); -// test_graph(ct2); + Constrained_triangulation_2 ct2 = ct2_data(); + test_graph(ct2); -// Constrained_Delaunay_triangulation_2 cdt2 = cdt2_data(); -// test_graph(cdt2); + Constrained_Delaunay_triangulation_2 cdt2 = cdt2_data(); + test_graph(cdt2); -// CDT_P2 cdtp2 = cdtp2_data(); -// test_graph(cdtp2); + CDT_P2 cdtp2 = cdtp2_data(); + test_graph(cdtp2); -// Triangulation_hierarchy_2 t2h = t2h_data(); -// test_graph(t2h); + Triangulation_hierarchy_2 t2h = t2h_data(); + test_graph(t2h); + + // no dynamic pmaps in triangulations (yet) +// Triangulation_no_id_2 t2_no_id = t2_no_id_data(); +// test_initialized_index_maps(t2_no_id); +// test_initialized_index_maps_const(t2_no_id); std::cout << "Done!" << std::endl; From b0cfe5a96d8ff8518de1ee5640664094694fc5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 15:31:03 +0100 Subject: [PATCH 51/86] Don't necessarily initialize the halfedge index map in copy_face_graph --- BGL/include/CGAL/boost/graph/copy_face_graph.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/copy_face_graph.h b/BGL/include/CGAL/boost/graph/copy_face_graph.h index 9f6ae2925c7..4e0dc04cd93 100644 --- a/BGL/include/CGAL/boost/graph/copy_face_graph.h +++ b/BGL/include/CGAL/boost/graph/copy_face_graph.h @@ -199,12 +199,8 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, typedef typename boost::graph_traits::halfedge_descriptor tm_halfedge_descriptor; std::vector hedges(num_halfedges(sm)); - // init halfedge index map - /// \TODO shall we keep that? - BGL::internal::initialize_halfedge_index_map(get(boost::halfedge_index, sm), const_cast(sm)); - copy_face_graph_impl(sm, tm, - bind_property_maps(get(boost::halfedge_index, sm), + bind_property_maps(get_initialized_halfedge_index_map(sm), make_property_map(hedges)), v2v, h2h, f2f, sm_vpm, tm_vpm); From 0a2b590110698a201a18b001f570aa5bb846527b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 15:31:40 +0100 Subject: [PATCH 52/86] Use the BGL automatic index map initializer --- .../CGAL/Polyhedral_complex_mesh_domain_3.h | 9 ++-- .../include/CGAL/Polyhedral_mesh_domain_3.h | 41 ------------------- .../Polyhedral_mesh_domain_with_features_3.h | 7 +--- 3 files changed, 6 insertions(+), 51 deletions(-) diff --git a/Mesh_3/include/CGAL/Polyhedral_complex_mesh_domain_3.h b/Mesh_3/include/CGAL/Polyhedral_complex_mesh_domain_3.h index ae6413ca009..9421e883a45 100644 --- a/Mesh_3/include/CGAL/Polyhedral_complex_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_complex_mesh_domain_3.h @@ -750,8 +750,7 @@ detect_features(FT angle_in_degree, for(Polyhedron_type& p : poly) { initialize_ts(p); - using Mesh_3::internal::Get_face_index_pmap; - Get_face_index_pmap get_face_index_pmap(p); + #ifdef CGAL_MESH_3_VERBOSE std::size_t poly_id = &p-&poly[0]; std::cerr << "Polyhedron #" << poly_id << " :\n"; @@ -768,9 +767,9 @@ detect_features(FT angle_in_degree, , eif , pid_map , PMP::parameters::first_index(nb_of_patch_plus_one) - .face_index_map(get_face_index_pmap(p)) - .vertex_incident_patches_map(vip_map) - .vertex_feature_degree_map(vertex_feature_degree_map)); + .face_index_map(get_initialized_face_index_map(p)) + .vertex_incident_patches_map(vip_map) + .vertex_feature_degree_map(vertex_feature_degree_map)); Mesh_3::internal::Is_featured_edge is_featured_edge(p); diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h index f9a7a0d5cf4..42abf9d1256 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h @@ -105,47 +105,6 @@ struct IGT_generator } // end namespace details } // end namespace Mesh_3 -namespace Mesh_3 { -namespace internal { - -template ::value> -class Get_face_index_pmap { -public: - typedef typename boost::property_map::const_type Pmap; - Get_face_index_pmap(const Polyhedron_type&) {} - Pmap operator()(const Polyhedron_type& polyhedron) { - return get(CGAL::face_index, polyhedron); - } -}; - -template -class Get_face_index_pmap { - typedef typename boost::graph_traits::face_descriptor - face_descriptor; - typedef std::map Map; -public: - Get_face_index_pmap(const Polyhedron_type& polyhedron) { - int id = 0; - for(face_descriptor f : faces(polyhedron)) - { - face_ids[f] = id++; - } - } - typedef boost::associative_property_map Pmap; - - Pmap operator()(const Polyhedron_type&) { - return Pmap(face_ids); - } -private: - Map face_ids; -}; - -} // end namespace internal -} // end namespace Mesh_3 - /** * @class Polyhedral_mesh_domain_3 * 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 d5f9979bc9b..ea92e1341ea 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 @@ -348,9 +348,6 @@ detect_features(FT angle_in_degree, std::vector& poly) typedef typename boost::property_map >::type VIPMap; typedef typename boost::property_map::type EIFMap; - using Mesh_3::internal::Get_face_index_pmap; - Get_face_index_pmap get_face_index_pmap(p); - PIDMap pid_map = get(face_patch_id_t(), p); VIPMap vip_map = get(vertex_incident_patches_t(), p); EIFMap eif_map = get(CGAL::edge_is_feature, p); @@ -360,8 +357,8 @@ detect_features(FT angle_in_degree, std::vector& poly) , eif_map , pid_map , PMP::parameters::first_index(nb_of_patch_plus_one) - .face_index_map(get_face_index_pmap(p)) - .vertex_incident_patches_map(vip_map)); + .face_index_map(get_initialized_face_index_map(p)) + .vertex_incident_patches_map(vip_map)); Mesh_3::internal::Is_featured_edge is_featured_edge(p); From 96b6cd002b8234e775b59e3e7b6d18ccffdb5207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 15:32:02 +0100 Subject: [PATCH 53/86] Remove obsolete call to index map initializations These maps are obtained using get_initialized_face_index_map(g, np) --- .../internal/Corefinement/Face_graph_output_builder.h | 4 ---- .../internal/Corefinement/Output_builder_for_autorefinement.h | 3 --- 2 files changed, 7 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index d854eec8a37..f6dca078d05 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -460,10 +460,6 @@ public: Intersection_edge_map& intersection_edges1 = mesh_to_intersection_edges[&tm1]; Intersection_edge_map& intersection_edges2 = mesh_to_intersection_edges[&tm2]; - // this will initialize face indices if the face index map is writable. - BGL::internal::initialize_face_index_map(fids1, tm1); - BGL::internal::initialize_face_index_map(fids2, tm2); - // bitset to identify coplanar faces boost::dynamic_bitset<> tm1_coplanar_faces(num_faces(tm1), 0); boost::dynamic_bitset<> tm2_coplanar_faces(num_faces(tm2), 0); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h index 33db7adf4da..0e37037ceb5 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h @@ -236,9 +236,6 @@ public: intersection_edges.insert(edge(p.second.h2, tm)); } - // this will initialize face indices if the face index map is writable. - BGL::internal::initialize_face_index_map(fids, tm); - // bitset to identify coplanar faces boost::dynamic_bitset<> tm_coplanar_faces(num_faces(tm), 0); From d15040ca26cd47d271d91d3ffb7e6c5bb00ff362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 16:45:48 +0100 Subject: [PATCH 54/86] Revert aeb4451, boost/CGAL namespaces will be fixed in another PR --- BGL/doc/BGL/CGAL/boost/graph/properties.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BGL/doc/BGL/CGAL/boost/graph/properties.h b/BGL/doc/BGL/CGAL/boost/graph/properties.h index a7416d53eae..2e8bb8b3eaa 100644 --- a/BGL/doc/BGL/CGAL/boost/graph/properties.h +++ b/BGL/doc/BGL/CGAL/boost/graph/properties.h @@ -1,5 +1,4 @@ -/// CGAL Namespace -namespace CGAL { +namespace boost { /// \ingroup PkgBGLProperties /// @{ From 4a77f29804d2cf0cd13ba66eb640e489e24f9ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 17:02:25 +0100 Subject: [PATCH 55/86] Replace index map validity runtime check with an assertion --- .../include/CGAL/Polygon_mesh_processing/border.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index 4622c12f626..fdce35a61fc 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -98,19 +98,7 @@ namespace Polygon_mesh_processing { typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - //make a minimal check that it's properly initialized : - //if the 2 first faces have the same id, we know the property map is not initialized - if (boost::is_same::Is_internal_map, - boost::true_type>::value) - { - typename boost::range_iterator::type it = boost::const_begin(faces); - if (get(fmap, *it) == get(fmap, *std::next(it))) - { - std::cerr << "WARNING : the internal property map for CGAL::face_index_t" << std::endl - << " is not properly initialized." << std::endl - << " Initialize it before calling border_halfedges()" << std::endl; - } - } + CGAL_assertion(BGL::internal::is_index_map_valid(fmap, num_faces(pmesh), faces(pmesh))); std::vector present(num_faces(pmesh), false); for(face_descriptor fd : faces) From 547ff7764bd5fb64e7efd177c41f80e9772d3e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 17:04:52 +0100 Subject: [PATCH 56/86] Fix doc typo --- .../Surface_mesh_simplification/edge_collapse_polyhedron.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cpp index 4287233a4c4..0549a04058f 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_polyhedron.cpp @@ -42,7 +42,7 @@ int main(int argc, char** argv) // The surface mesh and stop conditions are mandatory arguments. // The index maps are needed because the vertices and edges // of this surface mesh lack an "id()" field. - std::cout << "Collapsing edges of LCC: " << filename << ", aiming for " << edge_count_treshold << " final edges..." << std::endl; + std::cout << "Collapsing edges of Polyhedron: " << filename << ", aiming for " << edge_count_treshold << " final edges..." << std::endl; int r = SMS::edge_collapse(surface_mesh, stop, CGAL::parameters::vertex_index_map(get(CGAL::vertex_external_index, surface_mesh)) .halfedge_index_map(get(CGAL::halfedge_external_index, surface_mesh))); From 4334e954c0778b324099691bcd652e21ba454173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 5 Mar 2020 17:30:15 +0100 Subject: [PATCH 57/86] Parameter > PropertyTag for clarity --- .../internal/initialized_index_maps_helpers.h | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h index 1205072fa5e..0a1d3cf3a08 100644 --- a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -78,8 +78,8 @@ bool is_index_map_valid(const CGAL::internal_np::face_index_t, FaceIndexProperty return is_index_map_valid(face_index_map, num_faces(g), faces(g)); } -template -void initialize_index_map(const Parameter, IndexPropertyMap, const Graph&) +template +void initialize_index_map(const PropertyTag, IndexPropertyMap, const Graph&) { // Unknown parameter; should never be here. CGAL_assertion(false); @@ -118,8 +118,8 @@ struct Index_map_initializer put(face_index_map, fd, i++); } - template - void operator()(const Parameter, IndexPropertyMap, const Graph&) + template + void operator()(const PropertyTag, IndexPropertyMap, const Graph&) { // Unknown parameter; should never be here. CGAL_assertion(false); @@ -129,8 +129,8 @@ struct Index_map_initializer template struct Index_map_initializer { - template - void operator()(const Parameter, IndexPropertyMap, const Graph&) + template + void operator()(const PropertyTag, IndexPropertyMap, const Graph&) { // The property map is not writable; should never be here. CGAL_assertion_msg(false, "You are trying to initialize a non-writable property map"); @@ -161,9 +161,9 @@ CGAL_DEF_INITIALIZE_ID_MAP_FUNCTION(face) #undef CGAL_DEF_INITIALIZE_ID_FUCNTION // Using the pmap passed in named parameters ------------------------------------------------------- -template +template IndexMap get_initialized_index_map_const(const IndexMap index_map, - const Parameter p, Tag, DynamicTag, + const PropertyTag p, Tag, DynamicTag, const Graph& g) { CGAL_USE(g); @@ -173,9 +173,9 @@ IndexMap get_initialized_index_map_const(const IndexMap index_map, return index_map; } -template +template IndexMap get_initialized_index_map(const IndexMap index_map, - const Parameter p, Tag, DynamicTag, + const PropertyTag p, Tag, DynamicTag, Graph& g) { CGAL_USE(g); @@ -186,10 +186,10 @@ IndexMap get_initialized_index_map(const IndexMap index_map, } // Using the internal to the mesh ------------------------------------------------------------------ -template +template InternalIndexMap get_initialized_internal_index_map(InternalIndexMap index_map, - const Parameter p, + const PropertyTag p, const Graph& g) { if(CGAL::internal::Is_writable_property_map::value) @@ -205,20 +205,20 @@ get_initialized_internal_index_map(InternalIndexMap index_map, return index_map; } -template +template typename boost::property_map::const_type get_initialized_index_map_const(CGAL::internal_np::Param_not_found, - const Parameter p, const Tag tag, DynamicTag, + const PropertyTag p, const Tag tag, DynamicTag, const Graph& g) { return get_initialized_internal_index_map(get(tag, g), p, g); } // same as above, non-const graph overload -template +template typename boost::property_map::type get_initialized_index_map(CGAL::internal_np::Param_not_found, - const Parameter p, const Tag tag, DynamicTag, + const PropertyTag p, const Tag tag, DynamicTag, Graph& g) { // From now on the correct property map has been acquired @@ -227,30 +227,30 @@ get_initialized_index_map(CGAL::internal_np::Param_not_found, } // Create a dynamic property and initialize it ----------------------------------------------------- -template +template DynamicIndexMap get_initialized_dynamic_index_map(DynamicIndexMap index_map, - const Parameter p, + const PropertyTag p, const Graph& g) { Index_map_initializer{}(p, index_map, g); return index_map; } -template +template typename boost::property_map::const_type get_initialized_index_map_const(CGAL::internal_np::Param_not_found, - const Parameter p, const DynamicTag dtag, DynamicTag, + const PropertyTag p, const DynamicTag dtag, DynamicTag, const Graph& g) { return get_initialized_dynamic_index_map(get(dtag, g), p, g); } // same as above, non-const graph overload -template +template typename boost::property_map::type get_initialized_index_map(CGAL::internal_np::Param_not_found, - const Parameter p, const DynamicTag dtag, DynamicTag, + const PropertyTag p, const DynamicTag dtag, DynamicTag, Graph& g) { // From now on the correct property map has been acquired @@ -258,7 +258,7 @@ get_initialized_index_map(CGAL::internal_np::Param_not_found, return get_initialized_dynamic_index_map(get(dtag, g), p, g); } -template > class GetInitializedIndexMap @@ -269,22 +269,22 @@ public: CGAL::graph_has_property::value, Tag, DynamicTag>::type Final_tag; typedef typename internal_np::Lookup_named_param_def< - Parameter, + PropertyTag, NamedParameters, typename boost::property_map::const_type>::type const_type; typedef typename internal_np::Lookup_named_param_def< - Parameter, + PropertyTag, NamedParameters, typename boost::property_map::type>::type type; - static const_type get_const(const Parameter p, const Graph& g, const NamedParameters& np) + static const_type get_const(const PropertyTag p, const Graph& g, const NamedParameters& np) { return BGL::internal::get_initialized_index_map_const(parameters::get_parameter(np, p), p, Final_tag{}, DynamicTag{}, g); } - static type get(const Parameter p, Graph& g, const NamedParameters& np) + static type get(const PropertyTag p, Graph& g, const NamedParameters& np) { return BGL::internal::get_initialized_index_map(parameters::get_parameter(np, p), p, Final_tag{}, DynamicTag{}, g); From 937478addb7a302ea482c0bce10637512a170ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 6 Mar 2020 13:42:38 +0100 Subject: [PATCH 58/86] Rephrase doc to reflect the possibility of garbage in the mesh --- .../include/CGAL/Surface_mesh_deformation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h b/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h index a3c6080dee3..c6bbf55fe09 100644 --- a/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h +++ b/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h @@ -437,8 +437,8 @@ public: * * @pre `triangle_mesh` consists of only triangular facets * @param triangle_mesh triangulated surface mesh to deform - * @param vertex_index_map property map which associates an id to each vertex, from `0` to `num_vertices(triangle_mesh)-1`. - * @param hedge_index_map property map which associates an id to each halfedge, from `0` to `2*num_edges(triangle_mesh)-1`. + * @param vertex_index_map property map which associates a unique id to each vertex, between `0` to `num_vertices(triangle_mesh)-1`. + * @param hedge_index_map property map which associates a unique id to each halfedge, between `0` to `2*num_edges(triangle_mesh)-1`. * @param vertex_point_map property map which associates a point to each vertex of the triangle mesh. * @param weight_calculator function object or pointer for weight calculation */ From ad62f89a20bce6605cb988617328ede15914724c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 6 Mar 2020 15:16:30 +0100 Subject: [PATCH 59/86] Use the new index map initializer functions and fix doc --- .../CGAL/boost/graph/Face_filtered_graph.h | 100 +++++++++--------- .../boost/graph/METIS/partition_dual_graph.h | 12 +-- .../CGAL/boost/graph/METIS/partition_graph.h | 12 +-- BGL/include/CGAL/boost/graph/io.h | 16 +-- BGL/test/BGL/test_Face_filtered_graph.cpp | 20 ++-- .../NamedParameters.txt | 16 ++- .../connected_components.h | 20 ---- .../CGAL/Polygon_mesh_processing/repair.h | 11 +- .../Polygon_mesh_processing/stitch_borders.h | 22 ++-- .../include/CGAL/Surface_mesh_deformation.h | 70 ++++++------ .../edge_collapse.h | 9 +- .../edge_collapse.h | 6 +- 12 files changed, 136 insertions(+), 178 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/Face_filtered_graph.h b/BGL/include/CGAL/boost/graph/Face_filtered_graph.h index ffd943fb9c4..3a116f34c7a 100644 --- a/BGL/include/CGAL/boost/graph/Face_filtered_graph.h +++ b/BGL/include/CGAL/boost/graph/Face_filtered_graph.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -71,9 +72,9 @@ namespace CGAL * \cgalModels \bgllink{VertexListGraph} */ template::type, - typename VIMap = typename boost::property_map::type, - typename HIMap = typename boost::property_map::type> + typename FIMap = typename CGAL::GetInitializedFaceIndexMap::const_type, + typename VIMap = typename CGAL::GetInitializedVertexIndexMap::const_type, + typename HIMap = typename CGAL::GetInitializedHalfedgeIndexMap::const_type> struct Face_filtered_graph { typedef boost::graph_traits gt; @@ -115,31 +116,31 @@ struct Face_filtered_graph * * \cgalNamedParamsBegin * \cgalParamBegin{face_index_map} - * a property map containing an index for each face initialized from 0 to `num_vertices(graph)` + * a property map containing for each face of `graph` a unique index between `0` and `num_faces(graph)-1` * \cgalParamEnd * \cgalParamBegin{vertex_index_map} - * a property map containing an index for each vertex initialized 0 to `num_vertices(graph)` + * a property map containing for each vertex of `graph` a unique index between `0` and `num_vertices(graph)-1` * \cgalParamEnd * \cgalParamBegin{halfedge_index_map} - * a property map containing an index for each halfedge initialized 0 to `num_halfedges(graph)` + * a property map containing for each halfedge of `graph` a unique index between `0` and `num_halfedges(graph)-1` * \cgalParamEnd * \cgalNamedParamsEnd */ template Face_filtered_graph(const Graph& graph, const FacePatchIndexRange& selected_face_patch_indices, - FacePatchIndexMap face_patch_index_map, - const CGAL_BGL_NP_CLASS& np - #ifndef DOXYGEN_RUNNING - , typename boost::enable_if< - typename boost::has_range_const_iterator::type - >::type* = 0 - #endif - ) - : _graph(const_cast(graph)) - , fimap(parameters::choose_parameter(parameters::get_parameter(np, internal_np::face_index), get_const_property_map(face_index, graph))) - , vimap(parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_index), get_const_property_map(boost::vertex_index, graph))) - , himap(parameters::choose_parameter(parameters::get_parameter(np, internal_np::halfedge_index), get_const_property_map(halfedge_index, graph))) + FacePatchIndexMap face_patch_index_map, + const CGAL_BGL_NP_CLASS& np +#ifndef DOXYGEN_RUNNING + , typename boost::enable_if< + typename boost::has_range_const_iterator::type + >::type* = 0 +#endif + ) + : _graph(const_cast(graph)), + fimap(CGAL::get_initialized_face_index_map(graph, np)), + vimap(CGAL::get_initialized_vertex_index_map(graph, np)), + himap(CGAL::get_initialized_halfedge_index_map(graph, np)) { set_selected_faces(selected_face_patch_indices, face_patch_index_map); } @@ -152,10 +153,10 @@ struct Face_filtered_graph typename boost::has_range_const_iterator::type >::type* = 0 ) - : _graph(const_cast(graph)) - , fimap(get(CGAL::face_index, graph)) - , vimap(get(boost::vertex_index, graph)) - , himap(get(CGAL::halfedge_index, graph)) + : _graph(const_cast(graph)), + fimap(CGAL::get_initialized_face_index_map(graph)), + vimap(CGAL::get_initialized_vertex_index_map(graph)), + himap(CGAL::get_initialized_halfedge_index_map(graph)) { set_selected_faces(selected_face_patch_indices, face_patch_index_map); } @@ -175,38 +176,37 @@ struct Face_filtered_graph * * \cgalNamedParamsBegin * \cgalParamBegin{face_index_map} - * a property map containing an index for each face initialized from 0 to `num_vertices(graph)` + * a property map containing for each face of `graph` a unique index between `0` and `num_faces(graph)-1` * \cgalParamEnd * \cgalParamBegin{vertex_index_map} - * a property map containing an index for each vertex initialized 0 to `num_vertices(graph)` + * a property map containing for each vertex of `graph` a unique index between `0` and `num_vertices(graph)-1` * \cgalParamEnd * \cgalParamBegin{halfedge_index_map} - * a property map containing an index for each halfedge initialized 0 to `num_halfedges(graph)` + * a property map containing for each halfedge of `graph` a unique index between `0` and `num_halfedges(graph)-1` * \cgalParamEnd * \cgalNamedParamsEnd */ template Face_filtered_graph(const Graph& graph, - typename boost::property_traits::value_type selected_face_patch_index, - FacePatchIndexMap face_patch_index_map, - const CGAL_BGL_NP_CLASS& np - ) - : _graph(const_cast(graph)) - , fimap(parameters::choose_parameter(parameters::get_parameter(np, internal_np::face_index), get_const_property_map(face_index, graph))) - , vimap(parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_index), get_const_property_map(boost::vertex_index, graph))) - , himap(parameters::choose_parameter(parameters::get_parameter(np, internal_np::halfedge_index), get_const_property_map(halfedge_index, graph))) + typename boost::property_traits::value_type selected_face_patch_index, + FacePatchIndexMap face_patch_index_map, + const CGAL_BGL_NP_CLASS& np) + : _graph(const_cast(graph)), + fimap(CGAL::get_initialized_face_index_map(graph, np)), + vimap(CGAL::get_initialized_vertex_index_map(graph, np)), + himap(CGAL::get_initialized_halfedge_index_map(graph, np)) { set_selected_faces(selected_face_patch_index, face_patch_index_map); } template Face_filtered_graph(const Graph& graph, - typename boost::property_traits::value_type pid, - FacePatchIndexMap face_patch_index_map) - : _graph(const_cast(graph)) - , fimap(get(CGAL::face_index, graph)) - , vimap(get(boost::vertex_index, graph)) - , himap(get(CGAL::halfedge_index, graph)) + typename boost::property_traits::value_type pid, + FacePatchIndexMap face_patch_index_map) + : _graph(const_cast(graph)), + fimap(CGAL::get_initialized_face_index_map(graph)), + vimap(CGAL::get_initialized_vertex_index_map(graph)), + himap(CGAL::get_initialized_halfedge_index_map(graph)) { set_selected_faces(pid, face_patch_index_map); } @@ -236,10 +236,10 @@ struct Face_filtered_graph Face_filtered_graph(const Graph& graph, const FaceRange& selected_faces, const CGAL_BGL_NP_CLASS& np) - : _graph(const_cast(graph)) - , fimap(parameters::choose_parameter(parameters::get_parameter(np, internal_np::face_index), get_const_property_map(face_index, graph))) - , vimap(parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_index), get_const_property_map(boost::vertex_index, graph))) - , himap(parameters::choose_parameter(parameters::get_parameter(np, internal_np::halfedge_index), get_const_property_map(halfedge_index, graph))) + : _graph(const_cast(graph)), + fimap(CGAL::get_initialized_face_index_map(graph, np)), + vimap(CGAL::get_initialized_vertex_index_map(graph, np)), + himap(CGAL::get_initialized_halfedge_index_map(graph, np)) { set_selected_faces(selected_faces); } @@ -247,10 +247,10 @@ struct Face_filtered_graph template Face_filtered_graph(const Graph& graph, const FaceRange& selected_faces) - : _graph(const_cast(graph)) - , fimap(get(CGAL::face_index, graph)) - , vimap(get(boost::vertex_index, graph)) - , himap(get(CGAL::halfedge_index, graph)) + : _graph(const_cast(graph)), + fimap(CGAL::get_initialized_face_index_map(graph)), + vimap(CGAL::get_initialized_vertex_index_map(graph)), + himap(CGAL::get_initialized_halfedge_index_map(graph)) { set_selected_faces(selected_faces); } @@ -293,12 +293,12 @@ struct Face_filtered_graph template void set_selected_faces(const FacePatchIndexRange& selected_face_patch_indices, FacePatchIndexMap face_patch_index_map - #ifndef DOXYGEN_RUNNING +#ifndef DOXYGEN_RUNNING , typename boost::enable_if< typename boost::has_range_const_iterator::type >::type* = 0 - #endif - ) +#endif + ) { face_indices.clear(); vertex_indices.clear(); diff --git a/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h b/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h index 50c0bcf7e37..d11a426b5e1 100644 --- a/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h +++ b/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h @@ -42,17 +42,14 @@ void partition_dual_graph(const TriangleMesh& tm, CGAL_precondition(CGAL::is_triangle_mesh(tm)); CGAL_precondition_msg(nparts > 1, ("Partitioning requires a number of parts > 1")); - using parameters::choose_parameter; using parameters::get_parameter; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_iterator face_iterator; - // vertex index map - typedef typename CGAL::GetVertexIndexMap::type Indices; - Indices indices = choose_parameter(get_parameter(np, internal_np::vertex_index), - get_const_property_map(boost::vertex_index, tm)); + typedef typename CGAL::GetInitializedVertexIndexMap::type Indices; + Indices indices = CGAL::get_initialized_vertex_index_map(tm, np); idx_t nn = static_cast(num_vertices(tm)); idx_t ne = static_cast(num_faces(tm)); @@ -136,9 +133,6 @@ void partition_dual_graph(const TriangleMesh& tm, int nparts, /// based on the mesh's dual graph. The resulting partition is stored in the vertex and/or face /// property maps that are passed as parameters using \ref bgl_namedparameters "Named Parameters". /// -/// Property map for `CGAL::vertex_index_t` should be either available -/// as an internal property map to `tm` or provided as \ref bgl_namedparameters "Named Parameters". -/// /// \param tm a triangle mesh /// \param nparts the number of parts in the final partition /// \param np optional \ref bgl_namedparameters "Named Parameters" described below @@ -148,7 +142,7 @@ void partition_dual_graph(const TriangleMesh& tm, int nparts, /// /// \cgalNamedParamsBegin /// \cgalParamBegin{vertex_index_map} -/// is a property map containing the index of each vertex of `tm` intialized from `0` to `num_vertices(tm)-1`. +/// is a property map containing for each vertex of `tm` a unique index between `0` and `num_vertices(tm)-1`. /// \cgalParamEnd /// \cgalParamBegin{METIS_options} /// is a parameter used in to pass options to the METIS mesh diff --git a/BGL/include/CGAL/boost/graph/METIS/partition_graph.h b/BGL/include/CGAL/boost/graph/METIS/partition_graph.h index ec60ecbc11a..4ef813efcc6 100644 --- a/BGL/include/CGAL/boost/graph/METIS/partition_graph.h +++ b/BGL/include/CGAL/boost/graph/METIS/partition_graph.h @@ -77,17 +77,14 @@ void partition_graph(const TriangleMesh& tm, CGAL_precondition(CGAL::is_triangle_mesh(tm)); CGAL_precondition_msg(nparts > 1, ("Partitioning requires a number of parts > 1")); - using parameters::choose_parameter; using parameters::get_parameter; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_iterator face_iterator; - //Vertex index map - typedef typename CGAL::GetVertexIndexMap::type Indices; - Indices indices = choose_parameter(get_parameter(np, internal_np::vertex_index), - get_const_property_map(boost::vertex_index, tm)); + typedef typename CGAL::GetInitializedVertexIndexMap::type Indices; + Indices indices = CGAL::get_initialized_vertex_index_map(tm, np); idx_t nn = static_cast(num_vertices(tm)); idx_t ne = static_cast(num_faces(tm)); @@ -168,9 +165,6 @@ void partition_graph(const TriangleMesh& tm, int nparts, /// mesh's nodal graph. The resulting partition is stored in the vertex and/or face /// property maps that are passed as parameters using \ref bgl_namedparameters "Named Parameters". /// -/// Property map for `CGAL::vertex_index_t` should be either available -/// as an internal property map to `tm` or provided as \ref bgl_namedparameters "Named Parameters". -/// /// \param tm a triangle mesh /// \param nparts the number of parts in the final partition /// \param np optional \ref bgl_namedparameters "Named Parameters" described below @@ -180,7 +174,7 @@ void partition_graph(const TriangleMesh& tm, int nparts, /// /// \cgalNamedParamsBegin /// \cgalParamBegin{vertex_index_map} -/// is a property map containing the index of each vertex of `tm` intialized from `0` to `num_vertices(tm)-1`. +/// is a property map containing for each vertex of `tm` a unique index between `0` and `num_vertices(tm)-1`. /// \cgalParamEnd /// \cgalParamBegin{METIS_options} /// is a parameter used in to pass options to the METIS mesh diff --git a/BGL/include/CGAL/boost/graph/io.h b/BGL/include/CGAL/boost/graph/io.h index f8e91ea49c2..7a7de91f470 100644 --- a/BGL/include/CGAL/boost/graph/io.h +++ b/BGL/include/CGAL/boost/graph/io.h @@ -417,13 +417,9 @@ write_polys(std::ostream& os, { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::face_iterator face_iterator; - typedef typename CGAL::GetVertexIndexMap::type Vimap; - using parameters::get_parameter; - using parameters::choose_parameter; - - Vimap V = choose_parameter(get_parameter(np, internal_np::vertex_index), - get_const_property_map(boost::vertex_index, mesh)); + typedef typename CGAL::GetInitializedVertexIndexMap::const_type Vimap; + Vimap V = CGAL::get_initialized_vertex_index_map(mesh, np); std::vector connectivity_table; std::vector offsets; @@ -456,13 +452,9 @@ write_polys_tag(std::ostream& os, { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::face_iterator face_iterator; - typedef typename CGAL::GetVertexIndexMap::type Vimap; - using parameters::get_parameter; - using parameters::choose_parameter; - - Vimap V = choose_parameter(get_parameter(np, internal_np::vertex_index), - get_const_property_map(boost::vertex_index, mesh)); + typedef typename CGAL::GetInitializedVertexIndexMap::const_type Vimap; + Vimap V = CGAL::get_initialized_vertex_index_map(mesh, np); std::string formatattribute = binary ? " format=\"appended\"" : " format=\"ascii\""; diff --git a/BGL/test/BGL/test_Face_filtered_graph.cpp b/BGL/test/BGL/test_Face_filtered_graph.cpp index bbf57e5b2c2..0a579fe96cc 100644 --- a/BGL/test/BGL/test_Face_filtered_graph.cpp +++ b/BGL/test/BGL/test_Face_filtered_graph.cpp @@ -491,13 +491,13 @@ int main() typedef boost::graph_traits PolyTraits; - typedef boost::property_map::type VPMap; + typedef boost::property_map::const_type VPMap; typedef PolyTraits::face_descriptor poly_face_descriptor; typedef boost::associative_property_map< std::map > FCMap; - typedef boost::property_map::type FIMap; - typedef boost::property_map::type VIMap; - typedef boost::property_map::type HIMap; + typedef boost::property_map::const_type FIMap; + typedef boost::property_map::const_type VIMap; + typedef boost::property_map::const_type HIMap; typedef CGAL::Face_filtered_graph Poly_Adapter; auto poly = std::make_unique(); CGAL::make_tetrahedron( @@ -516,14 +516,14 @@ int main() FCMap poly_fccmap(fc_map); VPMap vpmap = get(boost::vertex_point, *poly); - CGAL::Polygon_mesh_processing::connected_components(*poly, poly_fccmap, CGAL::Polygon_mesh_processing::parameters:: - edge_is_constrained_map(Constraint(*poly, vpmap)). - face_index_map(poly_fimap)); + CGAL::Polygon_mesh_processing::connected_components(*poly, poly_fccmap, + CGAL::Polygon_mesh_processing::parameters::edge_is_constrained_map(Constraint(*poly, vpmap)) + .face_index_map(poly_fimap)); Poly_Adapter poly_adapter(*poly, pids, poly_fccmap, - CGAL::parameters::face_index_map(poly_fimap). - vertex_index_map(poly_vimap). - halfedge_index_map(poly_himap)); + CGAL::parameters::face_index_map(poly_fimap) + .vertex_index_map(poly_vimap) + .halfedge_index_map(poly_himap)); test_mesh(poly_adapter); } diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt index 20cea4f136f..b9d52b7d67d 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt @@ -32,20 +32,26 @@ is the property map with the points associated to the vertices of the polygon me \cgalNPEnd \cgalNPBegin{vertex_index_map} \anchor PMP_vertex_index_map -is the property map containing the index of each vertex of the input polygon mesh.\n +is the property map associating a unique index to each vertex of a polygon mesh. +If this parameter is not passed, internal machinery will create and initialize a vertex index +property map, either using the internal property map if it exists or using an external map. The latter +might result in (slightly) performance due to non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` as key type and the value type \code typename boost::property_traits::type>::value_type \endcode -Default: \code boost::get(CGAL::vertex_index, pmesh)\endcode +Default: an initialized vertex index property map \cgalNPEnd \cgalNPBegin{face_index_map} \anchor PMP_face_index_map -is the property map containing the index of each face of the input polygon mesh.\n +is the property map associating a unique index to each face of a polygon mesh. +If this parameter is not passed, internal machinery will create and initialize a face index +property map, either using the internal property map if it exists or using an external map. The latter +might result in (slightly) performance due to non-constant complexity for index access.\n +\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode -Default: \code boost::get(CGAL::face_index, pmesh)\endcode -If this internal property map exists, its values must be initialized. +Default: an initialized face index property map \cgalNPEnd \cgalNPBegin{edge_is_constrained_map} \anchor PMP_edge_is_constrained_map diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index c072237ec9d..07923fd8aeb 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -324,10 +324,6 @@ std::size_t number_of_connected_components(const PolygonMesh& pmesh) * By default, the size of a face is `1` (and thus the size of a connected component is the number * of faces it contains), but it is also possible to pass custom sizes, such as the area of the face. * -* If `PolygonMesh` has a non modifiable internal property map -* for `CGAL::face_index_t` (resp. `CGAL::vertex_index_t`) and no `face_index_map` (resp. `vertex_index_map`) is given -* as a named parameter, then the internal one must be initialized. Otherwise, it will be. - * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" * @@ -455,10 +451,6 @@ std::size_t keep_largest_connected_components(PolygonMesh& pmesh, * the size of a connected component is the number of faces it contains), but it is also possible * to pass custom sizes, such as the area of the face. * -* If `PolygonMesh` has a non modifiable internal property map -* for `CGAL::face_index_t` (resp. `CGAL::vertex_index_t`) and no `face_index_map` (resp. `vertex_index_map`) is given -* as a named parameter, then the internal one must be initialized. Otherwise, it will be. - * * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam ThresholdValueType the type of the threshold value * \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" @@ -715,10 +707,6 @@ void keep_or_remove_connected_components(PolygonMesh& pmesh * \note If the removal of the connected components makes `pmesh` a non-manifold surface, * then the behavior of this function is undefined. * -* If `PolygonMesh` has a non modifiable internal property map -* for `CGAL::face_index_t` (resp. `CGAL::vertex_index_t`) and no `face_index_map` (resp. `vertex_index_map`) is given -* as a named parameter, then the internal one(s) must be initialized. Otherwise, it will be. -* * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" * \tparam ComponentRange a range of ids convertible to `std::size` @@ -799,10 +787,6 @@ void remove_connected_components(PolygonMesh& pmesh * keeps the connected components not designated by the faces in `components_to_remove`, * and removes the other connected components and all isolated vertices. * -* If `PolygonMesh` has a non modifiable internal property map -* for `CGAL::face_index_t` (resp. `CGAL::vertex_index_t`) and no `face_index_map` (resp. `vertex_index_map`) is given -* as a named parameter, then the internal one must be initialized. Otherwise, it will be. -* * \note If the removal of the connected components makes `pmesh` a non-manifold surface, * then the behavior of this function is undefined. * @@ -856,10 +840,6 @@ void remove_connected_components(PolygonMesh& pmesh * keeps the connected components designated by the faces in `components_to_keep`, * and removes the other connected components and all isolated vertices. * -* If `PolygonMesh` has a non modifiable internal property map -* for `CGAL::face_index_t` (resp. `CGAL::vertex_index_t`) and no `face_index_map` (resp. `vertex_index_map`) is given -* as a named parameter, then the internal one must be initialized. Otherwise, it will be. -* * \note If the removal of the connected components makes `pmesh` a non-manifold surface, * then the behavior of this function is undefined. * diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h index df7ba18fb66..3f2e8a6c03d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -111,10 +111,6 @@ std::size_t remove_isolated_vertices(PolygonMesh& pmesh) /// As a consequence of the last sentence, the area or volume criteria can be disabled /// by passing zero (`0`) as threshold value. /// -/// Property maps for `CGAL::face_index_t` and `CGAL::vertex_index_t` -/// must be either available as internal property maps -/// to `tmesh` or provided as \ref pmp_namedparameters "Named Parameters". -/// /// \tparam TriangleMesh a model of `FaceListGraph` and `MutableFaceGraph` /// \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" /// @@ -129,8 +125,6 @@ std::size_t remove_isolated_vertices(PolygonMesh& pmesh) /// \cgalParamBegin{edge_is_constrained_map} a property map containing the constrained-or-not status of each edge of `pmesh` \cgalParamEnd /// \cgalParamBegin{face_index_map} a property map containing the index of each face of `tmesh` \cgalParamEnd /// \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `tmesh`. -/// If this parameter is omitted, an internal property map for -/// `CGAL::vertex_point_t` should be available in `TriangleMesh` \cgalParamEnd /// \cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel` \cgalParamEnd /// \cgalParamBegin{dry_run} a Boolean parameter. If set to `true`, the mesh will not be altered, /// but the number of components that would be removed is returned. The default value is `false`.\cgalParamEnd @@ -162,9 +156,8 @@ std::size_t remove_connected_components_of_negligible_size(TriangleMesh& tmesh, const VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, tmesh)); - typedef typename GetFaceIndexMap::type FaceIndexMap; - FaceIndexMap fim = choose_parameter(get_parameter(np, internal_np::face_index), - get_property_map(boost::face_index, tmesh)); + typedef typename GetInitializedFaceIndexMap::type FaceIndexMap; + FaceIndexMap fim = CGAL::get_initialized_face_index_map(tmesh, np); FT area_threshold = choose_parameter(get_parameter(np, internal_np::area_threshold), FT(-1)); FT volume_threshold = choose_parameter(get_parameter(np, internal_np::volume_threshold), FT(-1)); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h index 3464fe3f181..9e565d205f8 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h @@ -860,16 +860,18 @@ std::size_t stitch_borders(PolygonMesh& pmesh, /// @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below /// /// \cgalNamedParamsBegin -/// \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `pmesh`. -/// If this parameter is omitted, an internal property map for -/// `CGAL::vertex_point_t` must be available in `PolygonMesh`.\cgalParamEnd -/// \cgalParamBegin{apply_per_connected_component} -/// specifies if the borders should only be stitched inside their own connected component. -/// In that case, an initialized property map for `CGAL::face_index_t` should be either available as an internal property map -/// to `pmesh` or provided as the \ref pmp_namedparameters "Named Parameter" `face_index_map`. If this is not the case, -/// a default map will be created on the fly. -/// Default value is `false`.\cgalParamEnd -/// \cgalParamBegin{face_index_map} a property map containing the index of each face of `pmesh` \cgalParamEnd +/// \cgalParamBegin{vertex_point_map} +/// the property map with the points associated to the vertices of `pmesh`. +/// If this parameter is omitted, an internal property map for +/// `CGAL::vertex_point_t` must be available in `PolygonMesh`. +/// \cgalParamEnd +/// \cgalParamBegin{apply_per_connected_component} +/// specifies if the borders should only be stitched inside their own connected component. +/// Default value is `false`. +/// \cgalParamEnd +/// \cgalParamBegin{face_index_map} +/// a property map containing for each face of `pmesh` a unique index between `0` and `num_faces(pmesh)-1` +/// \cgalParamEnd /// \cgalNamedParamsEnd /// /// @return the number of pairs of halfedges that were stitched. diff --git a/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h b/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h index c6bbf55fe09..d425ce57fc8 100644 --- a/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h +++ b/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h @@ -215,13 +215,9 @@ public: // Index maps #ifndef DOXYGEN_RUNNING typedef typename Default::Get< - VIM, - typename boost::property_map::type - >::type Vertex_index_map; + VIM, typename CGAL::GetInitializedVertexIndexMap::type>::type Vertex_index_map; typedef typename Default::Get< - HIM, - typename boost::property_map::type - >::type Hedge_index_map; + HIM, typename CGAL::GetInitializedHalfedgeIndexMap::type>::type Hedge_index_map; #else /// vertex index map type typedef VIM Vertex_index_map; @@ -356,9 +352,10 @@ public: //vertex_point_map set by default Surface_mesh_deformation(Triangle_mesh& triangle_mesh, Vertex_index_map vertex_index_map, - Hedge_index_map hedge_index_map - ) - : m_triangle_mesh(triangle_mesh), vertex_index_map(vertex_index_map), hedge_index_map(hedge_index_map), + Hedge_index_map hedge_index_map) + : m_triangle_mesh(triangle_mesh), + vertex_index_map(vertex_index_map), + hedge_index_map(hedge_index_map), ros_id_map(std::vector(num_vertices(triangle_mesh), (std::numeric_limits::max)() )), is_roi_map(std::vector(num_vertices(triangle_mesh), false)), is_ctrl_map(std::vector(num_vertices(triangle_mesh), false)), @@ -374,10 +371,10 @@ public: //vertex_point_map and hedge_index_map set by default Surface_mesh_deformation(Triangle_mesh& triangle_mesh, - Vertex_index_map vertex_index_map - ) - : m_triangle_mesh(triangle_mesh), vertex_index_map(vertex_index_map), - hedge_index_map(get(boost::halfedge_index, triangle_mesh)), + Vertex_index_map vertex_index_map) + : m_triangle_mesh(triangle_mesh), + vertex_index_map(vertex_index_map), + hedge_index_map(CGAL::get_initialized_halfedge_index_map(triangle_mesh)), ros_id_map(std::vector(num_vertices(triangle_mesh), (std::numeric_limits::max)() )), is_roi_map(std::vector(num_vertices(triangle_mesh), false)), is_ctrl_map(std::vector(num_vertices(triangle_mesh), false)), @@ -393,8 +390,8 @@ public: //vertex_point_map, hedge_index_map and vertex_index_map set by default Surface_mesh_deformation(Triangle_mesh& triangle_mesh) : m_triangle_mesh(triangle_mesh), - vertex_index_map(get(boost::vertex_index, triangle_mesh)), - hedge_index_map(get(boost::halfedge_index, triangle_mesh)), + vertex_index_map(CGAL::get_initialized_vertex_index_map(triangle_mesh)), + hedge_index_map(CGAL::get_halfedge_vertex_index_map(triangle_mesh)), ros_id_map(std::vector(num_vertices(triangle_mesh), (std::numeric_limits::max)() )), is_roi_map(std::vector(num_vertices(triangle_mesh), false)), is_ctrl_map(std::vector(num_vertices(triangle_mesh), false)), @@ -413,18 +410,19 @@ public: Vertex_index_map vertex_index_map, Hedge_index_map hedge_index_map, Vertex_point_map vertex_point_map, - Weight_calculator weight_calculator = Weight_calculator() - ) - : m_triangle_mesh(triangle_mesh), vertex_index_map(vertex_index_map), hedge_index_map(hedge_index_map), - ros_id_map(std::vector(num_vertices(triangle_mesh), (std::numeric_limits::max)() )), - is_roi_map(std::vector(num_vertices(triangle_mesh), false)), - is_ctrl_map(std::vector(num_vertices(triangle_mesh), false)), - m_iterations(5), m_tolerance(1e-4), - need_preprocess_factorization(true), - need_preprocess_region_of_solution(true), - last_preprocess_successful(false), - weight_calculator(weight_calculator), - vertex_point_map(vertex_point_map) + Weight_calculator weight_calculator = Weight_calculator()) + : m_triangle_mesh(triangle_mesh), + vertex_index_map(vertex_index_map), + hedge_index_map(hedge_index_map), + ros_id_map(std::vector(num_vertices(triangle_mesh), (std::numeric_limits::max)() )), + is_roi_map(std::vector(num_vertices(triangle_mesh), false)), + is_ctrl_map(std::vector(num_vertices(triangle_mesh), false)), + m_iterations(5), m_tolerance(1e-4), + need_preprocess_factorization(true), + need_preprocess_region_of_solution(true), + last_preprocess_successful(false), + weight_calculator(weight_calculator), + vertex_point_map(vertex_point_map) { init(); } @@ -433,21 +431,23 @@ public: /// \name Construction /// @{ /** - * The constructor of a deformation object + * The constructor of a deformation object. * * @pre `triangle_mesh` consists of only triangular facets * @param triangle_mesh triangulated surface mesh to deform - * @param vertex_index_map property map which associates a unique id to each vertex, between `0` to `num_vertices(triangle_mesh)-1`. - * @param hedge_index_map property map which associates a unique id to each halfedge, between `0` to `2*num_edges(triangle_mesh)-1`. + * @param vertex_index_map a property map which associates a unique id to each vertex, + * between `0` to `num_vertices(triangle_mesh)-1`. + * @param hedge_index_map property map which associates a unique id to each halfedge, + * between `0` to `2*num_edges(triangle_mesh)-1`. * @param vertex_point_map property map which associates a point to each vertex of the triangle mesh. * @param weight_calculator function object or pointer for weight calculation + * */ Surface_mesh_deformation(Triangle_mesh& triangle_mesh, - Vertex_index_map vertex_index_map=get(boost::vertex_index, triangle_mesh), - Hedge_index_map hedge_index_map=get(boost::halfedge_index, triangle_mesh), - Vertex_point_map vertex_point_map=get(boost::vertex_point, triangle_mesh), - Weight_calculator weight_calculator = Weight_calculator() - ); + Vertex_index_map vertex_index_map = unspecified_internal_vertex_index_map, + Hedge_index_map hedge_index_map = unspecified_internal_face_index_map, + Vertex_point_map vertex_point_map = get(boost::vertex_point, triangle_mesh), + Weight_calculator weight_calculator = Weight_calculator()); /// @} #endif diff --git a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/edge_collapse.h b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/edge_collapse.h index 91c1b70cb33..081c1d890c3 100644 --- a/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/edge_collapse.h +++ b/Surface_mesh_simplification/doc/Surface_mesh_simplification/CGAL/Surface_mesh_simplification/edge_collapse.h @@ -16,17 +16,16 @@ the number of edges effectively removed. @param np optional sequence of \ref sms_namedparameters "Named Parameters" among the ones listed below \cgalNamedParamsBegin - \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of the mesh. - If this parameter is omitted, an internal property map for - `CGAL::vertex_point_t` should be available in `TriangleMesh`. + \cgalParamBegin{vertex_point_map} + the property map with the points associated to the vertices of the mesh. \cgalParamEnd \cgalParamBegin{geom_traits} an instance of a geometric traits class, model of `Kernel`, compatible with the value type of the vertex point map. \cgalParamEnd - \cgalParamBegin{halfedge_index_map} the property map containing an index for each halfedge, - initialized 0 to `num_halfedges(graph)`. + \cgalParamBegin{halfedge_index_map} + the property map containing for each halfedge of `surface_mesh` a unique index between `0` to `num_halfedges(graph)`. \cgalParamEnd \cgalParamBegin{get_cost} diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h index 0602aa8a6ff..d83ef51cffb 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/edge_collapse.h @@ -92,12 +92,10 @@ int edge_collapse(TM& tmesh, return internal::edge_collapse(tmesh, should_stop, choose_parameter(get_parameter(np, internal_np::geom_traits), Geom_traits()), - choose_parameter(get_parameter(np, internal_np::vertex_index), - get_const_property_map(boost::vertex_index, tmesh)), + CGAL::get_initialized_vertex_index_map(tmesh, np), choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, tmesh)), - choose_parameter(get_parameter(np, internal_np::halfedge_index), - get_const_property_map(boost::halfedge_index, tmesh)), + CGAL::get_initialized_halfedge_index_map(tmesh, np), choose_parameter(get_parameter(np, internal_np::edge_is_constrained), No_constrained_edge_map()), choose_parameter(get_parameter(np, internal_np::get_cost_policy), From 38da5ae2c41e98d5755d84bafcd359624b4ea9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 6 Mar 2020 15:30:11 +0100 Subject: [PATCH 60/86] Rename 'faces' parameter to avoid conflict with function 'faces(FaceGraph)' --- .../CGAL/Polygon_mesh_processing/border.h | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index 79177a258b0..477ca994b4a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -53,7 +53,7 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc template - HalfedgeOutputIterator border_halfedges_impl(const FaceRange& faces + HalfedgeOutputIterator border_halfedges_impl(const FaceRange& face_range , HalfedgeOutputIterator out , const PM& pmesh) { @@ -64,7 +64,7 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc // the bool is true if the halfedge stored is the one of the face, // false if it is its opposite std::map border; - for(face_descriptor f : faces) + for(face_descriptor f : face_range) { for(halfedge_descriptor h : halfedges_around_face(halfedge(f, pmesh), pmesh)) @@ -94,13 +94,13 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc , typename FaceRange , typename HalfedgeOutputIterator , typename NamedParameters> - HalfedgeOutputIterator border_halfedges_impl(const FaceRange& faces + HalfedgeOutputIterator border_halfedges_impl(const FaceRange& face_range , typename boost::cgal_no_property::type , HalfedgeOutputIterator out , const PM& pmesh , const NamedParameters& /* np */) { - return border_halfedges_impl(faces, out, pmesh); + return border_halfedges_impl(face_range, out, pmesh); } template::halfedge_desc , typename FaceIndexMap , typename HalfedgeOutputIterator , typename NamedParameters> - HalfedgeOutputIterator border_halfedges_impl(const FaceRange& faces + HalfedgeOutputIterator border_halfedges_impl(const FaceRange& face_range , const FaceIndexMap& fmap , HalfedgeOutputIterator out , const PM& pmesh @@ -120,10 +120,10 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc CGAL_assertion(BGL::internal::is_index_map_valid(fmap, num_faces(pmesh), faces(pmesh))); std::vector present(num_faces(pmesh), false); - for(face_descriptor fd : faces) + for(face_descriptor fd : face_range) present[get(fmap, fd)] = true; - for(face_descriptor fd : faces) + for(face_descriptor fd : face_range) for(halfedge_descriptor hd : halfedges_around_face(halfedge(fd, pmesh), pmesh)) { @@ -161,9 +161,9 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc for patch border * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" * - * @param pmesh the polygon mesh to which `faces` belong - * @param faces the range of faces defining the patch whose border halfedges - * are collected + * @param pmesh the polygon mesh to which the faces in `face_range` belong + * @param face_range the range of faces defining the patch whose border halfedges + * are collected * @param out the output iterator that collects the border halfedges of the patch, * seen from outside. * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below @@ -178,17 +178,18 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc , typename FaceRange , typename HalfedgeOutputIterator , typename NamedParameters> - HalfedgeOutputIterator border_halfedges(const FaceRange& faces + HalfedgeOutputIterator border_halfedges(const FaceRange& face_range , const PolygonMesh& pmesh , HalfedgeOutputIterator out , const NamedParameters& np) { - if (faces.empty()) return out; + if (face_range.empty()) + return out; typedef typename CGAL::GetInitializedFaceIndexMap::const_type FIMap; FIMap fim = CGAL::get_initialized_face_index_map(pmesh, np); - return internal::border_halfedges_impl(faces, fim, out, pmesh, np); + return internal::border_halfedges_impl(face_range, fim, out, pmesh, np); } template::halfedge_desc template - HalfedgeOutputIterator border_halfedges(const FaceRange& faces + HalfedgeOutputIterator border_halfedges(const FaceRange& face_range , const PolygonMesh& pmesh , HalfedgeOutputIterator out) { - return border_halfedges(faces, pmesh, out, + return border_halfedges(face_range, pmesh, out, CGAL::Polygon_mesh_processing::parameters::all_default()); } @@ -220,7 +221,7 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc // // @tparam PolygonMesh model of `HalfedgeGraph`. // - // @param pmesh the polygon mesh to which `faces` belong + // @param pmesh the polygon mesh to which `face_range` belong // template unsigned int number_of_borders(const PolygonMesh& pmesh) From 5e0798c88f24694d5f5367051b7fa903fef9c96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 6 Mar 2020 18:16:04 +0100 Subject: [PATCH 61/86] Add a comment to clarify assertion --- .../boost/graph/internal/initialized_index_maps_helpers.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h index 0a1d3cf3a08..ad58419b087 100644 --- a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -168,6 +168,8 @@ IndexMap get_initialized_index_map_const(const IndexMap index_map, { CGAL_USE(g); CGAL_USE(p); + + // If you are passing a pmap via NPs, it must be initialized CGAL_assertion(is_index_map_valid(p, index_map, g)); return index_map; @@ -180,6 +182,8 @@ IndexMap get_initialized_index_map(const IndexMap index_map, { CGAL_USE(g); CGAL_USE(p); + + // If you are passing a pmap via NPs, it must be initialized CGAL_assertion(is_index_map_valid(p, index_map, g)); return index_map; From 9d5ce20393e210239d703b42b8cf8a0544d8cbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 6 Mar 2020 18:16:37 +0100 Subject: [PATCH 62/86] Clean doc --- .../include/CGAL/Polygon_mesh_processing/border.h | 9 ++------- .../include/CGAL/Polygon_mesh_processing/clip.h | 9 --------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h index 477ca994b4a..c52695b90cf 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/border.h @@ -149,13 +149,8 @@ std::size_t border_size(typename boost::graph_traits::halfedge_desc * For each returned halfedge `h`, `opposite(h, pmesh)` belongs to a face of the patch, * but `face(h, pmesh)` does not belong to the patch. * - * @tparam PolygonMesh model of `HalfedgeGraph`. If `PolygonMesh` - * has an internal non mutable property map - * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; else, it will be. - * @tparam FaceRange range of - `boost::graph_traits::%face_descriptor`, model of `Range`. - Its iterator type is `InputIterator`. + * @tparam PolygonMesh model of `HalfedgeGraph` + * @tparam FaceRange a model of `Range` with value type `boost::graph_traits::%face_descriptor`. * @tparam HalfedgeOutputIterator model of `OutputIterator` holding `boost::graph_traits::%halfedge_descriptor` for patch border diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h index 5b914813af2..d4c08dded70 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -274,10 +274,6 @@ clip_to_bbox(const Plane_3& plane, * \pre \link CGAL::Polygon_mesh_processing::does_bound_a_volume() `CGAL::Polygon_mesh_processing::does_bound_a_volume(clipper)` \endlink * * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. - * If `TriangleMesh` has an internal not modifiable property map - * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; otherwise, it will be. - * * @tparam NamedParameters1 a sequence of \ref pmp_namedparameters "Named Parameters" * @tparam NamedParameters2 a sequence of \ref pmp_namedparameters "Named Parameters" * @@ -366,9 +362,6 @@ bool dispatch_clip_call(TriangleMesh& tm, TriangleMesh& clipper, * \pre \link CGAL::Polygon_mesh_processing::does_self_intersect() `!CGAL::Polygon_mesh_processing::does_self_intersect(tm)` \endlink * * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. - * If `TriangleMesh` has an internal non modifiable property map - * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; otherwise, it will be. * An internal property map for `CGAL::vertex_point_t` must be available. * * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" @@ -446,8 +439,6 @@ bool clip( TriangleMesh& tm, * \pre \link CGAL::Polygon_mesh_processing::does_self_intersect() `!CGAL::Polygon_mesh_processing::does_self_intersect(tm)` \endlink * * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. - * If `TriangleMesh` has an internal property map for `CGAL::face_index_t`, - * as a named parameter, then it must be initialized. * An internal property map for `CGAL::vertex_point_t` must be available. * * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" From 84186fc78f051706cdde6abc1a118b84d818e99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 09:55:58 +0100 Subject: [PATCH 63/86] Allow face index maps of different type in Face_graph_output_builder + don't take references to property maps --- .../Polygon_mesh_processing/corefinement.h | 19 +++--- .../Corefinement/Face_graph_output_builder.h | 66 +++++++++---------- .../internal/Corefinement/face_graph_utils.h | 41 +++++++----- 3 files changed, 64 insertions(+), 62 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h index ed2461228a0..3685fda8745 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h @@ -39,7 +39,7 @@ namespace internal { template bool recursive_does_bound_a_volume(const TriangleMesh& tm, Vpm& vpm, - Fid_map& fid_map, + Fid_map fid_map, const std::vector& xtrm_vertices, boost::dynamic_bitset<>& cc_handled, const std::vector& face_cc, @@ -514,13 +514,11 @@ corefine_and_compute_boolean_operations( Edge_mark_map_tuple; // Face index point maps - typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap; + typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap1; typedef typename CGAL::GetInitializedFaceIndexMap::type FaceIndexMap2; - CGAL_static_assertion((std::is_same::value)); - - FaceIndexMap fid_map1 = get_initialized_face_index_map(tm1, np1); - FaceIndexMap fid_map2 = get_initialized_face_index_map(tm2, np2); + FaceIndexMap1 fid_map1 = get_initialized_face_index_map(tm1, np1); + FaceIndexMap2 fid_map2 = get_initialized_face_index_map(tm2, np2); // User visitor typedef typename internal_np::Lookup_named_param_def < @@ -535,7 +533,8 @@ corefine_and_compute_boolean_operations( typedef Corefinement::Face_graph_output_builder Algo_visitor; Ecm_in ecm_in(tm1,tm2,ecm1,ecm2); Edge_mark_map_tuple ecms_out(ecm_out_0, ecm_out_1, ecm_out_2, ecm_out_3); - Ob ob(tm1, tm2, vpm1, vpm2, fid_map1, fid_map2, ecm_in, - vpm_out_tuple, ecms_out, uv, output); + Ob ob(tm1, tm2, vpm1, vpm2, fid_map1, fid_map2, ecm_in, vpm_out_tuple, ecms_out, uv, output); // special case used for clipping open meshes if ( parameters::choose_parameter( parameters::get_parameter(np1, internal_np::use_bool_op_to_clip_surface), @@ -927,8 +925,7 @@ namespace experimental { const NamedParameters& np) { // Vertex point maps - typedef typename GetVertexPointMap::type Vpm; + typedef typename GetVertexPointMap::type Vpm; Vpm vpm = parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point), get_property_map(boost::vertex_point, tm)); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index f6dca078d05..dc9fb1978c6 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -60,7 +60,8 @@ namespace params=PMP::parameters; template + template static void fill_polylines_to_skip( Intersection_polylines& polylines, @@ -223,8 +226,8 @@ class Face_graph_output_builder const std::vector& tm2_patch_ids, const boost::dynamic_bitset<>& patches_of_tm1_used, const boost::dynamic_bitset<>& patches_of_tm2_used, - const FIM& fids1, - const FIM& fids2, + const FIM1 fids1, + const FIM2 fids2, const TM& tm1, const TM& tm2) { @@ -341,18 +344,17 @@ class Face_graph_output_builder public: - Face_graph_output_builder( TriangleMesh& tm1, - TriangleMesh& tm2, - const VertexPointMap &vpm1, - const VertexPointMap &vpm2, - const FaceIdMap& fids1, - const FaceIdMap& fids2, - EdgeMarkMapBind& marks_on_input_edges, + Face_graph_output_builder(TriangleMesh& tm1, + TriangleMesh& tm2, + const VertexPointMap vpm1, + const VertexPointMap vpm2, + FaceIdMap1 fids1, + FaceIdMap2 fids2, + EdgeMarkMapBind& marks_on_input_edges, const VpmOutTuple& output_vpms, - EdgeMarkMapTuple& out_edge_mark_maps, - UserVisitor& user_visitor, - const std::array< - boost::optional, 4 >& requested_output) + EdgeMarkMapTuple& out_edge_mark_maps, + UserVisitor& user_visitor, + const std::array, 4 >& requested_output) : tm1(tm1), tm2(tm2) , vpm1(vpm1), vpm2(vpm2) , fids1(fids1), fids2(fids2) @@ -616,9 +618,8 @@ public: std::size_t nb_patches_tm1 = PMP::connected_components(tm1, bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0])), - params::edge_is_constrained_map( - is_marked_1) - .face_index_map(fids1)); + params::edge_is_constrained_map(is_marked_1) + .face_index_map(fids1)); std::vector tm1_patch_sizes(nb_patches_tm1, 0); for(std::size_t i : tm1_patch_ids) @@ -630,9 +631,8 @@ public: std::size_t nb_patches_tm2 = PMP::connected_components(tm2, bind_property_maps(fids2,make_property_map(&tm2_patch_ids[0])), - params::edge_is_constrained_map( - is_marked_2) - .face_index_map(fids2)); + params::edge_is_constrained_map(is_marked_2) + .face_index_map(fids2)); std::vector tm2_patch_sizes(nb_patches_tm2, 0); for(Node_id i : tm2_patch_ids) @@ -1241,9 +1241,8 @@ public: polyline_lengths.push_back(polyline_info.second+1); } - typedef Patch_container Patches; + typedef Patch_container Patches1; + typedef Patch_container Patches2; boost::unordered_set border_nm_vertices; // only used if used_to_clip_a_surface == true if (used_to_clip_a_surface) @@ -1275,8 +1274,8 @@ public: } //store the patch description in a container to avoid recomputing it several times - Patches patches_of_tm1( tm1, tm1_patch_ids, fids1, intersection_edges1, nb_patches_tm1), - patches_of_tm2( tm2, tm2_patch_ids, fids2, intersection_edges2, nb_patches_tm2); + Patches1 patches_of_tm1(tm1, tm1_patch_ids, fids1, intersection_edges1, nb_patches_tm1); + Patches2 patches_of_tm2(tm2, tm2_patch_ids, fids2, intersection_edges2, nb_patches_tm2); // for each boolean operation, define two bitsets of patches contributing // to the result @@ -1456,11 +1455,12 @@ public: // operation in tm1 with removal (and optionally inside-out) delayed // First backup the border edges of patches to be used - Patches tmp_patches_of_tm1(tm1, - patches_of_tm1.patch_ids, - patches_of_tm1.fids, - patches_of_tm1.is_intersection_edge, - patches_of_tm1.patches.size()); + Patches1 tmp_patches_of_tm1(tm1, + patches_of_tm1.patch_ids, + patches_of_tm1.fids, + patches_of_tm1.is_intersection_edge, + patches_of_tm1.patches.size()); + boost::dynamic_bitset<> patches_of_tm1_removed = ~patches_of_tm1_used[inplace_operation_tm1]; for (std::size_t i = patches_of_tm1_removed.find_first(); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h index e75e4ccfce2..c188231238c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h @@ -424,7 +424,7 @@ template void extract_patch_simplices( std::size_t patch_id, PolygonMesh& pm, - const FaceIndexMap& fids, + const FaceIndexMap fids, const std::vector& patch_ids, std::vector::face_descriptor>& patch_faces, std::set::vertex_descriptor>& interior_vertices, @@ -480,13 +480,13 @@ struct Patch_container{ // external data members PolygonMesh& pm; const std::vector& patch_ids; - const FaceIndexMap& fids; + const FaceIndexMap fids; const IsIntersectionEdge& is_intersection_edge; // constructor Patch_container( PolygonMesh& pm, const std::vector& patch_ids, - const FaceIndexMap& fids, + const FaceIndexMap fids, const IsIntersectionEdge& is_intersection_edge, std::size_t nb_patches ) : patches(nb_patches) @@ -1010,14 +1010,15 @@ template < class TriangleMesh, class EdgeMarkMap2, class EdgeMarkMapOut, class IntersectionPolylines, - class PatchContainer, + class PatchContainer1, + class PatchContainer2, class UserVisitor> void fill_new_triangle_mesh( TriangleMesh& output, const boost::dynamic_bitset<>& patches_of_tm1_to_import, const boost::dynamic_bitset<>& patches_of_tm2_to_import, - PatchContainer& patches_of_tm1, - PatchContainer& patches_of_tm2, + PatchContainer1& patches_of_tm1, + PatchContainer2& patches_of_tm2, bool reverse_orientation_of_patches_from_tm1, bool reverse_orientation_of_patches_from_tm2, const IntersectionPolylines& polylines, @@ -1256,7 +1257,8 @@ void disconnect_patches( } template & patches_of_tm1_to_keep, const boost::dynamic_bitset<>& patches_of_tm2_to_import, - PatchContainer& patches_of_tm1, - PatchContainer& patches_of_tm2, + PatchContainer1& patches_of_tm1, + PatchContainer2& patches_of_tm2, bool reverse_patch_orientation_tm2, const IntersectionPolylines& polylines, const VertexPointMap& vpm1, @@ -1416,7 +1418,8 @@ remove_patches(TriangleMesh& tm, } template & patches_of_tm1_to_keep, const boost::dynamic_bitset<>& patches_of_tm2_to_import, - PatchContainer& patches_of_tm1, - PatchContainer& patches_of_tm2, + PatchContainer1& patches_of_tm1, + PatchContainer2& patches_of_tm2, bool reverse_patch_orientation_tm1, bool reverse_patch_orientation_tm2, const VertexPointMap& vpm1, @@ -1485,14 +1488,15 @@ void compute_inplace_operation( template void compute_border_edge_map( const TriangleMesh& tm1, const TriangleMesh& tm2, const IntersectionPolylines& polylines, - PatchContainer& patches_of_tm1, - PatchContainer& patches_of_tm2, + PatchContainer1& patches_of_tm1, + PatchContainer2& patches_of_tm2, EdgeMap& tm2_edge_to_tm1_edge) { typedef boost::graph_traits GT; @@ -1520,7 +1524,8 @@ void compute_border_edge_map( template & patches_of_tm1_to_keep, const boost::dynamic_bitset<>& patches_of_tm2_to_import, - PatchContainer& patches_of_tm1, - PatchContainer& patches_of_tm2, + PatchContainer1& patches_of_tm1, + PatchContainer2& patches_of_tm2, bool reverse_patch_orientation_tm1, bool reverse_patch_orientation_tm2, const VertexPointMap& vpm1, From d7f24b98e81bf65fb6cb5be7ad52309f1ff48a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 09:56:55 +0100 Subject: [PATCH 64/86] Correctly initialize face index maps in coref/autoref --- .../internal/Corefinement/Face_graph_output_builder.h | 7 +++++++ .../Corefinement/Output_builder_for_autorefinement.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index dc9fb1978c6..602ae2a2fde 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -462,6 +462,13 @@ public: Intersection_edge_map& intersection_edges1 = mesh_to_intersection_edges[&tm1]; Intersection_edge_map& intersection_edges2 = mesh_to_intersection_edges[&tm2]; + // The property map must be either writable or well-initialized + if(!BGL::internal::is_index_map_valid(fids1, num_faces(tm1), faces(tm1))) + BGL::internal::initialize_face_index_map(fids1, tm1); + + if(!BGL::internal::is_index_map_valid(fids2, num_faces(tm2), faces(tm2))) + BGL::internal::initialize_face_index_map(fids2, tm2); + // bitset to identify coplanar faces boost::dynamic_bitset<> tm1_coplanar_faces(num_faces(tm1), 0); boost::dynamic_bitset<> tm2_coplanar_faces(num_faces(tm2), 0); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h index 0e37037ceb5..031d23a1c36 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h @@ -236,6 +236,10 @@ public: intersection_edges.insert(edge(p.second.h2, tm)); } + // The property map must be either writable or well-initialized + if(!BGL::internal::is_index_map_valid(fids, num_faces(tm), faces(tm))) + BGL::internal::initialize_face_index_map(fids, tm); + // bitset to identify coplanar faces boost::dynamic_bitset<> tm_coplanar_faces(num_faces(tm), 0); From 54b5f74edd843da6a5e6bd4a8f7cf8d40ab643c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 09:57:13 +0100 Subject: [PATCH 65/86] Remove obsolete call dispatcher mechanism Which also was kinda broken: if a face index map was actually passed as named parameter, it would be ignored. --- .../CGAL/Polygon_mesh_processing/clip.h | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h index d4c08dded70..4ca94f6d2aa 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -331,26 +331,6 @@ clip( TriangleMesh& tm, np_c); } -namespace internal{ -template -bool dispatch_clip_call(TriangleMesh& tm, TriangleMesh& clipper, - const NamedParameters& np, Tag_false) -{ - return clip(tm, clipper, - np.face_index_map(get(CGAL::dynamic_face_property_t(), tm)), - parameters::face_index_map(get(CGAL::dynamic_face_property_t(), clipper))); -} - -template -bool dispatch_clip_call(TriangleMesh& tm, TriangleMesh& clipper, - const NamedParameters& np, Tag_true) -{ - return clip(tm, clipper, - np.face_index_map(get(face_index, tm)), - parameters::face_index_map(get(face_index, clipper))); -} -} - /** * \ingroup PMP_corefinement_grp * clips `tm` by keeping the part that is on the negative side of `plane` (side opposite to its normal vector). @@ -423,9 +403,8 @@ bool clip( TriangleMesh& tm, default: break; } - // dispatch is needed because face index map for tm and clipper have to be of the same time - return internal::dispatch_clip_call(tm, clipper, - np, CGAL::graph_has_property()); + + return clip(tm, clipper, np, parameters::all_default()); } /** @@ -485,9 +464,7 @@ bool clip( TriangleMesh& tm, clipper); triangulate_faces(clipper); - // dispatch is needed because face index map for tm and clipper have to be of the same time - return internal::dispatch_clip_call(tm, clipper, - np, CGAL::graph_has_property()); + return clip(tm, clipper, np, parameters::all_default()); } /// \cond SKIP_IN_MANUAL From 550138a1162fdf76cf023ef9a5c46c2445cdba77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 09:58:48 +0100 Subject: [PATCH 66/86] Update PMP::clip tests (the pmaps must be initialized) --- .../Polygon_mesh_processing/test_pmp_clip.cpp | 696 ++++++++++-------- 1 file changed, 390 insertions(+), 306 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp index b7fe169bd6c..6c8b77d5ce8 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp @@ -19,374 +19,458 @@ template void test() { // test with a clipper mesh - TriangleMesh tm1, tm2; + { + TriangleMesh tm1, tm2; + std::ifstream("data-coref/elephant.off") >> tm1; + std::ifstream("data-coref/sphere.off") >> tm2; - std::ifstream input("data-coref/elephant.off"); - input >> tm1; - input.close(); - input.open("data-coref/sphere.off"); - input >> tm2; - input.close(); + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); - PMP::clip(tm1, tm2, - params::clip_volume(false) - .face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2)) - ); - assert(!CGAL::is_closed(tm1)); - CGAL::clear(tm1); - CGAL::clear(tm2); + PMP::clip(tm1, tm2, + params::clip_volume(false).face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(!CGAL::is_closed(tm1)); + } - input.open("data-coref/elephant.off"); - input >> tm1; - input.close(); - input.open("data-coref/sphere.off"); - input >> tm2; - input.close(); + { + TriangleMesh tm1, tm2; + std::ifstream("data-coref/elephant.off") >> tm1; + std::ifstream("data-coref/sphere.off") >> tm2; - PMP::clip(tm1, tm2, params::clip_volume(true) - .face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(CGAL::is_closed(tm1)); - CGAL::clear(tm1); - CGAL::clear(tm2); + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); + PMP::clip(tm1, tm2, + params::clip_volume(true).face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(CGAL::is_closed(tm1)); + } // test with a iso-cuboid - input.open("data-coref/elephant.off"); - input >> tm1; - input.close(); - K::Iso_cuboid_3 iso_cuboid(K::Point_3(0,0,0), K::Point_3(0.4, 0.6, 0.4)); + { + TriangleMesh tm1; + std::ifstream("data-coref/elephant.off") >> tm1; + K::Iso_cuboid_3 iso_cuboid(K::Point_3(0,0,0), K::Point_3(0.4, 0.6, 0.4)); - PMP::clip(tm1, iso_cuboid, params::clip_volume(true)); - assert(CGAL::is_closed(tm1)); - CGAL::clear(tm1); + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + + PMP::clip(tm1, iso_cuboid, params::clip_volume(true).face_index_map(custom_face_index_map_1)); + assert(CGAL::is_closed(tm1)); + } // test with a plane - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); + { + TriangleMesh tm1; + std::ifstream("data-coref/cube.off") >> tm1; + K::Plane_3 plane(0, 0, 1, -1); - K::Plane_3 plane(0, 0, 1, -1); + PMP::clip(tm1, plane, params::clip_volume(true)); + assert(CGAL::is_closed(tm1)); + } - PMP::clip(tm1, plane, params::clip_volume(true)); - assert(CGAL::is_closed(tm1)); - CGAL::clear(tm1); + { + TriangleMesh tm1; + std::ifstream("data-coref/cube.off") >> tm1; + K::Plane_3 plane(0, 0, 1, -1); - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - PMP::clip(tm1, plane, params::clip_volume(false) - .use_compact_clipper(false)); - assert(!CGAL::is_closed(tm1)); - CGAL::clear(tm1); + PMP::clip(tm1, plane, params::clip_volume(false).use_compact_clipper(false)); + assert(!CGAL::is_closed(tm1)); + } - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - PMP::clip(tm1, plane, params::clip_volume(false) - .use_compact_clipper(true)); - assert(CGAL::is_closed(tm1)); - CGAL::clear(tm1); + { + TriangleMesh tm1; + std::ifstream("data-coref/cube.off") >> tm1; + K::Plane_3 plane(0, 0, 1, -1); - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - PMP::clip(tm1, K::Plane_3(-0.236474, 0.437732, 0.867451, -0.838791), params::clip_volume(true)); - assert(CGAL::is_closed(tm1)); - assert(!CGAL::is_empty(tm1)); - CGAL::clear(tm1); + PMP::clip(tm1, plane, params::clip_volume(false).use_compact_clipper(true)); + assert(CGAL::is_closed(tm1)); + } - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - PMP::clip(tm1, K::Plane_3(0, 0, 1, 2)); - assert(CGAL::is_empty(tm1)); - CGAL::clear(tm1); + { + TriangleMesh tm1; + std::ifstream("data-coref/cube.off") >> tm1; - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - PMP::clip(tm1, K::Plane_3(0, 0, 1, -2)); - assert(!CGAL::is_empty(tm1)); - CGAL::clear(tm1); + PMP::clip(tm1, K::Plane_3(-0.236474, 0.437732, 0.867451, -0.838791), params::clip_volume(true)); + assert(CGAL::is_closed(tm1)); + assert(!CGAL::is_empty(tm1)); + } + + { + TriangleMesh tm1; + std::ifstream("data-coref/cube.off") >> tm1; + + PMP::clip(tm1, K::Plane_3(0, 0, 1, 2)); + assert(CGAL::is_empty(tm1)); + } + + { + TriangleMesh tm1; + std::ifstream("data-coref/cube.off") >> tm1; + + PMP::clip(tm1, K::Plane_3(0, 0, 1, -2)); + assert(!CGAL::is_empty(tm1)); + } // clipping with identity - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - input.open("data-coref/cube.off"); - input >> tm2; - input.close(); - PMP::clip(tm1, tm2,params::clip_volume(true) - .use_compact_clipper(true) - .face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(num_vertices(tm1)==8); - CGAL::clear(tm1); - CGAL::clear(tm2); + { + TriangleMesh tm1, tm2; + std::ifstream("data-coref/cube.off") >> tm1; + std::ifstream("data-coref/cube.off") >> tm2; - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - input.open("data-coref/cube.off"); - input >> tm2; - input.close(); - PMP::clip(tm1, tm2,params::clip_volume(false) - .use_compact_clipper(false) - .face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(CGAL::is_empty(tm1)); - CGAL::clear(tm1); - CGAL::clear(tm2); + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - input.open("data-coref/cube.off"); - input >> tm2; - input.close(); - PMP::clip(tm1, tm2,params::clip_volume(false) - .use_compact_clipper(true) - .face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(num_vertices(tm1)==8); - CGAL::clear(tm1); - CGAL::clear(tm2); + PMP::clip(tm1, tm2, + params::clip_volume(true) + .use_compact_clipper(true) + .face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(num_vertices(tm1) == 8); + } - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - input.open("data-coref/cube.off"); - input >> tm2; - input.close(); - PMP::transform(K::Aff_transformation_3(CGAL::TRANSLATION, K::Vector_3(1,0,0)), tm2); - PMP::clip(tm1, tm2,params::clip_volume(false) - .use_compact_clipper(false) - .face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(CGAL::is_empty(tm1)); - CGAL::clear(tm1); - CGAL::clear(tm2); + { + TriangleMesh tm1, tm2; + std::ifstream("data-coref/cube.off") >> tm1; + std::ifstream("data-coref/cube.off") >> tm2; - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - input.open("data-coref/cube.off"); - input >> tm2; - input.close(); - PMP::transform(K::Aff_transformation_3(CGAL::TRANSLATION, K::Vector_3(1,0,0)), tm2); - PMP::clip(tm1, tm2,params::clip_volume(false) - .use_compact_clipper(true) - .face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(vertices(tm1).size()==4); - CGAL::clear(tm1); - CGAL::clear(tm2); + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); + + PMP::clip(tm1, tm2, + params::clip_volume(false) + .use_compact_clipper(false) + .face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(CGAL::is_empty(tm1)); + } + + { + TriangleMesh tm1, tm2; + std::ifstream("data-coref/cube.off") >> tm1; + std::ifstream("data-coref/cube.off") >> tm2; + + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); + + PMP::clip(tm1, tm2, + params::clip_volume(false) + .use_compact_clipper(true) + .face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(num_vertices(tm1) == 8); + } + + { + TriangleMesh tm1, tm2; + std::ifstream("data-coref/cube.off") >> tm1; + std::ifstream("data-coref/cube.off") >> tm2; + + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); + + PMP::transform(K::Aff_transformation_3(CGAL::TRANSLATION, K::Vector_3(1,0,0)), tm2); + PMP::clip(tm1, tm2, + params::clip_volume(false) + .use_compact_clipper(false) + .face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(CGAL::is_empty(tm1)); + } + + { + TriangleMesh tm1, tm2; + std::ifstream("data-coref/cube.off") >> tm1; + std::ifstream("data-coref/cube.off") >> tm2; + + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); + + PMP::transform(K::Aff_transformation_3(CGAL::TRANSLATION, K::Vector_3(1,0,0)), tm2); + PMP::clip(tm1, tm2, + params::clip_volume(false) + .use_compact_clipper(true) + .face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(vertices(tm1).size() == 4); + } // test orientation + patch without input vertex - CGAL::make_tetrahedron( - K::Point_3(0.53, -1.3, 0.2), - K::Point_3(0.53, 1.1, 0.2), - K::Point_3(0.53, -1.3, 0.4), - K::Point_3(0.73, -1.3, 0.2), - tm2); - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - PMP::clip(tm1, tm2,params::clip_volume(false) - .face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(vertices(tm1).size()==6); - CGAL::clear(tm1); - CGAL::clear(tm2); + { + TriangleMesh tm1, tm2; + std::ifstream("data-coref/cube.off") >> tm1; - CGAL::make_tetrahedron( - K::Point_3(0.53, -1.3, 0.2), - K::Point_3(0.53, 1.1, 0.2), - K::Point_3(0.53, -1.3, 0.4), - K::Point_3(0.73, -1.3, 0.2), - tm2); - PMP::reverse_face_orientations(tm2); - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); - PMP::clip(tm1, tm2,params::clip_volume(false) - .face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(vertices(tm1).size()==6+8); - CGAL::clear(tm1); - CGAL::clear(tm2); + CGAL::make_tetrahedron(K::Point_3(0.53, -1.3, 0.2), + K::Point_3(0.53, 1.1, 0.2), + K::Point_3(0.53, -1.3, 0.4), + K::Point_3(0.73, -1.3, 0.2), + tm2); + + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); + + PMP::clip(tm1, tm2, + params::clip_volume(false) + .face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(vertices(tm1).size() == 6); + } + + { + TriangleMesh tm1, tm2; + std::ifstream("data-coref/cube.off") >> tm1; + + CGAL::make_tetrahedron(K::Point_3(0.53, -1.3, 0.2), + K::Point_3(0.53, 1.1, 0.2), + K::Point_3(0.53, -1.3, 0.4), + K::Point_3(0.73, -1.3, 0.2), + tm2); + PMP::reverse_face_orientations(tm2); + + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); + + PMP::clip(tm1, tm2, + params::clip_volume(false) + .face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(vertices(tm1).size() == 6+8); + } // clip meshes with intersection polyline opened - make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 ); - PMP::clip(tm1, K::Plane_3(1, 0, 0, -2)); - assert(vertices(tm1).size()==4); - CGAL::clear(tm1); + { + TriangleMesh tm1; + make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 ); + PMP::clip(tm1, K::Plane_3(1, 0, 0, -2)); + assert(vertices(tm1).size() == 4); + } - make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 ); - PMP::clip(tm1, K::Plane_3(-1, 0, 0, 2)); - assert(vertices(tm1).size()==3); - CGAL::clear(tm1); + { + TriangleMesh tm1; + make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 ); + PMP::clip(tm1, K::Plane_3(-1, 0, 0, 2)); + assert(vertices(tm1).size() == 3); + } // test with clipper on border edge - make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 1, 0), K::Point_3(1, 0, 0), tm1 ); - PMP::clip(tm1, K::Plane_3(0, 1, 0 , 0)); - assert(vertices(tm1).size()==0); - CGAL::clear(tm1); + { + TriangleMesh tm1; + make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 1, 0), K::Point_3(1, 0, 0), tm1 ); + PMP::clip(tm1, K::Plane_3(0, 1, 0 , 0)); + assert(vertices(tm1).size() == 0); + } - make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 1, 0), K::Point_3(1, 0, 0), tm1 ); - PMP::clip(tm1, K::Plane_3(0, -1, 0 , 0)); - assert(vertices(tm1).size()==4); - CGAL::clear(tm1); + { + TriangleMesh tm1; + make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 1, 0), K::Point_3(1, 0, 0), tm1 ); + PMP::clip(tm1, K::Plane_3(0, -1, 0 , 0)); + assert(vertices(tm1).size() == 4); + } // test with clipper on border edge: full triangle - make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 ); - PMP::clip(tm1, K::Plane_3(0, 0, 1, 0), params::use_compact_clipper(true)); - assert(vertices(tm1).size()!=0); - CGAL::clear(tm1); + { + TriangleMesh tm1; + make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 ); + PMP::clip(tm1, K::Plane_3(0, 0, 1, 0), params::use_compact_clipper(true)); + assert(vertices(tm1).size()!=0); + } - make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 ); - PMP::clip(tm1, K::Plane_3(0, 0, 1, 0), params::use_compact_clipper(false)); - assert(vertices(tm1).size()==0); - CGAL::clear(tm1); + { + TriangleMesh tm1; + make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 ); + PMP::clip(tm1, K::Plane_3(0, 0, 1, 0), params::use_compact_clipper(false)); + assert(vertices(tm1).size() == 0); + } // test tangencies - make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 2, 0), K::Point_3(1, 1, 0), tm1 ); - PMP::clip(tm1, K::Plane_3(1, 0, 0, -1)); - assert(vertices(tm1).size()==3); - CGAL::clear(tm1); + { + TriangleMesh tm1; + make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 2, 0), K::Point_3(1, 1, 0), tm1 ); + PMP::clip(tm1, K::Plane_3(1, 0, 0, -1)); + assert(vertices(tm1).size() == 3); + } - make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 2, 0), K::Point_3(1, 1, 0), tm1 ); - PMP::clip(tm1, K::Plane_3(-1, 0, 0, 1)); - assert(vertices(tm1).size()==0); - CGAL::clear(tm1); + { + TriangleMesh tm1; + make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 2, 0), K::Point_3(1, 1, 0), tm1 ); + PMP::clip(tm1, K::Plane_3(-1, 0, 0, 1)); + assert(vertices(tm1).size() == 0); + } - make_triangle( K::Point_3(0.5, 0, 0.5), K::Point_3(1, 0.5, 0.5), K::Point_3(0.5, 1, 0.5), tm1 ); - input.open("data-coref/cube.off"); - input >> tm2; - input.close(); - PMP::clip(tm1, tm2, params::face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(vertices(tm1).size()==3); - CGAL::clear(tm1); - CGAL::clear(tm2); + { + TriangleMesh tm1, tm2; + make_triangle( K::Point_3(0.5, 0, 0.5), K::Point_3(1, 0.5, 0.5), K::Point_3(0.5, 1, 0.5), tm1 ); + std::ifstream("data-coref/cube.off") >> tm2; - make_triangle( K::Point_3(0.5, 0, 0.5), K::Point_3(1, 0.5, 0.5), K::Point_3(0.5, 1, 0.5), tm1 ); - input.open("data-coref/cube.off"); - input >> tm2; - input.close(); - PMP::reverse_face_orientations(tm2); - PMP::clip(tm1, tm2, params::face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(vertices(tm1).size()==0); - CGAL::clear(tm1); - CGAL::clear(tm2); + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); -// test combinaison of use_compact_clipper and clip_volume - input.open("data-coref/cube.off"); - input >> tm1; - input.close(); + PMP::clip(tm1, tm2, + params::face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(vertices(tm1).size() == 3); + } - // -> closed mesh, true/true - PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(true).clip_volume(true)); - assert(CGAL::is_closed(tm1)); - assert(faces(tm1).size()==12); + { + TriangleMesh tm1, tm2; + make_triangle( K::Point_3(0.5, 0, 0.5), K::Point_3(1, 0.5, 0.5), K::Point_3(0.5, 1, 0.5), tm1 ); + std::ifstream("data-coref/cube.off") >> tm2; - // -> closed mesh, false/true - PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(false).clip_volume(true)); - assert(faces(tm1).size()==12); - assert(CGAL::is_closed(tm1)); + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); - // -> closed mesh, true/false - PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(true).clip_volume(false)); - assert(faces(tm1).size()==12); - assert(CGAL::is_closed(tm1)); + PMP::reverse_face_orientations(tm2); + PMP::clip(tm1, tm2, + params::face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(vertices(tm1).size() == 0); + } - // -> closed mesh, false/false - PMP::clip(tm1, K::Plane_3(1,0,0,-1), params::use_compact_clipper(false).clip_volume(false)); - assert(faces(tm1).size()==10); - assert(!CGAL::is_closed(tm1)); + // test combinaison of use_compact_clipper and clip_volume + { + TriangleMesh tm1; + std::ifstream("data-coref/cube.off") >> tm1; - // -> open mesh true/true - PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(true).clip_volume(true)); - assert(faces(tm1).size()==10); + // -> closed mesh, true/true + PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(true).clip_volume(true)); + assert(faces(tm1).size() == 12); + assert(CGAL::is_closed(tm1)); - // -> open mesh true/false - PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(true).clip_volume(false)); - assert(faces(tm1).size()==10); + // -> closed mesh, false/true + PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(false).clip_volume(true)); + assert(faces(tm1).size() == 12); + assert(CGAL::is_closed(tm1)); - // -> open mesh false/false - PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(false).clip_volume(false)); - assert(faces(tm1).size()==8); + // -> closed mesh, true/false + PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(true).clip_volume(false)); + assert(faces(tm1).size() == 12); + assert(CGAL::is_closed(tm1)); - // -> open mesh false/true - PMP::clip(tm1, K::Plane_3(0,-1,0,0), params::use_compact_clipper(false).clip_volume(true)); - assert(faces(tm1).size()==6); - CGAL::clear(tm1); -// done! + // -> closed mesh, false/false + PMP::clip(tm1, K::Plane_3(1,0,0,-1), params::use_compact_clipper(false).clip_volume(false)); + assert(faces(tm1).size() == 10); + assert(!CGAL::is_closed(tm1)); + + // -> open mesh true/true + PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(true).clip_volume(true)); + assert(faces(tm1).size() == 10); + + // -> open mesh true/false + PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(true).clip_volume(false)); + assert(faces(tm1).size() == 10); + + // -> open mesh false/false + PMP::clip(tm1, K::Plane_3(-1,0,0,0), params::use_compact_clipper(false).clip_volume(false)); + assert(faces(tm1).size() == 8); + + // -> open mesh false/true + PMP::clip(tm1, K::Plane_3(0,-1,0,0), params::use_compact_clipper(false).clip_volume(true)); + assert(faces(tm1).size() == 6); + } // test special case - input.open("data-clip/tm_1.off"); - input >> tm1; - input.close(); - input.open("data-clip/clipper_1.off"); - input >> tm2; - input.close(); - PMP::clip(tm1, tm2, params::face_index_map(get(CGAL::dynamic_face_property_t(), tm1)), - params::face_index_map(get(CGAL::dynamic_face_property_t(), tm2))); - assert(is_valid_polygon_mesh(tm1)); - CGAL::clear(tm1); - CGAL::clear(tm2); + { + TriangleMesh tm1, tm2; + std::ifstream("data-clip/tm_1.off") >> tm2; + std::ifstream("data-clip/clipper_1.off") >> tm2; + + auto custom_face_index_map_1 = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_1, tm1); + auto custom_face_index_map_2 = get(CGAL::dynamic_face_property_t(), tm2); + CGAL::BGL::internal::initialize_face_index_map(custom_face_index_map_2, tm2); + + PMP::clip(tm1, tm2, + params::face_index_map(custom_face_index_map_1), + params::face_index_map(custom_face_index_map_2)); + assert(is_valid_polygon_mesh(tm1)); + } // non-manifold border vertices - std::stringstream ss; - ss << "OFF\n 5 2 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 0 1 4\n3 1 2 3\n"; - ss >> tm1; - PMP::clip(tm1, K::Plane_3(-1,0,0,2)); - assert(vertices(tm1).size()==3); - CGAL::clear(tm1); + { + TriangleMesh tm1; + std::stringstream ss; + ss << "OFF\n 5 2 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 0 1 4\n3 1 2 3\n"; + ss >> tm1; + PMP::clip(tm1, K::Plane_3(-1,0,0,2)); + assert(vertices(tm1).size() == 3); + } - ss.str(std::string()); - ss << "OFF\n 7 4 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 3 5\n"; - ss >> tm1; - CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); - PMP::clip(tm1, K::Plane_3(-1,0,0,2)); - assert(vertices(tm1).size()==6); - CGAL::clear(tm1); - - ss.str(std::string()); - ss << "OFF\n 9 7 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 -1 0\n1 -1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 8 7\n3 1 3 5\n3 1 6 4\n3 1 0 8\n"; - ss >> tm1; - for (int i=0;i<3;++i) + { + TriangleMesh tm1; + std::stringstream ss; + ss << "OFF\n 7 4 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 3 5\n"; + ss >> tm1; CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); - PMP::clip(tm1, K::Plane_3(-1,0,0,2)); - assert(vertices(tm1).size()==7); - CGAL::clear(tm1); + PMP::clip(tm1, K::Plane_3(-1,0,0,2)); + assert(vertices(tm1).size() == 6); + } - ss.str(std::string()); - ss << "OFF\n 9 7 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 -1 0\n1 -1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 8 7\n3 1 3 5\n3 1 6 4\n3 1 0 8\n"; - ss >> tm1; - for (int i=0;i<3;++i) - CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); - PMP::clip(tm1, K::Plane_3(0,1,0,0)); - assert(vertices(tm1).size()==3); - CGAL::clear(tm1); + { + TriangleMesh tm1; + std::stringstream ss; + ss << "OFF\n 9 7 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 -1 0\n1 -1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 8 7\n3 1 3 5\n3 1 6 4\n3 1 0 8\n"; + ss >> tm1; + for (int i=0;i<3;++i) + CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); + PMP::clip(tm1, K::Plane_3(-1,0,0,2)); + assert(vertices(tm1).size() == 7); + } - ss.str(std::string()); - ss << "OFF\n 9 7 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 -1 0\n1 -1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 8 7\n3 1 3 5\n3 1 6 4\n3 1 0 8\n"; - ss >> tm1; - for (int i=0;i<3;++i) - CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); - PMP::clip(tm1, K::Plane_3(0,-1,0,0)); - assert(vertices(tm1).size()==7); - CGAL::clear(tm1); + { + TriangleMesh tm1; + std::stringstream ss; + ss << "OFF\n 9 7 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 -1 0\n1 -1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 8 7\n3 1 3 5\n3 1 6 4\n3 1 0 8\n"; + ss >> tm1; + for (int i=0;i<3;++i) + CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); + PMP::clip(tm1, K::Plane_3(0,1,0,0)); + assert(vertices(tm1).size() == 3); + } + + { + TriangleMesh tm1; + std::stringstream ss; + ss << "OFF\n 9 7 0\n 0 0 0\n2 0 0\n4 0 0\n4 1 0\n0 1 0\n3 1 0\n 1 1 0\n3 -1 0\n1 -1 0\n3 0 1 4\n3 1 2 3\n3 1 5 6\n3 1 8 7\n3 1 3 5\n3 1 6 4\n3 1 0 8\n"; + ss >> tm1; + for (int i=0;i<3;++i) + CGAL::Euler::remove_face(halfedge(*std::prev(faces(tm1).end()),tm1),tm1); + PMP::clip(tm1, K::Plane_3(0,-1,0,0)); + assert(vertices(tm1).size() == 7); + } } int main() { + std::cout << "Surface Mesh" << std::endl; test(); + + std::cout << "Polyhedron" << std::endl; test(); - return 0; + std::cout << "Done!" << std::endl; + + return EXIT_SUCCESS; } From 645d81d298f03fab0712a844716ca4431246048e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 09:59:41 +0100 Subject: [PATCH 67/86] Clean documentation These mentions can be regrouped in the namedparameters.txt file --- .../CGAL/Polygon_mesh_processing/connected_components.h | 9 --------- .../CGAL/Polygon_mesh_processing/detect_features.h | 3 --- .../include/CGAL/Polygon_mesh_processing/orientation.h | 6 ------ .../include/CGAL/Polygon_mesh_processing/remesh.h | 5 +---- 4 files changed, 1 insertion(+), 22 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 07923fd8aeb..d0482afc54f 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -171,10 +171,6 @@ connected_component(typename boost::graph_traits::face_descriptor s * \ingroup keep_connected_components_grp * computes for each face the index of the corresponding connected component. * - * If `PolygonMesh` has an internal non modifiable property map - * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; otherwise, it will be. - * * \tparam PolygonMesh a model of `FaceListGraph` * \tparam FaceComponentMap a model of `WritablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and @@ -746,11 +742,6 @@ void keep_connected_components(PolygonMesh& pmesh * \note If the removal of the connected components makes `pmesh` a non-manifold surface, * then the behavior of this function is undefined. * -* If `PolygonMesh` has a non modifiable internal property map -* for `CGAL::face_index_t` (resp. `CGAL::vertex_index_t`) and no `face_index_map` (resp. `vertex_index_map`) is given -* as a named parameter, then the internal one must be initialized. Otherwise, it will be. -* -* * \tparam PolygonMesh a model of `FaceListGraph` and `MutableFaceGraph` * \tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" * \tparam ComponentRange a range of ids convertible to `std::size` diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h index 34346781eca..55b007d16b3 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/detect_features.h @@ -369,9 +369,6 @@ namespace internal * computing a * surface patch id for each face. * - * If `PolygonMesh` has a non modifiable internal property map - * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; otherwise, it will be. * * \tparam PolygonMesh a model of `FaceGraph` * \tparam FT a number type. It is diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index 7991ad88b88..b70eefd073e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -438,9 +438,6 @@ void recursive_orient_volume_ccs( TriangleMesh& tm, * inward or outward oriented. * * @tparam TriangleMesh a model of `FaceListGraph` and `MutableFaceGraph` . -* If `TriangleMesh` has a non modifiable internal property map -* for `CGAL::face_index_t` and no `face_index_map` is given -* as a named parameter, then the internal one must be initialized; otherwise, it will be. * @tparam NamedParameters a sequence of \ref pmp_namedparameters * * @param tm a closed triangulated surface mesh @@ -541,9 +538,6 @@ void orient(TriangleMesh& tm) * See \ref coref_def_subsec for a precise definition. * * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. - * If `TriangleMesh` has a non modifiable internal property map - * for `CGAL::face_index_t` and no `face_index_map` is given - * as a named parameter, then the internal one must be initialized; otherwise, it will be. * @tparam NamedParameters a sequence of \ref pmp_namedparameters * * @param tm a closed triangulated surface mesh diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h index 4ab09ae8efc..5290d6b03fc 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h @@ -41,10 +41,7 @@ namespace Polygon_mesh_processing { * The descriptor types `boost::graph_traits::%face_descriptor` * and `boost::graph_traits::%halfedge_descriptor` must be * models of `Hashable`. -* If `PolygonMesh` has a non modifiable internal property map -* for `CGAL::face_index_t` and no `face_index_map` is given -* as a named parameter, then the internal one must be initialized; otherwise, it will be. - * +* * @tparam FaceRange range of `boost::graph_traits::%face_descriptor`, model of `Range`. Its iterator type is `ForwardIterator`. * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" From e8757d451a65ab516469688f396af336f8e57738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 10:02:44 +0100 Subject: [PATCH 68/86] Clarify doc of PMP::clip The face_index_map must be writable or stay well-initialized throughout creation and deletion of faces. --- .../include/CGAL/Polygon_mesh_processing/clip.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h index 4ca94f6d2aa..119057707ea 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -289,8 +289,8 @@ clip_to_bbox(const Plane_3& plane, * `CGAL::vertex_point_t` must be available in `TriangleMesh` * \cgalParamEnd * \cgalParamBegin{face_index_map} a property map containing the index of each face of `tm` (`clipper`). - * Note that if the property map is writable, the indices of the faces - * of `tm` and `clipper` will be set after refining `tm` with the intersection with `clipper`. + * This property map must be either writable, or be automatically updated + * when new faces are added and removed in the mesh. * \cgalParamEnd * \cgalParamBegin{visitor} a class model of `PMPCorefinementVisitor` * that is used to track the creation of new faces. From fba9a19fe4840015d8074bf4467b027aa52d46bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 10:03:31 +0100 Subject: [PATCH 69/86] Add missing #include's --- .../include/CGAL/Surface_mesh_deformation.h | 3 ++- .../Orbifold_Tutte_parameterizer_3.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h b/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h index d425ce57fc8..046a0e57d18 100644 --- a/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h +++ b/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h @@ -16,10 +16,11 @@ #include +#include +#include #include #include #include - #include #include diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbifold_Tutte_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbifold_Tutte_parameterizer_3.h index 3d570311b53..068a882f0e1 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbifold_Tutte_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbifold_Tutte_parameterizer_3.h @@ -25,6 +25,7 @@ #include #include +#include #include #include From fd864b7d99d2d0c6ade41c5d460c2a3a957f6f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 10:17:53 +0100 Subject: [PATCH 70/86] Add a performance warning when a dynamic property map is used as index map --- .../boost/graph/internal/initialized_index_maps_helpers.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h index ad58419b087..64a37a17e90 100644 --- a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -237,6 +237,11 @@ get_initialized_dynamic_index_map(DynamicIndexMap index_map, const PropertyTag p, const Graph& g) { +#ifdef CGAL_PERFORMANCE_WARNINGS + std::cerr << "Warning: the automatically selected index map is a dynamic property map," + << " which might not have constant-time access complexity." << std::endl; +#endif + Index_map_initializer{}(p, index_map, g); return index_map; } From ec30ebb709c0028609d1790a18716997be1f80bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 10:18:19 +0100 Subject: [PATCH 71/86] Move getter structs and global functions to appropriate BGL file --- .../internal/initialized_index_maps_helpers.h | 98 ----------------- .../CGAL/boost/graph/named_params_helper.h | 100 ++++++++++++++++++ 2 files changed, 100 insertions(+), 98 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h index 64a37a17e90..e392ff064a0 100644 --- a/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/initialized_index_maps_helpers.h @@ -302,104 +302,6 @@ public: } // namespace internal } // namespace BGL - -// @todo move below to named_params_helper.h - -#define CGAL_DEF_GET_INDEX_TYPE(CTYPE, TYPE) \ -template > \ -struct GetInitialized##CTYPE##IndexMap \ - : public BGL::internal::GetInitializedIndexMap, \ - Graph, NamedParameters> \ -{ }; - -CGAL_DEF_GET_INDEX_TYPE(Vertex, vertex) -CGAL_DEF_GET_INDEX_TYPE(Halfedge, halfedge) -CGAL_DEF_GET_INDEX_TYPE(Edge, edge) -CGAL_DEF_GET_INDEX_TYPE(Face, face) - -#undef CGAL_DEF_GET_INDEX_TYPE - -// @todo move below to properties.h - -// Define the following functions: -// -// get_initialized_vertex_index_map(); -// get_initialized_halfedge_index_map(); -// get_initialized_edge_index_map(); -// get_initialized_face_index_map() -// -// The function returns: -// - the index property map passed in the NPs, if passed in the NPs; it must be initialized by the user; -// - the internal index property map if it is the graph has one. It is initialized if needed and possible; -// - an initialized dynamic pmap otherwise. - -#define CGAL_DEF_GET_INITIALIZED_INDEX_MAP(TYPE) \ -template \ -typename BGL::internal::GetInitializedIndexMap, \ - Graph, NamedParameters>::const_type \ -get_initialized_##TYPE##_index_map(const Graph& g, \ - const NamedParameters& np) \ -{ \ - typedef BGL::internal::GetInitializedIndexMap, \ - Graph, NamedParameters> Index_map_getter; \ - return Index_map_getter::get_const(CGAL::internal_np::TYPE##_index_t{}, g, np); \ -} \ -template \ -typename BGL::internal::GetInitializedIndexMap, \ - Graph>::const_type \ -get_initialized_##TYPE##_index_map(const Graph& g) \ -{ \ - return get_initialized_##TYPE##_index_map(g, CGAL::parameters::all_default()); \ -} \ -/* same as above, non-const version*/ \ -template ::type>::value, int> = 0> \ -typename BGL::internal::GetInitializedIndexMap, \ - Graph, NamedParameters>::type \ -get_initialized_##TYPE##_index_map(Graph& g, \ - const NamedParameters& np) \ -{ \ - typedef BGL::internal::GetInitializedIndexMap, \ - Graph, NamedParameters> Index_map_getter; \ - return Index_map_getter::get(CGAL::internal_np::TYPE##_index_t{}, g, np); \ -} \ -template ::type>::value, int> = 0> \ -typename BGL::internal::GetInitializedIndexMap, \ - Graph>::type \ -get_initialized_##TYPE##_index_map(Graph& g) \ -{ \ - return get_initialized_##TYPE##_index_map(g, CGAL::parameters::all_default()); \ -} - -CGAL_DEF_GET_INITIALIZED_INDEX_MAP(vertex) -CGAL_DEF_GET_INITIALIZED_INDEX_MAP(halfedge) -CGAL_DEF_GET_INITIALIZED_INDEX_MAP(edge) -CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face) - -#undef CGAL_DEF_GET_INITIALIZED_INDEX_MAP - } // namespace CGAL #endif // CGAL_BOOST_GRAPH_INITIALIZED_INTERNAL_INDEX_MAPS_HELPERS diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index ab10db10ef2..04fbf27ed51 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -209,6 +209,106 @@ namespace CGAL { > ::type type; }; +// Define the following structs: +// +// GetInitializedVertexIndexMap +// GetInitializedHalfedgeIndexMap +// GetInitializedEdgeIndexMap +// GetInitializedFaceIndexMap + +#define CGAL_DEF_GET_INDEX_TYPE(CTYPE, TYPE) \ +template > \ +struct GetInitialized##CTYPE##IndexMap \ + : public BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters> \ +{ }; + +CGAL_DEF_GET_INDEX_TYPE(Vertex, vertex) +CGAL_DEF_GET_INDEX_TYPE(Halfedge, halfedge) +CGAL_DEF_GET_INDEX_TYPE(Edge, edge) +CGAL_DEF_GET_INDEX_TYPE(Face, face) + +#undef CGAL_DEF_GET_INDEX_TYPE + +// Define the following functions: +// +// get_initialized_vertex_index_map() +// get_initialized_halfedge_index_map() +// get_initialized_edge_index_map() +// get_initialized_face_index_map() +// +// The function returns: +// - the index property map passed in the NPs, if passed in the NPs; it must be initialized by the user; +// - the internal index property map if it is the graph has one. It is initialized if needed and possible; +// - an initialized dynamic pmap otherwise. + +#define CGAL_DEF_GET_INITIALIZED_INDEX_MAP(TYPE) \ +template \ +typename BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters>::const_type \ +get_initialized_##TYPE##_index_map(const Graph& g, \ + const NamedParameters& np) \ +{ \ + typedef BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters> Index_map_getter; \ + return Index_map_getter::get_const(CGAL::internal_np::TYPE##_index_t{}, g, np); \ +} \ +template \ +typename BGL::internal::GetInitializedIndexMap, \ + Graph>::const_type \ +get_initialized_##TYPE##_index_map(const Graph& g) \ +{ \ + return get_initialized_##TYPE##_index_map(g, CGAL::parameters::all_default()); \ +} \ +/* same as above, non-const version*/ \ +template ::type>::value, int> = 0> \ +typename BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters>::type \ +get_initialized_##TYPE##_index_map(Graph& g, \ + const NamedParameters& np) \ +{ \ + typedef BGL::internal::GetInitializedIndexMap, \ + Graph, NamedParameters> Index_map_getter; \ + return Index_map_getter::get(CGAL::internal_np::TYPE##_index_t{}, g, np); \ +} \ +template ::type>::value, int> = 0> \ +typename BGL::internal::GetInitializedIndexMap, \ + Graph>::type \ +get_initialized_##TYPE##_index_map(Graph& g) \ +{ \ + return get_initialized_##TYPE##_index_map(g, CGAL::parameters::all_default()); \ +} + +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(vertex) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(halfedge) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(edge) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face) + +#undef CGAL_DEF_GET_INITIALIZED_INDEX_MAP + template class GetFaceNormalMap { From bc84ca29a22d448d8ba6429d9a8e406373a40996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 10:18:43 +0100 Subject: [PATCH 72/86] Remove obsolete comment --- BGL/include/CGAL/boost/graph/properties.h | 1 - 1 file changed, 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/properties.h b/BGL/include/CGAL/boost/graph/properties.h index 1f28aac582d..589662ce0dc 100644 --- a/BGL/include/CGAL/boost/graph/properties.h +++ b/BGL/include/CGAL/boost/graph/properties.h @@ -149,7 +149,6 @@ struct Point_accessor reference operator[](Handle h) const { return h->point(); } }; -// @todo test this // this one is basically 'readable_property_map_tag' template ::category> From 05f0f956a858bea52ea0f1a349da27d2358c902d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 10:23:16 +0100 Subject: [PATCH 73/86] Fix bad copy paste --- .../include/CGAL/Surface_mesh_deformation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h b/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h index 046a0e57d18..06a8151e9b7 100644 --- a/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h +++ b/Surface_mesh_deformation/include/CGAL/Surface_mesh_deformation.h @@ -392,7 +392,7 @@ public: Surface_mesh_deformation(Triangle_mesh& triangle_mesh) : m_triangle_mesh(triangle_mesh), vertex_index_map(CGAL::get_initialized_vertex_index_map(triangle_mesh)), - hedge_index_map(CGAL::get_halfedge_vertex_index_map(triangle_mesh)), + hedge_index_map(CGAL::get_initialized_halfedge_index_map(triangle_mesh)), ros_id_map(std::vector(num_vertices(triangle_mesh), (std::numeric_limits::max)() )), is_roi_map(std::vector(num_vertices(triangle_mesh), false)), is_ctrl_map(std::vector(num_vertices(triangle_mesh), false)), @@ -446,7 +446,7 @@ public: */ Surface_mesh_deformation(Triangle_mesh& triangle_mesh, Vertex_index_map vertex_index_map = unspecified_internal_vertex_index_map, - Hedge_index_map hedge_index_map = unspecified_internal_face_index_map, + Hedge_index_map hedge_index_map = unspecified_internal_halfedge_index_map, Vertex_point_map vertex_point_map = get(boost::vertex_point, triangle_mesh), Weight_calculator weight_calculator = Weight_calculator()); /// @} From e4ff489623778708fa0bd8035b72647f2826727e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 10:40:21 +0100 Subject: [PATCH 74/86] Get rid of GetVertex/FaceIndexMap GetInitialized... should be used instead. Complete removal instead of simply doing: struct GetVertexIndexMap : public GetInitializedVertexIndexMap { } because there will anyway be a need to update code on the right side of GetVertexIndexMap fim = ... and it's more obvious if it breaks on the type directly. --- .../CGAL/boost/graph/named_params_helper.h | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index 04fbf27ed51..bcedc1cd124 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -177,38 +177,6 @@ namespace CGAL { > ::type type; }; - template - class GetFaceIndexMap - { - typedef typename property_map_selector::type DefaultMap; - typedef typename property_map_selector::const_type DefaultMap_const; - public: - typedef typename internal_np::Lookup_named_param_def < - internal_np::face_index_t, - NamedParameters, - DefaultMap - > ::type type; - typedef typename internal_np::Lookup_named_param_def < - internal_np::face_index_t, - NamedParameters, - DefaultMap_const - > ::type const_type; - typedef typename boost::is_same::type Is_internal_map; - typedef typename boost::is_same::type Is_internal_map_const; - }; - - template - class GetVertexIndexMap - { - typedef typename property_map_selector::type DefaultMap; - public: - typedef typename internal_np::Lookup_named_param_def < - internal_np::vertex_index_t, - NamedParameters, - DefaultMap - > ::type type; - }; - // Define the following structs: // // GetInitializedVertexIndexMap From 544dbb441a2ce0ef9690bdd1405e7e0b8c6c8e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 10:53:48 +0100 Subject: [PATCH 75/86] Add more information about index maps in BGL/PMP's NamedParameters.txt --- BGL/doc/BGL/NamedParameters.txt | 35 +++++++++++++------ BGL/include/CGAL/boost/graph/io.h | 3 +- .../NamedParameters.txt | 11 +++--- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/BGL/doc/BGL/NamedParameters.txt b/BGL/doc/BGL/NamedParameters.txt index ce3be60f8f4..bb8d5d91529 100644 --- a/BGL/doc/BGL/NamedParameters.txt +++ b/BGL/doc/BGL/NamedParameters.txt @@ -38,38 +38,51 @@ a \cgal point type as value type. \n \cgalNPEnd \cgalNPBegin{vertex_index_map} \anchor BGL_vertex_index_map -is the property map containing the index of each vertex of the input polygon mesh.\n +is the property map associating a unique index to each vertex of a polygon mesh `g`, +between `0` and `num_vertices(g)-1`. +If this parameter is not passed, internal machinery will create and initialize a vertex index +property map, either using the internal property map if it exists or using an external map. The latter +might result in - slightly - worsened performance due to non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` as key type and the value type \code typename boost::property_traits::type>::value_type \endcode -Default: \code boost::get(CGAL::vertex_index, pmesh)\endcode +Default: an initialized vertex index property map \cgalNPEnd \cgalNPBegin{halfedge_index_map} \anchor BGL_halfedge_index_map -is the property map containing the index of each halfedge of the input polygon mesh.\n +is the property map associating a unique index to each halfedge of a polygon mesh, +between `0` and `num_halfedges(g)-1`. +If this parameter is not passed, internal machinery will create and initialize a halfedge index +property map, either using the internal property map if it exists or using an external map. The latter +might result in - slightly - worsened performance due to non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%halfedge_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode -Default: \code boost::get(CGAL::halfedge_index, pmesh)\endcode -If this internal property map exists, its values should be initialized. +Default: an initialized halfedge index property map \cgalNPEnd \cgalNPBegin{edge_index_map} \anchor BGL_edge_index_map -is the property map containing the index of each edge of the input polygon mesh.\n +is the property map associating a unique index to each edge of a polygon mesh, +between `0` and `num_edges(g)-1`. +If this parameter is not passed, internal machinery will create and initialize a edge index +property map, either using the internal property map if it exists or using an external map. The latter +might result in - slightly - worsened performance due to non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%edge_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode -Default: \code boost::get(CGAL::edge_index, pmesh)\endcode -If this internal property map exists, its values should be initialized. +Default: an initialized edge index property map \cgalNPEnd \cgalNPBegin{face_index_map} \anchor BGL_face_index_map -is the property map containing the index of each face of the input polygon mesh.\n +is the property map associating a unique index to each face of a polygon mesh, +between `0` and `num_faces(g)-1`. +If this parameter is not passed, internal machinery will create and initialize a face index +property map, either using the internal property map if it exists or using an external map. The latter +might result in - slightly - worsened performance due to non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode -Default: \code boost::get(CGAL::face_index, pmesh)\endcode -If this internal property map exists, its values should be initialized. +Default: an initialized face index property map \cgalNPEnd \cgalNPBegin{edge_is_constrained_map} \anchor BGL_edge_is_constrained_map diff --git a/BGL/include/CGAL/boost/graph/io.h b/BGL/include/CGAL/boost/graph/io.h index 7a7de91f470..dd41b28a65f 100644 --- a/BGL/include/CGAL/boost/graph/io.h +++ b/BGL/include/CGAL/boost/graph/io.h @@ -630,8 +630,7 @@ write_polys_points(std::ostream& os, * `CGAL::vertex_point_t` must be available in `TriangleMesh`. * \cgalParamEnd * \cgalParamBegin{vertex_index_map} the property map with the indices associated to - * the vertices of `mesh`. If this parameter is omitted, an internal property map for - * `CGAL::vertex_index_t` must be available in `TriangleMesh`. + * the vertices of `mesh`. * \cgalParamEnd * \cgalNamedParamsEnd */ diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt index b9d52b7d67d..084afaada43 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt @@ -32,10 +32,11 @@ is the property map with the points associated to the vertices of the polygon me \cgalNPEnd \cgalNPBegin{vertex_index_map} \anchor PMP_vertex_index_map -is the property map associating a unique index to each vertex of a polygon mesh. +is the property map associating a unique index to each vertex of a polygon mesh, +between `0` and `num_vertices(g)-1`. If this parameter is not passed, internal machinery will create and initialize a vertex index property map, either using the internal property map if it exists or using an external map. The latter -might result in (slightly) performance due to non-constant complexity for index access.\n +might result in - slightly - worsened performance due to non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` as key type and the value type \code typename boost::property_traits::type>::value_type \endcode @@ -43,11 +44,11 @@ might result in (slightly) performance due to non-constant complexity for index \cgalNPEnd \cgalNPBegin{face_index_map} \anchor PMP_face_index_map -is the property map associating a unique index to each face of a polygon mesh. +is the property map associating a unique index to each face of a polygon mesh, +between `0` and `num_faces(g)-1`. If this parameter is not passed, internal machinery will create and initialize a face index property map, either using the internal property map if it exists or using an external map. The latter -might result in (slightly) performance due to non-constant complexity for index access.\n -\n +might result in - slightly - worsened performance due to non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode From 5bd944a8d20947eca16c67eb3600f0b548cc26ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 10:57:46 +0100 Subject: [PATCH 76/86] Fix namespace in BGL doc --- BGL/doc/BGL/CGAL/boost/graph/properties.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BGL/doc/BGL/CGAL/boost/graph/properties.h b/BGL/doc/BGL/CGAL/boost/graph/properties.h index 2e8bb8b3eaa..657357b86c8 100644 --- a/BGL/doc/BGL/CGAL/boost/graph/properties.h +++ b/BGL/doc/BGL/CGAL/boost/graph/properties.h @@ -1,4 +1,4 @@ -namespace boost { +namespace CGAL { /// \ingroup PkgBGLProperties /// @{ From 24e2f35a258abb2f2ab84009cde2b47ff2bd9cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 11:46:32 +0100 Subject: [PATCH 77/86] Document tparam of set_triangulation_ids --- BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h b/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h index 503e24967e3..15827d6758b 100644 --- a/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h +++ b/BGL/doc/BGL/CGAL/Triangulation_face_base_with_id_2.h @@ -49,6 +49,12 @@ int& id(); /// This function initializes vertex, edge, and face indices of the triangulation `tr` and must /// be called prior to using `tr` as a BGL graph in an algorithm that requires /// vertex, halfedge, edge, or face indices. +/// +/// \tparam Triangulation a 2D triangulation of \cgal, whose combinatorial data structure +/// has been initialized with the vertex and face classes `Triangulation_vertex_base_with_id_2` +/// and `Triangulation_face_base_with_id_2`. +/// +/// \sa the \ref PkgTriangulation2 package template void set_triangulation_ids(Triangulation& tr); From 13984054ae30be341facfdbc233e1da3ae95d155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 11:46:50 +0100 Subject: [PATCH 78/86] Fix some enum/classes not showing in the documentation of BGL --- BGL/doc/BGL/CGAL/boost/graph/properties.h | 1 + 1 file changed, 1 insertion(+) diff --git a/BGL/doc/BGL/CGAL/boost/graph/properties.h b/BGL/doc/BGL/CGAL/boost/graph/properties.h index 657357b86c8..a7416d53eae 100644 --- a/BGL/doc/BGL/CGAL/boost/graph/properties.h +++ b/BGL/doc/BGL/CGAL/boost/graph/properties.h @@ -1,3 +1,4 @@ +/// CGAL Namespace namespace CGAL { /// \ingroup PkgBGLProperties From ff8a21f6e66b7749af32d6996ef214d8d694783e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 9 Mar 2020 11:49:21 +0100 Subject: [PATCH 79/86] Minor doc rephrase (dynamic pmap is not always non-constant time access) --- BGL/doc/BGL/NamedParameters.txt | 8 ++++---- .../doc/Polygon_mesh_processing/NamedParameters.txt | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/BGL/doc/BGL/NamedParameters.txt b/BGL/doc/BGL/NamedParameters.txt index bb8d5d91529..db4900c0ae7 100644 --- a/BGL/doc/BGL/NamedParameters.txt +++ b/BGL/doc/BGL/NamedParameters.txt @@ -42,7 +42,7 @@ is the property map associating a unique index to each vertex of a polygon mesh between `0` and `num_vertices(g)-1`. If this parameter is not passed, internal machinery will create and initialize a vertex index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance due to non-constant complexity for index access.\n +might result in - slightly - worsened performance if case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` as key type and the value type \code typename boost::property_traits::type>::value_type \endcode @@ -54,7 +54,7 @@ is the property map associating a unique index to each halfedge of a polygon mes between `0` and `num_halfedges(g)-1`. If this parameter is not passed, internal machinery will create and initialize a halfedge index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance due to non-constant complexity for index access.\n +might result in - slightly - worsened performance if case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%halfedge_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode @@ -66,7 +66,7 @@ is the property map associating a unique index to each edge of a polygon mesh, between `0` and `num_edges(g)-1`. If this parameter is not passed, internal machinery will create and initialize a edge index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance due to non-constant complexity for index access.\n +might result in - slightly - worsened performance if case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%edge_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode @@ -78,7 +78,7 @@ is the property map associating a unique index to each face of a polygon mesh, between `0` and `num_faces(g)-1`. If this parameter is not passed, internal machinery will create and initialize a face index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance due to non-constant complexity for index access.\n +might result in - slightly - worsened performance if case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt index 084afaada43..13b0eff2f80 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt @@ -36,7 +36,7 @@ is the property map associating a unique index to each vertex of a polygon mesh, between `0` and `num_vertices(g)-1`. If this parameter is not passed, internal machinery will create and initialize a vertex index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance due to non-constant complexity for index access.\n +might result in - slightly - worsened performance if case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` as key type and the value type \code typename boost::property_traits::type>::value_type \endcode @@ -48,7 +48,7 @@ is the property map associating a unique index to each face of a polygon mesh, between `0` and `num_faces(g)-1`. If this parameter is not passed, internal machinery will create and initialize a face index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance due to non-constant complexity for index access.\n +might result in - slightly - worsened performance if case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode From 63e1a33a4f2de5bb8a8a74a00bbcf966d5d832d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 10 Mar 2020 09:07:23 +0100 Subject: [PATCH 80/86] Add missing #include --- .../include/CGAL/Polygon_mesh_processing/corefinement.h | 3 ++- .../test/Polygon_mesh_processing/test_orient_cc.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h index 3685fda8745..3c4f77b9bbe 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h @@ -17,11 +17,12 @@ #include +#include +#include #include #include #include #include -#include #include namespace CGAL { diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp index 34a54ecd273..a11d8766ebd 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp @@ -1,5 +1,7 @@ #include #include + +#include #include #include From 23c3da94b06d05dc8ae414e0c095ff8886c8e550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 10 Mar 2020 09:07:37 +0100 Subject: [PATCH 81/86] Fix using now-removed named parameter helper --- .../test/Polygon_mesh_processing/test_orient_cc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp index a11d8766ebd..8f846d3c455 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp @@ -14,13 +14,13 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Surface_mesh SMesh; template -bool test_orientation(TriangleMesh& tm, bool is_positive, const NamedParameters& np) +bool test_orientation(const TriangleMesh& tm, bool is_positive, const NamedParameters& np) { typedef boost::graph_traits Graph_traits; typedef typename Graph_traits::vertex_descriptor vertex_descriptor; typedef typename Graph_traits::face_descriptor face_descriptor; typedef typename CGAL::GetVertexPointMap::const_type Vpm; - typedef typename CGAL::GetFaceIndexMap::const_type Fid_map; + typedef typename CGAL::GetInitializedFaceIndexMap::const_type Fid_map; using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; @@ -28,8 +28,7 @@ bool test_orientation(TriangleMesh& tm, bool is_positive, const NamedParameters& Vpm vpm = choose_parameter(get_parameter(np, CGAL::internal_np::vertex_point), CGAL::get_const_property_map(boost::vertex_point, tm)); - Fid_map fid_map = choose_parameter(get_parameter(np, CGAL::internal_np::face_index), - CGAL::get_const_property_map(boost::face_index, tm)); + Fid_map fid_map = CGAL::get_initialized_face_index_map(tm, np); std::vector face_cc(num_faces(tm), std::size_t(-1)); @@ -129,5 +128,6 @@ int main() return 1; } + std::cout << "Done!" << std::endl; return 0; } From 1b9b960e09ff0ec30d9318871a1b4b21a0f1815a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 11 Mar 2020 16:45:21 +0100 Subject: [PATCH 82/86] Index maps must be initialized when passed via Named Parameters --- .../remeshing_test_P_SM_OM.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp index 1769df9e09c..bed1ad1c583 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp @@ -31,15 +31,21 @@ int main() } { - typedef CGAL::Polyhedron_3 P; - std::map::face_descriptor, std::size_t> fim; - P p; - std::ifstream in("data/elephant.off"); - in >> p; - PMP::isotropic_remeshing(faces(p), + typedef CGAL::Polyhedron_3 P; + + std::ifstream in("data/elephant.off"); + P p; + in >> p; + + std::map::face_descriptor, std::size_t> fim; + std::size_t fid = 0; + for(const boost::graph_traits

::face_descriptor f : faces(p)) + fim[f] = fid++; + + PMP::isotropic_remeshing(faces(p), 0.02, - p, - PMP::parameters::face_index_map(boost::make_assoc_property_map(fim))); + p, + PMP::parameters::face_index_map(boost::make_assoc_property_map(fim))); std::ofstream out("p.off"); out << p << std::endl; } From 0bc78c07cdd053ab659c817dd367b4055f827be1 Mon Sep 17 00:00:00 2001 From: Mael Date: Fri, 13 Mar 2020 18:36:27 +0100 Subject: [PATCH 83/86] Fix typo Co-Authored-By: Sebastien Loriot --- BGL/doc/BGL/NamedParameters.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BGL/doc/BGL/NamedParameters.txt b/BGL/doc/BGL/NamedParameters.txt index db4900c0ae7..47c1d3f866a 100644 --- a/BGL/doc/BGL/NamedParameters.txt +++ b/BGL/doc/BGL/NamedParameters.txt @@ -42,7 +42,7 @@ is the property map associating a unique index to each vertex of a polygon mesh between `0` and `num_vertices(g)-1`. If this parameter is not passed, internal machinery will create and initialize a vertex index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance if case of non-constant complexity for index access.\n +might result in - slightly - worsened performance in case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` as key type and the value type \code typename boost::property_traits::type>::value_type \endcode @@ -54,7 +54,7 @@ is the property map associating a unique index to each halfedge of a polygon mes between `0` and `num_halfedges(g)-1`. If this parameter is not passed, internal machinery will create and initialize a halfedge index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance if case of non-constant complexity for index access.\n +might result in - slightly - worsened performance in case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%halfedge_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode @@ -66,7 +66,7 @@ is the property map associating a unique index to each edge of a polygon mesh, between `0` and `num_edges(g)-1`. If this parameter is not passed, internal machinery will create and initialize a edge index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance if case of non-constant complexity for index access.\n +might result in - slightly - worsened performance in case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%edge_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode @@ -78,7 +78,7 @@ is the property map associating a unique index to each face of a polygon mesh, between `0` and `num_faces(g)-1`. If this parameter is not passed, internal machinery will create and initialize a face index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance if case of non-constant complexity for index access.\n +might result in - slightly - worsened performance in case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode From d94dace5e9a3d3ddc8c6e8531956bf71935f7692 Mon Sep 17 00:00:00 2001 From: Mael Date: Fri, 13 Mar 2020 18:37:47 +0100 Subject: [PATCH 84/86] Fix typo (PMP) Co-Authored-By: Sebastien Loriot --- .../doc/Polygon_mesh_processing/NamedParameters.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt index 13b0eff2f80..b95f8671c34 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/NamedParameters.txt @@ -36,7 +36,7 @@ is the property map associating a unique index to each vertex of a polygon mesh, between `0` and `num_vertices(g)-1`. If this parameter is not passed, internal machinery will create and initialize a vertex index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance if case of non-constant complexity for index access.\n +might result in - slightly - worsened performance in case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` as key type and the value type \code typename boost::property_traits::type>::value_type \endcode @@ -48,7 +48,7 @@ is the property map associating a unique index to each face of a polygon mesh, between `0` and `num_faces(g)-1`. If this parameter is not passed, internal machinery will create and initialize a face index property map, either using the internal property map if it exists or using an external map. The latter -might result in - slightly - worsened performance if case of non-constant complexity for index access.\n +might result in - slightly - worsened performance in case of non-constant complexity for index access.\n Type: a class model of `ReadablePropertyMap` with `boost::graph_traits::%face_descriptor` as key type and the value type: \code typename boost::property_traits::type>::value_type \endcode From f6d994c003af54d08ebe3929d0730217626a41e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 16 Mar 2020 09:07:52 +0100 Subject: [PATCH 85/86] Do not expose internal classes in BGL::FFG's default templates --- .../CGAL/boost/graph/Face_filtered_graph.h | 101 ++++++++++-------- 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/Face_filtered_graph.h b/BGL/include/CGAL/boost/graph/Face_filtered_graph.h index 3a116f34c7a..875eb7f3e73 100644 --- a/BGL/include/CGAL/boost/graph/Face_filtered_graph.h +++ b/BGL/include/CGAL/boost/graph/Face_filtered_graph.h @@ -18,22 +18,22 @@ #include #include #include -#include -#include -#include -#include #include -#include +#include +#include + #include +#include +#include #include +#include #ifdef DOXYGEN_RUNNING #define CGAL_BGL_NP_TEMPLATE_PARAMETERS NamedParameters #define CGAL_BGL_NP_CLASS NamedParameters #endif -namespace CGAL -{ +namespace CGAL { /*! * \ingroup PkgBGLAdaptors @@ -63,18 +63,18 @@ namespace CGAL * missing if the default is fine. * * \tparam Graph must be a model of a `FaceListGraph`, `HalfedgeListGraph`, and \bgllink{VertexListGraph}. - * \tparam FIMap a model of `ReadablePropertyMap` with `face_descriptor` as key and `graph_traits::%faces_size_type` as value - * \tparam VIMap a model of `ReadablePropertyMap` with `vertex_descriptor` as key and `graph_traits::%vertices_size_type` as value - * \tparam HIMap a model of `ReadablePropertyMap` with `halfedge_descriptor` as key and `graph_traits::%halfedges_size_type` as value + * \tparam FIMap a model of `ReadablePropertyMap` with `graph_traits::%face_descriptor` as key and `graph_traits::%faces_size_type` as value + * \tparam VIMap a model of `ReadablePropertyMap` with `graph_traits::%vertex_descriptor` as key and `graph_traits::%vertices_size_type` as value + * \tparam HIMap a model of `ReadablePropertyMap` with `graph_traits::%halfedge_descriptor` as key and `graph_traits::%halfedges_size_type` as value * * \cgalModels `FaceListGraph` * \cgalModels `HalfedgeListGraph` * \cgalModels \bgllink{VertexListGraph} */ template::const_type, - typename VIMap = typename CGAL::GetInitializedVertexIndexMap::const_type, - typename HIMap = typename CGAL::GetInitializedHalfedgeIndexMap::const_type> + typename FIMap = Default, + typename VIMap = Default, + typename HIMap = Default> struct Face_filtered_graph { typedef boost::graph_traits gt; @@ -94,10 +94,15 @@ struct Face_filtered_graph #endif // non documented types - typedef typename boost::property_traits< FIMap >::value_type face_index_type; - typedef typename boost::property_traits< VIMap >::value_type vertex_index_type; - typedef typename boost::property_traits< HIMap >::value_type halfedge_index_type; - typedef Face_filtered_graph Self; + typedef typename Default::Get::const_type>::type FIM; + typedef typename Default::Get::const_type>::type VIM; + typedef typename Default::Get::const_type>::type HIM; + + typedef typename boost::property_traits::value_type face_index_type; + typedef typename boost::property_traits::value_type vertex_index_type; + typedef typename boost::property_traits::value_type halfedge_index_type; + + typedef Face_filtered_graph Self; /*! * \brief Constructor where the set of selected faces is specified as a range of patch ids. @@ -407,7 +412,7 @@ struct Face_filtered_graph return selected_halfedges.count(); } - Property_map_binder< FIMap, typename Pointer_property_map< typename boost::property_traits< FIMap >::value_type >::type > + Property_map_binder::value_type>::type> get_face_index_map() const { if (face_indices.empty()) @@ -422,7 +427,7 @@ struct Face_filtered_graph return bind_property_maps(fimap, make_property_map(face_indices) ); } - Property_map_binder< VIMap, typename Pointer_property_map< typename boost::property_traits< VIMap >::value_type >::type > + Property_map_binder::value_type>::type> get_vertex_index_map() const { if (vertex_indices.empty()) @@ -437,7 +442,7 @@ struct Face_filtered_graph return bind_property_maps(vimap, make_property_map(vertex_indices) ); } - Property_map_binder< HIMap, typename Pointer_property_map< typename boost::property_traits< HIMap >::value_type >::type > + Property_map_binder::value_type >::type> get_halfedge_index_map() const { if (halfedge_indices.empty()) @@ -510,9 +515,9 @@ struct Face_filtered_graph private: Graph& _graph; - FIMap fimap; - VIMap vimap; - HIMap himap; + FIM fimap; + VIM vimap; + HIM himap; boost::dynamic_bitset<> selected_faces; boost::dynamic_bitset<> selected_vertices; boost::dynamic_bitset<> selected_halfedges; @@ -1142,38 +1147,40 @@ CGAL_FILTERED_FACE_GRAPH_DYNAMIC_PMAP_SPECIALIZATION(dynamic_face_property_t) #undef CGAL_FILTERED_FACE_GRAPH_DYNAMIC_PMAP_SPECIALIZATION - - //specializations for indices -template -struct property_map, CGAL::face_index_t>{ - typedef typename CGAL::Property_map_binder< FIMap, - typename CGAL::Pointer_property_map< typename boost::property_traits< FIMap >::value_type >::type > type; - typedef type const_type; +template +struct property_map, CGAL::face_index_t> +{ + typedef typename CGAL::Face_filtered_graph::FIM FIM; + typedef typename CGAL::Property_map_binder::value_type>::type> type; + typedef type const_type; +}; + +template +struct property_map, boost::vertex_index_t> +{ + typedef typename CGAL::Face_filtered_graph::VIM VIM; + typedef typename CGAL::Property_map_binder::value_type>::type> type; + typedef type const_type; }; template -struct property_map, boost::vertex_index_t>{ - typedef typename CGAL::Property_map_binder< VIMap, - typename CGAL::Pointer_property_map< typename boost::property_traits< VIMap >::value_type >::type > type; - typedef type const_type; +struct property_map, CGAL::halfedge_index_t> +{ + typedef typename CGAL::Face_filtered_graph::HIM HIM; + typedef typename CGAL::Property_map_binder::value_type>::type> type; + typedef type const_type; }; -template +} // namespace boost -struct property_map, CGAL::halfedge_index_t>{ - typedef typename CGAL::Property_map_binder< HIMap, - typename CGAL::Pointer_property_map< typename boost::property_traits< HIMap >::value_type >::type > type; - typedef type const_type; -}; -}// namespace boost #endif // CGAL_BOOST_GRAPH_FACE_FILTERED_GRAPH_H From 2cb71708af524d56c275e4c301faee9dbf9ce77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 16 Mar 2020 09:25:23 +0100 Subject: [PATCH 86/86] Use proper index type in automatically-initialized index maps --- .../CGAL/boost/graph/named_params_helper.h | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_params_helper.h b/BGL/include/CGAL/boost/graph/named_params_helper.h index bcedc1cd124..297c93e0f18 100644 --- a/BGL/include/CGAL/boost/graph/named_params_helper.h +++ b/BGL/include/CGAL/boost/graph/named_params_helper.h @@ -184,21 +184,21 @@ namespace CGAL { // GetInitializedEdgeIndexMap // GetInitializedFaceIndexMap -#define CGAL_DEF_GET_INDEX_TYPE(CTYPE, TYPE) \ +#define CGAL_DEF_GET_INDEX_TYPE(CTYPE, DTYPE, STYPE) \ template > \ struct GetInitialized##CTYPE##IndexMap \ - : public BGL::internal::GetInitializedIndexMap, \ + : public BGL::internal::GetInitializedIndexMap, \ Graph, NamedParameters> \ { }; -CGAL_DEF_GET_INDEX_TYPE(Vertex, vertex) -CGAL_DEF_GET_INDEX_TYPE(Halfedge, halfedge) -CGAL_DEF_GET_INDEX_TYPE(Edge, edge) -CGAL_DEF_GET_INDEX_TYPE(Face, face) +CGAL_DEF_GET_INDEX_TYPE(Vertex, vertex, typename boost::graph_traits::vertices_size_type) +CGAL_DEF_GET_INDEX_TYPE(Halfedge, halfedge, typename boost::graph_traits::halfedges_size_type) +CGAL_DEF_GET_INDEX_TYPE(Edge, edge, typename boost::graph_traits::edges_size_type) +CGAL_DEF_GET_INDEX_TYPE(Face, face, typename boost::graph_traits::faces_size_type) #undef CGAL_DEF_GET_INDEX_TYPE @@ -214,30 +214,30 @@ CGAL_DEF_GET_INDEX_TYPE(Face, face) // - the internal index property map if it is the graph has one. It is initialized if needed and possible; // - an initialized dynamic pmap otherwise. -#define CGAL_DEF_GET_INITIALIZED_INDEX_MAP(TYPE) \ +#define CGAL_DEF_GET_INITIALIZED_INDEX_MAP(DTYPE, STYPE) \ template \ -typename BGL::internal::GetInitializedIndexMap, \ +typename BGL::internal::GetInitializedIndexMap, \ Graph, NamedParameters>::const_type \ -get_initialized_##TYPE##_index_map(const Graph& g, \ +get_initialized_##DTYPE##_index_map(const Graph& g, \ const NamedParameters& np) \ { \ - typedef BGL::internal::GetInitializedIndexMap, \ + typedef BGL::internal::GetInitializedIndexMap, \ Graph, NamedParameters> Index_map_getter; \ - return Index_map_getter::get_const(CGAL::internal_np::TYPE##_index_t{}, g, np); \ + return Index_map_getter::get_const(CGAL::internal_np::DTYPE##_index_t{}, g, np); \ } \ template \ -typename BGL::internal::GetInitializedIndexMap, \ +typename BGL::internal::GetInitializedIndexMap, \ Graph>::const_type \ -get_initialized_##TYPE##_index_map(const Graph& g) \ +get_initialized_##DTYPE##_index_map(const Graph& g) \ { \ - return get_initialized_##TYPE##_index_map(g, CGAL::parameters::all_default()); \ + return get_initialized_##DTYPE##_index_map(g, CGAL::parameters::all_default()); \ } \ /* same as above, non-const version*/ \ template ::type>::value, int> = 0> \ -typename BGL::internal::GetInitializedIndexMap, \ +typename BGL::internal::GetInitializedIndexMap, \ Graph, NamedParameters>::type \ -get_initialized_##TYPE##_index_map(Graph& g, \ +get_initialized_##DTYPE##_index_map(Graph& g, \ const NamedParameters& np) \ { \ - typedef BGL::internal::GetInitializedIndexMap, \ + typedef BGL::internal::GetInitializedIndexMap, \ Graph, NamedParameters> Index_map_getter; \ - return Index_map_getter::get(CGAL::internal_np::TYPE##_index_t{}, g, np); \ + return Index_map_getter::get(CGAL::internal_np::DTYPE##_index_t{}, g, np); \ } \ template ::type>::value, int> = 0> \ -typename BGL::internal::GetInitializedIndexMap, \ +typename BGL::internal::GetInitializedIndexMap, \ Graph>::type \ -get_initialized_##TYPE##_index_map(Graph& g) \ +get_initialized_##DTYPE##_index_map(Graph& g) \ { \ - return get_initialized_##TYPE##_index_map(g, CGAL::parameters::all_default()); \ + return get_initialized_##DTYPE##_index_map(g, CGAL::parameters::all_default()); \ } -CGAL_DEF_GET_INITIALIZED_INDEX_MAP(vertex) -CGAL_DEF_GET_INITIALIZED_INDEX_MAP(halfedge) -CGAL_DEF_GET_INITIALIZED_INDEX_MAP(edge) -CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(vertex, typename boost::graph_traits::vertices_size_type) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(halfedge, typename boost::graph_traits::halfedges_size_type) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(edge, typename boost::graph_traits::edges_size_type) +CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits::faces_size_type) #undef CGAL_DEF_GET_INITIALIZED_INDEX_MAP