39 #ifndef PCL_OCTREE_ITERATOR_H 40 #define PCL_OCTREE_ITERATOR_H 46 #include "octree_nodes.h" 47 #include "octree_key.h" 49 #include <pcl/point_cloud.h> 50 #include <pcl/point_types.h> 56 #pragma GCC system_header 77 template<
typename OctreeT>
78 class OctreeIteratorBase :
public std::iterator<std::forward_iterator_tag, const OctreeNode, void,
79 const OctreeNode*, const OctreeNode&>
93 octree_ (0), current_state_(0), max_octree_depth_(max_depth_arg)
104 octree_ (octree_arg), current_state_(0), max_octree_depth_(max_depth_arg)
114 octree_ (src.octree_), current_state_(0), max_octree_depth_(max_depth_arg)
141 return (( octree_ ==other.
octree_) &&
151 return (( octree_ !=other.
octree_) &&
160 if (octree_ && (!max_octree_depth_))
162 max_octree_depth_ = octree_->getTreeDepth();
173 assert(current_state_!=0);
175 return (current_state_->key_);
185 assert(current_state_!=0);
187 return (current_state_->depth_);
197 assert(current_state_!=0);
199 return (current_state_->node_);
210 assert(current_state_!=0);
212 return (current_state_->node_->getNodeType () ==
BRANCH_NODE);
222 assert(current_state_!=0);
224 return (current_state_->node_->getNodeType () ==
LEAF_NODE);
233 if (octree_ && current_state_)
235 return (current_state_->node_);
251 assert(current_state_!=0);
257 const BranchNode* current_branch =
static_cast<const BranchNode*
> (current_state_->node_);
260 ret = octree_->getBranchBitPattern (*current_branch);
274 assert(current_state_!=0);
275 assert(this->isLeafNode());
277 LeafNode* leaf_node =
static_cast<LeafNode*
>(current_state_->node_);
279 return leaf_node->getContainer();
289 assert(current_state_!=0);
290 assert(this->isLeafNode());
292 LeafNode* leaf_node =
static_cast<LeafNode*
>(current_state_->node_);
294 return leaf_node->getContainer();
300 const BranchContainer&
304 assert(current_state_!=0);
305 assert(this->isBranchNode());
307 BranchNode* branch_node =
static_cast<BranchNode*
>(current_state_->node_);
309 return branch_node->getContainer();
319 assert(current_state_!=0);
320 assert(this->isBranchNode());
322 BranchNode* branch_node =
static_cast<BranchNode*
>(current_state_->node_);
324 return branch_node->getContainer();
330 virtual unsigned long 333 unsigned long id = 0;
336 assert(current_state_!=0);
340 const OctreeKey& key = getCurrentOctreeKey();
342 unsigned int depth = octree_->getTreeDepth ();
343 id = key.
x << (depth * 2) | key.
y << (depth * 1) | key.
z << (depth * 0);
366 template<
typename OctreeT>
405 this->current_state_ = &stack_.back();
408 this->current_state_ = 0;
452 template<
typename OctreeT>
491 this->current_state_ = &FIFO_.front();
494 this->current_state_ = 0;
534 template<
typename OctreeT>
586 }
while ((this->current_state_) && (this->current_state_->node_->getNodeType () !=
LEAF_NODE));
611 if (this->current_state_ && (this->current_state_->node_->getNodeType () ==
LEAF_NODE))
612 ret = this->current_state_->node_;
void reset()
Reset iterator.
bool operator==(const OctreeIteratorBase &other) const
Equal comparison operator.
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.
OctreeIteratorBase(const OctreeIteratorBase &src, unsigned int max_depth_arg=0)
Copy constructor.
OctreeIteratorBase & operator=(const OctreeIteratorBase &src)
Copy operator.
OctreeT::LeafContainer LeafContainer
std::deque< IteratorState > FIFO_
FIFO list.
std::vector< IteratorState > stack_
Stack structure.
IteratorState * current_state_
Pointer to current iterator state.
Octree leaf node iterator class.
OctreeT::BranchNode BranchNode
LeafContainer & getLeafContainer()
Method for retrieving a single leaf container from the octree leaf node.
unsigned int max_octree_depth_
Maximum octree depth.
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.
OctreeLeafNodeIterator(unsigned int max_depth_arg=0)
Empty constructor.
bool isLeafNode() const
check if current node is a branch node
OctreeLeafNodeIterator(OctreeT *octree_arg, unsigned int max_depth_arg=0)
Constructor.
virtual ~OctreeLeafNodeIterator()
Empty deconstructor.
unsigned int getCurrentOctreeDepth() const
Get the current depth level of octree.
void reset()
Reset the iterator to the root node of the octree.
OctreeT * octree_
Reference to octree class.
OctreeDepthFirstIterator & operator++()
Preincrement operator.
OctreeT::LeafNode LeafNode
Abstract octree iterator class
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.
Abstract octree node class
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.