#include <CGAL/Shape_detection/Region_growing/Point_set/K_neighbor_query.h>
K nearest neighbors search in a set of 2D or 3D points.
This class returns the K nearest neighbors of a query point in a point set.
Template Parameters
Is Model Of: NeighborQuery
using Item = Item_
Item type. Needs to be compatible to Region_type::Item.
using Region = std::vector< Item >
template<typename InputRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
K_neighbor_query (const InputRange &input_range, const NamedParameters &np=parameters::default_values ())
initializes a Kd-tree with input points. More...
◆ K_neighbor_query()
template<typename GeomTraits , typename Item_ , typename PointMap >
template<typename InputRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
initializes a Kd-tree with input points.
Template Parameters
Parameters
input_range an instance of InputRange
with 2D or 3D points
np a sequence of Named Parameters among the ones listed below
Optional Named Parameters
item_map
an instance of a model of ReadablePropertyMap
with InputRange::const_iterator
as key type and Item
as value type.
Default: A default is provided when Item
is InputRange::const_iterator
or its value type.
k_neighbors
the number of returned neighbors per each query point
Type: std::size_t
Default: 12
point_map
Precondition input_range.size() > 0
K > 0
◆ operator()()
template<typename GeomTraits , typename Item_ , typename PointMap >
implements NeighborQuery::operator()()
.
This operator finds the K
closest points to the point around the query point query
using a Kd-tree. These references to the points are returned in neighbors
.
Parameters
query Item
of the query point
neighbors Items
of points, which are neighbors of the query point
Precondition query
is a valid const_iterator of InputRange