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