18 #ifndef __itkPostOrderTreeIterator_h
19 #define __itkPostOrderTreeIterator_h
25 template<
class TTreeType >
64 template<
class TTreeType >
68 if ( tree->GetRoot() == 0 )
77 itkGenericExceptionMacro(<<
"Can't downcast root node to TreeNodeType *");
87 template<
class TTreeType >
95 template<
class TTreeType >
99 if ( const_cast< TreeNodeType * >( FindNextNode() ) !=
NULL )
108 template<
class TTreeType >
112 this->m_Position =
const_cast< TreeNodeType *
>( FindNextNode() );
113 return this->m_Position->Get();
118 template<
class TTreeType >
122 if ( this->m_Position ==
NULL || this->m_Position == this->m_Root )
129 if ( sister !=
NULL )
131 return FindMostRightLeaf(sister);
133 if(this->m_Position->GetParent() == 0)
140 itkGenericExceptionMacro(<<
"Can't downcast to TreeNodeType *");
146 template<
class TTreeType >
150 if ( !node->HasParent() )
158 itkGenericExceptionMacro(<<
"Can't downcast to TreeNodeType *");
161 int childPosition = parent->ChildPosition(node);
162 int lastChildPosition = parent->CountChildren() - 1;
164 while ( childPosition < lastChildPosition )
166 if(parent->GetChild(childPosition + 1) == 0)
175 itkGenericExceptionMacro(<<
"Can't downcast to TreeNodeType *");
184 template<
class TTreeType >
188 while ( node->HasChildren() )
191 int childCount = node->CountChildren();
197 if(node->GetChild(i) == 0)
203 helpNode =
dynamic_cast<TreeNodeType *
>(node->GetChild(i));
206 itkGenericExceptionMacro(<<
"Can't downcast to TreeNodeType *");
211 while ( helpNode ==
NULL && i < childCount );
213 if ( helpNode ==
NULL )
223 template<
class TTreeType >