Developer Documentation
SkeletonT< PointT >::Iterator Class Reference

Iterator class for the skeleton. More...

#include <Type-Skeleton/ObjectTypes/Skeleton/SkeletonT.hh>

Public Member Functions

 Iterator ()
 Default constructor. More...
 
 Iterator (Joint *_root)
 Constructor - Creates an iterator for the given (sub-)tree. More...
 
 Iterator (const Iterator &other)
 Copy Constructor - Creates a copy of the given iterator. More...
 
 ~Iterator ()
 Destructor.
 
Iteratoroperator= (const Iterator &other)
 Assignment Operator. More...
 
Iteratoroperator++ ()
 Increase the iterator. More...
 
bool operator!= (const Iterator &other) const
 Compares the iterators. More...
 
bool operator== (const Iterator &other) const
 Compares the iterators. More...
 
Jointoperator* () const
 Returns a pointer to the current joint.
 
Jointoperator-> () const
 Returns a pointer to the current joint. More...
 
 operator bool () const
 Returns false if the iterator is done iterating. More...
 

Private Member Functions

JointnextSibling (Joint *_pParent, Joint *_pJoint)
 Given a parent and one of its child nodes this method finds and returns the next sibling. More...
 

Private Attributes

JointpCurrent_
 
std::stack< Joint * > stJoints_
 

Detailed Description

template<class PointT>
class SkeletonT< PointT >::Iterator

Iterator class for the skeleton.

This iterator can be used to iterate over all joints in a top-down (root to leaf), left-to-right order. It is possible to iterate over subtrees by constructing an iterator passing the root of the subtree as parameter. Cast the iterator to boolean to test if it iterated all joints.

Definition at line 82 of file SkeletonT.hh.

Constructor & Destructor Documentation

◆ Iterator() [1/3]

template<typename PointT >
SkeletonT< PointT >::Iterator::Iterator ( )

Default constructor.

Creates an invalid iterator, not pointing to anything yet.

Definition at line 73 of file SkeletonT_impl.hh.

◆ Iterator() [2/3]

template<typename PointT >
SkeletonT< PointT >::Iterator::Iterator ( Joint _root)

Constructor - Creates an iterator for the given (sub-)tree.

The iterator will traverse all nodes below _root (inclusive _root) in a top-down, "left-to-right" manner.

Definition at line 86 of file SkeletonT_impl.hh.

◆ Iterator() [3/3]

template<typename PointT >
SkeletonT< PointT >::Iterator::Iterator ( const Iterator other)

Copy Constructor - Creates a copy of the given iterator.

This iterator will become a copy of the given iterator. They both point to the same position now, but iterate the tree independently.

Definition at line 100 of file SkeletonT_impl.hh.

Member Function Documentation

◆ nextSibling()

template<typename PointT >
SkeletonT< PointT >::Joint * SkeletonT< PointT >::Iterator::nextSibling ( Joint _pParent,
Joint _pJoint 
)
private

Given a parent and one of its child nodes this method finds and returns the next sibling.

Parameters
_pParentThe parent node, take it from the stack
_pJointA child node of _pParent, its next sibling is wanted
Returns
Either a pointer to the sibling or 0 if there are no more siblings

Definition at line 258 of file SkeletonT_impl.hh.

◆ operator bool()

template<typename PointT >
SkeletonT< PointT >::Iterator::operator bool ( ) const

Returns false if the iterator is done iterating.

There are two ways to test if the joint iterator has reached its end. Cast it to bool and test if it is false or compare it to the return value of SkeletonT<>::end.

Definition at line 243 of file SkeletonT_impl.hh.

◆ operator!=()

template<typename PointT >
bool SkeletonT< PointT >::Iterator::operator!= ( const Iterator other) const

Compares the iterators.

The iterators are equal if they point to the same joint, no matter where they began to iterate.

Definition at line 187 of file SkeletonT_impl.hh.

◆ operator++()

template<typename PointT >
SkeletonT< PointT >::Iterator & SkeletonT< PointT >::Iterator::operator++ ( )

Increase the iterator.

The iterator will be changed to point to the next child, or whatever joint is next.

Definition at line 141 of file SkeletonT_impl.hh.

◆ operator->()

template<typename PointT >
SkeletonT< PointT >::Joint * SkeletonT< PointT >::Iterator::operator-> ( ) const

Returns a pointer to the current joint.

This way it is possible to access the joint by calling:

...
it->method();

Definition at line 229 of file SkeletonT_impl.hh.

◆ operator=()

template<typename PointT >
SkeletonT< PointT >::Iterator & SkeletonT< PointT >::Iterator::operator= ( const Iterator other)

Assignment Operator.

Assign values from given iterator to this iterator and also return self

Definition at line 126 of file SkeletonT_impl.hh.

◆ operator==()

template<typename PointT >
bool SkeletonT< PointT >::Iterator::operator== ( const Iterator other) const

Compares the iterators.

The iterators are equal if they point to the same joint, no matter where they began to iterate.

Definition at line 200 of file SkeletonT_impl.hh.


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