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