38#ifndef PCL_SEARCH_SEARCH_IMPL_HPP_
39#define PCL_SEARCH_SEARCH_IMPL_HPP_
41#include <pcl/search/search.h>
44template <
typename Po
intT>
53template <
typename Po
intT>
const std::string&
60template <
typename Po
intT>
void
67template <
typename Po
intT>
bool
70 return (sorted_results_);
74template <
typename Po
intT>
void
84template <
typename Po
intT>
int
89 assert (index >= 0 && index <
static_cast<index_t> (cloud.
size ()) &&
"Out-of-bounds error in nearestKSearch!");
94template <
typename Po
intT>
int
102 assert (index >= 0 && index <
static_cast<index_t> (input_->size ()) &&
"Out-of-bounds error in nearestKSearch!");
105 assert (index >= 0 && index <
static_cast<index_t> (indices_->size ()) &&
"Out-of-bounds error in nearestKSearch!");
106 if (index >=
static_cast<index_t> (indices_->size ()) || index < 0)
112template <
typename Po
intT>
void
118 if (indices.empty ())
122 for (std::size_t i = 0; i < cloud.
size (); i++)
129 for (std::size_t i = 0; i < indices.size (); i++)
135template <
typename Po
intT>
int
139 unsigned int max_nn)
const
141 assert (index >= 0 && index <
static_cast<index_t> (cloud.
size ()) &&
"Out-of-bounds error in radiusSearch!");
146template <
typename Po
intT>
int
153 assert (index >= 0 && index <
static_cast<index_t> (input_->size ()) &&
"Out-of-bounds error in radiusSearch!");
156 assert (index >= 0 && index <
static_cast<index_t> (indices_->size ()) &&
"Out-of-bounds error in radiusSearch!");
161template <
typename Po
intT>
void
168 unsigned int max_nn)
const
170 if (indices.empty ())
174 for (std::size_t i = 0; i < cloud.
size (); i++)
181 for (std::size_t i = 0; i < indices.size (); i++)
187template <
typename Po
intT>
void
189 Indices& indices, std::vector<float>& distances)
const
191 Indices order (indices.size ());
192 for (std::size_t idx = 0; idx < order.size (); ++idx)
193 order [idx] =
static_cast<index_t> (idx);
195 Compare compare (distances);
196 sort (order.begin (), order.end (), compare);
199 for (std::size_t idx = 0; idx < order.size (); ++idx)
200 sorted [idx] = indices[order [idx]];
205 sort (distances.begin (), distances.end ());
208#define PCL_INSTANTIATE_Search(T) template class PCL_EXPORTS pcl::search::Search<T>;
Iterator class for point clouds with or without given indices.
PointCloud represents the base class in PCL for storing collections of 3D points.
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.
void sortResults(Indices &indices, std::vector< float > &distances) const
virtual const std::string & getName() const
Returns the search method name.
typename PointCloud::ConstPtr PointCloudConstPtr
Search(const std::string &name="", bool sorted=false)
Constructor.
pcl::IndicesConstPtr IndicesConstPtr
virtual int nearestKSearch(const PointT &point, int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const =0
Search for the 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 int radiusSearch(const PointT &point, 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.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
IndicesAllocator<> Indices
Type used for indices in PCL.