Point Cloud Library (PCL)  1.14.1-dev
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
pcl::KdTree< PointT > Class Template Referenceabstract

KdTree represents the base spatial locator class for kd-tree implementations. More...

#include <pcl/kdtree/kdtree.h>

+ Inheritance diagram for pcl::KdTree< PointT >:
+ Collaboration diagram for pcl::KdTree< PointT >:

Public Types

using IndicesPtr = shared_ptr< Indices >
 
using IndicesConstPtr = shared_ptr< const Indices >
 
using PointCloud = pcl::PointCloud< PointT >
 
using PointCloudPtr = typename PointCloud::Ptr
 
using PointCloudConstPtr = typename PointCloud::ConstPtr
 
using PointRepresentation = pcl::PointRepresentation< PointT >
 
using PointRepresentationConstPtr = typename PointRepresentation::ConstPtr
 
using Ptr = shared_ptr< KdTree< PointT > >
 
using ConstPtr = shared_ptr< const KdTree< PointT > >
 

Public Member Functions

 KdTree (bool sorted=true)
 Empty constructor for KdTree. More...
 
virtual void setInputCloud (const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr())
 Provide a pointer to the input dataset. More...
 
IndicesConstPtr getIndices () const
 Get a pointer to the vector of indices used. More...
 
PointCloudConstPtr getInputCloud () const
 Get a pointer to the input point cloud dataset. More...
 
void setPointRepresentation (const PointRepresentationConstPtr &point_representation)
 Provide a pointer to the point representation to use to convert points into k-D vectors. More...
 
PointRepresentationConstPtr getPointRepresentation () const
 Get a pointer to the point representation used when converting points into k-D vectors. More...
 
virtual ~KdTree ()=default
 Destructor for KdTree. More...
 
