Point Cloud Library (PCL)  1.14.0-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 {
60  OctreeNode* node_{nullptr};
63  IteratorState() = default;
64  IteratorState(OctreeNode* node, const OctreeKey& key, uindex_t depth)
65  : node_(node), key_(key), depth_(depth)
66  {}
67 };
68 
69 /** \brief @b Abstract octree iterator class
70  * \note Octree iterator base class
71  * \ingroup octree
72  * \author Julius Kammerl (julius@kammerl.de)
73  */
74 template <typename OctreeT>
76 public:
77  using iterator_category = std::forward_iterator_tag;
78  using value_type = const OctreeNode;
79  using difference_type = void;
80  using pointer = const OctreeNode*;
81  using reference = const OctreeNode&;
82 
83  using LeafNode = typename OctreeT::LeafNode;
84  using BranchNode = typename OctreeT::BranchNode;
85 
86  using LeafContainer = typename OctreeT::LeafContainer;
87  using BranchContainer = typename OctreeT::BranchContainer;
88 
89  /** \brief Empty constructor.
90  */
92 
93  /** \brief Constructor.
94  * \param[in] max_depth_arg Depth limitation during traversal
95  */
96  explicit OctreeIteratorBase(uindex_t max_depth_arg)
97  : octree_(nullptr), current_state_(nullptr), max_octree_depth_(max_depth_arg)
98  {
99  this->reset();
100  }
101 
102  /** \brief Constructor.
103  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
104  * root node.
105  */
106  OctreeIteratorBase(OctreeT* octree_arg) : OctreeIteratorBase(octree_arg, 0u) {}
107 
108  /** \brief Constructor.
109  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
110  * root node.
111  * \param[in] max_depth_arg Depth limitation during traversal
112  */
113  explicit OctreeIteratorBase(OctreeT* octree_arg, uindex_t max_depth_arg)
114  : octree_(octree_arg), current_state_(0), max_octree_depth_(max_depth_arg)
115  {
116  this->reset();
117  }
118 
119  /** \brief Constructor.
120  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
121  * root node.
122  * \param[in] max_depth_arg Depth limitation during traversal
123  * \param[in] current_state A pointer to the current iterator state
124  *
125  * \warning For advanced users only.
126  */
127  explicit OctreeIteratorBase(OctreeT* octree_arg,
128  uindex_t max_depth_arg,
129  IteratorState* current_state)
130  : octree_(octree_arg), current_state_(current_state), max_octree_depth_(max_depth_arg)
131  {}
132 
133  /** \brief Empty deconstructor. */
134  virtual ~OctreeIteratorBase() = default;
135 
136  /** \brief Equal comparison operator
137  * \param[in] other OctreeIteratorBase to compare with
138  */
139  bool
140  operator==(const OctreeIteratorBase& other) const
141  {
142  if (this == &other) // same object
143  return true;
144  if (octree_ != other.octree_) // refer to different octrees
145  return false;
146  if (!current_state_ && !other.current_state_) // both are end iterators
147  return true;
149  other.current_state_ && // null dereference protection
151  return true;
152  return false;
153  }
154 
155  /** \brief Inequal comparison operator
156  * \param[in] other OctreeIteratorBase to compare with
157  */
158  bool
159  operator!=(const OctreeIteratorBase& other) const
160  {
161  return !operator==(other);
162  }
163 
164  /** \brief Reset iterator */
165  inline void
167  {
168  current_state_ = 0;
169  if (octree_ && (!max_octree_depth_)) {
170  max_octree_depth_ = octree_->getTreeDepth();
171  }
172  }
173 
174  /** \brief Preincrement operator.
175  * \note step to next octree node
176  */
177  virtual OctreeIteratorBase&
178  operator++() = 0;
179 
180  /** \brief Get octree key for the current iterator octree node
181  * \return octree key of current node
182  */
183  inline const OctreeKey&
185  {
186  assert(octree_ != 0);
187  assert(current_state_ != 0);
188 
189  return (current_state_->key_);
190  }
191 
192  /** \brief Get the current depth level of octree
193  * \return depth level
194  */
195  inline uindex_t
197  {
198  assert(octree_ != 0);
199  assert(current_state_ != 0);
200 
201  return (current_state_->depth_);
202  }
203 
204  /** \brief Get the current octree node
205  * \return pointer to current octree node
206  */
207  inline OctreeNode*
209  {
210  assert(octree_ != 0);
211  assert(current_state_ != 0);
212 
213  return (current_state_->node_);
214  }
215 
216  /** \brief check if current node is a branch node
217  * \return true if current node is a branch node, false otherwise
218  */
219  inline bool
220  isBranchNode() const
221  {
222  assert(octree_ != 0);
223  assert(current_state_ != 0);
224 
226  }
227 
228  /** \brief check if current node is a branch node
229  * \return true if current node is a branch node, false otherwise
230  */
231  inline bool
232  isLeafNode() const
233  {
234  assert(octree_ != 0);
235  assert(current_state_ != 0);
236 
237  return (current_state_->node_->getNodeType() == LEAF_NODE);
238  }
239 
240  /** \brief *operator.
241  * \return pointer to the current octree node
242  */
243  virtual OctreeNode*
244  operator*() const
245  { // return designated object
246  if (octree_ && current_state_) {
247  return (current_state_->node_);
248  }
249  else {
250  return 0;
251  }
252  }
253 
254  /** \brief Get bit pattern of children configuration of current node
255  * \return bit pattern (byte) describing the existence of 8 children of the current
256  * node
257  */
258  inline char
260  {
261  char ret = 0;
262 
263  assert(octree_ != 0);
264  assert(current_state_ != 0);
265 
266  if (isBranchNode()) {
267 
268  // current node is a branch node
269  const BranchNode* current_branch =
270  static_cast<const BranchNode*>(current_state_->node_);
271 
272  // get child configuration bit pattern
273  ret = octree_->getBranchBitPattern(*current_branch);
274  }
275 
276  return (ret);
277  }
278 
279  /** \brief Method for retrieving a single leaf container from the octree leaf node
280  * \return Reference to container class of leaf node.
281  */
282  const LeafContainer&
284  {
285  assert(octree_ != 0);
286  assert(current_state_ != 0);
287  assert(this->isLeafNode());
288 
289  LeafNode* leaf_node = static_cast<LeafNode*>(current_state_->node_);
290 
291  return leaf_node->getContainer();
292  }
293 
294  /** \brief Method for retrieving a single leaf container from the octree leaf node
295  * \return Reference to container class of leaf node.
296  */
299  {
300  assert(octree_ != 0);
301  assert(current_state_ != 0);
302  assert(this->isLeafNode());
303 
304  LeafNode* leaf_node = static_cast<LeafNode*>(current_state_->node_);
305 
306  return leaf_node->getContainer();
307  }
308 
309  /** \brief Method for retrieving the container from an octree branch node
310  * \return BranchContainer.
311  */
312  const BranchContainer&
314  {
315  assert(octree_ != 0);
316  assert(current_state_ != 0);
317  assert(this->isBranchNode());
318 
319  BranchNode* branch_node = static_cast<BranchNode*>(current_state_->node_);
320 
321  return branch_node->getContainer();
322  }
323 
324  /** \brief Method for retrieving the container from an octree branch node
325  * \return BranchContainer.
326  */
329  {
330  assert(octree_ != 0);
331  assert(current_state_ != 0);
332  assert(this->isBranchNode());
333 
334  BranchNode* branch_node = static_cast<BranchNode*>(current_state_->node_);
335 
336  return branch_node->getContainer();
337  }
338 
339  /** \brief get a integer identifier for current node (note: identifier depends on tree
340  * depth). \return node id.
341  */
342  virtual unsigned long
343  getNodeID() const
344  {
345  unsigned long id = 0;
346 
347  assert(octree_ != 0);
348  assert(current_state_ != 0);
349 
350  if (current_state_) {
351  const OctreeKey& key = getCurrentOctreeKey();
352  // calculate integer id with respect to octree key
353  uindex_t depth = octree_->getTreeDepth();
354  id = static_cast<unsigned long>(key.x) << (depth * 2) |
355  static_cast<unsigned long>(key.y) << (depth * 1) |
356  static_cast<unsigned long>(key.z) << (depth * 0);
357  }
358 
359  return id;
360  }
361 
362 protected:
363  /** \brief Reference to octree class. */
364  OctreeT* octree_;
365 
366  /** \brief Pointer to current iterator state. */
368 
369  /** \brief Maximum octree depth */
371 };
372 
373 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
374 /** \brief @b Octree iterator class
375  * \note This class implements a forward iterator for traversing octrees in a
376  * depth-first manner.
377  * \ingroup octree
378  * \author Julius Kammerl (julius@kammerl.de)
379  */
380 template <typename OctreeT>
382 
383 public:
386 
387  /** \brief Empty constructor.
388  * \param[in] max_depth_arg Depth limitation during traversal
389  */
390  explicit OctreeDepthFirstIterator(uindex_t max_depth_arg = 0);
391 
392  /** \brief Constructor.
393  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
394  * root node.
395  * \param[in] max_depth_arg Depth limitation during traversal
396  */
397  explicit OctreeDepthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0);
398 
399  /** \brief Constructor.
400  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
401  * root node.
402  * \param[in] max_depth_arg Depth limitation during traversal
403  * \param[in] current_state A pointer to the current iterator state
404  * \param[in] stack A stack structure used for depth first search
405  *
406  * \warning For advanced users only.
407  */
409  OctreeT* octree_arg,
410  uindex_t max_depth_arg,
411  IteratorState* current_state,
412  const std::vector<IteratorState>& stack = std::vector<IteratorState>())
413  : OctreeIteratorBase<OctreeT>(octree_arg, max_depth_arg, current_state), stack_(stack)
414  {}
415 
416  /** \brief Copy Constructor.
417  * \param[in] other Another OctreeDepthFirstIterator to copy from
418  */
420  : OctreeIteratorBase<OctreeT>(other), stack_(other.stack_)
421  {
422  this->current_state_ = stack_.size() ? &stack_.back() : NULL;
423  }
424 
425  /** \brief Copy assignment
426  * \param[in] src the iterator to copy into this
427  */
430  {
431 
433 
434  stack_ = src.stack_;
435 
436  if (stack_.size()) {
437  this->current_state_ = &stack_.back();
438  }
439  else {
440  this->current_state_ = 0;
441  }
442 
443  return (*this);
444  }
445 
446  /** \brief Reset the iterator to the root node of the octree
447  */
448  virtual void
449  reset();
450 
451  /** \brief Preincrement operator.
452  * \note recursively step to next octree node
453  */
455  operator++();
456 
457  /** \brief postincrement operator.
458  * \note recursively step to next octree node
459  */
462  {
463  OctreeDepthFirstIterator _Tmp = *this;
464  ++*this;
465  return (_Tmp);
466  }
467 
468  /** \brief Skip all child voxels of current node and return to parent node.
469  */
470  void
471  skipChildVoxels();
472 
473 protected:
474  /** Stack structure. */
475  std::vector<IteratorState> stack_;
476 };
477 
478 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
479 /** \brief @b Octree iterator class
480  * \note This class implements a forward iterator for traversing octrees in a
481  * breadth-first manner.
482  * \ingroup octree
483  * \author Julius Kammerl (julius@kammerl.de)
484  */
485 template <typename OctreeT>
487 public:
488  // public typedefs
491 
492  /** \brief Empty constructor.
493  * \param[in] max_depth_arg Depth limitation during traversal
494  */
495  explicit OctreeBreadthFirstIterator(uindex_t max_depth_arg = 0);
496 
497  /** \brief Constructor.
498  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
499  * root node.
500  * \param[in] max_depth_arg Depth limitation during traversal
501  */
502  explicit OctreeBreadthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0);
503 
504  /** \brief Constructor.
505  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
506  * root node.
507  * \param[in] max_depth_arg Depth limitation during traversal
508  * \param[in] current_state A pointer to the current iterator state
509  *
510  * \warning For advanced users only.
511  */
513  OctreeT* octree_arg,
514  uindex_t max_depth_arg,
515  IteratorState* current_state,
516  const std::deque<IteratorState>& fifo = std::deque<IteratorState>())
517  : OctreeIteratorBase<OctreeT>(octree_arg, max_depth_arg, current_state), FIFO_(fifo)
518  {}
519 
520  /** \brief Copy Constructor.
521  * \param[in] other Another OctreeBreadthFirstIterator to copy from
522  */
524  : OctreeIteratorBase<OctreeT>(other), FIFO_(other.FIFO_)
525  {
526  this->current_state_ = FIFO_.size() ? &FIFO_.front() : NULL;
527  }
528 
529  /** \brief Copy operator.
530  * \param[in] src the iterator to copy into this
531  */
534  {
535 
537 
538  FIFO_ = src.FIFO_;
539 
540  if (FIFO_.size()) {
541  this->current_state_ = &FIFO_.front();
542  }
543  else {
544  this->current_state_ = 0;
545  }
546 
547  return (*this);
548  }
549 
550  /** \brief Reset the iterator to the root node of the octree
551  */
552  void
553  reset();
554 
555  /** \brief Preincrement operator.
556  * \note step to next octree node
557  */
559  operator++();
560 
561  /** \brief postincrement operator.
562  * \note step to next octree node
563  */
566  {
567  OctreeBreadthFirstIterator _Tmp = *this;
568  ++*this;
569  return (_Tmp);
570  }
571 
572 protected:
573  /** FIFO list */
574  std::deque<IteratorState> FIFO_;
575 };
576 
577 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
578 /** \brief @b Octree iterator class
579  * \note Iterator over all existing nodes at a given depth. It walks across an octree
580  * in a breadth-first manner.
581  * \ingroup octree
582  * \author Fabien Rozar (fabien.rozar@gmail.com)
583  */
584 template <typename OctreeT>
586 public:
587  // public typedefs
590 
591  /** \brief Empty constructor.
592  */
594 
595  /** \brief Constructor.
596  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
597  * root node.
598  * \param[in] fixed_depth_arg Depth level during traversal
599  */
600  explicit OctreeFixedDepthIterator(OctreeT* octree_arg, uindex_t fixed_depth_arg = 0);
601 
602  /** \brief Constructor.
603  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
604  * root node.
605  * \param[in] fixed_depth_arg Depth level during traversal
606  * \param[in] current_state A pointer to the current iterator state
607  * \param[in] fifo Internal container of octree node to go through
608  *
609  * \warning For advanced users only.
610  */
612  OctreeT* octree_arg,
613  uindex_t fixed_depth_arg,
614  IteratorState* current_state,
615  const std::deque<IteratorState>& fifo = std::deque<IteratorState>())
616  : OctreeBreadthFirstIterator<OctreeT>(
617  octree_arg, fixed_depth_arg, current_state, fifo)
618  , fixed_depth_(fixed_depth_arg)
619  {}
620 
621  /** \brief Copy Constructor.
622  * \param[in] other Another OctreeFixedDepthIterator to copy from
623  */
625  : OctreeBreadthFirstIterator<OctreeT>(other)
626  {
627  this->fixed_depth_ = other.fixed_depth_;
628  }
629 
630  /** \brief Copy assignment.
631  * \param[in] src the iterator to copy into this
632  * \return pointer to the current octree node
633  */
636  {
638  this->fixed_depth_ = src.fixed_depth_;
639 
640  return (*this);
641  }
642 
643  /** \brief Reset the iterator to the first node at the depth given as parameter
644  * \param[in] fixed_depth_arg Depth level during traversal
645  */
646  void
647  reset(uindex_t fixed_depth_arg);
648 
649  /** \brief Reset the iterator to the first node at the current depth
650  */
651  void
653  {
654  this->reset(fixed_depth_);
655  }
656 
657 protected:
659 
660  /** \brief Given level of the node to be iterated */
662 };
663 
664 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
665 /** \brief Octree leaf node iterator class
666  * \note This class implements a forward iterator for traversing the leaf nodes of an
667  * octree data structure.
668  * \ingroup octree
669  * \author Julius Kammerl (julius@kammerl.de)
670  */
671 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
672 template <typename OctreeT>
676 
677 public:
678  /** \brief Empty constructor.
679  * \param[in] max_depth_arg Depth limitation during traversal
680  */
681  explicit OctreeLeafNodeDepthFirstIterator(uindex_t max_depth_arg = 0)
682  : OctreeDepthFirstIterator<OctreeT>(max_depth_arg)
683  {
684  reset();
685  }
686 
687  /** \brief Constructor.
688  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
689  * root node.
690  * \param[in] max_depth_arg Depth limitation during traversal
691  */
692  explicit OctreeLeafNodeDepthFirstIterator(OctreeT* octree_arg,
693  uindex_t max_depth_arg = 0)
694  : OctreeDepthFirstIterator<OctreeT>(octree_arg, max_depth_arg)
695  {
696  reset();
697  }
698 
699  /** \brief Constructor.
700  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
701  * root node.
702  * \param[in] max_depth_arg Depth limitation during traversal
703  * \param[in] current_state A pointer to the current iterator state
704  *
705  * \warning For advanced users only.
706  */
708  OctreeT* octree_arg,
709  uindex_t max_depth_arg,
710  IteratorState* current_state,
711  const std::vector<IteratorState>& stack = std::vector<IteratorState>())
712  : OctreeDepthFirstIterator<OctreeT>(octree_arg, max_depth_arg, current_state, stack)
713  {}
714 
715  /** \brief Reset the iterator to the root node of the octree
716  */
717  inline void
719  {
721  this->operator++();
722  }
723 
724  /** \brief Preincrement operator.
725  * \note recursively step to next octree leaf node
726  */
729  {
730  do {
732  } while ((this->current_state_) &&
733  (this->current_state_->node_->getNodeType() != LEAF_NODE));
734 
735  return (*this);
736  }
737 
738  /** \brief postincrement operator.
739  * \note step to next octree node
740  */
743  {
745  ++*this;
746  return (_Tmp);
747  }
748 
749  /** \brief *operator.
750  * \return pointer to the current octree leaf node
751  */
752  OctreeNode*
753  operator*() const override
754  {
755  // return designated object
756  OctreeNode* ret = 0;
757 
758  if (this->current_state_ &&
759  (this->current_state_->node_->getNodeType() == LEAF_NODE))
760  ret = this->current_state_->node_;
761  return (ret);
762  }
763 };
764 
765 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
766 /** \brief Octree leaf node iterator class
767  * \note This class implements a forward iterator for traversing the leaf nodes of an
768  * octree data structure in the breadth first way.
769  * \ingroup octree
770  * \author Fabien Rozar
771  * (fabien.rozar@gmail.com)
772  */
773 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
774 template <typename OctreeT>
778 
779 public:
780  /** \brief Empty constructor.
781  * \param[in] max_depth_arg Depth limitation during traversal
782  */
783  explicit OctreeLeafNodeBreadthFirstIterator(uindex_t max_depth_arg = 0);
784 
785  /** \brief Constructor.
786  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
787  * root node.
788  * \param[in] max_depth_arg Depth limitation during traversal
789  */
790  explicit OctreeLeafNodeBreadthFirstIterator(OctreeT* octree_arg,
791  uindex_t max_depth_arg = 0);
792 
793  /** \brief Copy constructor.
794  * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its
795  * root node.
796  * \param[in] max_depth_arg Depth limitation during traversal
797  * \param[in] current_state A pointer to the current iterator state
798  * \param[in] fifo Internal container of octree node to go through
799  *
800  * \warning For advanced users only.
801  */
803  OctreeT* octree_arg,
804  uindex_t max_depth_arg,
805  IteratorState* current_state,
806  const std::deque<IteratorState>& fifo = std::deque<IteratorState>());
807 
808  /** \brief Reset the iterator to the first leaf in the breadth first way.
809  */
810  inline void
811  reset();
812 
813  /** \brief Preincrement operator.
814  * \note recursively step to next octree leaf node
815  */
817  operator++();
818 
819  /** \brief Postincrement operator.
820  * \note step to next octree node
821  */
823  operator++(int);
824 
825  /** \brief *operator.
826  * \return pointer to the current octree leaf node
827  */
828  OctreeNode*
829  operator*() const override
830  {
831  // return designated object
832  OctreeNode* ret = 0;
833 
834  if (this->current_state_ &&
835  (this->current_state_->node_->getNodeType() == LEAF_NODE))
836  ret = this->current_state_->node_;
837  return (ret);
838  }
839 };
840 
841 } // namespace octree
842 } // namespace pcl
843 
844 /*
845  * Note: Since octree iterators depend on octrees, don't precompile them.
846  */
847 #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
IteratorState(OctreeNode *node, const OctreeKey &key, uindex_t depth)