39 #ifndef PCL_SEARCH_SEARCH_H_
40 #define PCL_SEARCH_SEARCH_H_
42 #include <pcl/point_cloud.h>
43 #include <pcl/for_each_type.h>
44 #include <pcl/common/concatenate.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&
123 virtual PointCloudConstPtr
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
188 std::vector<int> &k_indices,
189 std::vector<float> &k_sqr_distances)
const;
210 std::vector<int> &k_indices,
211 std::vector<float> &k_sqr_distances)
const;
222 int k, std::vector< std::vector<int> >& k_indices,
223 std::vector< std::vector<float> >& k_sqr_distances)
const;
233 template <
typename Po
intTDiff>
void
235 std::vector< std::vector<float> > &k_sqr_distances)
const
243 if (indices.empty ())
246 for (
size_t i = 0; i < cloud.
size(); i++)
251 nearestKSearch (pc,std::vector<int>(),k,k_indices,k_sqr_distances);
255 pc.
resize (indices.size());
256 for (
size_t i = 0; i < indices.size(); i++)
259 cloud[indices[i]], pc[i]));
261 nearestKSearch (pc,std::vector<int>(),k,k_indices,k_sqr_distances);
277 std::vector<float>& k_sqr_distances,
unsigned int max_nn = 0)
const = 0;
289 template <
typename Po
intTDiff>
inline int
290 radiusSearchT (
const PointTDiff &point,
double radius, std::vector<int> &k_indices,
291 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const
299 return (
radiusSearch (p, radius, k_indices, k_sqr_distances, max_nn));
321 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
322 unsigned int max_nn = 0)
const;
344 radiusSearch (
int index,
double radius, std::vector<int> &k_indices,
345 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const;
359 const std::vector<int>& indices,
361 std::vector< std::vector<int> >& k_indices,
362 std::vector< std::vector<float> > &k_sqr_distances,
363 unsigned int max_nn = 0)
const;
376 template <
typename Po
intTDiff>
void
378 const std::vector<int>& indices,
380 std::vector< std::vector<int> > &k_indices,
381 std::vector< std::vector<float> > &k_sqr_distances,
382 unsigned int max_nn = 0)
const
390 if (indices.empty ())
393 for (
size_t i = 0; i < cloud.
size (); ++i)
395 radiusSearch (pc, std::vector<int> (), radius, k_indices, k_sqr_distances, max_nn);
399 pc.
resize (indices.size ());
400 for (
size_t i = 0; i < indices.size (); ++i)
402 radiusSearch (pc, std::vector<int>(), radius, k_indices, k_sqr_distances, max_nn);
408 sortResults (std::vector<int>& indices, std::vector<float>& distances)
const;
418 Compare (
const std::vector<float>& distances)
419 : distances_ (distances)
424 operator () (
int first,
int second)
const
426 return (distances_ [first] < distances_[second]);
429 const std::vector<float>& distances_;
435 #ifdef PCL_NO_PRECOMPILE
436 #include <pcl/search/impl/search.hpp>
439 #endif //#ifndef _PCL_SEARCH_SEARCH_H_
Search(const std::string &name="", bool sorted=false)
Constructor.
void resize(size_t n)
Resize the cloud.
PointCloudConstPtr input_
Helper functor structure for concatenate.
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.
void sortResults(std::vector< int > &indices, std::vector< float > &distances) const
boost::shared_ptr< const pcl::search::Search< PointT > > ConstPtr
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.
PointCloud::ConstPtr PointCloudConstPtr
boost::shared_ptr< const std::vector< int > > IndicesConstPtr
pcl::PointCloud< PointT > PointCloud
virtual ~Search()
Destructor.
virtual void setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr())
Pass the input dataset that the search will be performed on.
boost::shared_ptr< pcl::search::Search< PointT > > Ptr
boost::shared_ptr< PointCloud< PointT > > Ptr
boost::shared_ptr< const std::vector< int > > IndicesConstPtr
virtual const std::string & getName() const
Returns the search method name.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
virtual IndicesConstPtr getIndices() const
Get a pointer to the vector of indices used.
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.
virtual void setSortedResults(bool sorted)
sets whether the results should be sorted (ascending in the distance) or not
virtual PointCloudConstPtr getInputCloud() const
Get a pointer to the input point cloud dataset.
boost::shared_ptr< std::vector< int > > IndicesPtr
boost::mpl::remove_if< Sequence1, boost::mpl::not_< boost::mpl::contains< Sequence2, boost::mpl::_1 > > >::type type
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.
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.
virtual bool getSortedResults()
Gets whether the results should be sorted (ascending in the distance) or not Otherwise the results ma...
PointCloud::Ptr PointCloudPtr
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.
A point structure representing Euclidean xyz coordinates, and the RGB color.