Skip to content

Commit b5a35ed

Browse files
committed
Merge pull request #89 from aecins/devel
Updated getUnknownLeafCenters to have tree depth as a parameter
2 parents 8ff7c0f + efb26c8 commit b5a35ed

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

octomap/include/octomap/OcTreeBaseImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ namespace octomap {
213213
// -- access tree nodes ------------------
214214

215215
/// return centers of leafs that do NOT exist (but could) in a given bounding box
216-
void getUnknownLeafCenters(point3d_list& node_centers, point3d pmin, point3d pmax) const;
216+
void getUnknownLeafCenters(point3d_list& node_centers, point3d pmin, point3d pmax, unsigned int depth = 0) const;
217217

218218

219219
// -- raytracing -----------------------

octomap/include/octomap/OcTreeBaseImpl.hxx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -856,26 +856,31 @@ namespace octomap {
856856
}
857857

858858
template <class NODE,class I>
859-
void OcTreeBaseImpl<NODE,I>::getUnknownLeafCenters(point3d_list& node_centers, point3d pmin, point3d pmax) const {
859+
void OcTreeBaseImpl<NODE,I>::getUnknownLeafCenters(point3d_list& node_centers, point3d pmin, point3d pmax, unsigned int depth) const {
860860

861+
assert(depth <= tree_depth);
862+
if (depth == 0)
863+
depth = tree_depth;
864+
861865
float diff[3];
862866
unsigned int steps[3];
867+
float step_size = this->resolution * pow(2, tree_depth-depth);
863868
for (int i=0;i<3;++i) {
864869
diff[i] = pmax(i) - pmin(i);
865-
steps[i] = floor(diff[i] / this->resolution);
870+
steps[i] = floor(diff[i] / step_size);
866871
// std::cout << "bbx " << i << " size: " << diff[i] << " " << steps[i] << " steps\n";
867872
}
868873

869874
point3d p = pmin;
870875
NODE* res;
871876
for (unsigned int x=0; x<steps[0]; ++x) {
872-
p.x() += this->resolution;
877+
p.x() += step_size;
873878
for (unsigned int y=0; y<steps[1]; ++y) {
874-
p.y() += this->resolution;
879+
p.y() += step_size;
875880
for (unsigned int z=0; z<steps[2]; ++z) {
876881
// std::cout << "querying p=" << p << std::endl;
877-
p.z() += this->resolution;
878-
res = this->search(p);
882+
p.z() += step_size;
883+
res = this->search(p,depth);
879884
if (res == NULL) {
880885
node_centers.push_back(p);
881886
}

0 commit comments

Comments
 (0)