1#ifndef included_AMP_kdtree2
2#define included_AMP_kdtree2
26template<u
int8_t NDIM,
class TYPE>
30 using Point = std::array<double, NDIM>;
39 kdtree2(
const std::vector<Point> &x,
const std::vector<TYPE> &data );
42 std::array<double, 2 * NDIM>
box()
const;
45 inline size_t size()
const {
return d_N; }
100 std::vector<std::tuple<Point, TYPE>>
143 void getPoints( std::vector<std::pair<Point, TYPE>> &x )
const;
145 findNearest(
const Point &x,
size_t N, std::tuple<Point, TYPE> *nearest,
double *dist )
const;
148 std::vector<std::tuple<Point, TYPE>> &nearest )
const;
153 std::vector<std::tuple<Point, TYPE>> &nearest )
const;
A class used to to perform kd-tree based operations.
void initialize(size_t N, Point *x, TYPE *data)
kdtree2(size_t N, Point *x, TYPE *data)
std::vector< std::pair< Point, TYPE > > getPointsAndData() const
Return the points in the tree.
kdtree2 & operator=(const kdtree2 &)=delete
std::vector< Point > getPoints() const
Return the points in the tree.
kdtree2(const std::vector< Point > &x, const std::vector< TYPE > &data)
Constructor.
bool intersect(const Point &x, double dist2) const
void findNearest(const Point &x, size_t N, std::tuple< Point, TYPE > *nearest, double *dist) const
bool empty() const
Return true if the tree is empty.
kdtree2(const kdtree2 &)=delete
std::array< double, 2 *NDIM > box() const
Return the bounding box for the tree.
std::unique_ptr< data_struct > d_data
std::vector< std::tuple< Point, TYPE > > findNearestRay(const Point &x, const Point &dir, double dist) const
Search the tree for the nearest points to a ray.
void getPoints(std::vector< Point > &x) const
void checkNearest(const Point &x, size_t N, std::tuple< Point, TYPE > *nearest, double *dist) const
void findNearestRay(const Point &x, const Point &dir, const Point &n_inv, double dist2, std::vector< std::tuple< Point, TYPE > > &nearest) const
void splitData(size_t N, Point *x, TYPE *data)
void getPoints(std::vector< std::pair< Point, TYPE > > &x) const
size_t size() const
Return the number of entries stored in the tree.
void findNearest(const Point &x, double dist2, std::vector< std::tuple< Point, TYPE > > &nearest) const
std::unique_ptr< kdtree2 > d_right
std::vector< std::tuple< Point, TYPE > > findNearest(const Point &x, int N) const
Search the tree for the nearest neighbor points.
void add(const Point &x, const TYPE &data)
Add a point.
std::tuple< Point, TYPE > findNearest(const Point &x) const
Search the tree for the nearest neighbor point.
std::vector< std::tuple< Point, TYPE > > findNearest(const Point &x, double dist) const
Search the tree for the nearest neighbor points.
std::unique_ptr< kdtree2 > d_left
kdtree2(kdtree2 &&)=default
kdtree2 & operator=(kdtree2 &&)=default
A class used to store information for a point.
data_struct(const data_struct &)=delete
void add(const Point &x2, const TYPE &d2)
data_struct & operator=(const data_struct &)=delete