11#ifndef NSEARCH_NSEARCH_H
12#define NSEARCH_NSEARCH_H
46 bool parallel =
true) = 0;
63 const util::Point &searchPoint,
const double &search_r,
64 std::vector<int> &neighs,
65 std::vector<float> &sqr_dist) = 0;
74 const util::Point &searchPoint,
const double &search_r,
75 std::vector<size_t> &neighs,
76 std::vector<double> &sqr_dist) = 0;
93 const double &search_r,
94 std::vector<size_t> &neighs,
95 std::vector<double> &sqr_dist,
96 const size_t &searchPointTag,
97 const std::vector<size_t> &dataTags) = 0;
110 const double &search_r,
111 std::vector<int> &neighs,
112 std::vector<float> &sqr_dist,
113 const size_t &searchPointTag,
114 const std::vector<size_t> &dataTags) = 0;
131 const double &search_r,
132 std::vector<size_t> &neighs,
133 std::vector<double> &sqr_dist,
134 const size_t &searchPointTag,
135 const std::vector<size_t> &dataTags) = 0;
148 const double &search_r,
149 std::vector<int> &neighs,
150 std::vector<float> &sqr_dist,
151 const size_t &searchPointTag,
152 const std::vector<size_t> &dataTags) = 0;
164 double &sqrDistNeigh) = 0;
177template <
int dim = 3>
192 nanoflann::KDTreeSingleIndexAdaptorParams(max_leafs )) {
201 auto t1 = steady_clock::now();
203 auto t2 = steady_clock::now();
217 bool parallel =
true)
override {
228 const util::Point &searchPoint,
const double &search_r,
229 std::vector<size_t> &neighs,
230 std::vector<double> &sqr_dist)
override {
232 double query_pt[3] = {searchPoint[0], searchPoint[1], searchPoint[2]};
234 TreeSearchRes resultSet(search_r * search_r, neighs, sqr_dist);
235 return d_tree.radiusSearchCustomCallback(&query_pt[0], resultSet,
d_params);
245 const util::Point &searchPoint,
const double &search_r,
246 std::vector<int> &neighs,
247 std::vector<float> &sqr_dist)
override {
251 std::vector<size_t> neighs_temp;
252 std::vector<double> sqr_dist_temp;
254 this->
radiusSearch(searchPoint, search_r, neighs_temp, sqr_dist_temp);
259 for (
size_t i=0; i<N; i++) {
260 neighs.push_back(
int(neighs_temp[i]));
261 sqr_dist.push_back(
float(sqr_dist_temp[i]));
280 const double &search_r,
281 std::vector<size_t> &neighs,
282 std::vector<double> &sqr_dist,
283 const size_t &searchPointTag,
284 const std::vector<size_t> &dataTags)
override {
286 double query_pt[3] = {searchPoint[0], searchPoint[1], searchPoint[2]};
289 neighs, sqr_dist, searchPointTag, dataTags);
291 return d_tree.radiusSearchCustomCallback(&query_pt[0], resultSet,
d_params);
305 const double &search_r,
306 std::vector<int> &neighs,
307 std::vector<float> &sqr_dist,
308 const size_t &searchPointTag,
309 const std::vector<size_t> &dataTags)
override {
312 std::vector<size_t> neighs_temp;
313 std::vector<double> sqr_dist_temp;
316 neighs_temp, sqr_dist_temp,
317 searchPointTag, dataTags);
322 for (
size_t i=0; i<N; i++) {
323 neighs.push_back(
int(neighs_temp[i]));
324 sqr_dist.push_back(
float(sqr_dist_temp[i]));
342 const double &search_r,
343 std::vector<size_t> &neighs,
344 std::vector<double> &sqr_dist,
345 const size_t &searchPointTag,
346 const std::vector<size_t> &dataTags)
override {
348 double query_pt[3] = {searchPoint[0], searchPoint[1], searchPoint[2]};
352 searchPointTag, dataTags);
354 return d_tree.radiusSearchCustomCallback(&query_pt[0], resultSet,
d_params);
368 const double &search_r,
369 std::vector<int> &neighs,
370 std::vector<float> &sqr_dist,
371 const size_t &searchPointTag,
372 const std::vector<size_t> &dataTags)
override {
375 std::vector<size_t> neighs_temp;
376 std::vector<double> sqr_dist_temp;
379 neighs_temp, sqr_dist_temp,
380 searchPointTag, dataTags);
385 for (
size_t i=0; i<N; i++) {
386 neighs.push_back(
int(neighs_temp[i]));
387 sqr_dist.push_back(
float(sqr_dist_temp[i]));
403 double &sqrDistNeigh)
override {
405 double query_pt[3] = {searchPoint[0], searchPoint[1], searchPoint[2]};
406 unsigned int neigh_temp = 0;
407 d_tree.knnSearch(&query_pt[0], 1, &neigh_temp, &sqrDistNeigh);
416 nanoflann::KDTreeSingleIndexAdaptor<
A class for nearest neighbor search.
virtual size_t radiusSearchExcludeTag(const util::Point &searchPoint, const double &search_r, std::vector< size_t > &neighs, std::vector< double > &sqr_dist, const size_t &searchPointTag, const std::vector< size_t > &dataTags)=0
Perform radius search to find points in a point cloud within specified distance from a given point....
virtual size_t radiusSearch(const util::Point &searchPoint, const double &search_r, std::vector< int > &neighs, std::vector< float > &sqr_dist)=0
Perform radius search to find points in a point cloud within specified distance from a given point.
virtual double updatePointCloud(const std::vector< util::Point > &x, bool parallel=true)=0
Function to implement point cloud update.
std::string d_treeType
name of tree: nflann_kdtree
virtual size_t radiusSearchExcludeTag(const util::Point &searchPoint, const double &search_r, std::vector< int > &neighs, std::vector< float > &sqr_dist, const size_t &searchPointTag, const std::vector< size_t > &dataTags)=0
= 0
virtual size_t radiusSearch(const util::Point &searchPoint, const double &search_r, std::vector< size_t > &neighs, std::vector< double > &sqr_dist)=0
Perform radius search to find points in a point cloud within specified distance from a given point....
size_t d_debug
control the verbosity
virtual size_t radiusSearchIncludeTag(const util::Point &searchPoint, const double &search_r, std::vector< size_t > &neighs, std::vector< double > &sqr_dist, const size_t &searchPointTag, const std::vector< size_t > &dataTags)=0
Perform radius search to find points in a point cloud within specified distance from a given point....
virtual double setInputCloud()=0
Set input cloud.
BaseNSearch(std::string name, size_t debug=0)
Constructor.
virtual size_t radiusSearchIncludeTag(const util::Point &searchPoint, const double &search_r, std::vector< int > &neighs, std::vector< float > &sqr_dist, const size_t &searchPointTag, const std::vector< size_t > &dataTags)=0
= 0
virtual void closestPoint(const util::Point &searchPoint, size_t &neigh, double &sqrDistNeigh)=0
Find the closest points to the specified point.
A class for nearest neighbor search using nanoflann library.
nanoflann::SearchParameters d_params
Tree search parameters.
double setInputCloud() override
Set input cloud.
size_t radiusSearch(const util::Point &searchPoint, const double &search_r, std::vector< int > &neighs, std::vector< float > &sqr_dist) override
Perform radius search to find points in a point cloud within specified distance from a given point....
size_t radiusSearchIncludeTag(const util::Point &searchPoint, const double &search_r, std::vector< int > &neighs, std::vector< float > &sqr_dist, const size_t &searchPointTag, const std::vector< size_t > &dataTags) override
= 0
size_t radiusSearchExcludeTag(const util::Point &searchPoint, const double &search_r, std::vector< int > &neighs, std::vector< float > &sqr_dist, const size_t &searchPointTag, const std::vector< size_t > &dataTags) override
= 0
PointCloudAdaptor d_cloud
coordinates of the points
NFlannSearchKd(const PointCloud &x, size_t debug=0, size_t max_leafs=10)
Constructor.
double updatePointCloud(const std::vector< util::Point > &x, bool parallel=true) override
Function to implement point cloud update.
nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< double, PointCloudAdaptor >, PointCloudAdaptor, dim > d_tree
Tree.
size_t radiusSearch(const util::Point &searchPoint, const double &search_r, std::vector< size_t > &neighs, std::vector< double > &sqr_dist) override
Perform radius search to find points in a point cloud within specified distance from a given point....
size_t radiusSearchIncludeTag(const util::Point &searchPoint, const double &search_r, std::vector< size_t > &neighs, std::vector< double > &sqr_dist, const size_t &searchPointTag, const std::vector< size_t > &dataTags) override
= 0
size_t radiusSearchExcludeTag(const util::Point &searchPoint, const double &search_r, std::vector< size_t > &neighs, std::vector< double > &sqr_dist, const size_t &searchPointTag, const std::vector< size_t > &dataTags) override
= 0
void closestPoint(const util::Point &searchPoint, size_t &neigh, double &sqrDistNeigh) override
= 0
To collect results of nanoflann tree search. In this class, we check the tag of a potential point and...
To collect results of nanoflann tree search. In this class, we check the tag of a potential point and...
To collect results of nanoflann tree search. Default result output of nanoflann search uses std::vect...
Methods for performing efficient search of neighboring points.
std::vector< util::Point > PointCloud
Define list of points for tree search using nanoflann lib.
float timeDiff(std::chrono::steady_clock::time_point begin, std::chrono::steady_clock::time_point end, std::string unit="microseconds")
Returns difference between two times.
Allows custom point cloud data structure to interface with nanoflann. See https://github....
A structure to represent 3d vectors.