\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 5.0.2 - Shape Detection
CGAL::Shape_detection::Point_set::K_neighbor_query< GeomTraits, InputRange, PointMap > Class Template Reference

#include <CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/K_neighbor_query.h>

Definition

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
GeomTraitsmust be a model of Kernel.
InputRangemust be a model of ConstRange whose iterator type is RandomAccessIterator.
PointMapmust be an LvaluePropertyMap whose key type is the value type of the input range and value type is Kernel::Point_2 or Kernel::Point_3.
Is Model Of:
NeighborQuery
Examples:
Shape_detection/region_growing_on_point_set_3.cpp.

Initialization

 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...
 

Access

void operator() (const std::size_t query_index, std::vector< std::size_t > &neighbors) const
 implements NeighborQuery::operator()(). More...
 

Constructor & Destructor Documentation

◆ K_neighbor_query()

template<typename GeomTraits , typename InputRange , typename PointMap >
CGAL::Shape_detection::Point_set::K_neighbor_query< GeomTraits, InputRange, PointMap >::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.

Parameters
input_rangean instance of InputRange with 2D or 3D points
kthe number of returned neighbors per each query point. Default is 12.
point_mapan 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

Member Function Documentation

◆ operator()()

template<typename GeomTraits , typename InputRange , typename PointMap >
void CGAL::Shape_detection::Point_set::K_neighbor_query< GeomTraits, InputRange, PointMap >::operator() ( const std::size_t  query_index,
std::vector< std::size_t > &  neighbors 
) const

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_indexindex of the query point
neighborsindices of points, which are neighbors of the query point
Precondition
query_index >= 0 && query_index < input_range.size()