diff --git a/octree/include/pcl/octree/impl/octree_iterator.hpp b/octree/include/pcl/octree/impl/octree_iterator.hpp index 1dfa96ea00b..0ab04323cb8 100644 --- a/octree/include/pcl/octree/impl/octree_iterator.hpp +++ b/octree/include/pcl/octree/impl/octree_iterator.hpp @@ -133,15 +133,16 @@ namespace pcl if ( (this->max_octree_depth_>=stack_entry.depth_) && (stack_entry.node_->getNodeType () == BRANCH_NODE) ) { - unsigned char child_idx; - // current node is a branch node BranchNode* current_branch = static_cast (stack_entry.node_); + unsigned char child_idx = 8; + // add all children to stack - for (child_idx = 0; child_idx < 8; ++child_idx) + do { + --child_idx; // if child exist @@ -156,7 +157,7 @@ namespace pcl current_key.popBranch(); } - } + } while (child_idx != 0); } if (stack_.size ())