41 #include <pcl/point_cloud.h> 42 #include <pcl/for_each_type.h> 43 #include <pcl/common/concatenate.h> 44 #include <pcl/common/copy_point.h> 72 template<
typename Po
intT>
80 typedef boost::shared_ptr<pcl::search::Search<PointT> >
Ptr;
81 typedef boost::shared_ptr<const pcl::search::Search<PointT> >
ConstPtr;
87 Search (
const std::string& name =
"",
bool sorted =
false);
97 virtual const std::string&
120 const IndicesConstPtr &indices = IndicesConstPtr ());
123 virtual PointCloudConstPtr
130 virtual IndicesConstPtr
146 std::vector<float> &k_sqr_distances)
const = 0;
157 template <
typename Po
intTDiff>
inline int 159 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
const 184 std::vector<int> &k_indices,
185 std::vector<float> &k_sqr_distances)
const;
206 std::vector<int> &k_indices,
207 std::vector<float> &k_sqr_distances)
const;
217 nearestKSearch (
const PointCloud& cloud,
const std::vector<int>& indices,
218 int k, std::vector< std::vector<int> >& k_indices,
219 std::vector< std::vector<float> >& k_sqr_distances)
const;
229 template <
typename Po
intTDiff>
void 231 std::vector< std::vector<float> > &k_sqr_distances)
const 239 if (indices.empty ())
242 for (
size_t i = 0; i < cloud.
size(); i++)
247 nearestKSearch (pc,std::vector<int>(),k,k_indices,k_sqr_distances);
251 pc.
resize (indices.size());
252 for (
size_t i = 0; i < indices.size(); i++)
255 cloud[indices[i]], pc[i]));
257 nearestKSearch (pc,std::vector<int>(),k,k_indices,k_sqr_distances);
273 std::vector<float>& k_sqr_distances,
unsigned int max_nn = 0)
const = 0;
285 template <
typename Po
intTDiff>
inline int 286 radiusSearchT (
const PointTDiff &point,
double radius, std::vector<int> &k_indices,
287 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const 291 return (
radiusSearch (p, radius, k_indices, k_sqr_distances, max_nn));
312 radiusSearch (
const PointCloud &cloud,
int index,
double radius,
313 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
314 unsigned int max_nn = 0)
const;
336 radiusSearch (
int index,
double radius, std::vector<int> &k_indices,
337 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const;
351 const std::vector<int>& indices,
353 std::vector< std::vector<int> >& k_indices,
354 std::vector< std::vector<float> > &k_sqr_distances,
355 unsigned int max_nn = 0)
const;
368 template <
typename Po
intTDiff>
void 370 const std::vector<int>& indices,
372 std::vector< std::vector<int> > &k_indices,
373 std::vector< std::vector<float> > &k_sqr_distances,
374 unsigned int max_nn = 0)
const 382 if (indices.empty ())
385 for (
size_t i = 0; i < cloud.
size (); ++i)
387 radiusSearch (pc, std::vector<int> (), radius, k_indices, k_sqr_distances, max_nn);
391 pc.
resize (indices.size ());
392 for (
size_t i = 0; i < indices.size (); ++i)
394 radiusSearch (pc, std::vector<int>(), radius, k_indices, k_sqr_distances, max_nn);
400 sortResults (std::vector<int>& indices, std::vector<float>& distances)
const;
410 Compare (
const std::vector<float>& distances)
411 : distances_ (distances)
416 operator () (
int first,
int second)
const 418 return (distances_ [first] < distances_[second]);
421 const std::vector<float>& distances_;
427 #ifdef PCL_NO_PRECOMPILE 428 #include <pcl/search/impl/search.hpp> void nearestKSearchT(const pcl::PointCloud< PointTDiff > &cloud, const std::vector< int > &indices, int k, std::vector< std::vector< int > > &k_indices, std::vector< std::vector< float > > &k_sqr_distances) const
Search for the k-nearest neighbors for the given query point.
PointCloud::ConstPtr PointCloudConstPtr
virtual const std::string & getName() const
Returns the search method name.
boost::shared_ptr< const std::vector< int > > IndicesConstPtr
pcl::PointCloud< PointT > PointCloud
boost::shared_ptr< std::vector< int > > IndicesPtr
virtual bool getSortedResults()
Gets whether the results should be sorted (ascending in the distance) or not Otherwise the results ma...
virtual void setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr())
Pass the input dataset that the search will be performed on.
This file defines compatibility wrappers for low level I/O functions.
virtual int radiusSearch(const PointT &point, 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.
virtual ~Search()
Destructor.
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.
PointCloudConstPtr input_
virtual IndicesConstPtr getIndices() const
Get a pointer to the vector of indices used.
virtual void setSortedResults(bool sorted)
sets whether the results should be sorted (ascending in the distance) or not
boost::shared_ptr< PointCloud< PointT > > Ptr
PointCloud::Ptr PointCloudPtr
boost::shared_ptr< pcl::search::Search< PointT > > Ptr
boost::mpl::remove_if< Sequence1, boost::mpl::not_< boost::mpl::contains< Sequence2, boost::mpl::_1 > > >::type type
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
virtual PointCloudConstPtr getInputCloud() const
Get a pointer to the input point cloud dataset.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
void radiusSearchT(const pcl::PointCloud< PointTDiff > &cloud, const std::vector< int > &indices, double radius, std::vector< std::vector< int > > &k_indices, std::vector< std::vector< float > > &k_sqr_distances, unsigned int max_nn=0) const
Search for all the nearest neighbors of the query points in a given radius.
virtual int nearestKSearch(const PointT &point, int k, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances) const =0
Search for the k-nearest neighbors for the given query point.
void sortResults(std::vector< int > &indices, std::vector< float > &distances) const
boost::shared_ptr< const pcl::search::Search< PointT > > ConstPtr
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.
void resize(size_t n)
Resize the cloud.
A point structure representing Euclidean xyz coordinates, and the RGB color.
Search(const std::string &name="", bool sorted=false)
Constructor.
Helper functor structure for concatenate.
void copyPoint(const PointInT &point_in, PointOutT &point_out)
Copy the fields of a source point into a target point.