39 #ifndef PCL_OCTREE_ITERATOR_H 40 #define PCL_OCTREE_ITERATOR_H 46 #include <pcl/octree/octree_nodes.h> 47 #include <pcl/octree/octree_key.h> 53 #pragma GCC system_header 74 template<
typename OctreeT>
75 class OctreeIteratorBase :
public std::iterator<std::forward_iterator_tag, const OctreeNode, void,
76 const OctreeNode*, const OctreeNode&>
90 octree_ (0), current_state_(0), max_octree_depth_(max_depth_arg)
101 octree_ (octree_arg), current_state_(0), max_octree_depth_(max_depth_arg)
111 octree_ (src.octree_), current_state_(0), max_octree_depth_(max_depth_arg)
138 return (( octree_ ==other.
octree_) &&
148 return (( octree_ !=other.
octree_) &&
157 if (octree_ && (!max_octree_depth_))
159 max_octree_depth_ = octree_->getTreeDepth();
170 assert(current_state_!=0);
172 return (current_state_->key_);
182 assert(current_state_!=0);
184 return (current_state_->depth_);
194 assert(current_state_!=0);
196 return (current_state_->node_);
207 assert(current_state_!=0);
209 return (current_state_->node_->getNodeType () ==
BRANCH_NODE);
219 assert(current_state_!=0);
221 return (current_state_->node_->getNodeType () ==
LEAF_NODE);
230 if (octree_ && current_state_)
232 return (current_state_->node_);
248 assert(current_state_!=0);
254 const BranchNode* current_branch =
static_cast<const BranchNode*
> (current_state_->node_);
257 ret = octree_->getBranchBitPattern (*current_branch);
271 assert(current_state_!=0);
272 assert(this->isLeafNode());
274 LeafNode* leaf_node =
static_cast<LeafNode*
>(current_state_->node_);
276 return leaf_node->getContainer();
286 assert(current_state_!=0);
287 assert(this->isLeafNode());
289 LeafNode* leaf_node =
static_cast<LeafNode*
>(current_state_->node_);
291 return leaf_node->getContainer();
297 const BranchContainer&
301 assert(current_state_!=0);
302 assert(this->isBranchNode());
304 BranchNode* branch_node =
static_cast<BranchNode*
>(current_state_->node_);
306 return branch_node->getContainer();
316 assert(current_state_!=0);
317 assert(this->isBranchNode());
319 BranchNode* branch_node =
static_cast<BranchNode*
>(current_state_->node_);
321 return branch_node->getContainer();
327 virtual unsigned long 330 unsigned long id = 0;
333 assert(current_state_!=0);
337 const OctreeKey& key = getCurrentOctreeKey();
339 unsigned int depth = octree_->getTreeDepth ();
340 id =
static_cast<unsigned long> (key.
x) << (depth * 2)
341 |
static_cast<unsigned long> (key.
y) << (depth * 1)
342 |
static_cast<unsigned long> (key.
z) << (depth * 0);
365 template<
typename OctreeT>
404 this->current_state_ = &stack_.back();
407 this->current_state_ = 0;
451 template<
typename OctreeT>
490 this->current_state_ = &FIFO_.front();
493 this->current_state_ = 0;
533 template<
typename OctreeT>
585 }
while ((this->current_state_) && (this->current_state_->node_->getNodeType () !=
LEAF_NODE));
610 if (this->current_state_ && (this->current_state_->node_->getNodeType () ==
LEAF_NODE))
611 ret = this->current_state_->node_;
622 #include <pcl/octree/impl/octree_iterator.hpp> bool isLeafNode() const
check if current node is a branch node
void reset()
Reset iterator.
const BranchContainer & getBranchContainer() const
Method for retrieving the container from an octree branch 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.
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.
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.
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.
OctreeLeafNodeIterator(unsigned int max_depth_arg=0)
Empty constructor.
char getNodeConfiguration() const
Get bit pattern of children configuration of current node.
virtual unsigned long getNodeID() const
get a integer identifier for current node (note: identifier depends on tree depth).
OctreeLeafNodeIterator(OctreeT *octree_arg, unsigned int max_depth_arg=0)
Constructor.
const OctreeKey & getCurrentOctreeKey() const
Get octree key for the current iterator octree node.
virtual ~OctreeLeafNodeIterator()
Empty deconstructor.
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
virtual ~OctreeIteratorBase()
Empty deconstructor.
bool operator==(const OctreeIteratorBase &other) const
Equal comparison operator.
Abstract octree node class
OctreeIteratorBase(OctreeT *octree_arg, unsigned int max_depth_arg=0)
Constructor.
BranchContainer & getBranchContainer()
Method for retrieving the container from an octree branch node.