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() = default;
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 Preincrement operator.
171  * \note step to next octree node
172  */
173  virtual OctreeIteratorBase&
174  operator++() = 0;
175 
176  /** \brief Get octree key for the current iterator octree node
177  * \return octree key of current node
178  */
179  inline const OctreeKey&
181  {
182  assert(octree_ != 0);
183  assert(current_state_ != 0);
184 
185  return (current_state_->key_);
186  }
187 
188  /** \brief Get the current depth level of octree
189  * \return depth level
190  */
191  inline uindex_t
193  {
194  assert(octree_ != 0);
195  assert(current_state_ != 0);
196 
197  return (current_state_->depth_);
198  }
199 
200  /** \brief Get the current octree node
201  * \return pointer to current octree node
202  */
203  inline OctreeNode*
205  {
206  assert(octree_ != 0);
207  assert(current_state_ != 0);
208 
209  return (current_state_->node_);
210  }
211 
212  /** \brief check if current node is a branch node
213  * \return true if current node is a branch node, false otherwise
214  */
215  inline bool
216  isBranchNode() const
217  {
218  assert(octree_ != 0);
219  assert(current_state_ != 0);
220 
222  }
223 
224  /** \brief check if current node is a branch node
225  * \return true if current node is a branch node, false otherwise
226  */
227  inline bool
228  isLeafNode() const
229  {
230  assert(octree_ != 0);
231  assert(current_state_ != 0);
232 
233  return (current_state_->node_->getNodeType() == LEAF_NODE);
234  }
235 
236  /** \brief *operator.
237  * \return pointer to the current octree node
238  */
239  virtual OctreeNode*
240  operator*() const
241  { // return designated object
242  if (octree_ && current_state_) {
243  return (current_state_->node_);
244  }
245  else {
246  return 0;
247  }
248  }
249 
250  /** \brief Get bit pattern of children configuration of current node
251  * \return bit pattern (byte) describing the existence of 8 children of the current
252  * node
253  */
254  inline char
256  {
257  char ret = 0;
258 
259  assert(octree_ != 0);
260  assert(current_state_ != 0);
261 
262  if (isBranchNode()) {
263 
264  // current node is a branch node
265  const BranchNode* current_branch =
266  static_cast<const BranchNode*>(current_state_->node_);
267 
268  // get child configuration bit pattern
269  ret = octree_->getBranchBitPattern(*current_branch);
270  }
271 
272  return (ret);
273  }
274 
275  /** \brief Method for retrieving a single leaf container from the octree leaf node
276  * \return Reference to container class of leaf node.
277  */
278  const LeafContainer&
280  {
281  assert(octree_ != 0);
282  assert(current_state_ != 0);
283  assert(this->isLeafNode());
284 
285  LeafNode* leaf_node = static_cast<LeafNode*>(current_state_->node_);
286 
287  return leaf_node->getContainer();
288  }
289 
290  /** \brief Method for retrieving a single leaf container from the octree leaf node
291  * \return Reference to container class of leaf node.
292  */
295  {
296  assert(octree_ != 0);
297  assert(current_state_ != 0);
298  assert(this->isLeafNode());
299 
300  LeafNode* leaf_node = static_cast<LeafNode*>(current_state_->node_);
301 
302  return leaf_node->getContainer();
303  }
304 
305  /** \brief Method for retrieving the container from an octree branch node
306  * \return BranchContainer.
307  */
308  const BranchContainer&
310  {
311  assert(octree_ != 0);
312  assert(current_state_ != 0);
313  assert(this->isBranchNode());
314 
315  BranchNode* branch_node = static_cast<BranchNode*>(current_state_->node_);
316 
317  return branch_node->getContainer();
318  }
319 
320  /** \brief Method for retrieving the container from an octree branch node
321  * \return BranchContainer.
322  */
325  {
326  assert(octree_ != 0);
327  assert(current_state_ != 0);
328  assert(this->isBranchNode());
329 
330  BranchNode* branch_node = static_cast<BranchNode*>(current_state_->node_);
331 
332  return branch_node->getContainer();
333  }
334 
335  /** \brief get a integer identifier for current node (note: identifier depends on tree
336  * depth). \return node id.
337  */
338  virtual unsigned long
339  getNodeID() const
340  {
341  unsigned long id = 0;
342 
343  assert(octree_ != 0);
344  assert(current_state_ != 0);
345 
346  if (current_state_) {
347  const OctreeKey& key = getCurrentOctreeKey();
348  // calculate integer id with respect to octree key
349  uindex_t depth = octree_->getTreeDepth();
350  id = static_cast<unsigned long>(key.x) << (depth * 2) |
351  static_cast<unsigned long>(key.y) << (depth * 1) |
352  static_cast<unsigned long>(key.z) << (depth * 0);
353  }
354 
355  return id;
356  }
357 
358 protected:
359  /** \brief Reference to octree class. */
360  OctreeT* octree_;
361 
362  /** \brief Pointer to current iterator state. */
364 
365  /** \brief Maximum octree depth */
367 };
368 
369 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
370 /** \brief @b Octree iterator class
371  * \note This class implements a forward iterator for traversing octrees in a
372  * depth-first manner.
373  * \ingroup octree
374  * \author Julius Kammerl (julius@kammerl.de)
375  */
376 template <typename OctreeT>
378 
379 public:
382 
383  /** \brief Empty constructor.
384  * \param[in] max_depth_arg Depth limitation during traversal
385  */
386  explicit OctreeDepthFirstIterator(uindex_t max_depth_arg = 0);
387 
388  /** \brief Constructor.
389  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
390  * root node.
391  * \param[in] max_depth_arg Depth limitation during traversal
392  */
393  explicit OctreeDepthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0);
394 
395  /** \brief Constructor.
396  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
397  * root node.
398  * \param[in] max_depth_arg Depth limitation during traversal
399  * \param[in] current_state A pointer to the current iterator state
400  * \param[in] stack A stack structure used for depth first search
401  *
402  * \warning For advanced users only.
403  */
405  OctreeT* octree_arg,
406  uindex_t max_depth_arg,
407  IteratorState* current_state,
408  const std::vector<IteratorState>& stack = std::vector<IteratorState>())
409  : OctreeIteratorBase<OctreeT>(octree_arg, max_depth_arg, current_state), stack_(stack)
410  {}
411 
412  /** \brief Copy Constructor.
413  * \param[in] other Another OctreeDepthFirstIterator to copy from
414  */
416  : OctreeIteratorBase<OctreeT>(other), stack_(other.stack_)
417  {
418  this->current_state_ = stack_.size() ? &stack_.back() : NULL;
419  }
420 
421  /** \brief Copy assignment
422  * \param[in] src the iterator to copy into this
423  */
426  {
427 
429 
430  stack_ = src.stack_;
431 
432  if (stack_.size()) {
433  this->current_state_ = &stack_.back();
434  }
435  else {
436  this->current_state_ = 0;
437  }
438 
439  return (*this);
440  }
441 
442  /** \brief Reset the iterator to the root node of the octree
443  */
444  virtual void
445  reset();
446 
447  /** \brief Preincrement operator.
448  * \note recursively step to next octree node
449  */
451  operator++();
452 
453  /** \brief postincrement operator.
454  * \note recursively step to next octree node
455  */
458  {
459  OctreeDepthFirstIterator _Tmp = *this;
460  ++*this;
461  return (_Tmp);
462  }
463 
464  /** \brief Skip all child voxels of current node and return to parent node.
465  */
466  void
467  skipChildVoxels();
468 
469 protected:
470  /** Stack structure. */
471  std::vector<IteratorState> stack_;
472 };
473 
474 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
475 /** \brief @b Octree iterator class
476  * \note This class implements a forward iterator for traversing octrees in a
477  * breadth-first manner.
478  * \ingroup octree
479  * \author Julius Kammerl (julius@kammerl.de)
480  */
481 template <typename OctreeT>
483 public:
484  // public typedefs
487 
488  /** \brief Empty constructor.
489  * \param[in] max_depth_arg Depth limitation during traversal
490  */
491  explicit OctreeBreadthFirstIterator(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  */
498  explicit OctreeBreadthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0);
499 
500  /** \brief Constructor.
501  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
502  * root node.
503  * \param[in] max_depth_arg Depth limitation during traversal
504  * \param[in] current_state A pointer to the current iterator state
505  *
506  * \warning For advanced users only.
507  */
509  OctreeT* octree_arg,
510  uindex_t max_depth_arg,
511  IteratorState* current_state,
512  const std::deque<IteratorState>& fifo = std::deque<IteratorState>())
513  : OctreeIteratorBase<OctreeT>(octree_arg, max_depth_arg, current_state), FIFO_(fifo)
514  {}
515 
516  /** \brief Copy Constructor.
517  * \param[in] other Another OctreeBreadthFirstIterator to copy from
518  */
520  : OctreeIteratorBase<OctreeT>(other), FIFO_(other.FIFO_)
521  {
522  this->current_state_ = FIFO_.size() ? &FIFO_.front() : NULL;
523  }
524 
525  /** \brief Copy operator.
526  * \param[in] src the iterator to copy into this
527  */
530  {
531 
533 
534  FIFO_ = src.FIFO_;
535 
536  if (FIFO_.size()) {
537  this->current_state_ = &FIFO_.front();
538  }
539  else {
540  this->current_state_ = 0;
541  }
542 
543  return (*this);
544  }
545 
546  /** \brief Reset the iterator to the root node of the octree
547  */
548  void
549  reset();
550 
551  /** \brief Preincrement operator.
552  * \note step to next octree node
553  */
555  operator++();
556 
557  /** \brief postincrement operator.
558  * \note step to next octree node
559  */
562  {
563  OctreeBreadthFirstIterator _Tmp = *this;
564  ++*this;
565  return (_Tmp);
566  }
567 
568 protected:
569  /** FIFO list */
570  std::deque<IteratorState> FIFO_;
571 };
572 
573 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
574 /** \brief @b Octree iterator class
575  * \note Iterator over all existing nodes at a given depth. It walks across an octree
576  * in a breadth-first manner.
577  * \ingroup octree
578  * \author Fabien Rozar (fabien.rozar@gmail.com)
579  */
580 template <typename OctreeT>
582 public:
583  // public typedefs
586 
587  /** \brief Empty constructor.
588  */
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  */
596  explicit OctreeFixedDepthIterator(OctreeT* octree_arg, uindex_t fixed_depth_arg = 0);
597 
598  /** \brief Constructor.
599  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
600  * root node.
601  * \param[in] fixed_depth_arg Depth level during traversal
602  * \param[in] current_state A pointer to the current iterator state
603  * \param[in] fifo Internal container of octree node to go through
604  *
605  * \warning For advanced users only.
606  */
608  OctreeT* octree_arg,
609  uindex_t fixed_depth_arg,
610  IteratorState* current_state,
611  const std::deque<IteratorState>& fifo = std::deque<IteratorState>())
612  : OctreeBreadthFirstIterator<OctreeT>(
613  octree_arg, fixed_depth_arg, current_state, fifo)
614  , fixed_depth_(fixed_depth_arg)
615  {}
616 
617  /** \brief Copy Constructor.
618  * \param[in] other Another OctreeFixedDepthIterator to copy from
619  */
621  : OctreeBreadthFirstIterator<OctreeT>(other)
622  {
623  this->fixed_depth_ = other.fixed_depth_;
624  }
625 
626  /** \brief Copy assignment.
627  * \param[in] src the iterator to copy into this
628  * \return pointer to the current octree node
629  */
632  {
634  this->fixed_depth_ = src.fixed_depth_;
635 
636  return (*this);
637  }
638 
639  /** \brief Reset the iterator to the first node at the depth given as parameter
640  * \param[in] fixed_depth_arg Depth level during traversal
641  */
642  void
643  reset(uindex_t fixed_depth_arg);
644 
645  /** \brief Reset the iterator to the first node at the current depth
646  */
647  void
649  {
650  this->reset(fixed_depth_);
651  }
652 
653 protected:
655 
656  /** \brief Given level of the node to be iterated */
658 };
659 
660 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
661 /** \brief Octree leaf node iterator class
662  * \note This class implements a forward iterator for traversing the leaf nodes of an
663  * octree data structure.
664  * \ingroup octree
665  * \author Julius Kammerl (julius@kammerl.de)
666  */
667 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
668 template <typename OctreeT>
672 
673 public:
674  /** \brief Empty constructor.
675  * \param[in] max_depth_arg Depth limitation during traversal
676  */
677  explicit OctreeLeafNodeDepthFirstIterator(uindex_t max_depth_arg = 0)
678  : OctreeDepthFirstIterator<OctreeT>(max_depth_arg)
679  {
680  reset();
681  }
682 
683  /** \brief Constructor.
684  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
685  * root node.
686  * \param[in] max_depth_arg Depth limitation during traversal
687  */
688  explicit OctreeLeafNodeDepthFirstIterator(OctreeT* octree_arg,
689  uindex_t max_depth_arg = 0)
690  : OctreeDepthFirstIterator<OctreeT>(octree_arg, max_depth_arg)
691  {
692  reset();
693  }
694 
695  /** \brief Constructor.
696  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
697  * root node.
698  * \param[in] max_depth_arg Depth limitation during traversal
699  * \param[in] current_state A pointer to the current iterator state
700  *
701  * \warning For advanced users only.
702  */
704  OctreeT* octree_arg,
705  uindex_t max_depth_arg,
706  IteratorState* current_state,
707  const std::vector<IteratorState>& stack = std::vector<IteratorState>())
708  : OctreeDepthFirstIterator<OctreeT>(octree_arg, max_depth_arg, current_state, stack)
709  {}
710 
711  /** \brief Reset the iterator to the root node of the octree
712  */
713  inline void
715  {
717  this->operator++();
718  }
719 
720  /** \brief Preincrement operator.
721  * \note recursively step to next octree leaf node
722  */
725  {
726  do {
728  } while ((this->current_state_) &&
729  (this->current_state_->node_->getNodeType() != LEAF_NODE));
730 
731  return (*this);
732  }
733 
734  /** \brief postincrement operator.
735  * \note step to next octree node
736  */
739  {
741  ++*this;
742  return (_Tmp);
743  }
744 
745  /** \brief *operator.
746  * \return pointer to the current octree leaf node
747  */
748  OctreeNode*
749  operator*() const override
750  {
751  // return designated object
752  OctreeNode* ret = 0;
753 
754  if (this->current_state_ &&
755  (this->current_state_->node_->getNodeType() == LEAF_NODE))
756  ret = this->current_state_->node_;
757  return (ret);
758  }
759 };
760 
761 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
762 /** \brief Octree leaf node iterator class
763  * \note This class implements a forward iterator for traversing the leaf nodes of an
764  * octree data structure in the breadth first way.
765  * \ingroup octree
766  * \author Fabien Rozar
767  * (fabien.rozar@gmail.com)
768  */
769 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
770 template <typename OctreeT>
774 
775 public:
776  /** \brief Empty constructor.
777  * \param[in] max_depth_arg Depth limitation during traversal
778  */
779  explicit OctreeLeafNodeBreadthFirstIterator(uindex_t max_depth_arg = 0);
780 
781  /** \brief Constructor.
782  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
783  * root node.
784  * \param[in] max_depth_arg Depth limitation during traversal
785  */
786  explicit OctreeLeafNodeBreadthFirstIterator(OctreeT* octree_arg,
787  uindex_t max_depth_arg = 0);
788 
789  /** \brief Copy constructor.
790  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
791  * root node.
792  * \param[in] max_depth_arg Depth limitation during traversal
793  * \param[in] current_state A pointer to the current iterator state
794  * \param[in] fifo Internal container of octree node to go through
795  *
796  * \warning For advanced users only.
797  */
799  OctreeT* octree_arg,
800  uindex_t max_depth_arg,
801  IteratorState* current_state,
802  const std::deque<IteratorState>& fifo = std::deque<IteratorState>());
803 
804  /** \brief Reset the iterator to the first leaf in the breadth first way.
805  */
806  inline void
807  reset();
808 
809  /** \brief Preincrement operator.
810  * \note recursively step to next octree leaf node
811  */
813  operator++();
814 
815  /** \brief Postincrement operator.
816  * \note step to next octree node
817  */
819  operator++(int);
820 
821  /** \brief *operator.
822  * \return pointer to the current octree leaf node
823  */
824  OctreeNode*
825  operator*() const override
826  {
827  // return designated object
828  OctreeNode* ret = 0;
829 
830  if (this->current_state_ &&
831  (this->current_state_->node_->getNodeType() == LEAF_NODE))
832  ret = this->current_state_->node_;
833  return (ret);
834  }
835 };
836 
837 } // namespace octree
838 } // namespace pcl
839 
840 /*
841  * Note: Since octree iterators depend on octrees, don't precompile them.
842  */
843 #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
char getNodeConfiguration() const
Get bit pattern of children configuration of current node.
virtual OctreeNode * operator*() const
*operator.
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.
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.
virtual ~OctreeIteratorBase()=default
Empty deconstructor.
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.
virtual OctreeIteratorBase & operator++()=0
Preincrement operator.
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.
OctreeNode * operator*() const override
*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.
OctreeNode * operator*() const override
*operator.
OctreeLeafNodeDepthFirstIterator(OctreeT *octree_arg, uindex_t max_depth_arg=0)
Constructor.
void reset()
Reset the iterator to the root node of the octree.
OctreeLeafNodeDepthFirstIterator(uindex_t max_depth_arg=0)
Empty constructor.
Abstract octree node class
Definition: octree_nodes.h:59
virtual node_type_t getNodeType() const =0
Pure virtual method for retrieving 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