39 #ifndef PCL_KDTREE_KDTREE_H_
40 #define PCL_KDTREE_KDTREE_H_
43 #include <pcl/pcl_macros.h>
44 #include <pcl/point_cloud.h>
45 #include <pcl/point_representation.h>
46 #include <pcl/common/io.h>
47 #include <pcl/common/copy_point.h>
55 template <
typename Po
intT>
59 typedef boost::shared_ptr <std::vector<int> >
IndicesPtr;
71 typedef boost::shared_ptr<KdTree<PointT> >
Ptr;
72 typedef boost::shared_ptr<const KdTree<PointT> >
ConstPtr;
88 setInputCloud (
const PointCloudConstPtr &cloud,
const IndicesConstPtr &indices = IndicesConstPtr ())
95 inline IndicesConstPtr
102 inline PointCloudConstPtr
120 inline PointRepresentationConstPtr
139 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
const = 0;
159 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
const
161 assert (index >= 0 && index < static_cast<int> (cloud.
points.size ()) &&
"Out-of-bounds error in nearestKSearch!");
174 template <
typename Po
intTDiff>
inline int
176 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
const
202 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
const
206 assert (index >= 0 && index < static_cast<int> (
input_->points.size ()) &&
"Out-of-bounds error in nearestKSearch!");
211 assert (index >= 0 && index < static_cast<int> (
indices_->size ()) &&
"Out-of-bounds error in nearestKSearch!");
228 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const = 0;
249 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
250 unsigned int max_nn = 0)
const
252 assert (index >= 0 && index < static_cast<int> (cloud.
points.size ()) &&
"Out-of-bounds error in radiusSearch!");
253 return (
radiusSearch(cloud.
points[index], radius, k_indices, k_sqr_distances, max_nn));
266 template <
typename Po
intTDiff>
inline int
267 radiusSearchT (
const PointTDiff &point,
double radius, std::vector<int> &k_indices,
268 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const
272 return (
radiusSearch (p, radius, k_indices, k_sqr_distances, max_nn));
296 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const
300 assert (index >= 0 && index < static_cast<int> (
input_->points.size ()) &&
"Out-of-bounds error in radiusSearch!");
301 return (
radiusSearch (
input_->points[index], radius, k_indices, k_sqr_distances, max_nn));
305 assert (index >= 0 && index < static_cast<int> (
indices_->size ()) &&
"Out-of-bounds error in radiusSearch!");
367 #endif //#ifndef _PCL_KDTREE_KDTREE_H_
boost::shared_ptr< std::vector< int > > IndicesPtr
pcl::PointCloud< PointT > PointCloud
virtual int radiusSearch(const PointT &p_q, double radius, std::vector< int > &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.
float getEpsilon() const
Get the search epsilon precision (error bound) for nearest neighbors searches.
bool sorted_
Return the radius search neighbours sorted.
This file defines compatibility wrappers for low level I/O functions.
void setPointRepresentation(const PointRepresentationConstPtr &point_representation)
Provide a pointer to the point representation to use to convert points into k-D vectors.
boost::shared_ptr< KdTree< PointT > > Ptr
virtual ~KdTree()
Destructor for KdTree.
PointCloudConstPtr getInputCloud() const
Get a pointer to the input point cloud dataset.
virtual int nearestKSearch(const PointCloud &cloud, int index, int k, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances) const
Search for k-nearest neighbors for the given query point.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
IndicesConstPtr getIndices() const
Get a pointer to the vector of indices used.
PointRepresentation provides a set of methods for converting a point structs/object into an n-dimensi...
int min_pts_
Minimum allowed number of k nearest neighbors points that a viable result must contain.
float epsilon_
Epsilon precision (error bound) for nearest neighbors searches.
virtual void setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr())
Provide a pointer to the input dataset.
PointRepresentationConstPtr point_representation_
For converting different point structures into k-dimensional vectors for nearest-neighbor search...
virtual int radiusSearch(const PointCloud &cloud, int index, double radius, std::vector< int > &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.
PointRepresentationConstPtr getPointRepresentation() const
Get a pointer to the point representation used when converting points into k-D vectors.
virtual int nearestKSearch(const PointT &p_q, int k, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances) const =0
Search for k-nearest neighbors for the given query point.
int getMinPts() const
Get the minimum allowed number of k nearest neighbors points that a viable result must contain...
PointCloudConstPtr input_
The input point cloud dataset containing the points we need to use.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
virtual int radiusSearch(int index, double radius, std::vector< int > &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).
virtual std::string getName() const =0
Class getName method.
IndicesConstPtr indices_
A pointer to the vector of point indices to use.
boost::shared_ptr< const PointRepresentation > PointRepresentationConstPtr
virtual int nearestKSearch(int index, int k, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances) const
Search for k-nearest neighbors for the given query point (zero-copy).
DefaultPointRepresentation extends PointRepresentation to define default behavior for common point ty...
int nearestKSearchT(const PointTDiff &point, int k, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances) const
Search for k-nearest neighbors for the given query point.
boost::shared_ptr< const std::vector< int > > IndicesConstPtr
virtual void setEpsilon(float eps)
Set the search epsilon precision (error bound) for nearest neighbors searches.
A point structure representing Euclidean xyz coordinates, and the RGB color.
void setMinPts(int min_pts)
Minimum allowed number of k nearest neighbors points that a viable result must contain.
boost::shared_ptr< PointCloud > PointCloudPtr
boost::shared_ptr< const KdTree< PointT > > ConstPtr
pcl::PointRepresentation< PointT > PointRepresentation
void copyPoint(const PointInT &point_in, PointOutT &point_out)
Copy the fields of a source point into a target point.
KdTree represents the base spatial locator class for kd-tree implementations.
KdTree(bool sorted=true)
Empty constructor for KdTree.
boost::shared_ptr< const PointCloud > PointCloudConstPtr
int radiusSearchT(const PointTDiff &point, double radius, std::vector< int > &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.