38 #ifndef PCL_SEARCH_SEARCH_IMPL_HPP_
39 #define PCL_SEARCH_SEARCH_IMPL_HPP_
41 #include <pcl/search/search.h>
44 template <
typename Po
intT>
47 , sorted_results_ (sorted)
53 template <
typename Po
intT>
const std::string&
60 template <
typename Po
intT>
void
63 sorted_results_ = sorted;
67 template <
typename Po
intT>
bool
70 return (sorted_results_);
74 template <
typename Po
intT>
void
84 template <
typename Po
intT>
int
87 Indices &k_indices, std::vector<float> &k_sqr_distances)
const
89 assert (index >= 0 && index <
static_cast<index_t> (cloud.
size ()) &&
"Out-of-bounds error in nearestKSearch!");
90 return (nearestKSearch (cloud[index], k, k_indices, k_sqr_distances));
94 template <
typename Po
intT>
int
98 std::vector<float> &k_sqr_distances)
const
102 assert (index >= 0 && index <
static_cast<index_t> (input_->size ()) &&
"Out-of-bounds error in nearestKSearch!");
103 return (nearestKSearch ((*input_)[index], k, k_indices, k_sqr_distances));
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)
108 return (nearestKSearch ((*input_)[(*indices_)[index]], k, k_indices, k_sqr_distances));
112 template <
typename Po
intT>
void
115 int k, std::vector<Indices>& k_indices,
116 std::vector< std::vector<float> >& k_sqr_distances)
const
118 if (indices.empty ())
120 k_indices.resize (cloud.
size ());
121 k_sqr_distances.resize (cloud.
size ());
122 for (std::size_t i = 0; i < cloud.
size (); i++)
123 nearestKSearch (cloud,
static_cast<index_t> (i), k, k_indices[i], k_sqr_distances[i]);
127 k_indices.resize (indices.size ());
128 k_sqr_distances.resize (indices.size ());
129 for (std::size_t i = 0; i < indices.size (); i++)
130 nearestKSearch (cloud, indices[i], k, k_indices[i], k_sqr_distances[i]);
135 template <
typename Po
intT>
int
138 Indices &k_indices, std::vector<float> &k_sqr_distances,
139 unsigned int max_nn)
const
141 assert (index >= 0 && index <
static_cast<index_t> (cloud.
size ()) &&
"Out-of-bounds error in radiusSearch!");
142 return (radiusSearch(cloud[index], radius, k_indices, k_sqr_distances, max_nn));
146 template <
typename Po
intT>
int
149 std::vector<float> &k_sqr_distances,
unsigned int max_nn )
const
153 assert (index >= 0 && index <
static_cast<index_t> (input_->size ()) &&
"Out-of-bounds error in radiusSearch!");
154 return (radiusSearch ((*input_)[index], radius, k_indices, k_sqr_distances, max_nn));
156 assert (index >= 0 && index <
static_cast<index_t> (indices_->size ()) &&
"Out-of-bounds error in radiusSearch!");
157 return (radiusSearch ((*input_)[(*indices_)[index]], radius, k_indices, k_sqr_distances, max_nn));
161 template <
typename Po
intT>
void
166 std::vector<Indices>& k_indices,
167 std::vector< std::vector<float> > &k_sqr_distances,
168 unsigned int max_nn)
const
170 if (indices.empty ())
172 k_indices.resize (cloud.
size ());
173 k_sqr_distances.resize (cloud.
size ());
174 for (std::size_t i = 0; i < cloud.
size (); i++)
175 radiusSearch (cloud,
static_cast<index_t> (i), radius,k_indices[i], k_sqr_distances[i], max_nn);
179 k_indices.resize (indices.size ());
180 k_sqr_distances.resize (indices.size ());
181 for (std::size_t i = 0; i < indices.size (); i++)
182 radiusSearch (cloud,indices[i],radius,k_indices[i],k_sqr_distances[i], max_nn);
187 template <
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);
198 Indices sorted (indices.size ());
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>;
210 #endif //#ifndef _PCL_SEARCH_SEARCH_IMPL_HPP_