8#include "nanoflann.hpp"
75 void Nearest(
const std::vector<float> &coordu, std::vector<size_t> &index)
const;
77 void Nearest(
const std::vector<double> &coordu, std::vector<size_t> &index)
const
79 std::vector<float> coordu_f;
80 for (
int i = 0; i < coordu.size(); i++) coordu_f.push_back(coordu[i]);
81 this->Nearest(coordu_f, index);
98 PointCloud2D(
const Grid &xg,
const Grid &yg)
106 for (
int i = 0; i < dims.size(); i++) nelem *= dims[i];
107 this->X.resize(nelem);
108 this->Y.resize(nelem);
114 for (
size_t i = 0; i < nelem; ++i, ++xitr, ++yitr) {
121 inline size_t kdtree_get_point_count()
const
130 inline float kdtree_get_pt(
const size_t idx,
int dim)
const
142 template<
class BBOX>
bool kdtree_get_bbox(BBOX & )
const {
return false; }
145 std::vector<float> X, Y;
149 typedef nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<float, PointCloud2D>, PointCloud2D, 2 > KDTreeType;
151 PointCloud2D _points;
153 std::vector<size_t> _dims;
206 void Nearest(
const std::vector<float> &coordu, std::vector<size_t> &coord)
const;
208 void Nearest(
const std::vector<double> &coordu, std::vector<size_t> &index)
const
210 std::vector<float> coordu_f;
211 for (
int i = 0; i < coordu.size(); i++) coordu_f.push_back(coordu[i]);
212 Nearest(coordu_f, index);
217 std::vector<std::size_t> dims;
218 for (
int i = 0; i < _min.size(); i++) { dims.push_back(_max[i] - _min[i] + 1); }
224 std::vector<size_t> _min;
225 std::vector<size_t> _max;
Abstract base class for a 2D or 3D structured or unstructured grid.
size_t GetNumDimensions() const
const DimsType & GetDimensions() const
ConstIterator cbegin(const CoordType &minu, const CoordType &maxu) const
This class implements a k-d tree for a structured grid over a reduced region-of-interest (ROI)
void Nearest(const std::vector< double > &coordu, std::vector< size_t > &index) const
void Nearest(const std::vector< float > &coordu, std::vector< size_t > &coord) const
KDTreeRGSubset(const KDTreeRG *kdtreerg, const std::vector< size_t > &min, const std::vector< size_t > &max)
std::vector< size_t > GetDimensions() const
This class implements a k-d space partitioning tree.
std::vector< size_t > GetDimensions() const
void Nearest(const std::vector< double > &coordu, std::vector< size_t > &index) const
KDTreeRG(const Grid &xg, const Grid &yg)
void Nearest(const std::vector< float > &coordu, std::vector< size_t > &index) const