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_) &&
141 for (int8_t i = 7; i >= 0; --i)
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_) &&
235 unsigned char child_idx;
242 for (child_idx = 0; child_idx < 8 ; ++child_idx)
246 if (this->octree_->branchHasChild(*current_branch, child_idx))
249 current_key.
pushBranch (
static_cast<unsigned char> (child_idx));
251 FIFO_entry.
node_ = this->octree_->getBranchChildPtr(*current_branch, child_idx);
253 FIFO_.push_back(FIFO_entry);
262 this->current_state_ = &FIFO_.front();
265 this->current_state_ = 0;
274 template<
typename OctreeT>
280 template<
typename OctreeT>
284 this->reset (fixed_depth_arg);
288 template<
typename OctreeT>
292 fixed_depth_ = fixed_depth_arg;
301 if ((!this->current_state_) || (fixed_depth_ <= this->getCurrentOctreeDepth ()))
304 if (this->octree_->getTreeDepth () < fixed_depth_)
306 PCL_WARN (
"[pcl::octree::FixedDepthIterator] The requested fixed depth was bigger than the octree's depth.\n");
307 PCL_WARN (
"[pcl::octree::FixedDepthIterator] fixed_depth = %d (instead of %d)\n", this->octree_->getTreeDepth (), fixed_depth_);
314 this->max_octree_depth_ = std::min (fixed_depth_, this->octree_->getTreeDepth ());
318 this->current_state_ = &FIFO_.front ();
321 while (this->current_state_ && (this->getCurrentOctreeDepth () != fixed_depth_))
326 template<
typename OctreeT>
334 template<
typename OctreeT>
342 template<
typename OctreeT>
344 unsigned int max_depth_arg,
346 const std::deque<IteratorState>& fifo)
354 template<
typename OctreeT>
362 template<
typename OctreeT>
369 }
while ((this->current_state_) && (this->current_state_->node_->getNodeType () !=
LEAF_NODE));
375 template<
typename OctreeT>