virtual int nearestKSearch (const PointT &p_q, unsigned int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const =0
 Search for k-nearest neighbors for the given query point. More...
 
virtual int nearestKSearch (const PointCloud &cloud, int index, unsigned int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const
 Search for k-nearest neighbors for the given query point. More...
 
template<typename PointTDiff >
int nearestKSearchT (const PointTDiff &point, unsigned int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const
 Search for k-nearest neighbors for the given query point. More...
 
virtual int nearestKSearch (int index, unsigned int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const
 Search for k-nearest neighbors for the given query point (zero-copy). More...
 
virtual int radiusSearch (const PointT &p_q, double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const =0
 Search for all the nearest neighbors of the query point in a given radius. More...
 
virtual int radiusSearch (const PointCloud &cloud, int index, double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const
 Search for all the nearest neighbors of the query point in a given radius. More...
 
template<typename PointTDiff >
int radiusSearchT (const PointTDiff &point, double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const
 Search for all the nearest neighbors of the query point in a given radius. More...
 
virtual int radiusSearch (int index, double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const
 Search for all the nearest neighbors of the query point in a given radius (zero-copy). More...
 
virtual void setEpsilon (float eps)
 Set the search epsilon precision (error bound) for nearest neighbors searches. More...
 
float getEpsilon () const
 Get the search epsilon precision (error bound) for nearest neighbors searches. More...
 
void setMinPts (int min_pts)
 Minimum allowed number of k nearest neighbors points that a viable result must contain. More...
 
int getMinPts () const
 Get the minimum allowed number of k nearest neighbors points that a viable result must contain. More...
 
bool getSortedResults () const
 Gets whether the results should be sorted (ascending in the distance) or not Otherwise the results may be returned in any order. More...
 

Protected Member Functions

virtual std::string getName () const =0
 Class getName method. More...
 

Protected Attributes

PointCloudConstPtr input_
 The input point cloud dataset containing the points we need to use. More...
 
IndicesConstPtr indices_
 A pointer to the vector of point indices to use. More...
 
float epsilon_ {0.0f}
 Epsilon precision (error bound) for nearest neighbors searches. More...
 
int min_pts_ {1}
 Minimum allowed number of k nearest neighbors points that a viable result must contain. More...
 
bool sorted_
 Return the radius search neighbours sorted. More...
 
PointRepresentationConstPtr point_representation_
 For converting different point structures into k-dimensional vectors for nearest-neighbor search. More...
 

Detailed Description

template<typename PointT>
class pcl::KdTree< PointT >

KdTree represents the base spatial locator class for kd-tree implementations.

Author
Radu B Rusu, Bastian Steder, Michael Dixon

Definition at line 55 of file kdtree.h.

Member Typedef Documentation

◆ ConstPtr

template<typename PointT >
using pcl::KdTree< PointT >::ConstPtr = shared_ptr<const KdTree<PointT> >

Definition at line 70 of file kdtree.h.

◆ IndicesConstPtr

template<typename PointT >
using pcl::KdTree< PointT >::IndicesConstPtr = shared_ptr<const Indices >

Definition at line 59 of file kdtree.h.

◆ IndicesPtr

template<typename PointT >
using pcl::KdTree< PointT >::IndicesPtr = shared_ptr<Indices >

Definition at line 58 of file kdtree.h.

◆ PointCloud

template<typename PointT >
using pcl::KdTree< PointT >::PointCloud = pcl::PointCloud<PointT>

Definition at line 61 of file kdtree.h.

◆ PointCloudConstPtr

template<typename PointT >
using pcl::KdTree< PointT >::PointCloudConstPtr = typename PointCloud::ConstPtr

Definition at line 63 of file kdtree.h.

◆ PointCloudPtr

template<typename PointT >
using pcl::KdTree< PointT >::PointCloudPtr = typename PointCloud::Ptr

Definition at line 62 of file kdtree.h.

◆ PointRepresentation

template<typename PointT >
using pcl::KdTree< PointT >::PointRepresentation = pcl::PointRepresentation<PointT>

Definition at line 65 of file kdtree.h.

◆ PointRepresentationConstPtr

template<typename PointT >
using pcl::KdTree< PointT >::PointRepresentationConstPtr = typename PointRepresentation::ConstPtr

Definition at line 66 of file kdtree.h.

◆ Ptr

template<typename PointT >
using pcl::KdTree< PointT >::Ptr = shared_ptr<KdTree<PointT> >

Definition at line 69 of file kdtree.h.

Constructor & Destructor Documentation

◆ KdTree()

template<typename PointT >
pcl::KdTree< PointT >::KdTree ( bool  sorted = true)
inline

Empty constructor for KdTree.

Sets some internal values to their defaults.

Parameters
[in]sortedset to true if the application that the tree will be used for requires sorted nearest neighbor indices (default). False otherwise.

Definition at line 75 of file kdtree.h.

◆ ~KdTree()

template<typename PointT >
virtual pcl::KdTree< PointT >::~KdTree ( )
virtualdefault

Destructor for KdTree.

Deletes all allocated data arrays and destroys the kd-tree structures.

Member Function Documentation

◆ getEpsilon()

template<typename PointT >
float pcl::KdTree< PointT >::getEpsilon ( ) const
inline

Get the search epsilon precision (error bound) for nearest neighbors searches.

Definition at line 314 of file kdtree.h.

References pcl::KdTree< PointT >::epsilon_.

◆ getIndices()

template<typename PointT >
IndicesConstPtr pcl::KdTree< PointT >::getIndices ( ) const
inline

Get a pointer to the vector of indices used.

Definition at line 94 of file kdtree.h.

References pcl::KdTree< PointT >::indices_.

Referenced by pcl::extractEuclideanClusters().

◆ getInputCloud()

template<typename PointT >
PointCloudConstPtr pcl::KdTree< PointT >::getInputCloud ( ) const
inline

Get a pointer to the input point cloud dataset.

Definition at line 101 of file kdtree.h.

References pcl::KdTree< PointT >::input_.

Referenced by pcl::extractEuclideanClusters().

◆ getMinPts()

template<typename PointT >
int pcl::KdTree< PointT >::getMinPts ( ) const
inline

Get the minimum allowed number of k nearest neighbors points that a viable result must contain.

Definition at line 330 of file kdtree.h.

References pcl::KdTree< PointT >::min_pts_.

◆ getName()

template<typename PointT >
virtual std::string pcl::KdTree< PointT >::getName ( ) const
protectedpure virtual

Class getName method.

◆ getPointRepresentation()

template<typename PointT >
PointRepresentationConstPtr pcl::KdTree< PointT >::getPointRepresentation ( ) const
inline

Get a pointer to the point representation used when converting points into k-D vectors.

Definition at line 119 of file kdtree.h.

References pcl::KdTree< PointT >::point_representation_.

◆ getSortedResults()

template<typename PointT >
bool pcl::KdTree< PointT >::getSortedResults ( ) const
inline

Gets whether the results should be sorted (ascending in the distance) or not Otherwise the results may be returned in any order.

Definition at line 339 of file kdtree.h.

References pcl::KdTree< PointT >::sorted_.

Referenced by pcl::extractEuclideanClusters().

◆ nearestKSearch() [1/3]

template<typename PointT >
virtual int pcl::KdTree< PointT >::nearestKSearch ( const PointCloud cloud,
int  index,
unsigned int  k,
Indices k_indices,
std::vector< float > &  k_sqr_distances 
) const
inlinevirtual

Search for k-nearest neighbors for the given query point.

Attention
This method does not do any bounds checking for the input index (i.e., index >= cloud.size () || index < 0), and assumes valid (i.e., finite) data.
Parameters
[in]cloudthe point cloud data
[in]indexa valid index in cloud representing a valid (i.e., finite) query point
[in]kthe number of neighbors to search for
[out]k_indicesthe resultant indices of the neighboring points (must be resized to k a priori!)
[out]k_sqr_distancesthe resultant squared distances to the neighboring points (must be resized to k a priori!)
Returns
number of neighbors found
Exceptions
assertsin debug mode if the index is not between 0 and the maximum number of points

Definition at line 156 of file kdtree.h.

References pcl::KdTree< PointT >::nearestKSearch(), and pcl::PointCloud< PointT >::size().

◆ nearestKSearch() [2/3]

template<typename PointT >
virtual int pcl::KdTree< PointT >::nearestKSearch ( const PointT p_q,
unsigned int  k,
Indices k_indices,
std::vector< float > &  k_sqr_distances 
) const
pure virtual

Search for k-nearest neighbors for the given query point.

Parameters
[in]p_qthe given query point
[in]kthe number of neighbors to search for
[out]k_indicesthe resultant indices of the neighboring points (must be resized to k a priori!)
[out]k_sqr_distancesthe resultant squared distances to the neighboring points (must be resized to k a priori!)
Returns
number of neighbors found

Implemented in pcl::KdTreeFLANN< PointTarget >, pcl::KdTreeFLANN< PointT, Dist >, pcl::KdTreeFLANN< pcl::VFHSignature308 >, pcl::KdTreeFLANN< pcl::PointXYZRGB >, pcl::KdTreeFLANN< pcl::PointXYZLAB >, pcl::KdTreeFLANN< pcl::InterestPoint >, and pcl::KdTreeFLANN< FeatureT >.

Referenced by pcl::KdTree< PointT >::nearestKSearch(), and pcl::KdTree< PointT >::nearestKSearchT().

◆ nearestKSearch() [3/3]

template<typename PointT >
virtual int pcl::KdTree< PointT >::nearestKSearch ( int  index,
unsigned int  k,
Indices k_indices,
std::vector< float > &  k_sqr_distances 
) const
inlinevirtual

Search for k-nearest neighbors for the given query point (zero-copy).

Attention
This method does not do any bounds checking for the input index (i.e., index >= cloud.size () || index < 0), and assumes valid (i.e., finite) data.
Parameters
[in]indexa valid index representing a valid query point in the dataset given by setInputCloud. If indices were given in setInputCloud, index will be the position in the indices vector.
[in]kthe number of neighbors to search for
[out]k_indicesthe resultant indices of the neighboring points (must be resized to k a priori!)
[out]k_sqr_distancesthe resultant squared distances to the neighboring points (must be resized to k a priori!)
Returns
number of neighbors found
Exceptions
assertsin debug mode if the index is not between 0 and the maximum number of points

Definition at line 199 of file kdtree.h.

References pcl::KdTree< PointT >::indices_, pcl::KdTree< PointT >::input_, and pcl::KdTree< PointT >::nearestKSearch().

◆ nearestKSearchT()

template<typename PointT >
template<typename PointTDiff >
int pcl::KdTree< PointT >::nearestKSearchT ( const PointTDiff &  point,
unsigned int  k,
Indices k_indices,
std::vector< float > &  k_sqr_distances 
) const
inline

Search for k-nearest neighbors for the given query point.

This method accepts a different template parameter for the point type.

Parameters
[in]pointthe given query point
[in]kthe number of neighbors to search for
[out]k_indicesthe resultant indices of the neighboring points (must be resized to k a priori!)
[out]k_sqr_distancesthe resultant squared distances to the neighboring points (must be resized to k a priori!)
Returns
number of neighbors found

Definition at line 173 of file kdtree.h.

References pcl::copyPoint(), and pcl::KdTree< PointT >::nearestKSearch().

Referenced by pcl::getApproximateIndices().

◆ radiusSearch() [1/3]

template<typename PointT >
virtual int pcl::KdTree< PointT >::radiusSearch ( const PointCloud cloud,
int  index,
double  radius,
Indices k_indices,
std::vector< float > &  k_sqr_distances,
unsigned int  max_nn = 0 
) const
inlinevirtual

Search for all the nearest neighbors of the query point in a given radius.

Attention
This method does not do any bounds checking for the input index (i.e., index >= cloud.size () || index < 0), and assumes valid (i.e., finite) data.
Parameters
[in]cloudthe point cloud data
[in]indexa valid index in cloud representing a valid (i.e., finite) query point
[in]radiusthe radius of the sphere bounding all of p_q's neighbors
[out]k_indicesthe resultant indices of the neighboring points
[out]k_sqr_distancesthe resultant squared distances to the neighboring points
[in]max_nnif given, bounds the maximum returned neighbors to this value. If max_nn is set to 0 or to a number higher than the number of points in the input cloud, all neighbors in radius will be returned.
Returns
number of neighbors found in radius
Exceptions
assertsin debug mode if the index is not between 0 and the maximum number of points

Definition at line 244 of file kdtree.h.

References pcl::KdTree< PointT >::radiusSearch(), and pcl::PointCloud< PointT >::size().

◆ radiusSearch() [2/3]

template<typename PointT >
virtual int pcl::KdTree< PointT >::radiusSearch ( const PointT p_q,
double  radius,
Indices k_indices,
std::vector< float > &  k_sqr_distances,
unsigned int  max_nn = 0 
) const
pure virtual

Search for all the nearest neighbors of the query point in a given radius.

Parameters
[in]p_qthe given query point
[in]radiusthe radius of the sphere bounding all of p_q's neighbors
[out]k_indicesthe resultant indices of the neighboring points
[out]k_sqr_distancesthe resultant squared distances to the neighboring points
[in]max_nnif given, bounds the maximum returned neighbors to this value. If max_nn is set to 0 or to a number higher than the number of points in the input cloud, all neighbors in radius will be returned.
Returns
number of neighbors found in radius

Implemented in pcl::KdTreeFLANN< PointTarget >, pcl::KdTreeFLANN< PointT, Dist >, pcl::KdTreeFLANN< pcl::VFHSignature308 >, pcl::KdTreeFLANN< pcl::PointXYZRGB >, pcl::KdTreeFLANN< pcl::PointXYZLAB >, pcl::KdTreeFLANN< pcl::InterestPoint >, and pcl::KdTreeFLANN< FeatureT >.

Referenced by pcl::extractEuclideanClusters(), pcl::KdTree< PointT >::radiusSearch(), and pcl::KdTree< PointT >::radiusSearchT().

◆ radiusSearch() [3/3]

template<typename PointT >
virtual int pcl::KdTree< PointT >::radiusSearch ( int  index,
double  radius,
Indices k_indices,
std::vector< float > &  k_sqr_distances,
unsigned int  max_nn = 0 
) const
inlinevirtual

Search for all the nearest neighbors of the query point in a given radius (zero-copy).

Attention
This method does not do any bounds checking for the input index (i.e., index >= cloud.size () || index < 0), and assumes valid (i.e., finite) data.
Parameters
[in]indexa valid index representing a valid query point in the dataset given by setInputCloud. If indices were given in setInputCloud, index will be the position in the indices vector.
[in]radiusthe radius of the sphere bounding all of p_q's neighbors
[out]k_indicesthe resultant indices of the neighboring points
[out]k_sqr_distancesthe resultant squared distances to the neighboring points
[in]max_nnif given, bounds the maximum returned neighbors to this value. If max_nn is set to 0 or to a number higher than the number of points in the input cloud, all neighbors in radius will be returned.
Returns
number of neighbors found in radius
Exceptions
assertsin debug mode if the index is not between 0 and the maximum number of points

Definition at line 291 of file kdtree.h.

References pcl::KdTree< PointT >::indices_, pcl::KdTree< PointT >::input_, and pcl::KdTree< PointT >::radiusSearch().

◆ radiusSearchT()

template<typename PointT >
template<typename PointTDiff >
int pcl::KdTree< PointT >::radiusSearchT ( const PointTDiff &  point,
double  radius,
Indices k_indices,
std::vector< float > &  k_sqr_distances,
unsigned int  max_nn = 0 
) const
inline

Search for all the nearest neighbors of the query point in a given radius.

Parameters
[in]pointthe given query point
[in]radiusthe radius of the sphere bounding all of p_q's neighbors
[out]k_indicesthe resultant indices of the neighboring points
[out]k_sqr_distancesthe resultant squared distances to the neighboring points
[in]max_nnif given, bounds the maximum returned neighbors to this value. If max_nn is set to 0 or to a number higher than the number of points in the input cloud, all neighbors in radius will be returned.
Returns
number of neighbors found in radius

Definition at line 263 of file kdtree.h.

References pcl::copyPoint(), and pcl::KdTree< PointT >::radiusSearch().

◆ setEpsilon()

template<typename PointT >
virtual void pcl::KdTree< PointT >::setEpsilon ( float  eps)
inlinevirtual

Set the search epsilon precision (error bound) for nearest neighbors searches.

Parameters
[in]epsprecision (error bound) for nearest neighbors searches

Reimplemented in pcl::KdTreeFLANN< PointT, Dist >, pcl::KdTreeFLANN< pcl::PointXYZRGB >, pcl::KdTreeFLANN< pcl::VFHSignature308 >, pcl::KdTreeFLANN< PointTarget >, pcl::KdTreeFLANN< pcl::PointXYZLAB >, pcl::KdTreeFLANN< pcl::InterestPoint >, and pcl::KdTreeFLANN< FeatureT >.

Definition at line 307 of file kdtree.h.

References pcl::KdTree< PointT >::epsilon_.

◆ setInputCloud()

template<typename PointT >
virtual void pcl::KdTree< PointT >::setInputCloud ( const PointCloudConstPtr cloud,
const IndicesConstPtr indices = IndicesConstPtr () 
)
inlinevirtual

Provide a pointer to the input dataset.

Parameters
[in]cloudthe const boost shared pointer to a PointCloud message
[in]indicesthe point indices subset that is to be used from cloud - if NULL the whole cloud is used

Reimplemented in pcl::KdTreeFLANN< PointT, Dist >, pcl::KdTreeFLANN< pcl::PointXYZRGB >, pcl::KdTreeFLANN< pcl::VFHSignature308 >, pcl::KdTreeFLANN< PointTarget >, pcl::KdTreeFLANN< pcl::PointXYZLAB >, pcl::KdTreeFLANN< pcl::InterestPoint >, and pcl::KdTreeFLANN< FeatureT >.

Definition at line 86 of file kdtree.h.

References pcl::KdTree< PointT >::indices_, and pcl::KdTree< PointT >::input_.

Referenced by pcl::KdTree< PointT >::setPointRepresentation().

◆ setMinPts()

template<typename PointT >
void pcl::KdTree< PointT >::setMinPts ( int  min_pts)
inline

Minimum allowed number of k nearest neighbors points that a viable result must contain.

Parameters
[in]min_ptsthe minimum number of neighbors in a viable neighborhood

Definition at line 323 of file kdtree.h.

References pcl::KdTree< PointT >::min_pts_.

◆ setPointRepresentation()

template<typename PointT >
void pcl::KdTree< PointT >::setPointRepresentation ( const PointRepresentationConstPtr point_representation)
inline

Provide a pointer to the point representation to use to convert points into k-D vectors.

Parameters
[in]point_representationthe const boost shared pointer to a PointRepresentation

Definition at line 110 of file kdtree.h.

References pcl::KdTree< PointT >::indices_, pcl::KdTree< PointT >::input_, pcl::KdTree< PointT >::point_representation_, and pcl::KdTree< PointT >::setInputCloud().

Member Data Documentation

◆ epsilon_

template<typename PointT >
float pcl::KdTree< PointT >::epsilon_ {0.0f}
protected

Epsilon precision (error bound) for nearest neighbors searches.

Definition at line 352 of file kdtree.h.

Referenced by pcl::KdTree< PointT >::getEpsilon(), and pcl::KdTree< PointT >::setEpsilon().

◆ indices_

template<typename PointT >
IndicesConstPtr pcl::KdTree< PointT >::indices_
protected

◆ input_

template<typename PointT >
PointCloudConstPtr pcl::KdTree< PointT >::input_
protected

◆ min_pts_

template<typename PointT >
int pcl::KdTree< PointT >::min_pts_ {1}
protected

Minimum allowed number of k nearest neighbors points that a viable result must contain.

Definition at line 355 of file kdtree.h.

Referenced by pcl::KdTree< PointT >::getMinPts(), and pcl::KdTree< PointT >::setMinPts().

◆ point_representation_

template<typename PointT >
PointRepresentationConstPtr pcl::KdTree< PointT >::point_representation_
protected

For converting different point structures into k-dimensional vectors for nearest-neighbor search.

Definition at line 361 of file kdtree.h.

Referenced by pcl::KdTree< PointT >::getPointRepresentation(), and pcl::KdTree< PointT >::setPointRepresentation().

◆ sorted_

template<typename PointT >
bool pcl::KdTree< PointT >::sorted_
protected

Return the radius search neighbours sorted.

Definition at line 358 of file kdtree.h.

Referenced by pcl::KdTree< PointT >::getSortedResults().


The documentation for this class was generated from the following file: