octomap 1.5.0
leaf_iterator Class Reference

Iterator to iterate over all leafs of the tree. More...

Inheritance diagram for leaf_iterator:
Collaboration diagram for leaf_iterator:

Public Member Functions

point3d getCoordinate () const
 return the center coordinate of the current node
unsigned getDepth () const
 return depth of the current node
OcTreeKey getIndexKey () const
const OcTreeKey & getKey () const
double getSize () const
double getX () const
double getY () const
double getZ () const
 leaf_iterator (OcTreeBaseImpl< NodeType, INTERFACE > const *tree, unsigned char depth=0)
 Constructor of the iterator.
 leaf_iterator (const leaf_iterator &other)
 leaf_iterator ()
bool operator!= (const iterator_base &other) const
 Comparison between iterators. First compares the tree, then stack size and top element of stack.
const NodeType & operator* () const
 Return the current node in the octree which the iterator is referring to.
NodeType & operator* ()
 Return the current node in the octree which the iterator is referring to.
leaf_iterator operator++ (int)
 postfix increment operator of iterator (it++)
leaf_iteratoroperator++ ()
 prefix increment operator of iterator (++it)
NodeType * operator-> ()
 Ptr operator will return the current node in the octree which the iterator is referring to.
NodeType const * operator-> () const
 Ptr operator will return the current node in the octree which the iterator is referring to.
bool operator== (const iterator_base &other) const
 Comparison between iterators. First compares the tree, then stack size and top element of stack.

Protected Member Functions

void singleIncrement ()
 One step of depth-first tree traversal.

Protected Attributes

unsigned char maxDepth
 Maximum depth for depth-limited queries.
std::stack< StackElement,
std::vector< StackElement > > 
stack
 Internal recursion stack. Apparently a stack of vector works fastest here.
OcTreeBaseImpl< NodeType,
INTERFACE > const * 
tree
 Octree this iterator is working on.

Detailed Description

Iterator to iterate over all leafs of the tree.

Inner nodes are skipped. See below for example usage. Note that the non-trivial call to tree->end_leafs() should be done only once for efficiency!

 for(OcTreeTYPE::leaf_iterator it = tree->begin_leafs(),
        end=tree->end_leafs(); it!= end; ++it)
 {
   //manipulate node, e.g.:
   std::cout << "Node center: " << it.getCoordinate() << std::endl;
   std::cout << "Node size: " << it.getSize() << std::endl;
   std::cout << "Node value: " << it->getValue() << std::endl;
 }

Constructor & Destructor Documentation

leaf_iterator::leaf_iterator ( ) [inline]
leaf_iterator::leaf_iterator ( OcTreeBaseImpl< NodeType, INTERFACE > const *  tree,
unsigned char  depth = 0 
) [inline]

Constructor of the iterator.

Parameters:
treeOcTreeBaseImpl on which the iterator is used on
depthMaximum depth to traverse the tree. 0 (default): unlimited

References operator++(), and iterator_base::stack.

leaf_iterator::leaf_iterator ( const leaf_iterator other) [inline]

Member Function Documentation

point3d iterator_base::getCoordinate ( ) const [inline, inherited]

return the center coordinate of the current node

References iterator_base::stack, and iterator_base::tree.

unsigned iterator_base::getDepth ( ) const [inline, inherited]

return depth of the current node

References iterator_base::stack.

OcTreeKey iterator_base::getIndexKey ( ) const [inline, inherited]
Returns:
the OcTreeKey of the current node, for nodes with depth != maxDepth

References octomap::computeIndexKey(), iterator_base::stack, and iterator_base::tree.

const OcTreeKey& iterator_base::getKey ( ) const [inline, inherited]
Returns:
the OcTreeKey of the current node

References iterator_base::stack.

double iterator_base::getSize ( ) const [inline, inherited]
Returns:
the side if the volume occupied by the current node

References iterator_base::stack, and iterator_base::tree.

double iterator_base::getX ( ) const [inline, inherited]
Returns:
single coordinate of the current node

References iterator_base::stack, and iterator_base::tree.

double iterator_base::getY ( ) const [inline, inherited]
Returns:
single coordinate of the current node

References iterator_base::stack, and iterator_base::tree.

double iterator_base::getZ ( ) const [inline, inherited]
Returns:
single coordinate of the current node

References iterator_base::stack, and iterator_base::tree.

bool iterator_base::operator!= ( const iterator_base other) const [inline, inherited]

Comparison between iterators. First compares the tree, then stack size and top element of stack.

References iterator_base::stack, and iterator_base::tree.

NodeType& iterator_base::operator* ( ) [inline, inherited]

Return the current node in the octree which the iterator is referring to.

References iterator_base::stack.

const NodeType& iterator_base::operator* ( ) const [inline, inherited]

Return the current node in the octree which the iterator is referring to.

References iterator_base::stack.

leaf_iterator leaf_iterator::operator++ ( int  ) [inline]

postfix increment operator of iterator (it++)

leaf_iterator& leaf_iterator::operator++ ( ) [inline]

prefix increment operator of iterator (++it)

References iterator_base::maxDepth, iterator_base::singleIncrement(), iterator_base::stack, and iterator_base::tree.

Referenced by leaf_iterator().

NodeType const* iterator_base::operator-> ( ) const [inline, inherited]

Ptr operator will return the current node in the octree which the iterator is referring to.

References iterator_base::stack.

NodeType* iterator_base::operator-> ( ) [inline, inherited]

Ptr operator will return the current node in the octree which the iterator is referring to.

References iterator_base::stack.

bool iterator_base::operator== ( const iterator_base other) const [inline, inherited]

Comparison between iterators. First compares the tree, then stack size and top element of stack.

References iterator_base::stack, and iterator_base::tree.

void iterator_base::singleIncrement ( ) [inline, protected, inherited]

Field Documentation


The documentation for this class was generated from the following file: