Orfeo Toolbox  3.16
itkRootTreeIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkRootTreeIterator.h,v $
5  Language: C++
6  Date: $Date: 2009-03-03 15:09:06 $
7  Version: $Revision: 1.3 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkRootTreeIterator_h
18 #define __itkRootTreeIterator_h
19 
20 #include <itkTreeIteratorBase.h>
21 
22 namespace itk {
23 
24 template <class TTreeType>
25 class RootTreeIterator : public TreeIteratorBase<TTreeType>
26 {
27 public:
28 
31  typedef TTreeType TreeType;
32  typedef typename TTreeType::ValueType ValueType;
34 
36  RootTreeIterator( TreeType* tree, const TreeNodeType* start=NULL);
37 
39  int GetType() const;
40 
43 
44 protected:
45 
47  const ValueType& Next();
48 
50  bool HasNext() const;
51 
52 private:
53 
55  const TreeNodeType* FindNextNode() const;
56 };
57 
58 
60 template <class TTreeType>
62  :TreeIteratorBase<TTreeType>(tree, start)
63 {
64  if(start)
65  {
66  this->m_Begin = const_cast<TreeNode<ValueType>*>(start);
67  }
68  this->m_Root = tree->GetRoot();
69  this->m_Position = this->m_Begin;
70 }
71 
73 template <class TTreeType>
74 int
76 {
78 }
79 
81 template <class TTreeType>
82 bool
84 {
85  if ( const_cast<TreeNodeType*>(FindNextNode()) != NULL )
86  {
87  return true;
88  }
89  return false;
90 }
91 
93 template <class TTreeType>
96 {
97  this->m_Position = const_cast<TreeNodeType*>(FindNextNode());
98  return this->m_Position->Get();
99 }
100 
102 template <class TTreeType>
105 {
106  if ( this->m_Position == NULL )
107  {
108  return NULL;
109  }
110  if ( this->m_Position == this->m_Root )
111  {
112  return NULL;
113  }
114  return this->m_Position->GetParent();
115 }
116 
118 template <class TTreeType>
120 {
121  RootTreeIterator<TTreeType>* clone = new RootTreeIterator<TTreeType>( const_cast<TTreeType*>(this->m_Tree), this->m_Position );
122  *clone = *this;
123  return clone;
124 }
125 
126 } // end namespace itk
127 
128 #endif

Generated at Sun Feb 3 2013 00:03:35 for Orfeo Toolbox with doxygen 1.8.1.1