From cd76994056d7e84d6a54de4e983e65a377ce51a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 18 Jan 2023 13:45:37 +0100 Subject: [PATCH] rename property map and deprecated old name --- .../internal/triangle_datum_covering.h | 8 +- .../Alpha_wrap_3/internal/splitting_helper.h | 8 +- .../CGAL/boost/graph/Face_filtered_graph.h | 18 +-- .../Corefinement/Face_graph_output_builder.h | 4 +- .../Generic_clip_output_builder.h | 4 +- .../Output_builder_for_autorefinement.h | 2 +- .../internal/Corefinement/face_graph_utils.h | 2 +- .../Polygon_mesh_processing/orientation.h | 6 +- .../Rigid_triangle_mesh_collision_detection.h | 2 +- .../test_orient_cc.cpp | 2 +- Property_map/include/CGAL/property_map.h | 148 +++++++++++++++++- .../region_growing_lines_on_point_set_2.cpp | 4 +- .../test_region_growing_basic.cpp | 4 +- .../test_region_growing_on_point_set_2.cpp | 4 +- ...on_growing_on_point_set_2_with_sorting.cpp | 4 +- .../test_region_growing_strict.cpp | 8 +- .../test_validity_sampled_data.cpp | 4 +- 17 files changed, 187 insertions(+), 45 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/triangle_datum_covering.h b/AABB_tree/include/CGAL/AABB_tree/internal/triangle_datum_covering.h index 6f7df8ae57c..842781f1234 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/triangle_datum_covering.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/triangle_datum_covering.h @@ -143,18 +143,18 @@ struct AABB_covered_triangle_tree_traits // Primitive ID --> box vector pos --> Bounding Box using BPMB = internal::Vector_property_map; - using BPM = CGAL::Property_map_binder; + using BPM = CGAL::Compose_property_map; // Primitive ID --> point vector pos --> Reference Point using RPPMB = internal::Vector_property_map; - using RPPM = CGAL::Property_map_binder; + using RPPM = CGAL::Compose_property_map; // Primitive ID --> Datum pos vector pos --> Datum pos --> Datum // The vector of data has size nf, but the vector of datum pos has size tree.size() using DPPMB = internal::Vector_property_map; // pos --> Datum pos - using DPPM = CGAL::Property_map_binder; // PID --> Datum pos + using DPPM = CGAL::Compose_property_map; // PID --> Datum pos using DPMB = internal::Vector_property_map; // Datum pos --> Datum - using DPM = CGAL::Property_map_binder; // PID --> Datum + using DPM = CGAL::Compose_property_map; // PID --> Datum using Primitive = CGAL::AABB_primitive box vector pos --> Bounding Box using BPMB = internal::Vector_property_map; - using BPM = CGAL::Property_map_binder; + using BPM = CGAL::Compose_property_map; // Primitive ID --> point vector pos --> Reference Point using RPPMB = internal::Vector_property_map; - using RPPM = CGAL::Property_map_binder; + using RPPM = CGAL::Compose_property_map; // Primitive ID --> Datum pos vector pos --> Datum pos --> Datum // The vector of data has size nf, but the vector of datum pos has size tree.size() using DPPMB = internal::Vector_property_map; // pos --> Datum pos - using DPPM = CGAL::Property_map_binder; // PID --> Datum pos + using DPPM = CGAL::Compose_property_map; // PID --> Datum pos using DPMB = internal::Vector_property_map; // Datum pos --> Datum - using DPM = CGAL::Property_map_binder; // PID --> Datum + using DPM = CGAL::Compose_property_map; // PID --> Datum using Primitive = CGAL::AABB_primitive::value_type>::type> + Compose_property_map::value_type>::type> get_face_index_map() const { is_imap_in_use.set(0); initialize_face_indices(); - return bind_property_maps(fimap, make_property_map(face_indices)); + return compose_property_maps(fimap, make_property_map(face_indices)); } - Property_map_binder::value_type>::type> + Compose_property_map::value_type>::type> get_vertex_index_map() const { is_imap_in_use.set(1); initialize_vertex_indices(); - return bind_property_maps(vimap, make_property_map(vertex_indices) ); + return compose_property_maps(vimap, make_property_map(vertex_indices) ); } - Property_map_binder::value_type >::type> + Compose_property_map::value_type >::type> get_halfedge_index_map() const { is_imap_in_use.set(2); initialize_halfedge_indices(); - return bind_property_maps(himap, make_property_map(halfedge_indices) ); + return compose_property_maps(himap, make_property_map(halfedge_indices) ); } /// returns `true` if around any vertex of a selected face there is at most a single umbrella @@ -1322,7 +1322,7 @@ struct property_map, boost typedef CGAL::Face_filtered_graph FFG; typedef typename FFG::FIM FIM; - typedef typename CGAL::Property_map_binder::value_type>::type> type; typedef type const_type; @@ -1334,7 +1334,7 @@ struct property_map, boost typedef CGAL::Face_filtered_graph FFG; typedef typename FFG::VIM VIM; - typedef typename CGAL::Property_map_binder::value_type>::type> type; typedef type const_type; @@ -1346,7 +1346,7 @@ struct property_map, boost typedef CGAL::Face_filtered_graph FFG; typedef typename FFG::HIM HIM; - typedef typename CGAL::Property_map_binder::value_type>::type> type; typedef type const_type; 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 f9595ef7358..604ad2348f1 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 @@ -707,7 +707,7 @@ public: Border_edge_map is_marked_1(intersection_edges1, tm1); std::size_t nb_patches_tm1 = connected_components(tm1, - bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0])), + compose_property_maps(fids1,make_property_map(&tm1_patch_ids[0])), parameters::edge_is_constrained_map(is_marked_1) .face_index_map(fids1)); @@ -720,7 +720,7 @@ public: Border_edge_map is_marked_2(intersection_edges2, tm2); std::size_t nb_patches_tm2 = connected_components(tm2, - bind_property_maps(fids2,make_property_map(&tm2_patch_ids[0])), + compose_property_maps(fids2,make_property_map(&tm2_patch_ids[0])), parameters::edge_is_constrained_map(is_marked_2) .face_index_map(fids2)); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Generic_clip_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Generic_clip_output_builder.h index 7ee732f4e83..d6f0c9bd116 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Generic_clip_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Generic_clip_output_builder.h @@ -148,7 +148,7 @@ public: std::size_t nb_patches_tm1 = connected_components(tm1, - bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0])), + compose_property_maps(fids1,make_property_map(&tm1_patch_ids[0])), parameters::edge_is_constrained_map(ecm1) .face_index_map(fids1)); @@ -228,7 +228,7 @@ public: } } - keep_connected_components(tm1, cc_to_keep, bind_property_maps(fids1,make_property_map(&tm1_patch_ids[0]))); + keep_connected_components(tm1, cc_to_keep, compose_property_maps(fids1,make_property_map(&tm1_patch_ids[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 5db5f0911ec..d8021ae23d2 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 @@ -349,7 +349,7 @@ public: is_intersection(intersection_edges); std::size_t nb_patches = connected_components(tm, - bind_property_maps(fids,make_property_map(patch_ids)), + compose_property_maps(fids,make_property_map(patch_ids)), parameters::edge_is_constrained_map(is_intersection) .face_index_map(fids)); 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 bff8f35189f..c700b5a6368 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 @@ -306,7 +306,7 @@ struct Side_of_helper typedef CGAL::Pointer_property_map::type Id_to_box; Id_to_box id_to_box = CGAL::make_property_map(face_bboxes); - typedef Property_map_binder BPM; + typedef Compose_property_map BPM; BPM bpm(fid, id_to_box); Compute_bbox compute_bbox(bpm); 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 31595ae0213..4f90dbfdd96 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -434,7 +434,7 @@ void orient(TriangleMesh& tm, // set the connected component id of each face std::size_t nb_cc = connected_components(tm, - bind_property_maps(fid_map,make_property_map(face_cc)), + compose_property_maps(fid_map,make_property_map(face_cc)), parameters::face_index_map(fid_map)); // extract a vertex with max z coordinate for each connected component @@ -844,7 +844,7 @@ volume_connected_components(const TriangleMesh& tm, // set the connected component id of each face const std::size_t nb_cc = connected_components(tm, - bind_property_maps(fid_map,make_property_map(face_cc)), + compose_property_maps(fid_map,make_property_map(face_cc)), parameters::face_index_map(fid_map)); // contains for each CC the CC that are in its bounded side @@ -1376,7 +1376,7 @@ void orient_to_bound_a_volume(TriangleMesh& tm, parameters::vertex_point_map(vpm) .geom_traits(gt) .nesting_levels(boost::ref(nesting_levels)) - .face_connected_component_map(bind_property_maps(fid_map,make_property_map(face_cc))) + .face_connected_component_map(compose_property_maps(fid_map,make_property_map(face_cc))) .i_used_for_volume_orientation(true) .do_orientation_tests(true) .is_cc_outward_oriented(boost::ref(is_cc_outward_oriented)) 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 d990d32b7a2..28a13ada396 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 @@ -575,7 +575,7 @@ public: std::size_t nb_cc = Polygon_mesh_processing::connected_components( - tm, bind_property_maps(fid_map, make_property_map(cc_ids)), + tm, compose_property_maps(fid_map, make_property_map(cc_ids)), parameters::face_index_map(fid_map)); if (nb_cc != 1) { 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 ae913ff8f5a..ea9cd6df87c 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 @@ -43,7 +43,7 @@ bool test_orientation(const TriangleMesh& tm, bool is_positive, const NamedParam // set the connected component id of each face std::size_t nb_cc = PMP::connected_components(tm, - CGAL::bind_property_maps(fid_map,CGAL::make_property_map(face_cc)), + CGAL::compose_property_maps(fid_map,CGAL::make_property_map(face_cc)), CGAL::parameters::face_index_map(fid_map)); // extract a vertex with max z coordinate for each connected component diff --git a/Property_map/include/CGAL/property_map.h b/Property_map/include/CGAL/property_map.h index a90320d09b9..58ed6340d71 100644 --- a/Property_map/include/CGAL/property_map.h +++ b/Property_map/include/CGAL/property_map.h @@ -101,9 +101,149 @@ make_OR_property_map(const PM1& pm1, const PM2& pm2) return OR_property_map(pm1, pm2); } -// A property map that uses the result of a property map as key. +#ifdef DOXYGEN_RUNNING +/// \ingroup PkgPropertyMapRef +/// Property map that composes two property maps, +/// that is `get(compose_property_map, k)` returns `get(value_map, get(key_map, k))`. template -struct Property_map_binder +struct Compose_property_map +{ + ///< Use the key type of `KeyMap` as keytype + typedef typename boost::property_traits::key_type key_type; + ///< Use the value type of `ValueMap` as value type + typedef typename boost::property_traits::value_type value_type; + ///< Use the reference type of `ValueMap` as reference + typedef typename boost::property_traits::reference reference; + typedef typename boost::property_traits::category category; +}; +#else +/// \ingroup PkgPropertyMapRef +/// Property map that composes two property maps, +/// that is `get(compose_property_map, k)` returns `get(value_map, get(key_map, k))`. +template ::category> +struct Compose_property_map; + + +template +struct Compose_property_map +{ + typedef typename boost::property_traits::key_type key_type; + typedef typename boost::property_traits::value_type value_type; + typedef typename boost::property_traits::reference reference; + typedef typename boost::property_traits::category category; + + KeyMap key_map; + ValueMap value_map; + + Compose_property_map(KeyMap key_map = KeyMap(), + ValueMap value_map = ValueMap()) + : key_map(key_map), value_map(value_map) + {} + + friend + reference get(Compose_property_map map, const key_type& k) + { + return get(map.value_map, get(map.key_map,k)); + } +}; + +template +struct Compose_property_map +{ + typedef typename boost::property_traits::key_type key_type; + typedef typename boost::property_traits::value_type value_type; + typedef typename boost::property_traits::reference reference; + typedef typename boost::property_traits::category category; + + KeyMap key_map; + ValueMap value_map; + + Compose_property_map(KeyMap key_map = KeyMap(), + ValueMap value_map = ValueMap()) + : key_map(key_map), value_map(value_map) + {} + + friend + void put(Compose_property_map map, const key_type& k, const value_type& v) + { + put(map.value_map, get(map.key_map,k), v); + } +}; + +template +struct Compose_property_map +{ + typedef typename boost::property_traits::key_type key_type; + typedef typename boost::property_traits::value_type value_type; + typedef typename boost::property_traits::reference reference; + typedef typename boost::property_traits::category category; + + KeyMap key_map; + ValueMap value_map; + + Compose_property_map(KeyMap key_map = KeyMap(), + ValueMap value_map = ValueMap()) + : key_map(key_map), value_map(value_map) + {} + + friend + reference get(Compose_property_map map, const key_type& k) + { + return get(map.value_map, get(map.key_map,k)); + } + + friend + void put(const Compose_property_map& map, const key_type& k, const value_type& v) + { + put(map.value_map, get(map.key_map,k), v); + } +}; + +template +struct Compose_property_map +{ + typedef typename boost::property_traits::key_type key_type; + typedef typename boost::property_traits::value_type value_type; + typedef typename boost::property_traits::reference reference; + typedef typename boost::property_traits::category category; + + KeyMap key_map; + ValueMap value_map; + + Compose_property_map(KeyMap key_map = KeyMap(), + ValueMap value_map = ValueMap()) + : key_map(key_map), value_map(value_map) + {} + + friend + reference get(Compose_property_map map, const key_type& k) + { + return get(map.value_map, get(map.key_map,k)); + } + + friend + void put(Compose_property_map map, key_type k, const value_type& v) + { + put(map.value_map, get(map.key_map,k), v); + } + + decltype(auto) + operator[](const key_type& k) const + { + return value_map[get(key_map, k)]; + } +}; + +template +Compose_property_map +compose_property_maps(const KeyMap& src, const ValueMap& tgt) +{ + return Compose_property_map(src, tgt); +} + +#ifndef CGAL_NO_DEPRECATED_CODE +template +struct CGAL_DEPRECATED Property_map_binder { typedef typename boost::property_traits::key_type key_type; typedef typename boost::property_traits::value_type value_type; @@ -137,12 +277,14 @@ struct Property_map_binder }; template +CGAL_DEPRECATED Property_map_binder bind_property_maps(const KeyMap& src, const ValueMap& tgt) { return Property_map_binder(src, tgt); } - +#endif +#endif /// Property map that accesses a value from an iterator /// diff --git a/Shape_detection/examples/Shape_detection/region_growing_lines_on_point_set_2.cpp b/Shape_detection/examples/Shape_detection/region_growing_lines_on_point_set_2.cpp index 85e24af621a..185385e250a 100644 --- a/Shape_detection/examples/Shape_detection/region_growing_lines_on_point_set_2.cpp +++ b/Shape_detection/examples/Shape_detection/region_growing_lines_on_point_set_2.cpp @@ -15,9 +15,9 @@ using Vector_2 = typename Kernel::Vector_2; using Point_with_normal = std::pair; using Point_set_2 = std::vector; -using Point_map = CGAL::Property_map_binder::type, +using Point_map = CGAL::Compose_property_map::type, CGAL::First_of_pair_property_map >; -using Normal_map = CGAL::Property_map_binder::type, +using Normal_map = CGAL::Compose_property_map::type, CGAL::Second_of_pair_property_map >; using Neighbor_query = CGAL::Shape_detection::Point_set::Sphere_neighbor_query; diff --git a/Shape_detection/test/Shape_detection/test_region_growing_basic.cpp b/Shape_detection/test/Shape_detection/test_region_growing_basic.cpp index 01e11b3199a..d1c4c11a045 100644 --- a/Shape_detection/test/Shape_detection/test_region_growing_basic.cpp +++ b/Shape_detection/test/Shape_detection/test_region_growing_basic.cpp @@ -24,9 +24,9 @@ using Vector_2 = typename Kernel::Vector_2; using Point_with_normal = std::pair; using Input_range = std::vector; using Deref_map = CGAL::Dereference_property_map; -using Point_map = CGAL::Property_map_binder>; -using Normal_map = CGAL::Property_map_binder>; using Neighbor_query = SD::Point_set::Sphere_neighbor_query; using Region_type = SD::Point_set::Least_squares_line_fit_region; diff --git a/Shape_detection/test/Shape_detection/test_region_growing_on_point_set_2.cpp b/Shape_detection/test/Shape_detection/test_region_growing_on_point_set_2.cpp index 6e0ddbce56a..ac293d67494 100644 --- a/Shape_detection/test/Shape_detection/test_region_growing_on_point_set_2.cpp +++ b/Shape_detection/test/Shape_detection/test_region_growing_on_point_set_2.cpp @@ -31,9 +31,9 @@ bool test_region_growing_on_point_set_2(int argc, char *argv[]) { using Input_range = std::vector; using Item = typename Input_range::const_iterator; using Deref_map = CGAL::Dereference_property_map; - using Point_map = CGAL::Property_map_binder>; - using Normal_map = CGAL::Property_map_binder>; using Neighbor_query = SD::Point_set::Sphere_neighbor_query; diff --git a/Shape_detection/test/Shape_detection/test_region_growing_on_point_set_2_with_sorting.cpp b/Shape_detection/test/Shape_detection/test_region_growing_on_point_set_2_with_sorting.cpp index 48ea50f7969..acf0640a56e 100644 --- a/Shape_detection/test/Shape_detection/test_region_growing_on_point_set_2_with_sorting.cpp +++ b/Shape_detection/test/Shape_detection/test_region_growing_on_point_set_2_with_sorting.cpp @@ -28,9 +28,9 @@ using Input_range = std::vector; using Item = Input_range::const_iterator; using Deref_map = CGAL::Dereference_property_map; -using Point_map = CGAL::Property_map_binder>; -using Normal_map = CGAL::Property_map_binder>; using Neighbor_query = SD::Point_set::Sphere_neighbor_query; diff --git a/Shape_detection/test/Shape_detection/test_region_growing_strict.cpp b/Shape_detection/test/Shape_detection/test_region_growing_strict.cpp index 62c54ac01c3..82ed06f3ca4 100644 --- a/Shape_detection/test/Shape_detection/test_region_growing_strict.cpp +++ b/Shape_detection/test/Shape_detection/test_region_growing_strict.cpp @@ -49,9 +49,9 @@ bool test_lines_points_with_normals() { std::vector< std::pair< typename Kernel::Line_2, std::vector > > regions; using Deref_map = CGAL::Dereference_property_map; - using Point_map = CGAL::Property_map_binder >; - using Normal_map = CGAL::Property_map_binder >; using Neighbor_query = CGAL::Shape_detection::Point_set::K_neighbor_query; @@ -305,9 +305,9 @@ bool test_planes_points_with_normals() { std::vector< std::pair< typename Kernel::Plane_3, std::vector > > regions; using Deref_map = CGAL::Dereference_property_map; - using Point_map = CGAL::Property_map_binder >; - using Normal_map = CGAL::Property_map_binder >; using Neighbor_query = CGAL::Shape_detection::Point_set::K_neighbor_query; diff --git a/Shape_detection/test/Shape_detection/test_validity_sampled_data.cpp b/Shape_detection/test/Shape_detection/test_validity_sampled_data.cpp index 3160836e98e..3f65401eb3e 100644 --- a/Shape_detection/test/Shape_detection/test_validity_sampled_data.cpp +++ b/Shape_detection/test/Shape_detection/test_validity_sampled_data.cpp @@ -34,8 +34,8 @@ using Item = Point_set::const_iterator; using Deref_map = CGAL::Dereference_property_map; using Point_map = CGAL::First_of_pair_property_map; using Normal_map = CGAL::Second_of_pair_property_map; -using RG_Point_map = CGAL::Property_map_binder; -using RG_Normal_map = CGAL::Property_map_binder; +using RG_Point_map = CGAL::Compose_property_map; +using RG_Normal_map = CGAL::Compose_property_map; using RG_query = SD::Point_set::Sphere_neighbor_query; using RG_region = SD::Point_set::Least_squares_plane_fit_region;