51 struct rtree_elt_base {
52 enum { RECTS_PER_LEAF=8 };
54 bool isleaf()
const {
return isleaf_; }
56 rtree_elt_base(
bool leaf,
const base_node& rmin_,
const base_node& rmax_)
57 : isleaf_(leaf), rmin(rmin_), rmax(rmax_) {}
58 virtual ~rtree_elt_base() {}
66 class rtree :
public boost::noncopyable {
68 typedef std::deque<box_index> box_cont;
69 typedef std::vector<const box_index*> pbox_cont;
70 typedef std::set<const box_index*> pbox_set;
73 box_index bi; bi.min = min; bi.max = max;
74 bi.id = (
id + 1) ?
id : boxes.size();
77 size_type nb_boxes()
const {
return boxes.size(); }
78 void clear() { root = std::unique_ptr<rtree_elt_base>(); boxes.clear(); }
86 void find_boxes_at_point(
const base_node& P, pbox_set& boxlst);
87 void find_line_intersecting_boxes(
const base_node& org,
90 void find_line_intersecting_boxes(
const base_node& org,
97 std::vector<size_type>& idvec) {
99 find_intersecting_boxes(bmin, bmax, bs);
100 pbox_set_to_idvec(bs, idvec);
103 std::vector<size_type>& idvec) {
105 find_containing_boxes(bmin, bmax, bs);
106 pbox_set_to_idvec(bs, idvec);
108 void find_contained_boxes(
const base_node& bmin,
110 std::vector<size_type>& idvec) {
112 find_contained_boxes(bmin, bmax, bs);
113 pbox_set_to_idvec(bs, idvec);
115 void find_boxes_at_point(
const base_node& P, std::vector<size_type>& idvec)
116 { pbox_set bs; find_boxes_at_point(P, bs); pbox_set_to_idvec(bs, idvec); }
117 void find_line_intersecting_boxes(
const base_node& org,
119 std::vector<size_type>& idvec) {
121 find_line_intersecting_boxes(org, dirv, bs);
122 pbox_set_to_idvec(bs, idvec);
124 void find_line_intersecting_boxes(
const base_node& org,
128 std::vector<size_type>& idvec) {
130 find_line_intersecting_boxes(org, dirv, bmin, bmax, bs);
131 pbox_set_to_idvec(bs, idvec);
137 static void pbox_set_to_idvec(pbox_set bs, std::vector<size_type>& idvec) {
138 idvec.reserve(bs.size()); idvec.resize(0);
139 for (pbox_set::const_iterator it=bs.begin(); it != bs.end(); ++it)
140 idvec.push_back((*it)->id);
144 std::unique_ptr<rtree_elt_base> root;
145 getfem::lock_factory locks_;
size_t size_type
used as the common size type in the library
Balanced tree of n-dimensional rectangles.