diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polyline.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polyline.h index 6c5b1f2b039..65343375907 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polyline.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polyline.h @@ -16,6 +16,7 @@ #include +#include #include #include #include diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polyline/Polyline_graph.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polyline/Polyline_graph.h new file mode 100644 index 00000000000..7f3ecbfb4ed --- /dev/null +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_polyline/Polyline_graph.h @@ -0,0 +1,107 @@ +// Copyright (c) 2020 GeometryFactory SARL (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Dmitry Anisimov +// + +#ifndef CGAL_SHAPE_DETECTION_REGION_GROWING_POLYLINE_GRAPH_H +#define CGAL_SHAPE_DETECTION_REGION_GROWING_POLYLINE_GRAPH_H + +#include + +// Boost includes. +#include +#include + +// Internal includes. +#include + +namespace CGAL { +namespace Shape_detection { +namespace Polyline { + + template< + typename GeomTraits, + typename PolygonMesh, + typename FaceRange = typename PolygonMesh::Face_range, + typename VertexToPointMap = typename boost::property_map::type> + class Polyline_graph { + + 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 Squared_length_3 = typename Traits::Compute_squared_length_3; + using Squared_distance_3 = typename Traits::Compute_squared_distance_3; + using Scalar_product_3 = typename Traits::Compute_scalar_product_3; + using Cross_product_3 = typename Traits::Construct_cross_product_vector_3; + + public: + template + Polyline_graph( + const PolygonMesh& pmesh, + const NamedParameters& np, + const VertexToPointMap vertex_to_point_map = VertexToPointMap(), + const GeomTraits traits = GeomTraits()) : + m_face_graph(pmesh), + m_face_range(faces(m_face_graph)), + m_vertex_to_point_map(vertex_to_point_map), + m_squared_length_3(traits.compute_squared_length_3_object()), + m_squared_distance_3(traits.compute_squared_distance_3_object()), + m_scalar_product_3(traits.compute_scalar_product_3_object()), + m_cross_product_3(traits.construct_cross_product_vector_3_object()) { + + CGAL_precondition(m_face_range.size() > 0); + m_distance_threshold = parameters::choose_parameter( + parameters::get_parameter(np, internal_np::distance_threshold), FT(1)); + CGAL_precondition(m_distance_threshold >= FT(0)); + } + + private: + const Face_graph& m_face_graph; + const Face_range m_face_range; + + FT m_distance_threshold; + FT m_cos_value_threshold; + 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; + + Plane_3 m_plane_of_best_fit; + Vector_3 m_normal_of_best_fit; + }; + +} // namespace Polyline +} // namespace Shape_detection +} // namespace CGAL + +#endif // CGAL_SHAPE_DETECTION_REGION_GROWING_POLYLINE_GRAPH_H