ITK
4.4.0
Insight Segmentation and Registration Toolkit
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
ITK
Modules
Core
Common
include
itkTreeIteratorBase.h
Go to the documentation of this file.
1
/*=========================================================================
2
*
3
* Copyright Insight Software Consortium
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0.txt
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*=========================================================================*/
18
#ifndef __itkTreeIteratorBase_h
19
#define __itkTreeIteratorBase_h
20
21
#include "
itkTreeNode.h
"
22
23
namespace
itk
24
{
41
template
<
class
TTreeType >
42
class
TreeIteratorBase
43
{
44
public
:
45
47
typedef
TreeIteratorBase
Self
;
48
typedef
typename
TTreeType::ValueType
ValueType
;
49
typedef
typename
TTreeType::TreeNodeType
TreeNodeType
;
50
typedef
typename
TreeNodeType::ChildIdentifier
ChildIdentifier
;
51
53
typedef
enum
54
{
55
UNDEFIND
= 0,
56
PREORDER
= 1,
57
INORDER
= 2,
58
POSTORDER
= 3,
59
LEVELORDER
= 4,
60
CHILD
= 5,
61
ROOT
= 6,
62
LEAF
= 7
63
}
64
NodeType
;
65
67
virtual
bool
Add
(
ValueType
element);
68
70
virtual
bool
Add
(
int
position,
ValueType
element);
71
73
virtual
bool
Add
(TTreeType & subTree);
74
76
virtual
const
ValueType
&
Get
()
const
;
77
79
virtual
TTreeType *
GetSubTree
()
const
;
80
82
virtual
bool
IsLeaf
()
const
;
83
85
virtual
bool
IsRoot
()
const
;
86
88
virtual
NodeType
GetType
()
const
= 0;
89
91
virtual
bool
GoToChild
(
ChildIdentifier
number = 0);
92
94
virtual
bool
GoToParent
();
95
97
void
Set
(
ValueType
element);
98
100
virtual
bool
HasChild
(
int
number = 0)
const
;
101
103
virtual
int
ChildPosition
(
ValueType
element)
const
;
104
106
virtual
bool
RemoveChild
(
int
number);
107
109
virtual
int
CountChildren
()
const
;
110
112
virtual
bool
HasParent
()
const
;
113
115
virtual
bool
Disconnect
();
116
118
virtual
TreeIteratorBase< TTreeType >
*
Children
();
119
121
virtual
TreeIteratorBase< TTreeType >
*
Parents
();
122
124
virtual
TreeIteratorBase< TTreeType >
*
GetChild
(
int
number)
const
;
125
127
virtual
int
Count
();
128
130
bool
Remove
();
131
133
virtual
TreeNodeType
*
GetNode
();
134
135
virtual
const
TreeNodeType
*
GetNode
()
const
;
136
138
TreeNodeType
*
GetRoot
();
139
140
const
TreeNodeType
*
GetRoot
()
const
;
141
143
TTreeType *
GetTree
()
const
;
144
146
const
TreeNodeType
*
GetParent
()
const
;
147
149
void
GoToBegin
() {
m_Position
=
m_Begin
; }
150
152
void
GoToEnd
() {
m_Position
=
m_End
; }
153
155
bool
IsAtBegin
(
void
)
const
{
return
(
m_Position
==
m_Begin
); }
156
159
bool
IsAtEnd
(
void
)
const
{
return
(
m_Position
==
m_End
); }
160
162
virtual
TreeIteratorBase< TTreeType >
*
Clone
() = 0;
163
165
Self
&
166
operator++
()
167
{
168
this->
Next
();
169
return
*
this
;
170
}
172
174
void
175
operator++
(
int
)
176
{
177
// itkAssertInDebugAndIgnoreInReleaseMacro( !IsAtEnd() );
178
this->
Next
();
179
}
181
183
const
Self
&
operator=
(
const
Self
& iterator)
184
{
185
if
(
this
!= &iterator)
186
{
187
m_Position
= iterator.
m_Position
;
188
m_Begin
= iterator.
m_Begin
;
189
m_End
= iterator.
m_End
;
190
m_Root
= iterator.
m_Root
;
191
m_Tree
= iterator.
m_Tree
;
192
}
193
return
*
this
;
194
}
196
197
virtual
~TreeIteratorBase
() {}
198
199
protected
:
200
202
TreeIteratorBase
(TTreeType *tree,
const
TreeNodeType
*start);
203
TreeIteratorBase
(
const
TTreeType *tree,
const
TreeNodeType
*start);
205
206
mutable
TreeNodeType
*
m_Position
;
// Current position of the iterator
207
mutable
TreeNodeType
*
m_Begin
;
208
mutable
TreeNodeType
*
m_End
;
209
const
TreeNodeType
*
m_Root
;
210
TTreeType *
m_Tree
;
211
212
virtual
bool
HasNext
()
const
= 0;
213
214
virtual
const
ValueType
&
Next
() = 0;
215
};
216
}
//end namespace itk
217
218
#ifndef ITK_MANUAL_INSTANTIATION
219
#include "itkTreeIteratorBase.hxx"
220
#endif
221
222
#endif
223
Generated on Mon May 13 2013 01:10:23 for ITK by
1.8.3.1