40 #ifndef PCL_OCTREE_ITERATOR_H 41 #define PCL_OCTREE_ITERATOR_H 47 #include <pcl/octree/octree_nodes.h> 48 #include <pcl/octree/octree_key.h> 54 #pragma GCC system_header 75 template<
typename OctreeT>
76 class OctreeIteratorBase :
public std::iterator<std::forward_iterator_tag, const OctreeNode, void,
77 const OctreeNode*, const OctreeNode&>
91 octree_ (0), current_state_(0), max_octree_depth_(max_depth_arg)
102 octree_ (octree_arg), current_state_(0), max_octree_depth_(max_depth_arg)
116 unsigned int max_depth_arg,
118 : octree_(octree_arg)
119 , current_state_ (current_state)
120 , max_octree_depth_ (max_depth_arg)
159 if (octree_ && (!max_octree_depth_))
161 max_octree_depth_ = octree_->getTreeDepth();
172 assert(current_state_!=0);
174 return (current_state_->key_);
184 assert(current_state_!=0);
186 return (current_state_->depth_);
196 assert(current_state_!=0);
198 return (current_state_->node_);
209 assert(current_state_!=0);
211 return (current_state_->node_->getNodeType () ==
BRANCH_NODE);
221 assert(current_state_!=0);
223 return (current_state_->node_->getNodeType () ==
LEAF_NODE);
232 if (octree_ && current_state_)
234 return (current_state_->node_);
250 assert(current_state_!=0);
256 const BranchNode* current_branch =
static_cast<const BranchNode*
> (current_state_->node_);
259 ret = octree_->getBranchBitPattern (*current_branch);
273 assert(current_state_!=0);
274 assert(this->isLeafNode());
276 LeafNode* leaf_node =
static_cast<LeafNode*
>(current_state_->node_);
278 return leaf_node->getContainer();
288 assert(current_state_!=0);
289 assert(this->isLeafNode());
291 LeafNode* leaf_node =
static_cast<LeafNode*
>(current_state_->node_);
293 return leaf_node->getContainer();
299 const BranchContainer&
303 assert(current_state_!=0);
304 assert(this->isBranchNode());
306 BranchNode* branch_node =
static_cast<BranchNode*
>(current_state_->node_);
308 return branch_node->getContainer();
318 assert(current_state_!=0);
319 assert(this->isBranchNode());
321 BranchNode* branch_node =
static_cast<BranchNode*
>(current_state_->node_);
323 return branch_node->getContainer();
329 virtual unsigned long 332 unsigned long id = 0;
335 assert(current_state_!=0);
339 const OctreeKey& key = getCurrentOctreeKey();
341 unsigned int 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);
367 template<
typename OctreeT>
398 unsigned int max_depth_arg,
400 const std::vector<IteratorState>& stack = std::vector<IteratorState> ())
410 , stack_ (other.stack_)
412 this->current_state_ = stack_.size ()? &stack_.back () : NULL;
428 this->current_state_ = &stack_.back ();
431 this->current_state_ = 0;
475 template<
typename OctreeT>
505 unsigned int max_depth_arg,
507 const std::deque<IteratorState>& fifo = std::deque<IteratorState> ())
517 , FIFO_ (other.FIFO_)
519 this->current_state_ = FIFO_.size ()? &FIFO_.front () : NULL;
535 this->current_state_ = &FIFO_.front();
538 this->current_state_ = 0;
578 template<
typename OctreeT>
607 unsigned int fixed_depth_arg,
609 const std::deque<IteratorState>& fifo = std::deque<IteratorState> ())
611 , fixed_depth_ (fixed_depth_arg)
640 reset (
unsigned int fixed_depth_arg);
647 this->reset (fixed_depth_);
664 template<
typename OctreeT>
701 unsigned int max_depth_arg,
703 const std::vector<IteratorState>& stack = std::vector<IteratorState> ())
728 }
while ((this->current_state_) && (this->current_state_->node_->getNodeType () !=
LEAF_NODE));
753 if (this->current_state_ && (this->current_state_->node_->getNodeType () ==
LEAF_NODE))
754 ret = this->current_state_->node_;
767 template<
typename OctreeT>
797 unsigned int max_depth_arg,
799 const std::deque<IteratorState>& fifo = std::deque<IteratorState> ());
826 #include <pcl/octree/impl/octree_iterator.hpp> bool isLeafNode() const
check if current node is a branch node
OctreeBreadthFirstIterator & operator=(const OctreeBreadthFirstIterator &src)
Copy operator.
void reset()
Reset iterator.
void reset()
Reset the iterator to the first node at the current depth.
const BranchContainer & getBranchContainer() const
Method for retrieving the container from an octree branch node.
This file defines compatibility wrappers for low level I/O functions.
OctreeT::LeafContainer LeafContainer
std::deque< IteratorState > FIFO_
FIFO list.
bool isBranchNode() const
check if current node is a branch node
const LeafContainer & getLeafContainer() const
Method for retrieving a single leaf container from the octree leaf node.
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.
OctreeT::BranchContainer BranchContainer
unsigned int getCurrentOctreeDepth() const
Get the current depth level of octree.
OctreeIteratorBase< OctreeT >::LeafNode LeafNode
OctreeIteratorBase< OctreeT >::BranchNode BranchNode
bool operator!=(const OctreeIteratorBase &other) const
Inequal comparison operator.
OctreeIteratorBase(unsigned int max_depth_arg=0)
Empty constructor.
OctreeNode * getCurrentOctreeNode() const
Get the current octree node.
OctreeLeafNodeDepthFirstIterator(OctreeT *octree_arg, unsigned int max_depth_arg, IteratorState *current_state, const std::vector< IteratorState > &stack=std::vector< IteratorState >())
Constructor.
char getNodeConfiguration() const
Get bit pattern of children configuration of current 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.
virtual unsigned long getNodeID() const
get a integer identifier for current node (note: identifier depends on tree depth).
const OctreeKey & getCurrentOctreeKey() const
Get octree key for the current iterator octree node.
OctreeDepthFirstIterator(const OctreeDepthFirstIterator &other)
Copy Constructor.
OctreeT * octree_
Reference to octree class.
OctreeDepthFirstIterator & operator++()
Preincrement operator.
OctreeT::LeafNode LeafNode
Abstract octree iterator class
OctreeIteratorBase< OctreeT >::BranchNode BranchNode
virtual ~OctreeIteratorBase()
Empty deconstructor.
bool operator==(const OctreeIteratorBase &other) const
Equal comparison operator.
bool operator==(const PCLHeader &lhs, const PCLHeader &rhs)
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
OctreeIteratorBase(OctreeT *octree_arg, unsigned int max_depth_arg=0)
Constructor.
Octree leaf node iterator class.
BranchContainer & getBranchContainer()
Method for retrieving the container from an octree branch node.