From 90e52d68f29068807585781921cfdee93fbb19d0 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 10 Oct 2024 12:56:54 +0200 Subject: [PATCH 1/2] documented that RegionType::Item and NeighborQuery::Item need to be hashable removed internal from example --- .../doc/Shape_detection/Concepts/NeighborQuery.h | 2 +- .../doc/Shape_detection/Concepts/RegionType.h | 2 +- .../region_growing_with_custom_classes.cpp | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h b/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h index 5495e5d0c9a..ed56b4bd8ea 100644 --- a/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h +++ b/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h @@ -15,7 +15,7 @@ class NeighborQuery { public: - /// The reference type to the elements of the input range, e.g., a const_iterator of the input range. + /// The reference type to the elements of the input range, e.g., a const_iterator of the input range. Must be a model of `Hashable`. typedef unspecified_type Item; /*! diff --git a/Shape_detection/doc/Shape_detection/Concepts/RegionType.h b/Shape_detection/doc/Shape_detection/Concepts/RegionType.h index f1366dc8aba..b178993f883 100644 --- a/Shape_detection/doc/Shape_detection/Concepts/RegionType.h +++ b/Shape_detection/doc/Shape_detection/Concepts/RegionType.h @@ -23,7 +23,7 @@ public: /// The parameters of the primitive covering the region. typedef unspecified_type Primitive; - /// The reference type to the elements of the input range, e.g., a const_iterator of the input range. + /// The reference type to the elements of the input range, e.g., a const_iterator of the input range. Must be a model of `Hashable`. typedef unspecified_type Item; // The region types is defined by a vector of Items. diff --git a/Shape_detection/examples/Shape_detection/region_growing_with_custom_classes.cpp b/Shape_detection/examples/Shape_detection/region_growing_with_custom_classes.cpp index a1d32efa020..f7058906cfe 100644 --- a/Shape_detection/examples/Shape_detection/region_growing_with_custom_classes.cpp +++ b/Shape_detection/examples/Shape_detection/region_growing_with_custom_classes.cpp @@ -69,7 +69,14 @@ namespace Custom { using Item = std::vector::const_iterator; using Region = std::vector; - using Region_unordered_map = std::unordered_map >; + struct hash_item { + std::size_t operator()(Item i) const { + using boost::hash_value; + return boost::hash_value(i.operator->()); + } + }; + + using Region_unordered_map = std::unordered_map; using Region_index_map = boost::associative_property_map; Region_index_map region_index_map() { From 812a20a45a1aa701cb139b7c769279b596d57892 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 10 Oct 2024 14:38:59 +0200 Subject: [PATCH 2/2] doc fix --- .../Shape_detection/Concepts/NeighborQuery.h | 2 +- .../doc/Shape_detection/Concepts/RegionType.h | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h b/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h index ed56b4bd8ea..f8f77632f1b 100644 --- a/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h +++ b/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h @@ -15,7 +15,7 @@ class NeighborQuery { public: - /// The reference type to the elements of the input range, e.g., a const_iterator of the input range. Must be a model of `Hashable`. + /// The reference type to the elements of the input range, e.g., a `const_iterator` of the input range. Must be a model of `Hashable`. typedef unspecified_type Item; /*! diff --git a/Shape_detection/doc/Shape_detection/Concepts/RegionType.h b/Shape_detection/doc/Shape_detection/Concepts/RegionType.h index b178993f883..6af2d59bf99 100644 --- a/Shape_detection/doc/Shape_detection/Concepts/RegionType.h +++ b/Shape_detection/doc/Shape_detection/Concepts/RegionType.h @@ -23,10 +23,10 @@ public: /// The parameters of the primitive covering the region. typedef unspecified_type Primitive; - /// The reference type to the elements of the input range, e.g., a const_iterator of the input range. Must be a model of `Hashable`. + /// The reference type to the elements of the input range, e.g., a `const_iterator` of the input range. Must be a model of `Hashable`. typedef unspecified_type Item; - // The region types is defined by a vector of Items. + // The Region type is defined by a `vector` of items. typedef std::vector Region; /*! @@ -37,11 +37,11 @@ public: typedef unspecified_type Region_index_map; /*! - checks if the item `i` can be added to the region represented by `region`. + checks if the `Item` `i` can be added to the `Region` represented by `region`. `CGAL::Shape_detection::Region_growing` calls this function each time when - trying to add a new item to a region. If this function returns `true`, the - item with the index `i`, is added to the region, otherwise ignored. + trying to add a new item to a `Region`. If this function returns `true`, the + item with the index `i`, is added to the `region`, otherwise ignored. */ bool is_part_of_region( const Item i, @@ -52,8 +52,8 @@ public: checks if `region` satisfies all necessary conditions. `CGAL::Shape_detection::Region_growing` calls this function at the end of each - propagation phase. If this function returns `true`, the region is accepted, - otherwise rejected. If the region is rejected, all its items are released and + propagation phase. If this function returns `true`, the `region` is accepted, + otherwise rejected. If the `region` is rejected, all its items are released and available for region growing again. */ bool is_valid_region( @@ -68,7 +68,7 @@ public: } /*! - enables to update any information about the region represented by the collection of Items `region`. + enables to update any information about the region represented by the collection of items `region`. `CGAL::Shape_detection::Region_growing` calls this function each time when a new seed item is selected. This case can be identified by checking the @@ -76,8 +76,8 @@ public: when enlarging the region. This case can be identified by checking the condition `region.size() > 1`. - This function also returns a Boolean at the first call when a new region - with one seed item is being created. When it is `true`, the new region is + This function also returns a boolean at the first call when a new `region` + with one seed item is being created. When it is `true`, the new `region` is further propagated, otherwise, it is rejected. */ bool update(