CGAL 5.6.1 - Shape Detection
CGAL::Shape_detection::Point_set::K_neighbor_query< GeomTraits, Item_, PointMap > Class Template Reference

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

Definition

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
GeomTraitsa model of Kernel
Item_a descriptor representing a given point. Must be a model of Hashable.
PointMapa model of ReadablePropertyMap 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

Public Types

using Item = Item_
 Item type. Needs to be compatible to Region_type::Item.
 
using Region = std::vector< Item >
 

Related Functions

(Note that these are not member functions.)

template<class PointSet3 >
using K_neighbor_query_for_point_set = K_neighbor_query< typename Kernel_traits< typename PointSet3::Point_3 >::Kernel, typename PointSet3::Index, typename PointSet3::Point_map >
 shortcut to ease the definition of the class when using CGAL::Point_set_3. More...
 
template<class PointSet3 , typename NamedParameters = CGAL::parameters::Default_named_parameters>
K_neighbor_query_for_point_set< PointSet3 > make_k_neighbor_query (const PointSet3 &ps, NamedParameters np=parameters::default_values())
 returns an instance of the sorting class to be used with CGAL::Point_set_3, with point and normal maps added to np.
 

Initialization

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

Access

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

Constructor & Destructor Documentation

◆ K_neighbor_query()

template<typename GeomTraits , typename Item_ , typename PointMap >
template<typename InputRange , typename NamedParameters = CGAL::parameters::Default_named_parameters>
CGAL::Shape_detection::Point_set::K_neighbor_query< GeomTraits, Item_, PointMap >::K_neighbor_query ( const InputRange &  input_range,
const NamedParameters &  np = parameters::default_values() 
)

initializes a Kd-tree with input points.

Template Parameters
InputRangea model of ConstRange whose iterator type is RandomAccessIterator
NamedParametersa sequence of Named Parameters
Parameters
input_rangean instance of InputRange with 2D or 3D points
npa sequence of Named Parameters among the ones listed below
Optional Named Parameters
  • 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.
  • the number of returned neighbors per each query point
  • Type: std::size_t
  • Default: 12
Precondition
input_range.size() > 0
K > 0

Member Function Documentation

◆ operator()()

template<typename GeomTraits , typename Item_ , typename PointMap >
void CGAL::Shape_detection::Point_set::K_neighbor_query< GeomTraits, Item_, PointMap >::operator() ( const Item  query,
std::vector< Item > &  neighbors 
) const

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
queryItem of the query point
neighborsItems of points, which are neighbors of the query point
Precondition
query is a valid const_iterator of InputRange