From d7a339d621c4a33c081ce85c79affc2f1f7cb070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Jul 2022 15:46:57 +0200 Subject: [PATCH] remove the need to keep a reference to the input range --- .../Point_set/K_neighbor_query.h | 2 -- .../Least_squares_circle_fit_region.h | 2 -- .../Least_squares_circle_fit_sorting.h | 18 ++++++------- .../Least_squares_cylinder_fit_region.h | 2 -- .../Least_squares_cylinder_fit_sorting.h | 18 ++++++------- .../Point_set/Least_squares_line_fit_region.h | 2 -- .../Least_squares_line_fit_sorting.h | 20 +++++++------- .../Least_squares_plane_fit_region.h | 2 -- .../Least_squares_plane_fit_sorting.h | 20 +++++++------- .../Least_squares_sphere_fit_region.h | 2 -- .../Least_squares_sphere_fit_sorting.h | 18 ++++++------- .../Point_set/Sphere_neighbor_query.h | 2 -- .../Polyline/Least_squares_line_fit_region.h | 2 -- .../Polyline/Least_squares_line_fit_sorting.h | 20 +++++++------- .../Least_squares_line_fit_region.h | 6 ++--- .../Least_squares_line_fit_sorting.h | 26 +++++++++---------- .../test_region_growing_strict.cpp | 2 +- 17 files changed, 66 insertions(+), 98 deletions(-) diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/K_neighbor_query.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/K_neighbor_query.h index 2611a5d5dd9..755c3914441 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/K_neighbor_query.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/K_neighbor_query.h @@ -150,7 +150,6 @@ namespace Point_set { K_neighbor_query( const InputRange& input_range, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_ref_gen(input_range.begin()), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_deref_pmap(m_point_map), @@ -211,7 +210,6 @@ namespace Point_set { /// \endcond private: - const Input_range& m_input_range; internal::reference_iterator_generator m_ref_gen; std::vector m_referenced_input_range; const Point_map m_point_map; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_circle_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_circle_fit_region.h index 7756b74aedc..b9eca8c66b1 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_circle_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_circle_fit_region.h @@ -186,7 +186,6 @@ namespace Point_set { Least_squares_circle_fit_region( const InputRange& input_range, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_normal_map(Point_set_processing_3_np_helper::get_normal_map(input_range, np)), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -375,7 +374,6 @@ namespace Point_set { /// \endcond private: - const Input_range& m_input_range; const Point_map m_point_map; const Normal_map m_normal_map; const GeomTraits m_traits; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_circle_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_circle_fit_sorting.h index caa7989a4e8..79cc5ffd318 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_circle_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_circle_fit_sorting.h @@ -114,7 +114,6 @@ namespace Point_set { const InputRange& input_range, NeighborQuery& neighbor_query, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_neighbor_query(neighbor_query), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -122,13 +121,13 @@ namespace Point_set { CGAL_precondition(input_range.size() > 0); - m_ordered.resize(m_input_range.size()); + m_ordered.resize(input_range.size()); std::size_t index = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) + for (auto it = input_range.begin(); it != input_range.end(); it++) m_ordered[index++] = it; - m_scores.resize(m_input_range.size()); + m_scores.resize(input_range.size()); } /// @} @@ -145,11 +144,11 @@ namespace Point_set { CGAL_precondition(m_scores.size() > 0); Compare_scores cmp(m_scores); - std::vector order(m_input_range.size()); + std::vector order(m_ordered.size()); std::iota(order.begin(), order.end(), 0); std::sort(order.begin(), order.end(), cmp); - order.resize(m_input_range.size() - seed_cutoff); + order.resize(m_ordered.size() - seed_cutoff); std::vector tmp(order.size()); for (std::size_t i = 0; i < order.size(); i++) @@ -172,7 +171,6 @@ namespace Point_set { /// @} private: - const Input_range& m_input_range; Neighbor_query& m_neighbor_query; const Point_map m_point_map; const Traits m_traits; @@ -184,10 +182,10 @@ namespace Point_set { std::vector neighbors; std::size_t idx = 0; std::size_t seed_cutoff = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) { + for (const Item& item :m_ordered) { neighbors.clear(); - m_neighbor_query(it, neighbors); - neighbors.push_back(it); + m_neighbor_query(item, neighbors); + neighbors.push_back(item); m_scores[idx] = internal::create_circle_2( neighbors, m_point_map, m_traits, true).second; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_cylinder_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_cylinder_fit_region.h index cb742abd68b..0b774ba4fc4 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_cylinder_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_cylinder_fit_region.h @@ -187,7 +187,6 @@ namespace Point_set { Least_squares_cylinder_fit_region( const InputRange& input_range, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_normal_map(Point_set_processing_3_np_helper::get_normal_map(input_range, np)), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -384,7 +383,6 @@ namespace Point_set { /// \endcond private: - const Input_range& m_input_range; const Point_map m_point_map; const Normal_map m_normal_map; const GeomTraits m_traits; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_cylinder_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_cylinder_fit_sorting.h index f22731167af..9d80ed36761 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_cylinder_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_cylinder_fit_sorting.h @@ -125,7 +125,6 @@ namespace Point_set { const InputRange& input_range, NeighborQuery& neighbor_query, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_neighbor_query(neighbor_query), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_normal_map(Point_set_processing_3_np_helper::get_normal_map(input_range, np)), @@ -134,13 +133,13 @@ namespace Point_set { CGAL_precondition(input_range.size() > 0); - m_ordered.resize(m_input_range.size()); + m_ordered.resize(input_range.size()); std::size_t index = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) + for (auto it = input_range.begin(); it != input_range.end(); it++) m_ordered[index++] = it; - m_scores.resize(m_input_range.size()); + m_scores.resize(input_range.size()); } /// @} @@ -156,11 +155,11 @@ namespace Point_set { CGAL_postcondition(m_scores.size() > 0); Compare_scores cmp(m_scores); - std::vector order(m_input_range.size()); + std::vector order(m_ordered.size()); std::iota(order.begin(), order.end(), 0); std::sort(order.begin(), order.end(), cmp); - order.resize(m_input_range.size() - seed_cutoff); + order.resize(m_ordered.size() - seed_cutoff); std::vector tmp(order.size()); for (std::size_t i = 0; i < order.size(); i++) @@ -183,7 +182,6 @@ namespace Point_set { /// @} private: - const Input_range& m_input_range; Neighbor_query& m_neighbor_query; const Point_map m_point_map; const Normal_map m_normal_map; @@ -196,10 +194,10 @@ namespace Point_set { std::vector neighbors; std::size_t idx = 0; std::size_t seed_cutoff = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) { + for (const Item& item : m_ordered) { neighbors.clear(); - m_neighbor_query(it, neighbors); - neighbors.push_back(it); + m_neighbor_query(item, neighbors); + neighbors.push_back(item); m_scores[idx] = -internal::create_cylinder( neighbors, m_point_map, m_normal_map, m_traits).second; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_region.h index 127f9ccc123..8838e9dcc71 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_region.h @@ -161,7 +161,6 @@ namespace Point_set { Least_squares_line_fit_region( const InputRange& input_range, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_normal_map(Point_set_processing_3_np_helper::get_normal_map(input_range, np)), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -359,7 +358,6 @@ namespace Point_set { /// \endcond private: - const Input_range& m_input_range; const Point_map m_point_map; const Normal_map m_normal_map; const GeomTraits m_traits; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_sorting.h index 330fd039187..abe1019bc33 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_sorting.h @@ -114,7 +114,6 @@ namespace Point_set { const InputRange& input_range, NeighborQuery& neighbor_query, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_neighbor_query(neighbor_query), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -122,13 +121,13 @@ namespace Point_set { CGAL_precondition(input_range.size() > 0); - m_ordered.resize(m_input_range.size()); + m_ordered.resize(input_range.size()); std::size_t index = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) + for (auto it = input_range.begin(); it != input_range.end(); it++) m_ordered[index++] = it; - m_scores.resize(m_input_range.size()); + m_scores.resize(input_range.size()); } /// @} @@ -144,12 +143,12 @@ namespace Point_set { CGAL_precondition(m_scores.size() > 0); Compare_scores cmp(m_scores); - std::vector order(m_input_range.size()); + std::vector order(m_ordered.size()); std::iota(order.begin(), order.end(), 0); std::sort(order.begin(), order.end(), cmp); - std::vector tmp(m_input_range.size()); - for (std::size_t i = 0; i < m_input_range.size(); i++) + std::vector tmp(m_ordered.size()); + for (std::size_t i = 0; i < m_ordered.size(); i++) tmp[i] = m_ordered[order[i]]; m_ordered.swap(tmp); @@ -169,7 +168,6 @@ namespace Point_set { /// @} private: - const Input_range& m_input_range; Neighbor_query& m_neighbor_query; const Point_map m_point_map; const Traits m_traits; @@ -180,10 +178,10 @@ namespace Point_set { std::vector neighbors; std::size_t idx = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) { + for (const Item& item : m_ordered) { neighbors.clear(); - m_neighbor_query(it, neighbors); - neighbors.push_back(it); + m_neighbor_query(item, neighbors); + neighbors.push_back(item); m_scores[idx++] = internal::create_line_2( neighbors, m_point_map, m_traits).second; } diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_plane_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_plane_fit_region.h index 324caa7acbb..de0720978b5 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_plane_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_plane_fit_region.h @@ -161,7 +161,6 @@ namespace Point_set { Least_squares_plane_fit_region( const InputRange& input_range, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_normal_map(Point_set_processing_3_np_helper::get_normal_map(input_range, np)), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -358,7 +357,6 @@ namespace Point_set { /// \endcond private: - const Input_range& m_input_range; const Point_map m_point_map; const Normal_map m_normal_map; const GeomTraits m_traits; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_plane_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_plane_fit_sorting.h index d98ce3d95f2..030867a0a32 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_plane_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_plane_fit_sorting.h @@ -114,7 +114,6 @@ namespace Point_set { const InputRange& input_range, NeighborQuery& neighbor_query, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_neighbor_query(neighbor_query), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -122,13 +121,13 @@ namespace Point_set { CGAL_precondition(input_range.size() > 0); - m_ordered.resize(m_input_range.size()); + m_ordered.resize(input_range.size()); std::size_t index = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) + for (auto it = input_range.begin(); it != input_range.end(); it++) m_ordered[index++] = it; - m_scores.resize(m_input_range.size()); + m_scores.resize(input_range.size()); } /// @} @@ -144,11 +143,11 @@ namespace Point_set { CGAL_precondition(m_scores.size() > 0); Compare_scores cmp(m_scores); - std::vector order(m_input_range.size()); + std::vector order(m_ordered.size()); std::iota(order.begin(), order.end(), 0); std::sort(order.begin(), order.end(), cmp); - std::vector tmp(m_input_range.size()); - for (std::size_t i = 0; i < m_input_range.size(); i++) + std::vector tmp(m_ordered.size()); + for (std::size_t i = 0; i < m_ordered.size(); i++) tmp[i] = m_ordered[order[i]]; m_ordered.swap(tmp); @@ -168,7 +167,6 @@ namespace Point_set { /// @} private: - const Input_range& m_input_range; Neighbor_query& m_neighbor_query; const Point_map m_point_map; const Traits m_traits; @@ -180,10 +178,10 @@ namespace Point_set { std::vector neighbors; std::size_t idx = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) { + for (const Item& item : m_ordered) { neighbors.clear(); - m_neighbor_query(it, neighbors); - neighbors.push_back(it); + m_neighbor_query(item, neighbors); + neighbors.push_back(item); m_scores[idx++] = internal::create_plane( neighbors, m_point_map, m_traits).second; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_sphere_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_sphere_fit_region.h index 2f5bc4cbc5d..d63dff1de8c 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_sphere_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_sphere_fit_region.h @@ -175,7 +175,6 @@ g Least_squares_sphere_fit_region( const InputRange& input_range, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_normal_map(Point_set_processing_3_np_helper::get_normal_map(input_range, np)), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -365,7 +364,6 @@ g /// \endcond private: - const Input_range& m_input_range; const Point_map m_point_map; const Normal_map m_normal_map; const GeomTraits m_traits; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_sphere_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_sphere_fit_sorting.h index 7a96b286048..e9b63b9a1c7 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_sphere_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_sphere_fit_sorting.h @@ -114,7 +114,6 @@ namespace Point_set { const InputRange& input_range, NeighborQuery& neighbor_query, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_neighbor_query(neighbor_query), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -122,13 +121,13 @@ namespace Point_set { CGAL_precondition(input_range.size() > 0); - m_ordered.resize(m_input_range.size()); + m_ordered.resize(input_range.size()); std::size_t index = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) + for (auto it = input_range.begin(); it != input_range.end(); it++) m_ordered[index++] = it; - m_scores.resize(m_input_range.size()); + m_scores.resize(input_range.size()); } /// @} @@ -144,11 +143,11 @@ namespace Point_set { CGAL_postcondition(m_scores.size() > 0); Compare_scores cmp(m_scores); - std::vector order(m_input_range.size()); + std::vector order(m_ordered.size()); std::iota(order.begin(), order.end(), 0); std::sort(order.begin(), order.end(), cmp); - order.resize(m_input_range.size() - seed_cutoff); + order.resize(m_ordered.size() - seed_cutoff); std::vector tmp(order.size()); for (std::size_t i = 0; i < order.size(); i++) @@ -171,7 +170,6 @@ namespace Point_set { /// @} private: - const Input_range& m_input_range; Neighbor_query& m_neighbor_query; const Point_map m_point_map; const Traits m_traits; @@ -183,10 +181,10 @@ namespace Point_set { std::vector neighbors; std::size_t idx = 0; std::size_t seed_cutoff = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) { + for (const Item& item : m_ordered) { neighbors.clear(); - m_neighbor_query(it, neighbors); - neighbors.push_back(it); + m_neighbor_query(item, neighbors); + neighbors.push_back(item); m_scores[idx] = internal::create_sphere( neighbors, m_point_map, m_traits, true).second; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Sphere_neighbor_query.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Sphere_neighbor_query.h index a78723eafe8..6c4eaeaaec9 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Sphere_neighbor_query.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Sphere_neighbor_query.h @@ -134,7 +134,6 @@ public: Sphere_neighbor_query( const InputRange& input_range, const CGAL_NP_CLASS& np = parameters::default_values()) : - m_input_range(input_range), m_ref_gen(input_range.begin()), m_point_map(Point_set_processing_3_np_helper::get_const_point_map(input_range, np)), m_deref_pmap(m_point_map), @@ -200,7 +199,6 @@ public: /// \endcond private: - const Input_range& m_input_range; internal::reference_iterator_generator m_ref_gen; const Point_map m_point_map; const Dereference_pmap m_deref_pmap; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polyline/Least_squares_line_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polyline/Least_squares_line_fit_region.h index dfc17db69fd..5e6641b5c84 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polyline/Least_squares_line_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polyline/Least_squares_line_fit_region.h @@ -162,7 +162,6 @@ namespace Polyline { Least_squares_line_fit_region( const InputRange& input_range, const NamedParameters& np = parameters::default_values()) : - m_input_range(input_range), m_point_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::point_map), PointMap())), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -346,7 +345,6 @@ namespace Polyline { /// \endcond private: - const Input_range& m_input_range; const Point_map m_point_map; const Traits m_traits; const Polyline_traits m_polyline_traits; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polyline/Least_squares_line_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polyline/Least_squares_line_fit_sorting.h index 4747fccd7f8..7710b137922 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polyline/Least_squares_line_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polyline/Least_squares_line_fit_sorting.h @@ -119,7 +119,6 @@ namespace Polyline { const InputRange& input_range, NeighborQuery& neighbor_query, const NamedParameters& np = parameters::default_values()) : - m_input_range(input_range), m_neighbor_query(neighbor_query), m_point_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::point_map), PointMap())), @@ -130,13 +129,13 @@ namespace Polyline { CGAL_precondition(input_range.size() > 0); - m_ordered.resize(m_input_range.size()); + m_ordered.resize(input_range.size()); std::size_t index = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) + for (auto it = input_range.begin(); it != input_range.end(); it++) m_ordered[index++] = it; - m_scores.resize(m_input_range.size()); + m_scores.resize(input_range.size()); } /// @} @@ -152,12 +151,12 @@ namespace Polyline { CGAL_precondition(m_scores.size() > 0); Compare_scores cmp(m_scores); - std::vector order(m_input_range.size()); + std::vector order(m_ordered.size()); std::iota(order.begin(), order.end(), 0); std::sort(order.begin(), order.end(), cmp); - std::vector tmp(m_input_range.size()); - for (std::size_t i = 0; i < m_input_range.size(); i++) + std::vector tmp(m_ordered.size()); + for (std::size_t i = 0; i < m_ordered.size(); i++) tmp[i] = m_ordered[order[i]]; m_ordered.swap(tmp); @@ -177,7 +176,6 @@ namespace Polyline { /// @} private: - const Input_range& m_input_range; Neighbor_query& m_neighbor_query; const Point_map m_point_map; Dereference_pmap m_deref_pmap; @@ -190,10 +188,10 @@ namespace Polyline { std::vector neighbors; std::size_t idx = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) { + for (const Item& item : m_ordered) { neighbors.clear(); - m_neighbor_query(it, neighbors); - neighbors.push_back(it); + m_neighbor_query(item, neighbors); + neighbors.push_back(item); m_scores[idx++] = m_polyline_traits.create_line( neighbors, m_point_map).second; } diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_region.h index b6e2a495237..fffaf93e7b3 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_region.h @@ -47,8 +47,8 @@ namespace Segment_set { a model of `ConstRange` whose iterator type is `RandomAccessIterator` \tparam SegmentMap - a model of `ReadablePropertyMap` whose key type is the value type of the input - range and value type is `Kernel::Segment_2` or `Kernel::Segment_3` + a model of `ReadablePropertyMap` whose key type is `Item` + and value type is `Kernel::Segment_2` or `Kernel::Segment_3` \cgalModels `RegionType` */ @@ -167,7 +167,6 @@ namespace Segment_set { Least_squares_line_fit_region( const InputRange& input_range, const NamedParameters& np = parameters::default_values()) : - m_input_range(input_range), m_segment_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::segment_map), SegmentMap())), m_traits(parameters::choose_parameter(parameters::get_parameter( @@ -343,7 +342,6 @@ namespace Segment_set { /// \endcond private: - const Input_range& m_input_range; const Segment_map m_segment_map; const GeomTraits m_traits; const Segment_set_traits m_segment_set_traits; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_sorting.h index c235d30b3e5..9bd3052f29d 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_sorting.h @@ -59,7 +59,7 @@ namespace Segment_set { using Input_range = InputRange; using Neighbor_query = NeighborQuery; using Segment_map = SegmentMap; - using Segment_type = typename Segment_map::value_type; + using Segment_type = typename boost::property_traits::value_type; /// \endcond /// Item type. @@ -104,7 +104,7 @@ namespace Segment_set { \cgalNamedParamsBegin \cgalParamNBegin{segment_map} - \cgalParamDescription{an instance of `SegmentMap` that maps a segment from `input_range` + \cgalParamDescription{an instance of `SegmentMap` that maps the `Item` of a segment to `Kernel::Segment_2` or `Kernel::Segment_3`} \cgalParamDefault{`SegmentMap()`} \cgalParamNEnd @@ -121,7 +121,6 @@ namespace Segment_set { const InputRange& input_range, NeighborQuery& neighbor_query, const NamedParameters& np = parameters::default_values()) : - m_input_range(input_range), m_neighbor_query(neighbor_query), m_segment_map(parameters::choose_parameter(parameters::get_parameter( np, internal_np::segment_map), SegmentMap())), @@ -131,13 +130,13 @@ namespace Segment_set { CGAL_precondition(input_range.size() > 0); - m_ordered.resize(m_input_range.size()); + m_ordered.resize(input_range.size()); std::size_t index = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) + for (auto it = input_range.begin(); it != input_range.end(); it++) m_ordered[index++] = internal::conditional_deref()(it); - m_scores.resize(m_input_range.size()); + m_scores.resize(input_range.size()); } /// @} @@ -154,12 +153,12 @@ namespace Segment_set { CGAL_precondition(m_scores.size() > 0); Compare_scores cmp(m_scores); - std::vector order(m_input_range.size()); + std::vector order(m_ordered.size()); std::iota(order.begin(), order.end(), 0); std::sort(order.begin(), order.end(), cmp); - std::vector tmp(m_input_range.size()); - for (std::size_t i = 0; i < m_input_range.size(); i++) + std::vector tmp(m_ordered.size()); + for (std::size_t i = 0; i < m_ordered.size(); i++) tmp[i] = m_ordered[order[i]]; m_ordered.swap(tmp); @@ -179,7 +178,6 @@ namespace Segment_set { /// @} private: - const Input_range& m_input_range; Neighbor_query& m_neighbor_query; const Segment_map m_segment_map; const GeomTraits m_traits; @@ -191,12 +189,12 @@ namespace Segment_set { std::vector neighbors; std::size_t idx = 0; - for (auto it = m_input_range.begin(); it != m_input_range.end(); it++) { + for (const Item& item : m_ordered) { neighbors.clear(); - m_neighbor_query(it, neighbors); - neighbors.push_back(internal::conditional_deref()(it)); + m_neighbor_query(item, neighbors); + neighbors.push_back(item); - const auto& segment = get(m_segment_map, *it); + const auto& segment = get(m_segment_map, internal::conditional_deref()(item)); const auto& source = segment.source(); const auto& target = segment.target(); if (source == target) 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 116ad4d3f14..b74af40eda7 100644 --- a/Shape_detection/test/Shape_detection/test_region_growing_strict.cpp +++ b/Shape_detection/test/Shape_detection/test_region_growing_strict.cpp @@ -189,7 +189,7 @@ bool test_lines_segment_set_2_sorting() { using Segment_2 = typename Kernel::Segment_2; using Segment_range = std::vector; - using Segment_map = CGAL::Identity_property_map; + using Segment_map = CGAL::Identity_property_map; using Region_type = CGAL::Shape_detection:: Segment_set::Least_squares_line_fit_region;