From c502a39ea9793caa0379ed2c75e1fb23fcc38d49 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Thu, 25 Mar 2021 17:16:27 +0100 Subject: [PATCH] added empty segment set classes + updated several docs --- .../Shape_detection/Concepts/NeighborQuery.h | 5 +- .../doc/Shape_detection/Concepts/RegionType.h | 12 +++-- .../doc/Shape_detection/Doxyfile.in | 12 +++-- .../Shape_detection/PackageDescription.txt | 23 +++++++++ .../doc/Shape_detection/examples.txt | 3 ++ .../region_growing_on_segment_set.cpp | 0 .../K_neighbor_query.h | 22 +++++++-- .../Least_squares_line_fit_region.h | 47 ++++++++++++++----- .../Least_squares_line_fit_sorting.h | 2 +- .../Least_squares_plane_fit_sorting.h | 2 +- .../Least_squares_plane_fit_sorting.h | 2 +- .../One_ring_neighbor_query.h | 2 +- .../Region_growing_on_segment_set.h | 0 .../Least_squares_line_fit_region.h | 0 .../Least_squares_line_fit_sorting.h | 0 Shape_detection/todo.md | 16 ++++++- 16 files changed, 116 insertions(+), 32 deletions(-) create mode 100644 Shape_detection/examples/Shape_detection/region_growing_on_segment_set.cpp create mode 100644 Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_segment_set.h create mode 100644 Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_segment_set/Least_squares_line_fit_region.h create mode 100644 Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_segment_set/Least_squares_line_fit_sorting.h diff --git a/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h b/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h index 1438be81fc0..9368aeea92f 100644 --- a/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h +++ b/Shape_detection/doc/Shape_detection/Concepts/NeighborQuery.h @@ -6,9 +6,10 @@ A concept that describes the set of methods used by the `CGAL::Shape_detection:: to access neighbors of an item. \cgalHasModel -- `CGAL::Shape_detection::Point_set::K_neighbor_query`, -- `CGAL::Shape_detection::Point_set::Sphere_neighbor_query`, +- `CGAL::Shape_detection::Point_set::K_neighbor_query` +- `CGAL::Shape_detection::Point_set::Sphere_neighbor_query` - `CGAL::Shape_detection::Polygon_mesh::One_ring_neighbor_query` +- `CGAL::Shape_detection::Polyline::One_ring_neighbor_query` */ class NeighborQuery { diff --git a/Shape_detection/doc/Shape_detection/Concepts/RegionType.h b/Shape_detection/doc/Shape_detection/Concepts/RegionType.h index 5d29c2dec7a..caa2f07fd19 100644 --- a/Shape_detection/doc/Shape_detection/Concepts/RegionType.h +++ b/Shape_detection/doc/Shape_detection/Concepts/RegionType.h @@ -9,9 +9,11 @@ A region is represented by a set of `indices` of the items, which are included i this region. \cgalHasModel -- `CGAL::Shape_detection::Point_set::Least_squares_line_fit_region`, -- `CGAL::Shape_detection::Point_set::Least_squares_plane_fit_region`, +- `CGAL::Shape_detection::Point_set::Least_squares_line_fit_region` +- `CGAL::Shape_detection::Point_set::Least_squares_plane_fit_region` +- `CGAL::Shape_detection::Segment_set::Least_squares_line_fit_region` - `CGAL::Shape_detection::Polygon_mesh::Least_squares_plane_fit_region` +- `CGAL::Shape_detection::Polyline::Least_squares_line_fit_region` */ class RegionType { @@ -50,8 +52,10 @@ public: represented by `indices`. `CGAL::Shape_detection::Region_growing` calls this function each time when a - new seed item is selected. In this case, `indices.size() = 1`. This function - is also called periodically when enlarging the region. In this case, `indices.size() > 1`. + new seed item is selected. This case can be identified by checking the + condition `indices.size() == 1`. This function is also called periodically + when enlarging the region. This case can be identified by checking the + condition `indices.size() > 1`. */ void update( const std::vector& indices) { diff --git a/Shape_detection/doc/Shape_detection/Doxyfile.in b/Shape_detection/doc/Shape_detection/Doxyfile.in index 894086d1932..d99d90c1ade 100644 --- a/Shape_detection/doc/Shape_detection/Doxyfile.in +++ b/Shape_detection/doc/Shape_detection/Doxyfile.in @@ -1,7 +1,11 @@ @INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Shape Detection" -EXTRACT_ALL = NO -HIDE_UNDOC_CLASSES = YES -WARN_IF_UNDOCUMENTED = NO -PREDEFINED = DOXYGEN_NS \ No newline at end of file +EXTRACT_ALL = NO +HIDE_UNDOC_CLASSES = YES +WARN_IF_UNDOCUMENTED = NO +PREDEFINED = DOXYGEN_NS +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES +EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \ + CGAL_BGL_NP_CLASS diff --git a/Shape_detection/doc/Shape_detection/PackageDescription.txt b/Shape_detection/doc/Shape_detection/PackageDescription.txt index 35e87d2dc4e..a726bf03bad 100644 --- a/Shape_detection/doc/Shape_detection/PackageDescription.txt +++ b/Shape_detection/doc/Shape_detection/PackageDescription.txt @@ -17,12 +17,24 @@ Concepts used for the parameters of the `CGAL::Shape_detection::Region_growing`. Models that can be used with the `CGAL::Shape_detection::Region_growing` for shape detection in a point set. +\defgroup PkgShapeDetectionRGOnSegments Segment Set +\ingroup PkgShapeDetectionRG + +Models that can be used with the `CGAL::Shape_detection::Region_growing` +for shape detection in a segment set. + \defgroup PkgShapeDetectionRGOnMesh Polygon Mesh \ingroup PkgShapeDetectionRG Models that can be used with the `CGAL::Shape_detection::Region_growing` for shape detection on a polygon mesh. +\defgroup PkgShapeDetectionRGOnPolyline Polyline +\ingroup PkgShapeDetectionRG + +Models that can be used with the `CGAL::Shape_detection::Region_growing` +for shape detection on a polyline. + \addtogroup PkgShapeDetectionRG \defgroup PkgShapeDetectionRANSAC Efficient RANSAC @@ -121,15 +133,26 @@ on a polygon mesh.} - `CGAL::Shape_detection::Point_set::Least_squares_line_fit_sorting` - `CGAL::Shape_detection::Point_set::Least_squares_plane_fit_sorting` +### Segment Set ### +- `CGAL::Shape_detection::Segment_set::Least_squares_line_fit_region` +- `CGAL::Shape_detection::Segment_set::Least_squares_line_fit_sorting` + ### Polygon Mesh ### - `CGAL::Shape_detection::Polygon_mesh::One_ring_neighbor_query` - `CGAL::Shape_detection::Polygon_mesh::Least_squares_plane_fit_region` - `CGAL::Shape_detection::Polygon_mesh::Least_squares_plane_fit_sorting` +### Polyline ### +- `CGAL::Shape_detection::Polyline::One_ring_neighbor_query` +- `CGAL::Shape_detection::Polyline::Least_squares_line_fit_region` +- `CGAL::Shape_detection::Polyline::Least_squares_line_fit_sorting` + ## Deprecated Components ## - `CGAL::Shape_detection::deprecated::Shape_detection_traits` - `CGAL::Shape_detection::deprecated::Region_growing_depr` ## Functions ## - `CGAL::regularize_planes()` +- `CGAL::region_growing_lines()` +- `CGAL::region_growing_planes()` */ diff --git a/Shape_detection/doc/Shape_detection/examples.txt b/Shape_detection/doc/Shape_detection/examples.txt index 166ca333643..88697c05e8b 100644 --- a/Shape_detection/doc/Shape_detection/examples.txt +++ b/Shape_detection/doc/Shape_detection/examples.txt @@ -6,9 +6,12 @@ \example Shape_detection/include/efficient_RANSAC_with_custom_shape.h \example Shape_detection/efficient_RANSAC_with_custom_shape.cpp \example Shape_detection/efficient_RANSAC_and_plane_regularization.cpp +\example Shape_detection/region_growing_basic.cpp \example Shape_detection/region_growing_on_point_set_2.cpp \example Shape_detection/region_growing_on_point_set_3.cpp +\example Shape_detection/region_growing_on_segment_set.cpp \example Shape_detection/region_growing_on_polygon_mesh.cpp +\example Shape_detection/region_growing_on_polyline.cpp \example Shape_detection/region_growing_with_custom_classes.cpp \example Shape_detection/shape_detection_basic_deprecated.cpp */ diff --git a/Shape_detection/examples/Shape_detection/region_growing_on_segment_set.cpp b/Shape_detection/examples/Shape_detection/region_growing_on_segment_set.cpp new file mode 100644 index 00000000000..e69de29bb2d 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 663a12c6c32..697ba690759 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 @@ -116,18 +116,30 @@ namespace Point_set { /*! \brief initializes a Kd-tree with input points. + \tparam NamedParameters + a sequence of \ref bgl_namedparameters "Named Parameters" + \param input_range an instance of `InputRange` with 2D or 3D points - \param k - the number of returned neighbors per each query point. %Default is 12. + \param np + a sequence of \ref bgl_namedparameters "Named Parameters" + among the ones listed below \param point_map an instance of `PointMap` that maps an item from `input_range` to `Kernel::Point_2` or to `Kernel::Point_3` + \cgalNamedParamsBegin + \cgalParamNBegin{neighbor_radius} + \cgalParamDescription{the number of returned neighbors per each query point} + \cgalParamType{`std::size_t`} + \cgalParamDefault{12} + \cgalParamNEnd + \cgalNamedParamsEnd + \pre `input_range.size() > 0` - \pre `k > 0` + \pre `K > 0` */ template K_neighbor_query( @@ -160,7 +172,7 @@ namespace Point_set { /*! \brief implements `NeighborQuery::operator()()`. - This operator finds indices of the `k` closest points to the point with + This operator finds indices of the `K` closest points to the point with the index `query_index` using a Kd-tree. These indices are returned in `neighbors`. \param query_index @@ -169,7 +181,7 @@ namespace Point_set { \param neighbors indices of points, which are neighbors of the query point - \pre `query_index >= 0 && query_index < input_range.size()` + \pre `query_index < input_range.size()` */ void operator()( const std::size_t query_index, 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 691ca19da86..cbef6bc4b3e 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 @@ -93,19 +93,16 @@ namespace Point_set { /*! \brief initializes all internal data structures. + \tparam NamedParameters + a sequence of \ref bgl_namedparameters "Named Parameters" + \param input_range an instance of `InputRange` with 2D points and corresponding 2D normal vectors - \param distance_threshold - the maximum distance from a point to a line. %Default is 1. - - \param angle_threshold - the maximum accepted angle in degrees between the normal of a point and - the normal of a line. %Default is 25 degrees. - - \param min_region_size - the minimum number of 2D points a region must have. %Default is 2. + \param np + a sequence of \ref bgl_namedparameters "Named Parameters" + among the ones listed below \param point_map an instance of `PointMap` that maps an item from `input_range` @@ -118,9 +115,35 @@ namespace Point_set { \param traits an instance of `GeomTraits` + \cgalNamedParamsBegin + \cgalParamNBegin{distance_threshold} + \cgalParamDescription{the maximum distance from a point to a line} + \cgalParamType{`GeomTraits::FT`} + \cgalParamDefault{1} + \cgalParamNEnd + \cgalParamNBegin{angle_deg_threshold} + \cgalParamDescription{the maximum accepted angle in degrees between + the normal of a point and the normal of a line} + \cgalParamType{`GeomTraits::FT`} + \cgalParamDefault{25 degrees} + \cgalParamNEnd + \cgalParamNBegin{cos_value_threshold} + \cgalParamDescription{the cos value computed as cos(angle_deg_threshold * PI / 180), + this value can be used instead of the angle_deg_threshold} + \cgalParamType{`GeomTraits::FT`} + \cgalParamDefault{cos(25 * PI / 180)} + \cgalParamNEnd + \cgalParamNBegin{min_region_size} + \cgalParamDescription{the minimum number of 2D points a region must have} + \cgalParamType{`std::size_t`} + \cgalParamDefault{2} + \cgalParamNEnd + \cgalNamedParamsEnd + \pre `input_range.size() > 0` \pre `distance_threshold >= 0` - \pre `angle_threshold >= 0 && angle_threshold <= 90` + \pre `angle_deg_threshold >= 0 && angle_deg_threshold <= 90` + \pre `cos_value_threshold >= 0 && cos_value_threshold <= 1` \pre `min_region_size > 0` */ template @@ -167,7 +190,7 @@ namespace Point_set { This function controls if a point with the index `query_index` is within the `distance_threshold` from the corresponding line and if the angle - between its normal and the line's normal is within the `angle_threshold`. + between its normal and the line's normal is within the `angle_deg_threshold`. If both conditions are satisfied, it returns `true`, otherwise `false`. \param query_index @@ -177,7 +200,7 @@ namespace Point_set { \return Boolean `true` or `false` - \pre `query_index >= 0 && query_index < input_range.size()` + \pre `query_index < input_range.size()` */ bool is_part_of_region( const std::size_t, 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 df7a6bf5862..94638c7a99f 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 @@ -30,7 +30,7 @@ namespace Point_set { \brief Sorting of 2D points with respect to the local line fit quality. Indices of 2D input points are sorted with respect to the quality of the - least squares line fit applied to the neighboring points of each point. + least squares line fit applied to the neighbor points of each point. \tparam GeomTraits a model of `Kernel` 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 298c4f2890e..ad6879645f7 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 @@ -30,7 +30,7 @@ namespace Point_set { \brief Sorting of 3D points with respect to the local plane fit quality. Indices of 3D input points are sorted with respect to the quality of the - least squares plane fit applied to the neighboring points of each point. + least squares plane fit applied to the neighbor points of each point. \tparam GeomTraits a model of `Kernel` 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 7dcd9785e13..959bbd7b911 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 @@ -30,7 +30,7 @@ namespace Polygon_mesh { \brief Sorting of polygon mesh faces with respect to the local plane fit quality. Indices of faces in a polygon mesh are sorted with respect to the quality of the - least squares plane fit applied to the vertices of neighboring faces of each face. + least squares plane fit applied to the vertices of neighbor faces of each face. \tparam GeomTraits a model of `Kernel` 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 c53b6600118..e5e498103a6 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 @@ -102,7 +102,7 @@ namespace Polygon_mesh { \param neighbors indices of faces, which are neighbors of the query face - \pre `query_index >= 0 && query_index < faces(pmesh).size()` + \pre `query_index < faces(pmesh).size()` */ void operator()( const std::size_t query_index, diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_segment_set.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_segment_set.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_segment_set/Least_squares_line_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_segment_set/Least_squares_line_fit_region.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_segment_set/Least_squares_line_fit_sorting.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Region_growing_on_segment_set/Least_squares_line_fit_sorting.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/Shape_detection/todo.md b/Shape_detection/todo.md index 0bd7f13e2a9..07fb4e74714 100644 --- a/Shape_detection/todo.md +++ b/Shape_detection/todo.md @@ -1,3 +1,7 @@ +- add region growing on segments +- move all free functions to the same file +- overload the line functions +- do we need free functions here - update the docs - ---- submission ---- - update the polyhedron demo @@ -29,4 +33,14 @@ - these faces are not necessary convex - move each face vertex to the position of the intersection point between all neighbor region planes - triangulate each face and tag exterior triangles beyond its boundaries, which are constraints in CDT -- that gives the new simplified surface mesh \ No newline at end of file +- that gives the new simplified surface mesh + +- add region type for segments +- the input graph can be split into polylines based on corners +- regularize_face_selection_borders() or better apply graph cut on the computed regions to close holes +- error in the graph cut can be controlled by the size to the ideal position of the corners + +- detect planes +- regularize regions +- decimate mesh +- update corner positions \ No newline at end of file