39 #ifndef PCL_OCTREE_ITERATOR_HPP_
40 #define PCL_OCTREE_ITERATOR_HPP_
42 #include <pcl/console/print.h>
47 template <
typename OctreeT>
56 template <
typename OctreeT>
66 template <
typename OctreeT>
74 stack_.reserve(this->max_octree_depth_);
81 stack_entry.
node_ = this->octree_->getRootNode();
85 stack_.push_back(stack_entry);
87 this->current_state_ = &stack_.back();
92 template <
typename OctreeT>
99 unsigned char current_depth = stack_.back().depth_;
102 while (stack_.size() && (stack_.back().depth_ >= current_depth))
106 this->current_state_ = &stack_.back();
109 this->current_state_ = 0;
115 template <
typename OctreeT>
127 if ((this->max_octree_depth_ >= stack_entry.
depth_) &&
135 for (std::int8_t i = 7; i >= 0; --i) {
136 const unsigned char child_idx = (
unsigned char)i;
139 if (this->octree_->branchHasChild(*current_branch, child_idx)) {
144 this->octree_->getBranchChildPtr(*current_branch, child_idx);
146 stack_.push_back(stack_entry);
154 this->current_state_ = &stack_.back();
157 this->current_state_ = 0;
165 template <
typename OctreeT>
176 template <
typename OctreeT>
188 template <
typename OctreeT>
200 FIFO_entry.
node_ = this->octree_->getRootNode();
204 FIFO_.push_back(FIFO_entry);
206 this->current_state_ = &FIFO_.front();
211 template <
typename OctreeT>
223 if ((this->max_octree_depth_ >= FIFO_entry.
depth_) &&
229 for (
unsigned char child_idx = 0; child_idx < 8; ++child_idx) {
232 if (this->octree_->branchHasChild(*current_branch, child_idx)) {
235 current_key.
pushBranch(static_cast<unsigned char>(child_idx));
238 this->octree_->getBranchChildPtr(*current_branch, child_idx);
240 FIFO_.push_back(FIFO_entry);
248 this->current_state_ = &FIFO_.front();
251 this->current_state_ = 0;
259 template <
typename OctreeT>
265 template <
typename OctreeT>
269 , fixed_depth_(fixed_depth_arg)
271 this->
reset(fixed_depth_arg);
275 template <
typename OctreeT>
280 fixed_depth_ = fixed_depth_arg;
282 if (!this->octree_) {
288 if ((!this->current_state_) || (fixed_depth_ <= this->getCurrentOctreeDepth()))
291 if (this->octree_->getTreeDepth() < fixed_depth_) {
292 PCL_WARN(
"[pcl::octree::FixedDepthIterator] The requested fixed depth was bigger "
293 "than the octree's depth.\n");
294 PCL_WARN(
"[pcl::octree::FixedDepthIterator] fixed_depth = %d (instead of %d)\n",
295 this->octree_->getTreeDepth(),
303 this->max_octree_depth_ = std::min(fixed_depth_, this->octree_->getTreeDepth());
307 this->current_state_ = &FIFO_.front();
310 while (this->current_state_ && (this->getCurrentOctreeDepth() != fixed_depth_))
315 template <
typename OctreeT>
324 template <
typename OctreeT>
326 OctreeT* octree_arg,
uindex_t max_depth_arg)
333 template <
typename OctreeT>
338 const std::deque<IteratorState>& fifo)
343 template <
typename OctreeT>
352 template <
typename OctreeT>
358 }
while ((this->current_state_) &&
359 (this->current_state_->node_->getNodeType() !=
LEAF_NODE));
365 template <
typename OctreeT>
void reset()
Reset iterator.
void reset()
Reset the iterator to the first node at the current depth.
virtual node_type_t getNodeType() const =0
Pure virtual method for retrieving the type of octree node (branch or leaf)
OctreeLeafNodeBreadthFirstIterator(uindex_t max_depth_arg=0)
Empty constructor.
void popBranch()
pop child node from octree key
void reset()
Reset the iterator to the root node of the octree.
typename OctreeT::BranchNode BranchNode
virtual void reset()
Reset the iterator to the root node of the octree.
OctreeBreadthFirstIterator(uindex_t 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.
OctreeDepthFirstIterator(uindex_t max_depth_arg=0)
Empty constructor.
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
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
OctreeLeafNodeBreadthFirstIterator & operator++()
Preincrement operator.
Octree leaf node iterator class.