43 #include <pcl/point_cloud.h>
44 #include <pcl/point_representation.h>
45 #include <pcl/common/copy_point.h>
54 template <
typename Po
intT>
69 using Ptr = shared_ptr<KdTree<PointT> >;
70 using ConstPtr = shared_ptr<const KdTree<PointT> >;
100 inline PointCloudConstPtr
137 Indices &k_indices, std::vector<float> &k_sqr_distances)
const = 0;
157 Indices &k_indices, std::vector<float> &k_sqr_distances)
const
159 assert (index >= 0 && index <
static_cast<int> (cloud.
size ()) &&
"Out-of-bounds error in nearestKSearch!");
160 return (
nearestKSearch (cloud[index], k, k_indices, k_sqr_distances));
172 template <
typename Po
intTDiff>
inline int
174 Indices &k_indices, std::vector<float> &k_sqr_distances)
const
200 Indices &k_indices, std::vector<float> &k_sqr_distances)
const
204 assert (index >= 0 && index <
static_cast<int> (
input_->size ()) &&
"Out-of-bounds error in nearestKSearch!");
207 assert (index >= 0 && index <
static_cast<int> (
indices_->size ()) &&
"Out-of-bounds error in nearestKSearch!");
224 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const = 0;
245 Indices &k_indices, std::vector<float> &k_sqr_distances,
246 unsigned int max_nn = 0)
const
248 assert (index >= 0 && index <
static_cast<int> (cloud.
size ()) &&
"Out-of-bounds error in radiusSearch!");
249 return (
radiusSearch(cloud[index], radius, k_indices, k_sqr_distances, max_nn));
262 template <
typename Po
intTDiff>
inline int
264 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const
268 return (
radiusSearch (p, radius, k_indices, k_sqr_distances, max_nn));
292 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const
296 assert (index >= 0 && index <
static_cast<int> (
input_->size ()) &&
"Out-of-bounds error in radiusSearch!");
299 assert (index >= 0 && index <
static_cast<int> (
indices_->size ()) &&
"Out-of-bounds error in radiusSearch!");
DefaultPointRepresentation extends PointRepresentation to define default behavior for common point ty...
KdTree represents the base spatial locator class for kd-tree implementations.
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).
shared_ptr< const Indices > IndicesConstPtr
PointRepresentationConstPtr point_representation_
For converting different point structures into k-dimensional vectors for nearest-neighbor search.
PointCloudConstPtr getInputCloud() const
Get a pointer to the input point cloud dataset.
KdTree(bool sorted=true)
Empty constructor for KdTree.
typename PointRepresentation::ConstPtr PointRepresentationConstPtr
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).
IndicesConstPtr getIndices() const
Get a pointer to the vector of indices used.
typename PointCloud::ConstPtr PointCloudConstPtr
virtual ~KdTree()=default
Destructor for KdTree.
typename PointCloud::Ptr PointCloudPtr
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.
PointCloudConstPtr input_
The input point cloud dataset containing the points we need to use.
float getEpsilon() const
Get the search epsilon precision (error bound) for nearest neighbors searches.
virtual void setEpsilon(float eps)
Set the search epsilon precision (error bound) for nearest neighbors searches.
float epsilon_
Epsilon precision (error bound) for nearest neighbors searches.
int min_pts_
Minimum allowed number of k nearest neighbors points that a viable result must contain.
shared_ptr< Indices > IndicesPtr
bool getSortedResults() const
Gets whether the results should be sorted (ascending in the distance) or not Otherwise the results ma...
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.
void setPointRepresentation(const PointRepresentationConstPtr &point_representation)
Provide a pointer to the point representation to use to convert points into k-D vectors.
void setMinPts(int min_pts)
Minimum allowed number of k nearest neighbors points that a viable result must contain.
virtual void setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr())
Provide a pointer to the input dataset.
bool sorted_
Return the radius search neighbours sorted.
int getMinPts() const
Get the minimum allowed number of k nearest neighbors points that a viable result must contain.
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.
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.
IndicesConstPtr indices_
A pointer to the vector of point indices to use.
shared_ptr< KdTree< PointT > > Ptr
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.
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.
shared_ptr< const KdTree< PointT > > ConstPtr
virtual std::string getName() const =0
Class getName method.
PointRepresentationConstPtr getPointRepresentation() const
Get a pointer to the point representation used when converting points into k-D vectors.
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
PointRepresentation provides a set of methods for converting a point structs/object into an n-dimensi...
shared_ptr< const PointRepresentation< PointT > > ConstPtr
void copyPoint(const PointInT &point_in, PointOutT &point_out)
Copy the fields of a source point into a target point.
Defines functions, macros and traits for allocating and using memory.
shared_ptr< const Indices > IndicesConstPtr
IndicesAllocator<> Indices
Type used for indices in PCL.
Defines all the PCL and non-PCL macros used.
A point structure representing Euclidean xyz coordinates, and the RGB color.