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_);
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;
239 static_cast<BranchNode*> (FIFO_entry.
node_);
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>
void reset()
Reset iterator.
void reset()
Reset the iterator to the first node at the current depth.
This file defines compatibility wrappers for low level I/O functions.
virtual node_type_t getNodeType() const =0
Pure virtual method for receiving the type of octree node (branch or leaf)
OctreeLeafNodeBreadthFirstIterator(unsigned int max_depth_arg=0)
Empty constructor.
OctreeT::BranchNode BranchNode
void popBranch()
pop child node from octree key
void reset()
Reset the iterator to the root node of the octree.
virtual void reset()
Reset the iterator to the root node of the octree.
OctreeDepthFirstIterator(unsigned int max_depth_arg=0)
Empty constructor.
void skipChildVoxels()
Skip all child voxels of current node and return to parent node.
void reset()
Reset the iterator to the first leaf in the breadth first way.
OctreeFixedDepthIterator()
Empty constructor.
OctreeBreadthFirstIterator & operator++()
Preincrement operator.
OctreeDepthFirstIterator & operator++()
Preincrement operator.
Abstract octree iterator class
void pushBranch(unsigned char childIndex)
push a child node to the octree key
OctreeLeafNodeBreadthFirstIterator & operator++()
Preincrement operator.
Octree leaf node iterator class.
OctreeBreadthFirstIterator(unsigned int max_depth_arg=0)
Empty constructor.