32 #ifndef BGEOT_KDTREE_H 33 #define BGEOT_KDTREE_H 47 struct kdtree_elt_base {
48 enum { PTS_PER_LEAF=8 };
50 bool isleaf()
const {
return (n != 0); }
51 kdtree_elt_base(
unsigned n_) : n(n_) {}
52 virtual ~kdtree_elt_base() {}
65 void swap(
index_node_pair& other) { std::swap(i,other.i); n.swap(other.n);}
103 class kdtree :
public boost::noncopyable {
105 std::unique_ptr<kdtree_elt_base> tree;
111 void reserve(
size_type n) { pts.reserve(n); }
114 size_type i = pts.size(); add_point_with_id(n,i);
return i;
121 GMM_ASSERT2(N == n.size(),
"invalid dimension");
122 if (tree) clear_tree();
125 size_type nb_points()
const {
return pts.size(); }
126 const kdtree_tab_type &points()
const {
return pts; }
129 void points_in_box(kdtree_tab_type &ipts,
137 typedef std::vector<size_type>::const_iterator ITER;
Balanced tree over a set of points.
size_t size_type
used as the common size type in the library
void add_point_with_id(const base_node &n, size_type i)
insert a new point, with an associated number.
void clear()
reset the tree, remove all points
store a point and the associated index for the kdtree.
size_type add_point(const base_node &n)
insert a new point
std::vector< index_node_pair > kdtree_tab_type
store a set of points with associated indexes.