octomap  1.8.0
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Macros Pages
tree_iterator Class Reference

Iterator over the complete tree (inner nodes and leafs). More...

+ Inheritance diagram for tree_iterator:
+ Collaboration diagram for tree_iterator:

Public Member Functions

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

Protected Member Functions

void singleIncrement ()
 One step of depth-first tree traversal. How this is used depends on the actual iterator. More...
 

Protected Attributes

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

Detailed Description

Iterator over the complete tree (inner nodes and leafs).

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

for(OcTreeTYPE::tree_iterator it = tree->begin_tree(),
end=tree->end_tree(); 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

tree_iterator::tree_iterator ( )
inline
tree_iterator::tree_iterator ( OcTreeBaseImpl< NodeType, INTERFACE > const *  tree,
uint8_t  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

Member Function Documentation

point3d iterator_base::getCoordinate ( ) const
inlineinherited

return the center coordinate of the current node

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

unsigned iterator_base::getDepth ( ) const
inlineinherited

return depth of the current node

References iterator_base::stack.

OcTreeKey iterator_base::getIndexKey ( ) const
inlineinherited
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
inlineinherited
Returns
the OcTreeKey of the current node

References iterator_base::stack.

double iterator_base::getSize ( ) const
inlineinherited
Returns
the side of the volume occupied by the current node

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

double iterator_base::getX ( ) const
inlineinherited
Returns
single coordinate of the current node

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

double iterator_base::getY ( ) const
inlineinherited
Returns
single coordinate of the current node

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

double iterator_base::getZ ( ) const
inlineinherited
Returns
single coordinate of the current node

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

bool tree_iterator::isLeaf ( ) const
inline
Returns
whether the current node is a leaf, i.e. has no children or is at max level

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

bool iterator_base::operator!= ( const iterator_base other) const
inlineinherited

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

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

const NodeType& iterator_base::operator* ( ) const
inlineinherited

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

References iterator_base::stack.

NodeType& iterator_base::operator* ( )
inlineinherited

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

References iterator_base::stack.

tree_iterator tree_iterator::operator++ ( int  )
inline

postfix increment operator of iterator (it++)

tree_iterator& tree_iterator::operator++ ( )
inline

Prefix increment operator to advance the iterator.

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

NodeType const* iterator_base::operator-> ( ) const
inlineinherited

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

References iterator_base::stack.

NodeType* iterator_base::operator-> ( )
inlineinherited

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
inlineinherited

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 ( )
inlineprotectedinherited

Field Documentation


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