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> 45 #include <pcl/common/copy_point.h> 73 template<
typename Po
intT>
81 typedef boost::shared_ptr<pcl::search::Search<PointT> >
Ptr;
82 typedef boost::shared_ptr<const pcl::search::Search<PointT> >
ConstPtr;
88 Search (
const std::string& name =
"",
bool sorted =
false);
98 virtual const std::string&
121 const IndicesConstPtr &indices = IndicesConstPtr ());
124 virtual PointCloudConstPtr
131 virtual IndicesConstPtr
147 std::vector<float> &k_sqr_distances)
const = 0;
158 template <
typename Po
intTDiff>
inline int 160 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances)
const 185 std::vector<int> &k_indices,
186 std::vector<float> &k_sqr_distances)
const;
207 std::vector<int> &k_indices,
208 std::vector<float> &k_sqr_distances)
const;
218 nearestKSearch (
const PointCloud& cloud,
const std::vector<int>& indices,
219 int k, std::vector< std::vector<int> >& k_indices,
220 std::vector< std::vector<float> >& k_sqr_distances)
const;
230 template <
typename Po
intTDiff>
void 232 std::vector< std::vector<float> > &k_sqr_distances)
const 240 if (indices.empty ())
243 for (
size_t i = 0; i < cloud.
size(); i++)
248 nearestKSearch (pc,std::vector<int>(),k,k_indices,k_sqr_distances);
252 pc.
resize (indices.size());
253 for (
size_t i = 0; i < indices.size(); i++)
256 cloud[indices[i]], pc[i]));
258 nearestKSearch (pc,std::vector<int>(),k,k_indices,k_sqr_distances);
274 std::vector<float>& k_sqr_distances,
unsigned int max_nn = 0)
const = 0;
286 template <
typename Po
intTDiff>
inline int 287 radiusSearchT (
const PointTDiff &point,
double radius, std::vector<int> &k_indices,
288 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const 292 return (
radiusSearch (p, radius, k_indices, k_sqr_distances, max_nn));
313 radiusSearch (
const PointCloud &cloud,
int index,
double radius,
314 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances,
315 unsigned int max_nn = 0)
const;
337 radiusSearch (
int index,
double radius, std::vector<int> &k_indices,
338 std::vector<float> &k_sqr_distances,
unsigned int max_nn = 0)
const;
352 const std::vector<int>& indices,
354 std::vector< std::vector<int> >& k_indices,
355 std::vector< std::vector<float> > &k_sqr_distances,
356 unsigned int max_nn = 0)
const;
369 template <
typename Po
intTDiff>
void 371 const std::vector<int>& indices,
373 std::vector< std::vector<int> > &k_indices,
374 std::vector< std::vector<float> > &k_sqr_distances,
375 unsigned int max_nn = 0)
const 383 if (indices.empty ())
386 for (
size_t i = 0; i < cloud.
size (); ++i)
388 radiusSearch (pc, std::vector<int> (), radius, k_indices, k_sqr_distances, max_nn);
392 pc.
resize (indices.size ());
393 for (
size_t i = 0; i < indices.size (); ++i)
395 radiusSearch (pc, std::vector<int>(), radius, k_indices, k_sqr_distances, max_nn);
401 sortResults (std::vector<int>& indices, std::vector<float>& distances)
const;
411 Compare (
const std::vector<float>& distances)
412 : distances_ (distances)
417 operator () (
int first,
int second)
const 419 return (distances_ [first] < distances_[second]);
422 const std::vector<float>& distances_;
428 #ifdef PCL_NO_PRECOMPILE 429 #include <pcl/search/impl/search.hpp> 432 #endif //#ifndef _PCL_SEARCH_SEARCH_H_ 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
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.
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 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.
PointCloudConstPtr input_
virtual void setSortedResults(bool sorted)
sets whether the results should be sorted (ascending in the distance) or not
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.
void sortResults(std::vector< int > &indices, std::vector< float > &distances) const
boost::shared_ptr< PointCloud< PointT > > Ptr
PointCloud::Ptr PointCloudPtr
boost::shared_ptr< pcl::search::Search< PointT > > Ptr
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.
boost::mpl::remove_if< Sequence1, boost::mpl::not_< boost::mpl::contains< Sequence2, boost::mpl::_1 > > >::type type
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
PointCloud represents the base class in PCL for storing collections of 3D points. ...
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.
virtual PointCloudConstPtr getInputCloud() const
Get a pointer to the input point cloud dataset.
boost::shared_ptr< const pcl::search::Search< PointT > > ConstPtr
virtual IndicesConstPtr getIndices() const
Get a pointer to the vector of indices used.
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.
virtual const std::string & getName() const
Returns the search method name.
void copyPoint(const PointInT &point_in, PointOutT &point_out)
Copy the fields of a source point into a target point.