octomap 1.9.8
Loading...
Searching...
No Matches
octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_iterator Class Reference

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

#include <OcTreeBaseImpl.h>

Inheritance diagram for octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_iterator:
Collaboration diagram for octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_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 OcTreeKeygetKey () 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.
NodeTypeoperator* ()
 Return the current node in the octree which the iterator is referring to.
const NodeTypeoperator* () const
 Return the current node in the octree which the iterator is referring to.
tree_iteratoroperator++ ()
 Prefix increment operator to advance the iterator.
tree_iterator operator++ (int)
 postfix increment operator of iterator (it++)
NodeTypeoperator-> ()
 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.
 tree_iterator ()
 tree_iterator (OcTreeBaseImpl< NodeType, INTERFACE > const *ptree, uint8_t depth=0)
 Constructor of the iterator.

Data Fields

OcTreeKey elements
 STL member.

Protected Member Functions

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

Protected Attributes

uint8_t 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

template<class NODE, class INTERFACE>
class octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_iterator

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;
}
OcTreeBaseImpl< NodeType, INTERFACE > const * tree
Octree this iterator is working on.
Definition OcTreeBaseImpl.h:159
const iterator end() const
Definition OcTreeBaseImpl.h:329

Constructor & Destructor Documentation

◆ tree_iterator() [1/2]

template<class NODE, class INTERFACE>
octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_iterator::tree_iterator ( )
inline

◆ tree_iterator() [2/2]

template<class NODE, class INTERFACE>
octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_iterator::tree_iterator ( OcTreeBaseImpl< NodeType, INTERFACE > const * ptree,
uint8_t depth = 0 )
inline

Constructor of the iterator.

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

Member Function Documentation

◆ getCoordinate()

template<class NODE, class INTERFACE>
point3d octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::getCoordinate ( ) const
inlineinherited

return the center coordinate of the current node

◆ getDepth()

template<class NODE, class INTERFACE>
unsigned octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::getDepth ( ) const
inlineinherited

return depth of the current node

◆ getIndexKey()

template<class NODE, class INTERFACE>
OcTreeKey octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::getIndexKey ( ) const
inlineinherited
Returns
the OcTreeKey of the current node, for nodes with depth != maxDepth

◆ getKey()

template<class NODE, class INTERFACE>
const OcTreeKey & octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::getKey ( ) const
inlineinherited
Returns
the OcTreeKey of the current node

◆ getSize()

template<class NODE, class INTERFACE>
double octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::getSize ( ) const
inlineinherited

◆ getX()

template<class NODE, class INTERFACE>
double octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::getX ( ) const
inlineinherited

◆ getY()

template<class NODE, class INTERFACE>
double octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::getY ( ) const
inlineinherited

◆ getZ()

template<class NODE, class INTERFACE>
double octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::getZ ( ) const
inlineinherited

◆ isLeaf()

template<class NODE, class INTERFACE>
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_iterator::isLeaf ( ) const
inline
Returns
whether the current node is a leaf, i.e. has no children or is at max level

References octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_size.

◆ operator!=()

template<class NODE, class INTERFACE>
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::operator!= ( const iterator_base & other) const
inlineinherited

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

◆ operator*() [1/2]

template<class NODE, class INTERFACE>
NodeType & octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::operator* ( )
inlineinherited

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

◆ operator*() [2/2]

template<class NODE, class INTERFACE>
const NodeType & octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::operator* ( ) const
inlineinherited

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

◆ operator++() [1/2]

template<class NODE, class INTERFACE>
tree_iterator & octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_iterator::operator++ ( )
inline

Prefix increment operator to advance the iterator.

◆ operator++() [2/2]

template<class NODE, class INTERFACE>
tree_iterator octomap::OcTreeBaseImpl< NODE, INTERFACE >::tree_iterator::operator++ ( int )
inline

postfix increment operator of iterator (it++)

◆ operator->() [1/2]

template<class NODE, class INTERFACE>
NodeType * octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::operator-> ( )
inlineinherited

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

◆ operator->() [2/2]

template<class NODE, class INTERFACE>
NodeType const * octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::operator-> ( ) const
inlineinherited

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

◆ operator==()

template<class NODE, class INTERFACE>
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::operator== ( const iterator_base & other) const
inlineinherited

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

◆ singleIncrement()

template<class NODE, class INTERFACE>
void octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::singleIncrement ( )
inlineprotectedinherited

One step of depth-first tree traversal. How this is used depends on the actual iterator.

Field Documentation

◆ elements

OcTreeKey std::vector< OcTreeKey >::elements
inherited

STL member.

◆ maxDepth

template<class NODE, class INTERFACE>
uint8_t octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::maxDepth
protectedinherited

Maximum depth for depth-limited queries.

Referenced by octomap::OcTreeBaseImpl< NODE, INTERFACE >::leaf_bbx_iterator::leaf_bbx_iterator().

◆ stack

template<class NODE, class INTERFACE>
std::stack<StackElement,std::vector<StackElement> > octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::stack
protectedinherited

Internal recursion stack. Apparently a stack of vector works fastest here.

◆ tree

template<class NODE, class INTERFACE>
OcTreeBaseImpl<NodeType,INTERFACE> const* octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator_base::tree
protectedinherited

Octree this iterator is working on.


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