From 31f5ce1f6a2b87cf9f0195eef6fc21847eafa9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 16 Feb 2023 17:28:12 +0100 Subject: [PATCH] fix PMP code --- .../doc/Shape_detection/Doxyfile.in | 1 - .../Polygon_mesh_processing/region_growing.h | 3 - .../Region_growing/Region_growing.h | 130 ++++++++++++++++-- 3 files changed, 122 insertions(+), 12 deletions(-) diff --git a/Shape_detection/doc/Shape_detection/Doxyfile.in b/Shape_detection/doc/Shape_detection/Doxyfile.in index bfe113e1dd7..41b38171cae 100644 --- a/Shape_detection/doc/Shape_detection/Doxyfile.in +++ b/Shape_detection/doc/Shape_detection/Doxyfile.in @@ -4,5 +4,4 @@ PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Shape Detection" EXTRACT_ALL = NO HIDE_UNDOC_CLASSES = YES WARN_IF_UNDOCUMENTED = NO -PREDEFINED = DOXYGEN_NS EXCLUDE = ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Polygon_mesh_processing diff --git a/Shape_detection/include/CGAL/Polygon_mesh_processing/region_growing.h b/Shape_detection/include/CGAL/Polygon_mesh_processing/region_growing.h index 44a0ffa19a1..25e6e50f9fd 100644 --- a/Shape_detection/include/CGAL/Polygon_mesh_processing/region_growing.h +++ b/Shape_detection/include/CGAL/Polygon_mesh_processing/region_growing.h @@ -96,9 +96,6 @@ region_growing_of_planes_on_faces(const PolygonMesh& mesh, using VPM = typename GetVertexPointMap < PolygonMesh, NamedParameters>::const_type; using Traits = typename GetGeomTraits::type; - using Graph_traits = boost::graph_traits; - using face_descriptor = typename Graph_traits::face_descriptor; - using parameters::choose_parameter; using parameters::get_parameter; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing.h index 27163d57105..63b6a168150 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing.h @@ -32,6 +32,17 @@ namespace CGAL { namespace Shape_detection { + template ::value> + struct pipo{ + static RegionMap create_map(RegionType) { return RegionMap(); } + }; + + template + struct pipo{ + static RegionMap create_map(RegionType& r ) { return r.region_index_map(); } + }; + /*! \ingroup PkgShapeDetectionRG @@ -79,7 +90,7 @@ namespace Shape_detection { using Running_queue = std::queue; public: - /// \name Initialization + /// \name Initialization (RegionMap is the default type) /// @{ /*! @@ -94,7 +105,7 @@ namespace Shape_detection { either `CGAL::Dereference_property_map` or `CGAL::Identity_property_map`. \param input_range - a range of input items for region growing. `input_range` must not be empty. + a range of input items for region growing. \param neighbor_query an instance of `NeighborQuery` that is used internally to @@ -106,18 +117,22 @@ namespace Shape_detection { \param item_map an instance of the property map to retrieve items from input values + + \pre `input_range.size() > 0` */ template Region_growing( const InputRange& input_range, NeighborQuery& neighbor_query, RegionType& region_type, - ItemMap item_map = ItemMap(), - std::enable_if_t::value>* = 0 + ItemMap item_map = ItemMap() +#ifndef DOXYGEN_RUNNING + , std::enable_if::value>* = 0 +#endif ) : m_neighbor_query(neighbor_query), m_region_type(region_type), - m_region_map(region_type.region_index_map()), + m_region_map(pipo::create_map(region_type)), m_visited(m_visited_map) { CGAL_precondition(input_range.size() > 0); @@ -134,8 +149,104 @@ namespace Shape_detection { clear(input_range, item_map_); } - /// \copydoc Region_growing() - /// \param rm external property map that will be filled when calling `detect()` + /*! + \brief initializes the region growing algorithm. + + \tparam InputRange + a model of `ConstRange` + + \tparam SeedRange + a model of `ConstRange` with `Item` as value type + + \tparam ItemMap + a model of `ReadablePropertyMap` with `InputRange::const_iterator` as key type and `Item` as value type. + A default can be deduced using the value type of `InputRange` and `Item` to be + either `CGAL::Dereference_property_map` or `CGAL::Identity_property_map`. + + \param input_range + a range of input items for region growing + + \param neighbor_query + an instance of `NeighborQuery` that is used internally to + access item's neighbors + + \param region_type + an instance of `RegionType` that is used internally to + control if items form a valid region type + + \param seed_range + a vector of `Item` that is used as seeds for the region growing. + Defaults to the full input_range. + + \param item_map + an instance of the property map to retrieve items from input values + + \pre `input_range.size() > 0` + */ + template + Region_growing( + const InputRange& input_range, + SeedRange& seed_range, + NeighborQuery& neighbor_query, + RegionType& region_type, + ItemMap item_map = ItemMap() +#ifndef DOXYGEN_RUNNING + , std::enable_if::value>* = 0 +#endif + ) : + m_neighbor_query(neighbor_query), + m_region_type(region_type), + m_region_map(pipo::create_map(region_type)), + m_visited(m_visited_map) { + + CGAL_precondition(input_range.size() > 0); + CGAL_precondition(seed_range.size() > 0); + m_seed_range.resize(seed_range.size()); + + using Item_helper = internal::Item_map_helper; + using Item_map = typename Item_helper::type; + Item_map item_map_ = Item_helper::get(item_map); + + std::size_t idx = 0; + for (auto it = seed_range.begin(); it != seed_range.end(); it++) + m_seed_range[idx++] = *it; + + clear(input_range, item_map_); + } + /// @} + + /// \name Initialization (RegionMap is a user provided type) + /// @{ + + /*! + \brief initializes the region growing algorithm. + + \tparam InputRange + a model of `ConstRange` + + \tparam ItemMap + a model of `ReadablePropertyMap` with `InputRange::const_iterator` as key type and `Item` as value type. + A default can be deduced using the value type of `InputRange` and `Item` to be + either `CGAL::Dereference_property_map` or `CGAL::Identity_property_map`. + + \param input_range + a range of input items for region growing. + + \param neighbor_query + an instance of `NeighborQuery` that is used internally to + access item's neighbors + + \param region_type + an instance of `RegionType` that is used internally to + control if items form a valid region type + + \param item_map + an instance of the property map to retrieve items from input values + + \param rm external property map that will be filled when calling `detect()` + + \pre `input_range.size() > 0` + */ template Region_growing( const InputRange& input_range, @@ -194,6 +305,8 @@ namespace Shape_detection { \param item_map an instance of the property map to retrieve items from input values + \param rm external property map that will be filled when calling `detect()` + \pre `input_range.size() > 0` */ template @@ -202,10 +315,11 @@ namespace Shape_detection { SeedRange& seed_range, NeighborQuery& neighbor_query, RegionType& region_type, + Region_map rm, ItemMap item_map = ItemMap()) : m_neighbor_query(neighbor_query), m_region_type(region_type), - m_region_map(region_type.region_index_map()), + m_region_map(rm), m_visited(m_visited_map) { CGAL_precondition(input_range.size() > 0);