std::vector<Uni::Robot *> QuadTree::get_leaves_at(const box &b) { std::vector<Uni::Robot *> found; if(!this->bounds.intersects(b)) { return found; // not in this quadrant } std::size_t i = 0, local_leaves = this->leaves.size(); for(; i < local_leaves; ++i) { if(b.contains_coord(this->leaves[i]->pose[0], this->leaves[i]->pose[1])) { found.push_back(this->leaves[i]); } } if(this->northwest == NULL) { return found; } std::vector<Uni::Robot *> nw = this->northwest->get_leaves_at(b); std::vector<Uni::Robot *> ne = this->northeast->get_leaves_at(b); std::vector<Uni::Robot *> sw = this->southwest->get_leaves_at(b); std::vector<Uni::Robot *> se = this->southeast->get_leaves_at(b); found.insert(found.end(), nw.begin(), nw.end()); found.insert(found.end(), ne.begin(), ne.end()); found.insert(found.end(), sw.begin(), sw.end()); found.insert(found.end(), se.begin(), se.end()); return found; }