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>
58 unsigned int max_depth_arg)
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>
167 unsigned int max_depth_arg)
177 template <
typename OctreeT>
179 OctreeT* octree_arg,
unsigned int max_depth_arg)
189 template <
typename OctreeT>
201 FIFO_entry.
node_ = this->octree_->getRootNode();
205 FIFO_.push_back(FIFO_entry);
207 this->current_state_ = &FIFO_.front();
212 template <
typename OctreeT>
224 if ((this->max_octree_depth_ >= FIFO_entry.
depth_) &&
230 for (
unsigned char child_idx = 0; child_idx < 8; ++child_idx) {
233 if (this->octree_->branchHasChild(*current_branch, child_idx)) {
236 current_key.
pushBranch(
static_cast<unsigned char>(child_idx));
239 this->octree_->getBranchChildPtr(*current_branch, child_idx);
241 FIFO_.push_back(FIFO_entry);
249 this->current_state_ = &FIFO_.front();
252 this->current_state_ = 0;
260 template <
typename OctreeT>
266 template <
typename OctreeT>
268 OctreeT* octree_arg,
unsigned int fixed_depth_arg)
270 , fixed_depth_(fixed_depth_arg)
272 this->
reset(fixed_depth_arg);
276 template <
typename OctreeT>
281 fixed_depth_ = fixed_depth_arg;
283 if (!this->octree_) {
289 if ((!this->current_state_) || (fixed_depth_ <= this->getCurrentOctreeDepth()))
292 if (this->octree_->getTreeDepth() < fixed_depth_) {
293 PCL_WARN(
"[pcl::octree::FixedDepthIterator] The requested fixed depth was bigger "
294 "than the octree's depth.\n");
295 PCL_WARN(
"[pcl::octree::FixedDepthIterator] fixed_depth = %d (instead of %d)\n",
296 this->octree_->getTreeDepth(),
304 this->max_octree_depth_ = std::min(fixed_depth_, this->octree_->getTreeDepth());
308 this->current_state_ = &FIFO_.front();
311 while (this->current_state_ && (this->getCurrentOctreeDepth() != fixed_depth_))
316 template <
typename OctreeT>
318 unsigned int max_depth_arg)
325 template <
typename OctreeT>
327 OctreeT* octree_arg,
unsigned int max_depth_arg)
334 template <
typename OctreeT>
337 unsigned int max_depth_arg,
339 const std::deque<IteratorState>& fifo)
344 template <
typename OctreeT>
353 template <
typename OctreeT>
359 }
while ((this->current_state_) &&
360 (this->current_state_->node_->getNodeType() !=
LEAF_NODE));
366 template <
typename OctreeT>