diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h index 73bca6c23bf..54760874786 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h @@ -66,14 +66,14 @@ namespace Point_set { class K_neighbor_query { public: - /// \cond SKIP_IN_MANUAL using Traits = GeomTraits; using Input_range = InputRange; using Point_map = PointMap; - using Point = typename Point_map::value_type; + /// \endcond + private: using Index_to_point_map = internal::Item_property_map; @@ -106,8 +106,8 @@ namespace Point_set { using Tree = typename Neighbor_search::Tree; - /// \endcond + public: /// \name Initialization /// @{ @@ -188,16 +188,19 @@ namespace Point_set { /// @} + /// \cond SKIP_IN_MANUAL + // A property map that can be used to access points when + // iterating over the indices counting items in the input range. + const Index_to_point_map& index_to_point_map() const { + return m_index_to_point_map; + } + /// \endcond + private: - - // Fields. const Input_range& m_input_range; - const std::size_t m_number_of_neighbors; - const Point_map m_point_map; const Index_to_point_map m_index_to_point_map; - Distance m_distance; Tree m_tree; }; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_region.h index 0dda7c92afc..2418077c5b0 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_region.h @@ -69,7 +69,6 @@ namespace Point_set { class Least_squares_line_fit_region { public: - /// \name Types /// @{ @@ -83,16 +82,18 @@ namespace Point_set { /// Number type. typedef typename GeomTraits::FT FT; - /// \cond SKIP_IN_MANUAL + /// @} + + private: using Point_2 = typename Traits::Point_2; using Vector_2 = typename Traits::Vector_2; using Line_2 = typename Traits::Line_2; - using Local_traits = Exact_predicates_inexact_constructions_kernel; - using Local_FT = typename Local_traits::FT; - using Local_point_2 = typename Local_traits::Point_2; - using Local_line_2 = typename Local_traits::Line_2; - using To_local_converter = Cartesian_converter; + using ITraits = Exact_predicates_inexact_constructions_kernel; + using IFT = typename ITraits::FT; + using IPoint_2 = typename ITraits::Point_2; + using ILine_2 = typename ITraits::Line_2; + using IConverter = Cartesian_converter; using Squared_length_2 = typename Traits::Compute_squared_length_2; using Squared_distance_2 = typename Traits::Compute_squared_distance_2; @@ -100,10 +101,8 @@ namespace Point_set { using Get_sqrt = internal::Get_sqrt; using Sqrt = typename Get_sqrt::Sqrt; - /// \endcond - - /// @} + public: /// \name Initialization /// @{ @@ -161,7 +160,7 @@ namespace Point_set { m_squared_distance_2(traits.compute_squared_distance_2_object()), m_scalar_product_2(traits.compute_scalar_product_2_object()), m_sqrt(Get_sqrt::sqrt_object(traits)), - m_to_local_converter() { + m_iconverter() { CGAL_precondition(input_range.size() > 0); @@ -264,19 +263,19 @@ namespace Point_set { } else { // update reference line and normal - std::vector points; + std::vector points; points.reserve(region.size()); for (std::size_t i = 0; i < region.size(); ++i) { CGAL_precondition(region[i] < m_input_range.size()); const auto& key = *(m_input_range.begin() + region[i]); - points.push_back(m_to_local_converter(get(m_point_map, key))); + points.push_back(m_iconverter(get(m_point_map, key))); } CGAL_postcondition(points.size() == region.size()); - Local_line_2 fitted_line; - Local_point_2 fitted_centroid; + ILine_2 fitted_line; + IPoint_2 fitted_centroid; // The best fit line will be a line fitted to all region points with // its normal being perpendicular to the line. @@ -284,8 +283,8 @@ namespace Point_set { points.begin(), points.end(), fitted_line, fitted_centroid, CGAL::Dimension_tag<0>(), - Local_traits(), - CGAL::Eigen_diagonalize_traits()); + ITraits(), + CGAL::Eigen_diagonalize_traits()); m_line_of_best_fit = Line_2( @@ -305,8 +304,6 @@ namespace Point_set { /// @} private: - - // Fields. const Input_range& m_input_range; const FT m_distance_threshold; @@ -321,7 +318,7 @@ namespace Point_set { const Scalar_product_2 m_scalar_product_2; const Sqrt m_sqrt; - const To_local_converter m_to_local_converter; + const IConverter m_iconverter; Line_2 m_line_of_best_fit; Vector_2 m_normal_of_best_fit; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_sorting.h index 9fb5262239d..91a6b91677f 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_sorting.h @@ -64,7 +64,6 @@ namespace Point_set { class Least_squares_line_fit_sorting { public: - /// \name Types /// @{ @@ -86,6 +85,15 @@ namespace Point_set { /// @} + private: + using ITraits = Exact_predicates_inexact_constructions_kernel; + using IFT = typename ITraits::FT; + using IPoint_2 = typename ITraits::Point_2; + using ILine_2 = typename ITraits::Line_2; + using IConverter = Cartesian_converter; + using Compare_scores = internal::Compare_scores; + + public: /// \name Initialization /// @{ @@ -112,7 +120,7 @@ namespace Point_set { m_input_range(input_range), m_neighbor_query(neighbor_query), m_point_map(point_map), - m_to_local_converter() { + m_iconverter() { CGAL_precondition(input_range.size() > 0); @@ -155,20 +163,17 @@ namespace Point_set { /// @} private: + const Input_range& m_input_range; + Neighbor_query& m_neighbor_query; + const Point_map m_point_map; + std::vector m_order; + std::vector m_scores; + const IConverter m_iconverter; - // Types. - using Local_traits = Exact_predicates_inexact_constructions_kernel; - using Local_FT = typename Local_traits::FT; - using Local_point_2 = typename Local_traits::Point_2; - using Local_line_2 = typename Local_traits::Line_2; - using To_local_converter = Cartesian_converter; - using Compare_scores = internal::Compare_scores; - - // Functions. void compute_scores() { std::vector neighbors; - std::vector points; + std::vector points; for (std::size_t i = 0; i < m_input_range.size(); ++i) { @@ -181,31 +186,21 @@ namespace Point_set { CGAL_precondition(neighbors[j] < m_input_range.size()); const auto& key = *(m_input_range.begin() + neighbors[j]); - points.push_back(m_to_local_converter(get(m_point_map, key))); + points.push_back(m_iconverter(get(m_point_map, key))); } CGAL_postcondition(points.size() == neighbors.size()); - Local_line_2 fitted_line; - Local_point_2 fitted_centroid; + ILine_2 fitted_line; + IPoint_2 fitted_centroid; m_scores[i] = CGAL::linear_least_squares_fitting_2( points.begin(), points.end(), fitted_line, fitted_centroid, CGAL::Dimension_tag<0>(), - Local_traits(), - CGAL::Eigen_diagonalize_traits()); + ITraits(), + CGAL::Eigen_diagonalize_traits()); } } - - // Fields. - const Input_range& m_input_range; - Neighbor_query& m_neighbor_query; - const Point_map m_point_map; - - std::vector m_order; - std::vector m_scores; - - const To_local_converter m_to_local_converter; }; } // namespace Point_set diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_plane_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_plane_fit_region.h index ca572c78f30..c00d147d327 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_plane_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_plane_fit_region.h @@ -69,7 +69,6 @@ namespace Point_set { class Least_squares_plane_fit_region { public: - /// \name Types /// @{ @@ -83,16 +82,18 @@ namespace Point_set { /// Number type. typedef typename GeomTraits::FT FT; - /// \cond SKIP_IN_MANUAL + /// @} + + private: using Point_3 = typename Traits::Point_3; using Vector_3 = typename Traits::Vector_3; using Plane_3 = typename Traits::Plane_3; - using Local_traits = Exact_predicates_inexact_constructions_kernel; - using Local_FT = typename Local_traits::FT; - using Local_point_3 = typename Local_traits::Point_3; - using Local_plane_3 = typename Local_traits::Plane_3; - using To_local_converter = Cartesian_converter; + using ITraits = Exact_predicates_inexact_constructions_kernel; + using IFT = typename ITraits::FT; + using IPoint_3 = typename ITraits::Point_3; + using IPlane_3 = typename ITraits::Plane_3; + using IConverter = Cartesian_converter; using Squared_length_3 = typename Traits::Compute_squared_length_3; using Squared_distance_3 = typename Traits::Compute_squared_distance_3; @@ -100,10 +101,8 @@ namespace Point_set { using Get_sqrt = internal::Get_sqrt; using Sqrt = typename Get_sqrt::Sqrt; - /// \endcond - - /// @} + public: /// \name Initialization /// @{ @@ -161,7 +160,7 @@ namespace Point_set { m_squared_distance_3(traits.compute_squared_distance_3_object()), m_scalar_product_3(traits.compute_scalar_product_3_object()), m_sqrt(Get_sqrt::sqrt_object(traits)), - m_to_local_converter() { + m_iconverter() { CGAL_precondition(input_range.size() > 0); @@ -265,19 +264,19 @@ namespace Point_set { } else { // update reference plane and normal - std::vector points; + std::vector points; points.reserve(region.size()); for (std::size_t i = 0; i < region.size(); ++i) { CGAL_precondition(region[i] < m_input_range.size()); const auto& key = *(m_input_range.begin() + region[i]); - points.push_back(m_to_local_converter(get(m_point_map, key))); + points.push_back(m_iconverter(get(m_point_map, key))); } CGAL_postcondition(points.size() == region.size()); - Local_plane_3 fitted_plane; - Local_point_3 fitted_centroid; + IPlane_3 fitted_plane; + IPoint_3 fitted_centroid; // The best fit plane will be a plane fitted to all region points with // its normal being perpendicular to the plane. @@ -285,8 +284,8 @@ namespace Point_set { points.begin(), points.end(), fitted_plane, fitted_centroid, CGAL::Dimension_tag<0>(), - Local_traits(), - CGAL::Eigen_diagonalize_traits()); + ITraits(), + CGAL::Eigen_diagonalize_traits()); m_plane_of_best_fit = Plane_3( @@ -306,8 +305,6 @@ namespace Point_set { /// @} private: - - // Fields. const Input_range& m_input_range; const FT m_distance_threshold; @@ -322,7 +319,7 @@ namespace Point_set { const Scalar_product_3 m_scalar_product_3; const Sqrt m_sqrt; - const To_local_converter m_to_local_converter; + const IConverter m_iconverter; Plane_3 m_plane_of_best_fit; Vector_3 m_normal_of_best_fit; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_plane_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_plane_fit_sorting.h index be22fa6946e..3919febc5fb 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_plane_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_plane_fit_sorting.h @@ -64,7 +64,6 @@ namespace Point_set { class Least_squares_plane_fit_sorting { public: - /// \name Types /// @{ @@ -86,6 +85,15 @@ namespace Point_set { /// @} + private: + using ITraits = Exact_predicates_inexact_constructions_kernel; + using IFT = typename ITraits::FT; + using IPoint_3 = typename ITraits::Point_3; + using IPlane_3 = typename ITraits::Plane_3; + using IConverter = Cartesian_converter; + using Compare_scores = internal::Compare_scores; + + public: /// \name Initialization /// @{ @@ -112,7 +120,7 @@ namespace Point_set { m_input_range(input_range), m_neighbor_query(neighbor_query), m_point_map(point_map), - m_to_local_converter() { + m_iconverter() { CGAL_precondition(input_range.size() > 0); @@ -155,20 +163,17 @@ namespace Point_set { /// @} private: + const Input_range& m_input_range; + Neighbor_query& m_neighbor_query; + const Point_map m_point_map; + std::vector m_order; + std::vector m_scores; + const IConverter m_iconverter; - // Types. - using Local_traits = Exact_predicates_inexact_constructions_kernel; - using Local_FT = typename Local_traits::FT; - using Local_point_3 = typename Local_traits::Point_3; - using Local_plane_3 = typename Local_traits::Plane_3; - using To_local_converter = Cartesian_converter; - using Compare_scores = internal::Compare_scores; - - // Functions. void compute_scores() { std::vector neighbors; - std::vector points; + std::vector points; for (std::size_t i = 0; i < m_input_range.size(); ++i) { @@ -181,31 +186,21 @@ namespace Point_set { CGAL_precondition(neighbors[j] < m_input_range.size()); const auto& key = *(m_input_range.begin() + neighbors[j]); - points.push_back(m_to_local_converter(get(m_point_map, key))); + points.push_back(m_iconverter(get(m_point_map, key))); } CGAL_postcondition(points.size() == neighbors.size()); - Local_plane_3 fitted_plane; - Local_point_3 fitted_centroid; + IPlane_3 fitted_plane; + IPoint_3 fitted_centroid; m_scores[i] = CGAL::linear_least_squares_fitting_3( points.begin(), points.end(), fitted_plane, fitted_centroid, CGAL::Dimension_tag<0>(), - Local_traits(), - CGAL::Eigen_diagonalize_traits()); + ITraits(), + CGAL::Eigen_diagonalize_traits()); } } - - // Fields. - const Input_range& m_input_range; - Neighbor_query& m_neighbor_query; - const Point_map m_point_map; - - std::vector m_order; - std::vector m_scores; - - const To_local_converter m_to_local_converter; }; } // namespace Point_set diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Sphere_neighbor_query.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Sphere_neighbor_query.h index 5dd67cef3d1..a70c6d42fd7 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Sphere_neighbor_query.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Sphere_neighbor_query.h @@ -67,7 +67,6 @@ namespace Point_set { class Sphere_neighbor_query { public: - /// \name Types /// @{ @@ -75,14 +74,15 @@ namespace Point_set { using Traits = GeomTraits; using Input_range = InputRange; using Point_map = PointMap; - using Point = typename Point_map::value_type; /// \endcond /// Number type. typedef typename GeomTraits::FT FT; - /// \cond SKIP_IN_MANUAL + /// @} + + private: using Index_to_point_map = internal::Item_property_map; @@ -102,10 +102,8 @@ namespace Point_set { using Tree = CGAL::Kd_tree; - /// \endcond - - /// @} + public: /// \name Initialization /// @{ @@ -185,16 +183,19 @@ namespace Point_set { /// @} + /// \cond SKIP_IN_MANUAL + // A property map that can be used to access points when + // iterating over the indices counting items in the input range. + const Index_to_point_map& index_to_point_map() const { + return m_index_to_point_map; + } + /// \endcond + private: - - // Fields. const Input_range& m_input_range; - const FT m_sphere_radius; - const Point_map m_point_map; const Index_to_point_map m_index_to_point_map; - Tree m_tree; }; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/Least_squares_plane_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/Least_squares_plane_fit_region.h index dc9caa0ff02..7dbd5f0823a 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/Least_squares_plane_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/Least_squares_plane_fit_region.h @@ -78,22 +78,31 @@ namespace Polygon_mesh { class Least_squares_plane_fit_region { public: + /// \name Types + /// @{ /// \cond SKIP_IN_MANUAL using Traits = GeomTraits; using Face_graph = PolygonMesh; using Face_range = FaceRange; using Vertex_to_point_map = VertexToPointMap; + /// \endcond + /// Number type. + typedef typename GeomTraits::FT FT; + + /// @} + + private: using Point_3 = typename Traits::Point_3; using Vector_3 = typename Traits::Vector_3; using Plane_3 = typename Traits::Plane_3; - using Local_traits = Exact_predicates_inexact_constructions_kernel; - using Local_FT = typename Local_traits::FT; - using Local_point_3 = typename Local_traits::Point_3; - using Local_plane_3 = typename Local_traits::Plane_3; - using To_local_converter = Cartesian_converter; + using ITraits = Exact_predicates_inexact_constructions_kernel; + using IFT = typename ITraits::FT; + using IPoint_3 = typename ITraits::Point_3; + using IPlane_3 = typename ITraits::Plane_3; + using IConverter = Cartesian_converter; using Squared_length_3 = typename Traits::Compute_squared_length_3; using Squared_distance_3 = typename Traits::Compute_squared_distance_3; @@ -102,16 +111,8 @@ namespace Polygon_mesh { using Get_sqrt = internal::Get_sqrt; using Sqrt = typename Get_sqrt::Sqrt; - /// \endcond - - /// \name Types - /// @{ - - /// Number type. - typedef typename GeomTraits::FT FT; - - /// @} + public: /// \name Initialization /// @{ @@ -164,7 +165,7 @@ namespace Polygon_mesh { m_scalar_product_3(traits.compute_scalar_product_3_object()), m_cross_product_3(traits.construct_cross_product_vector_3_object()), m_sqrt(Get_sqrt::sqrt_object(traits)), - m_to_local_converter() { + m_iconverter() { CGAL_precondition(m_face_range.size() > 0); @@ -266,7 +267,7 @@ namespace Polygon_mesh { } else { // update reference plane and normal - std::vector points; + std::vector points; for (std::size_t i = 0; i < region.size(); ++i) { CGAL_precondition(region[i] < m_face_range.size()); @@ -278,13 +279,13 @@ namespace Polygon_mesh { for (const auto vertex : vertices) { const Point_3& tmp_point = get(m_vertex_to_point_map, vertex); - points.push_back(m_to_local_converter(tmp_point)); + points.push_back(m_iconverter(tmp_point)); } } CGAL_postcondition(points.size() > 0); - Local_plane_3 fitted_plane; - Local_point_3 fitted_centroid; + IPlane_3 fitted_plane; + IPoint_3 fitted_centroid; // The best fit plane will be a plane fitted to all vertices of all // region faces with its normal being perpendicular to the plane. @@ -299,8 +300,8 @@ namespace Polygon_mesh { points.begin(), points.end(), fitted_plane, fitted_centroid, CGAL::Dimension_tag<0>(), - Local_traits(), - CGAL::Eigen_diagonalize_traits()); + ITraits(), + CGAL::Eigen_diagonalize_traits()); const Plane_3 unoriented_plane_of_best_fit = Plane_3( @@ -351,6 +352,25 @@ namespace Polygon_mesh { /// @} private: + const Face_graph& m_face_graph; + const Face_range m_face_range; + + const FT m_distance_threshold; + const FT m_normal_threshold; + const std::size_t m_min_region_size; + + const Vertex_to_point_map m_vertex_to_point_map; + + const Squared_length_3 m_squared_length_3; + const Squared_distance_3 m_squared_distance_3; + const Scalar_product_3 m_scalar_product_3; + const Cross_product_3 m_cross_product_3; + const Sqrt m_sqrt; + + const IConverter m_iconverter; + + Plane_3 m_plane_of_best_fit; + Vector_3 m_normal_of_best_fit; template void get_face_centroid( @@ -444,27 +464,6 @@ namespace Polygon_mesh { return max_face_distance; } - - // Fields. - const Face_graph& m_face_graph; - const Face_range m_face_range; - - const FT m_distance_threshold; - const FT m_normal_threshold; - const std::size_t m_min_region_size; - - const Vertex_to_point_map m_vertex_to_point_map; - - const Squared_length_3 m_squared_length_3; - const Squared_distance_3 m_squared_distance_3; - const Scalar_product_3 m_scalar_product_3; - const Cross_product_3 m_cross_product_3; - const Sqrt m_sqrt; - - const To_local_converter m_to_local_converter; - - Plane_3 m_plane_of_best_fit; - Vector_3 m_normal_of_best_fit; }; } // namespace Polygon_mesh diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/Least_squares_plane_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/Least_squares_plane_fit_sorting.h index 9c9b62ac44a..c30b69db2cf 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/Least_squares_plane_fit_sorting.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/Least_squares_plane_fit_sorting.h @@ -77,7 +77,6 @@ namespace Polygon_mesh { class Least_squares_plane_fit_sorting { public: - /// \name Types /// @{ @@ -100,6 +99,15 @@ namespace Polygon_mesh { /// @} + private: + using ITraits = Exact_predicates_inexact_constructions_kernel; + using IFT = typename ITraits::FT; + using IPoint_3 = typename ITraits::Point_3; + using IPlane_3 = typename ITraits::Plane_3; + using IConverter = Cartesian_converter; + using Compare_scores = internal::Compare_scores; + + public: /// \name Initialization /// @{ @@ -127,7 +135,7 @@ namespace Polygon_mesh { m_neighbor_query(neighbor_query), m_face_range(faces(m_face_graph)), m_vertex_to_point_map(vertex_to_point_map), - m_to_local_converter() { + m_iconverter() { CGAL_precondition(m_face_range.size() > 0); @@ -170,20 +178,18 @@ namespace Polygon_mesh { /// @} private: + const Face_graph& m_face_graph; + Neighbor_query& m_neighbor_query; + const Face_range m_face_range; + const Vertex_to_point_map m_vertex_to_point_map; + std::vector m_order; + std::vector m_scores; + const IConverter m_iconverter; - // Types. - using Local_traits = Exact_predicates_inexact_constructions_kernel; - using Local_FT = typename Local_traits::FT; - using Local_point_3 = typename Local_traits::Point_3; - using Local_plane_3 = typename Local_traits::Plane_3; - using To_local_converter = Cartesian_converter; - using Compare_scores = internal::Compare_scores; - - // Functions. void compute_scores() { std::vector neighbors; - std::vector points; + std::vector points; for (std::size_t i = 0; i < m_face_range.size(); ++i) { @@ -202,33 +208,22 @@ namespace Polygon_mesh { for (const auto vertex : vertices) { const auto& tmp_point = get(m_vertex_to_point_map, vertex); - points.push_back(m_to_local_converter(tmp_point)); + points.push_back(m_iconverter(tmp_point)); } } CGAL_postcondition(points.size() > 0); - Local_plane_3 fitted_plane; - Local_point_3 fitted_centroid; + IPlane_3 fitted_plane; + IPoint_3 fitted_centroid; m_scores[i] = CGAL::linear_least_squares_fitting_3( points.begin(), points.end(), fitted_plane, fitted_centroid, CGAL::Dimension_tag<0>(), - Local_traits(), - CGAL::Eigen_diagonalize_traits()); + ITraits(), + CGAL::Eigen_diagonalize_traits()); } } - - // Fields. - const Face_graph& m_face_graph; - Neighbor_query& m_neighbor_query; - const Face_range m_face_range; - const Vertex_to_point_map m_vertex_to_point_map; - - std::vector m_order; - std::vector m_scores; - - const To_local_converter m_to_local_converter; }; } // namespace Polygon_mesh diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/One_ring_neighbor_query.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/One_ring_neighbor_query.h index ebbdb23da18..acc435e5174 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/One_ring_neighbor_query.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh/One_ring_neighbor_query.h @@ -58,15 +58,16 @@ namespace Polygon_mesh { class One_ring_neighbor_query { public: - /// \cond SKIP_IN_MANUAL using Face_graph = PolygonMesh; using Face_range = FaceRange; - - using Face_to_index_map - = internal::Item_to_index_property_map; /// \endcond + private: + using Face_to_index_map + = internal::Item_to_index_property_map; + + public: /// \name Initialization /// @{ @@ -129,12 +130,16 @@ namespace Polygon_mesh { /// @} - private: + /// \cond SKIP_IN_MANUAL + // A property map that can be used to access indices of the input faces. + const Face_to_index_map& face_to_index_map() const { + return m_face_to_index_map; + } + /// \endcond - // Fields. + private: const Face_graph& m_face_graph; const Face_range m_face_range; - const Face_to_index_map m_face_to_index_map; }; diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/internal/utils.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/internal/utils.h index b0d25c7fb7e..ca17c3b4baa 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/internal/utils.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/internal/utils.h @@ -108,20 +108,18 @@ namespace internal { using Traits = typename Kernel_traits::Kernel; using FT = typename Traits::FT; - using Local_traits = - CGAL::Exact_predicates_inexact_constructions_kernel; - using To_local_converter = - Cartesian_converter; + using ITraits = CGAL::Exact_predicates_inexact_constructions_kernel; + using IConverter = Cartesian_converter; - using Local_FT = typename Local_traits::FT; - using Local_point_3 = typename Local_traits::Point_3; - using Local_plane_3 = typename Local_traits::Plane_3; + using IFT = typename ITraits::FT; + using IPoint_3 = typename ITraits::Point_3; + using IPlane_3 = typename ITraits::Plane_3; planes.clear(); planes.reserve(regions.size()); - std::vector points; - const To_local_converter to_local_converter = To_local_converter(); + std::vector points; + const IConverter iconverter = IConverter(); for (const auto& region : regions) { CGAL_assertion(region.size() > 0); @@ -132,21 +130,21 @@ namespace internal { CGAL_precondition(region[i] < input_range.size()); const auto& key = *(input_range.begin() + region[i]); - points.push_back(to_local_converter(get(point_map, key))); + points.push_back(iconverter(get(point_map, key))); } CGAL_postcondition(points.size() == region.size()); - Local_plane_3 fitted_plane; - Local_point_3 fitted_centroid; + IPlane_3 fitted_plane; + IPoint_3 fitted_centroid; CGAL::linear_least_squares_fitting_3( points.begin(), points.end(), fitted_plane, fitted_centroid, CGAL::Dimension_tag<0>(), - Local_traits(), - CGAL::Eigen_diagonalize_traits()); + ITraits(), + CGAL::Eigen_diagonalize_traits()); - const Plane_3 plane = Plane_3( + const Plane_3 plane = Plane_3( static_cast(fitted_plane.a()), static_cast(fitted_plane.b()), static_cast(fitted_plane.c()),