Point Cloud Library (PCL)  1.12.1-dev
octree_iterator.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, Willow Garage, Inc.
6  * Copyright (c) 2017-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of Willow Garage, Inc. nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  */
39 
40 #pragma once
41 
42 #include <pcl/octree/octree_key.h>
43 #include <pcl/octree/octree_nodes.h>
44 
45 #include <cstddef>
46 #include <deque>
47 #include <iterator>
48 #include <vector>
49 
50 // Ignore warnings in the above headers
51 #ifdef __GNUC__
52 #pragma GCC system_header
53 #endif
54 
55 namespace pcl {
56 namespace octree {
57 
58 // Octree iterator state pushed on stack/list
59 struct IteratorState {
63 };
64 
65 /** \brief @b Abstract octree iterator class
66  * \note Octree iterator base class
67  * \ingroup octree
68  * \author Julius Kammerl (julius@kammerl.de)
69  */
70 template <typename OctreeT>
72 public:
73  using iterator_category = std::forward_iterator_tag;
74  using value_type = const OctreeNode;
75  using difference_type = void;
76  using pointer = const OctreeNode*;
77  using reference = const OctreeNode&;
78 
79  using LeafNode = typename OctreeT::LeafNode;
80  using BranchNode = typename OctreeT::BranchNode;
81 
82  using LeafContainer = typename OctreeT::LeafContainer;
83  using BranchContainer = typename OctreeT::BranchContainer;
84 
85  /** \brief Empty constructor.
86  */
88 
89  /** \brief Constructor.
90  * \param[in] max_depth_arg Depth limitation during traversal
91  */
92  explicit OctreeIteratorBase(uindex_t max_depth_arg)
93  : octree_(nullptr), current_state_(nullptr), max_octree_depth_(max_depth_arg)
94  {
95  this->reset();
96  }
97 
98  /** \brief Constructor.
99  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
100  * root node.
101  */
102  OctreeIteratorBase(OctreeT* octree_arg) : OctreeIteratorBase(octree_arg, 0u) {}
103 
104  /** \brief Constructor.
105  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
106  * root node.
107  * \param[in] max_depth_arg Depth limitation during traversal
108  */
109  explicit OctreeIteratorBase(OctreeT* octree_arg, uindex_t max_depth_arg)
110  : octree_(octree_arg), current_state_(0), max_octree_depth_(max_depth_arg)
111  {
112  this->reset();
113  }
114 
115  /** \brief Constructor.
116  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
117  * root node.
118  * \param[in] max_depth_arg Depth limitation during traversal
119  * \param[in] current_state A pointer to the current iterator state
120  *
121  * \warning For advanced users only.
122  */
123  explicit OctreeIteratorBase(OctreeT* octree_arg,
124  uindex_t max_depth_arg,
125  IteratorState* current_state)
126  : octree_(octree_arg), current_state_(current_state), max_octree_depth_(max_depth_arg)
127  {}
128 
129  /** \brief Empty deconstructor. */
130  virtual ~OctreeIteratorBase() {}
131 
132  /** \brief Equal comparison operator
133  * \param[in] other OctreeIteratorBase to compare with
134  */
135  bool
136  operator==(const OctreeIteratorBase& other) const
137  {
138  if (this == &other) // same object
139  return true;
140  if (octree_ != other.octree_) // refer to different octrees
141  return false;
142  if (!current_state_ && !other.current_state_) // both are end iterators
143  return true;
145  other.current_state_ && // null dereference protection
147  return true;
148  return false;
149  }
150 
151  /** \brief Inequal comparison operator
152  * \param[in] other OctreeIteratorBase to compare with
153  */
154  bool
155  operator!=(const OctreeIteratorBase& other) const
156  {
157  return !operator==(other);
158  }
159 
160  /** \brief Reset iterator */
161  inline void
163  {
164  current_state_ = 0;
165  if (octree_ && (!max_octree_depth_)) {
166  max_octree_depth_ = octree_->getTreeDepth();
167  }
168  }
169 
170  /** \brief Get octree key for the current iterator octree node
171  * \return octree key of current node
172  */
173  inline const OctreeKey&
175  {
176  assert(octree_ != 0);
177  assert(current_state_ != 0);
178 
179  return (current_state_->key_);
180  }
181 
182  /** \brief Get the current depth level of octree
183  * \return depth level
184  */
185  inline uindex_t
187  {
188  assert(octree_ != 0);
189  assert(current_state_ != 0);
190 
191  return (current_state_->depth_);
192  }
193 
194  /** \brief Get the current octree node
195  * \return pointer to current octree node
196  */
197  inline OctreeNode*
199  {
200  assert(octree_ != 0);
201  assert(current_state_ != 0);
202 
203  return (current_state_->node_);
204  }
205 
206  /** \brief check if current node is a branch node
207  * \return true if current node is a branch node, false otherwise
208  */
209  inline bool
210  isBranchNode() const
211  {
212  assert(octree_ != 0);
213  assert(current_state_ != 0);
214 
216  }
217 
218  /** \brief check if current node is a branch node
219  * \return true if current node is a branch node, false otherwise
220  */
221  inline bool
222  isLeafNode() const
223  {
224  assert(octree_ != 0);
225  assert(current_state_ != 0);
226 
227  return (current_state_->node_->getNodeType() == LEAF_NODE);
228  }
229 
230  /** \brief *operator.
231  * \return pointer to the current octree node
232  */
233  inline OctreeNode*
234  operator*() const
235  { // return designated object
236  if (octree_ && current_state_) {
237  return (current_state_->node_);
238  }
239  else {
240  return 0;
241  }
242  }
243 
244  /** \brief Get bit pattern of children configuration of current node
245  * \return bit pattern (byte) describing the existence of 8 children of the current
246  * node
247  */
248  inline char
250  {
251  char ret = 0;
252 
253  assert(octree_ != 0);
254  assert(current_state_ != 0);
255 
256  if (isBranchNode()) {
257 
258  // current node is a branch node
259  const BranchNode* current_branch =
260  static_cast<const BranchNode*>(current_state_->node_);
261 
262  // get child configuration bit pattern
263  ret = octree_->getBranchBitPattern(*current_branch);
264  }
265 
266  return (ret);
267  }
268 
269  /** \brief Method for retrieving a single leaf container from the octree leaf node
270  * \return Reference to container class of leaf node.
271  */
272  const LeafContainer&
274  {
275  assert(octree_ != 0);
276  assert(current_state_ != 0);
277  assert(this->isLeafNode());
278 
279  LeafNode* leaf_node = static_cast<LeafNode*>(current_state_->node_);
280 
281  return leaf_node->getContainer();
282  }
283 
284  /** \brief Method for retrieving a single leaf container from the octree leaf node
285  * \return Reference to container class of leaf node.
286  */
289  {
290  assert(octree_ != 0);
291  assert(current_state_ != 0);
292  assert(this->isLeafNode());
293 
294  LeafNode* leaf_node = static_cast<LeafNode*>(current_state_->node_);
295 
296  return leaf_node->getContainer();
297  }
298 
299  /** \brief Method for retrieving the container from an octree branch node
300  * \return BranchContainer.
301  */
302  const BranchContainer&
304  {
305  assert(octree_ != 0);
306  assert(current_state_ != 0);
307  assert(this->isBranchNode());
308 
309  BranchNode* branch_node = static_cast<BranchNode*>(current_state_->node_);
310 
311  return branch_node->getContainer();
312  }
313 
314  /** \brief Method for retrieving the container from an octree branch node
315  * \return BranchContainer.
316  */
319  {
320  assert(octree_ != 0);
321  assert(current_state_ != 0);
322  assert(this->isBranchNode());
323 
324  BranchNode* branch_node = static_cast<BranchNode*>(current_state_->node_);
325 
326  return branch_node->getContainer();
327  }
328 
329  /** \brief get a integer identifier for current node (note: identifier depends on tree
330  * depth). \return node id.
331  */
332  virtual unsigned long
333  getNodeID() const
334  {
335  unsigned long id = 0;
336 
337  assert(octree_ != 0);
338  assert(current_state_ != 0);
339 
340  if (current_state_) {
341  const OctreeKey& key = getCurrentOctreeKey();
342  // calculate integer id with respect to octree key
343  uindex_t depth = octree_->getTreeDepth();
344  id = static_cast<unsigned long>(key.x) << (depth * 2) |
345  static_cast<unsigned long>(key.y) << (depth * 1) |
346  static_cast<unsigned long>(key.z) << (depth * 0);
347  }
348 
349  return id;
350  }
351 
352 protected:
353  /** \brief Reference to octree class. */
354  OctreeT* octree_;
355 
356  /** \brief Pointer to current iterator state. */
358 
359  /** \brief Maximum octree depth */
361 };
362 
363 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
364 /** \brief @b Octree iterator class
365  * \note This class implements a forward iterator for traversing octrees in a
366  * depth-first manner.
367  * \ingroup octree
368  * \author Julius Kammerl (julius@kammerl.de)
369  */
370 template <typename OctreeT>
372 
373 public:
376 
377  /** \brief Empty constructor.
378  * \param[in] max_depth_arg Depth limitation during traversal
379  */
380  explicit OctreeDepthFirstIterator(uindex_t max_depth_arg = 0);
381 
382  /** \brief Constructor.
383  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
384  * root node.
385  * \param[in] max_depth_arg Depth limitation during traversal
386  */
387  explicit OctreeDepthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0);
388 
389  /** \brief Constructor.
390  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
391  * root node.
392  * \param[in] max_depth_arg Depth limitation during traversal
393  * \param[in] current_state A pointer to the current iterator state
394  *
395  * \warning For advanced users only.
396  */
398  OctreeT* octree_arg,
399  uindex_t max_depth_arg,
400  IteratorState* current_state,
401  const std::vector<IteratorState>& stack = std::vector<IteratorState>())
402  : OctreeIteratorBase<OctreeT>(octree_arg, max_depth_arg, current_state), stack_(stack)
403  {}
404 
405  /** \brief Copy Constructor.
406  * \param[in] other Another OctreeDepthFirstIterator to copy from
407  */
409  : OctreeIteratorBase<OctreeT>(other), stack_(other.stack_)
410  {
411  this->current_state_ = stack_.size() ? &stack_.back() : NULL;
412  }
413 
414  /** \brief Copy assignment
415  * \param[in] src the iterator to copy into this
416  */
419  {
420 
422 
423  stack_ = src.stack_;
424 
425  if (stack_.size()) {
426  this->current_state_ = &stack_.back();
427  }
428  else {
429  this->current_state_ = 0;
430  }
431 
432  return (*this);
433  }
434 
435  /** \brief Reset the iterator to the root node of the octree
436  */
437  virtual void
438  reset();
439 
440  /** \brief Preincrement operator.
441  * \note recursively step to next octree node
442  */
444  operator++();
445 
446  /** \brief postincrement operator.
447  * \note recursively step to next octree node
448  */
451  {
452  OctreeDepthFirstIterator _Tmp = *this;
453  ++*this;
454  return (_Tmp);
455  }
456 
457  /** \brief Skip all child voxels of current node and return to parent node.
458  */
459  void
460  skipChildVoxels();
461 
462 protected:
463  /** Stack structure. */
464  std::vector<IteratorState> stack_;
465 };
466 
467 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
468 /** \brief @b Octree iterator class
469  * \note This class implements a forward iterator for traversing octrees in a
470  * breadth-first manner.
471  * \ingroup octree
472  * \author Julius Kammerl (julius@kammerl.de)
473  */
474 template <typename OctreeT>
476 public:
477  // public typedefs
480 
481  /** \brief Empty constructor.
482  * \param[in] max_depth_arg Depth limitation during traversal
483  */
484  explicit OctreeBreadthFirstIterator(uindex_t max_depth_arg = 0);
485 
486  /** \brief Constructor.
487  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
488  * root node.
489  * \param[in] max_depth_arg Depth limitation during traversal
490  */
491  explicit OctreeBreadthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0);
492 
493  /** \brief Constructor.
494  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
495  * root node.
496  * \param[in] max_depth_arg Depth limitation during traversal
497  * \param[in] current_state A pointer to the current iterator state
498  *
499  * \warning For advanced users only.
500  */
502  OctreeT* octree_arg,
503  uindex_t max_depth_arg,
504  IteratorState* current_state,
505  const std::deque<IteratorState>& fifo = std::deque<IteratorState>())
506  : OctreeIteratorBase<OctreeT>(octree_arg, max_depth_arg, current_state), FIFO_(fifo)
507  {}
508 
509  /** \brief Copy Constructor.
510  * \param[in] other Another OctreeBreadthFirstIterator to copy from
511  */
513  : OctreeIteratorBase<OctreeT>(other), FIFO_(other.FIFO_)
514  {
515  this->current_state_ = FIFO_.size() ? &FIFO_.front() : NULL;
516  }
517 
518  /** \brief Copy operator.
519  * \param[in] src the iterator to copy into this
520  */
523  {
524 
526 
527  FIFO_ = src.FIFO_;
528 
529  if (FIFO_.size()) {
530  this->current_state_ = &FIFO_.front();
531  }
532  else {
533  this->current_state_ = 0;
534  }
535 
536  return (*this);
537  }
538 
539  /** \brief Reset the iterator to the root node of the octree
540  */
541  void
542  reset();
543 
544  /** \brief Preincrement operator.
545  * \note step to next octree node
546  */
548  operator++();
549 
550  /** \brief postincrement operator.
551  * \note step to next octree node
552  */
555  {
556  OctreeBreadthFirstIterator _Tmp = *this;
557  ++*this;
558  return (_Tmp);
559  }
560 
561 protected:
562  /** FIFO list */
563  std::deque<IteratorState> FIFO_;
564 };
565 
566 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
567 /** \brief @b Octree iterator class
568  * \note Iterator over all existing nodes at a given depth. It walks across an octree
569  * in a breadth-first manner.
570  * \ingroup octree
571  * \author Fabien Rozar (fabien.rozar@gmail.com)
572  */
573 template <typename OctreeT>
575 public:
576  // public typedefs
579 
580  /** \brief Empty constructor.
581  */
583 
584  /** \brief Constructor.
585  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
586  * root node.
587  * \param[in] fixed_depth_arg Depth level during traversal
588  */
589  explicit OctreeFixedDepthIterator(OctreeT* octree_arg, uindex_t fixed_depth_arg = 0);
590 
591  /** \brief Constructor.
592  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
593  * root node.
594  * \param[in] fixed_depth_arg Depth level during traversal
595  * \param[in] current_state A pointer to the current iterator state
596  * \param[in] fifo Internal container of octree node to go through
597  *
598  * \warning For advanced users only.
599  */
601  OctreeT* octree_arg,
602  uindex_t fixed_depth_arg,
603  IteratorState* current_state,
604  const std::deque<IteratorState>& fifo = std::deque<IteratorState>())
605  : OctreeBreadthFirstIterator<OctreeT>(
606  octree_arg, fixed_depth_arg, current_state, fifo)
607  , fixed_depth_(fixed_depth_arg)
608  {}
609 
610  /** \brief Copy Constructor.
611  * \param[in] other Another OctreeFixedDepthIterator to copy from
612  */
614  : OctreeBreadthFirstIterator<OctreeT>(other)
615  {
616  this->fixed_depth_ = other.fixed_depth_;
617  }
618 
619  /** \brief Copy assignment.
620  * \param[in] src the iterator to copy into this
621  * \return pointer to the current octree node
622  */
625  {
627  this->fixed_depth_ = src.fixed_depth_;
628 
629  return (*this);
630  }
631 
632  /** \brief Reset the iterator to the first node at the depth given as parameter
633  * \param[in] fixed_depth_arg Depth level during traversal
634  */
635  void
636  reset(uindex_t fixed_depth_arg);
637 
638  /** \brief Reset the iterator to the first node at the current depth
639  */
640  void
642  {
643  this->reset(fixed_depth_);
644  }
645 
646 protected:
648 
649  /** \brief Given level of the node to be iterated */
651 };
652 
653 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
654 /** \brief Octree leaf node iterator class
655  * \note This class implements a forward iterator for traversing the leaf nodes of an
656  * octree data structure.
657  * \ingroup octree
658  * \author Julius Kammerl (julius@kammerl.de)
659  */
660 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
661 template <typename OctreeT>
665 
666 public:
667  /** \brief Empty constructor.
668  * \param[in] max_depth_arg Depth limitation during traversal
669  */
670  explicit OctreeLeafNodeDepthFirstIterator(uindex_t max_depth_arg = 0)
671  : OctreeDepthFirstIterator<OctreeT>(max_depth_arg)
672  {
673  reset();
674  }
675 
676  /** \brief Constructor.
677  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
678  * root node.
679  * \param[in] max_depth_arg Depth limitation during traversal
680  */
681  explicit OctreeLeafNodeDepthFirstIterator(OctreeT* octree_arg,
682  uindex_t max_depth_arg = 0)
683  : OctreeDepthFirstIterator<OctreeT>(octree_arg, max_depth_arg)
684  {
685  reset();
686  }
687 
688  /** \brief Constructor.
689  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
690  * root node.
691  * \param[in] max_depth_arg Depth limitation during traversal
692  * \param[in] current_state A pointer to the current iterator state
693  *
694  * \warning For advanced users only.
695  */
697  OctreeT* octree_arg,
698  uindex_t max_depth_arg,
699  IteratorState* current_state,
700  const std::vector<IteratorState>& stack = std::vector<IteratorState>())
701  : OctreeDepthFirstIterator<OctreeT>(octree_arg, max_depth_arg, current_state, stack)
702  {}
703 
704  /** \brief Reset the iterator to the root node of the octree
705  */
706  inline void
708  {
710  this->operator++();
711  }
712 
713  /** \brief Preincrement operator.
714  * \note recursively step to next octree leaf node
715  */
718  {
719  do {
721  } while ((this->current_state_) &&
722  (this->current_state_->node_->getNodeType() != LEAF_NODE));
723 
724  return (*this);
725  }
726 
727  /** \brief postincrement operator.
728  * \note step to next octree node
729  */
732  {
734  ++*this;
735  return (_Tmp);
736  }
737 
738  /** \brief *operator.
739  * \return pointer to the current octree leaf node
740  */
741  OctreeNode*
742  operator*() const
743  {
744  // return designated object
745  OctreeNode* ret = 0;
746 
747  if (this->current_state_ &&
748  (this->current_state_->node_->getNodeType() == LEAF_NODE))
749  ret = this->current_state_->node_;
750  return (ret);
751  }
752 };
753 
754 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
755 /** \brief Octree leaf node iterator class
756  * \note This class implements a forward iterator for traversing the leaf nodes of an
757  * octree data structure in the breadth first way.
758  * \ingroup octree
759  * \author Fabien Rozar
760  * (fabien.rozar@gmail.com)
761  */
762 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
763 template <typename OctreeT>
767 
768 public:
769  /** \brief Empty constructor.
770  * \param[in] max_depth_arg Depth limitation during traversal
771  */
772  explicit OctreeLeafNodeBreadthFirstIterator(uindex_t max_depth_arg = 0);
773 
774  /** \brief Constructor.
775  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
776  * root node.
777  * \param[in] max_depth_arg Depth limitation during traversal
778  */
779  explicit OctreeLeafNodeBreadthFirstIterator(OctreeT* octree_arg,
780  uindex_t max_depth_arg = 0);
781 
782  /** \brief Copy constructor.
783  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
784  * root node.
785  * \param[in] max_depth_arg Depth limitation during traversal
786  * \param[in] current_state A pointer to the current iterator state
787  * \param[in] fifo Internal container of octree node to go through
788  *
789  * \warning For advanced users only.
790  */
792  OctreeT* octree_arg,
793  uindex_t max_depth_arg,
794  IteratorState* current_state,
795  const std::deque<IteratorState>& fifo = std::deque<IteratorState>());
796 
797  /** \brief Reset the iterator to the first leaf in the breadth first way.
798  */
799  inline void
800  reset();
801 
802  /** \brief Preincrement operator.
803  * \note recursively step to next octree leaf node
804  */
806  operator++();
807 
808  /** \brief Postincrement operator.
809  * \note step to next octree node
810  */
812  operator++(int);
813 };
814 
815 } // namespace octree
816 } // namespace pcl
817 
818 /*
819  * Note: Since octree iterators depend on octrees, don't precompile them.
820  */
821 #include <pcl/octree/impl/octree_iterator.hpp>
typename OctreeIteratorBase< OctreeT >::LeafNode LeafNode
OctreeBreadthFirstIterator & operator=(const OctreeBreadthFirstIterator &src)
Copy operator.
OctreeBreadthFirstIterator(const OctreeBreadthFirstIterator &other)
Copy Constructor.
OctreeBreadthFirstIterator & operator++()
Preincrement operator.
OctreeBreadthFirstIterator(OctreeT *octree_arg, uindex_t max_depth_arg, IteratorState *current_state, const std::deque< IteratorState > &fifo=std::deque< IteratorState >())
Constructor.
void reset()
Reset the iterator to the root node of the octree.
OctreeBreadthFirstIterator(uindex_t max_depth_arg=0)
Empty constructor.
std::deque< IteratorState > FIFO_
FIFO list.
OctreeBreadthFirstIterator operator++(int)
postincrement operator.
typename OctreeIteratorBase< OctreeT >::BranchNode BranchNode
typename OctreeIteratorBase< OctreeT >::BranchNode BranchNode
typename OctreeIteratorBase< OctreeT >::LeafNode LeafNode
OctreeDepthFirstIterator(const OctreeDepthFirstIterator &other)
Copy Constructor.
std::vector< IteratorState > stack_
Stack structure.
void skipChildVoxels()
Skip all child voxels of current node and return to parent node.
OctreeDepthFirstIterator & operator++()
Preincrement operator.
OctreeDepthFirstIterator & operator=(const OctreeDepthFirstIterator &src)
Copy assignment.
OctreeDepthFirstIterator operator++(int)
postincrement operator.
OctreeDepthFirstIterator(OctreeT *octree_arg, uindex_t max_depth_arg, IteratorState *current_state, const std::vector< IteratorState > &stack=std::vector< IteratorState >())
Constructor.
virtual void reset()
Reset the iterator to the root node of the octree.
OctreeDepthFirstIterator(uindex_t max_depth_arg=0)
Empty constructor.
OctreeFixedDepthIterator(OctreeT *octree_arg, uindex_t fixed_depth_arg, IteratorState *current_state, const std::deque< IteratorState > &fifo=std::deque< IteratorState >())
Constructor.
void reset()
Reset the iterator to the first node at the current depth.
OctreeFixedDepthIterator(const OctreeFixedDepthIterator &other)
Copy Constructor.
OctreeFixedDepthIterator & operator=(const OctreeFixedDepthIterator &src)
Copy assignment.
uindex_t fixed_depth_
Given level of the node to be iterated.
Abstract octree iterator class
OctreeNode * operator*() const
*operator.
char getNodeConfiguration() const
Get bit pattern of children configuration of current node.
OctreeIteratorBase(uindex_t max_depth_arg)
Constructor.
OctreeT * octree_
Reference to octree class.
const OctreeKey & getCurrentOctreeKey() const
Get octree key for the current iterator octree node.
typename OctreeT::BranchNode BranchNode
LeafContainer & getLeafContainer()
Method for retrieving a single leaf container from the octree leaf node.
OctreeIteratorBase(OctreeT *octree_arg, uindex_t max_depth_arg, IteratorState *current_state)
Constructor.
uindex_t max_octree_depth_
Maximum octree depth.
uindex_t getCurrentOctreeDepth() const
Get the current depth level of octree.
OctreeIteratorBase()
Empty constructor.
OctreeIteratorBase(OctreeT *octree_arg, uindex_t max_depth_arg)
Constructor.
virtual ~OctreeIteratorBase()
Empty deconstructor.
bool isBranchNode() const
check if current node is a branch node
OctreeIteratorBase(OctreeT *octree_arg)
Constructor.
OctreeNode * getCurrentOctreeNode() const
Get the current octree node.
const LeafContainer & getLeafContainer() const
Method for retrieving a single leaf container from the octree leaf node.
virtual unsigned long getNodeID() const
get a integer identifier for current node (note: identifier depends on tree depth).
typename OctreeT::LeafNode LeafNode
BranchContainer & getBranchContainer()
Method for retrieving the container from an octree branch node.
bool operator==(const OctreeIteratorBase &other) const
Equal comparison operator.
bool operator!=(const OctreeIteratorBase &other) const
Inequal comparison operator.
typename OctreeT::BranchContainer BranchContainer
IteratorState * current_state_
Pointer to current iterator state.
std::forward_iterator_tag iterator_category
const BranchContainer & getBranchContainer() const
Method for retrieving the container from an octree branch node.
typename OctreeT::LeafContainer LeafContainer
bool isLeafNode() const
check if current node is a branch node
Octree key class
Definition: octree_key.h:54
OctreeLeafNodeBreadthFirstIterator(uindex_t max_depth_arg=0)
Empty constructor.
void reset()
Reset the iterator to the first leaf in the breadth first way.
OctreeLeafNodeBreadthFirstIterator & operator++()
Preincrement operator.
Octree leaf node iterator class.
OctreeLeafNodeDepthFirstIterator & operator++()
Preincrement operator.
OctreeLeafNodeDepthFirstIterator(OctreeT *octree_arg, uindex_t max_depth_arg, IteratorState *current_state, const std::vector< IteratorState > &stack=std::vector< IteratorState >())
Constructor.
OctreeLeafNodeDepthFirstIterator operator++(int)
postincrement operator.
OctreeLeafNodeDepthFirstIterator(OctreeT *octree_arg, uindex_t max_depth_arg=0)
Constructor.
void reset()
Reset the iterator to the root node of the octree.
OctreeNode * operator*() const
*operator.
OctreeLeafNodeDepthFirstIterator(uindex_t max_depth_arg=0)
Empty constructor.
Abstract octree node class
Definition: octree_nodes.h:58
virtual node_type_t getNodeType() const =0
Pure virtual method for receiving the type of octree node (branch or leaf)
detail::int_type_t< detail::index_type_size, false > uindex_t
Type used for an unsigned index in PCL.
Definition: types.h:120