#include <CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h>
K nearest neighbors search in a set of Kernel::Point_2
or Kernel::Point_3
.
This class returns the K nearest neighbors of a query point in a point set.
- Template Parameters
-
- Is Model Of:
NeighborQuery
- Examples:
- Shape_detection/region_growing_planes_on_point_set_3.cpp.
|
| K_neighbor_query (const InputRange &input_range, const std::size_t k=12, const PointMap point_map=PointMap()) |
| initializes a Kd-tree with input points. More...
|
|
◆ K_neighbor_query()
template<typename GeomTraits , typename InputRange , typename PointMap >
initializes a Kd-tree with input points.
- Parameters
-
input_range | an instance of InputRange with 2D or 3D points |
k | the number of returned neighbors per each query point. Default is 12. |
point_map | an instance of PointMap that maps an item from input_range to Kernel::Point_2 or to Kernel::Point_3 |
- Precondition
input_range.size() > 0
-
k > 0
◆ operator()()
template<typename GeomTraits , typename InputRange , typename PointMap >
implements NeighborQuery::operator()()
.
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
.
- Parameters
-
query_index | index of the query point |
neighbors | indices of points, which are neighbors of the query point |
- Precondition
query_index >= 0 && query_index < input_range.size()