39 #ifndef PCL_OCTREE_ITERATOR_HPP_
40 #define PCL_OCTREE_ITERATOR_HPP_
42 #include <pcl/console/print.h>
49 template<
typename OctreeT>
58 template<
typename OctreeT>
67 template<
typename OctreeT>
75 stack_.reserve (this->max_octree_depth_);
82 stack_entry.
node_ = this->octree_->getRootNode ();
86 stack_.push_back(stack_entry);
88 this->current_state_ = &stack_.back();
94 template<
typename OctreeT>
101 unsigned char current_depth = stack_.back ().depth_;
104 while (stack_.size () && (stack_.back ().depth_ >= current_depth))
109 this->current_state_ = &stack_.back();
112 this->current_state_ = 0;
119 template<
typename OctreeT>
133 if ( (this->max_octree_depth_>=stack_entry.
depth_) &&
138 static_cast<BranchNode*> (stack_entry.
node_);
143 const unsigned char child_idx = (
unsigned char) i;
146 if (this->octree_->branchHasChild(*current_branch, child_idx))
151 stack_entry.
node_ = this->octree_->getBranchChildPtr(*current_branch, child_idx);
153 stack_.push_back(stack_entry);
162 this->current_state_ = &stack_.back();
165 this->current_state_ = 0;
173 template<
typename OctreeT>
184 template<
typename OctreeT>
195 template<
typename OctreeT>
207 FIFO_entry.
node_ = this->octree_->getRootNode ();
211 FIFO_.push_back(FIFO_entry);
213 this->current_state_ = &FIFO_.front();
218 template<
typename OctreeT>
232 if ( (this->max_octree_depth_>=FIFO_entry.
depth_) &&
237 static_cast<BranchNode*> (FIFO_entry.
node_);
240 for (
unsigned char child_idx = 0; child_idx < 8 ; ++child_idx)
244 if (this->octree_->branchHasChild(*current_branch, child_idx))
247 current_key.
pushBranch (static_cast<unsigned char> (child_idx));
249 FIFO_entry.
node_ = this->octree_->getBranchChildPtr(*current_branch, child_idx);
251 FIFO_.push_back(FIFO_entry);
260 this->current_state_ = &FIFO_.front();
263 this->current_state_ = 0;
272 template<
typename OctreeT>
278 template<
typename OctreeT>
282 this->
reset (fixed_depth_arg);
286 template<
typename OctreeT>
290 fixed_depth_ = fixed_depth_arg;
299 if ((!this->current_state_) || (fixed_depth_ <= this->getCurrentOctreeDepth ()))
302 if (this->octree_->getTreeDepth () < fixed_depth_)
304 PCL_WARN (
"[pcl::octree::FixedDepthIterator] The requested fixed depth was bigger than the octree's depth.\n");
305 PCL_WARN (
"[pcl::octree::FixedDepthIterator] fixed_depth = %d (instead of %d)\n", this->octree_->getTreeDepth (), fixed_depth_);
312 this->max_octree_depth_ = std::min (fixed_depth_, this->octree_->getTreeDepth ());
316 this->current_state_ = &FIFO_.front ();
319 while (this->current_state_ && (this->getCurrentOctreeDepth () != fixed_depth_))
324 template<
typename OctreeT>
332 template<
typename OctreeT>
340 template<
typename OctreeT>
342 unsigned int max_depth_arg,
344 const std::deque<IteratorState>& fifo)
352 template<
typename OctreeT>
360 template<
typename OctreeT>
367 }
while ((this->current_state_) && (this->current_state_->node_->getNodeType () !=
LEAF_NODE));
373 template<
typename OctreeT>