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
QuadEdgeMesh
include
itkQuadEdgeMeshFrontIterator.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 __itkQuadEdgeMeshFrontIterator_h
19
#define __itkQuadEdgeMeshFrontIterator_h
20
21
#include "
itkMapContainer.h
"
22
23
// -------------------------------------------------------------------------
24
#define itkQEDefineFrontIteratorMethodsMacro(MeshTypeArg) \
25
/* Dual definition placed before others because of .NET that cannot */
\
26
/* cope with definition of FrontIterator (that further hides the */
\
27
/* definition of the template). */
\
28
typedef typename MeshTypeArg::QEDual QEDualType; \
29
typedef typename MeshTypeArg::QEPrimal QEPrimalType; \
30
typedef QuadEdgeMeshFrontIterator< MeshTypeArg, \
31
QEDualType > FrontDualIterator; \
32
typedef QuadEdgeMeshConstFrontIterator< MeshTypeArg, \
33
QEDualType > \
34
ConstFrontDualIterator; \
35
typedef QuadEdgeMeshFrontIterator< MeshTypeArg, \
36
QEPrimalType > FrontIterator; \
37
typedef QuadEdgeMeshConstFrontIterator< MeshTypeArg, \
38
QEPrimalType > \
39
ConstFrontIterator; \
40
\
41
virtual FrontIterator BeginFront(QEPrimalType * seed = (QEPrimalType *)0) \
42
{ \
43
return ( FrontIterator(this, true, seed) ); \
44
} \
45
\
46
virtual ConstFrontIterator BeginFront(QEPrimalType * seed) const \
47
{ return ( ConstFrontIterator(this, true, seed) ); } \
48
\
49
virtual FrontIterator EndFront() \
50
{ \
51
return ( FrontIterator(this, false) ); \
52
} \
53
\
54
virtual ConstFrontIterator EndFront() const \
55
{ return ( ConstFrontIterator(this, false) ); } \
56
\
57
virtual FrontDualIterator BeginDualFront(QEDualType * seed = (QEDualType *)0) \
58
{ \
59
return ( FrontDualIterator(this, true, seed) ); \
60
} \
61
\
62
virtual ConstFrontDualIterator BeginDualFront(QEDualType * seed) const \
63
{ return ( ConstFrontDualIterator(this, true, seed) ); } \
64
\
65
virtual FrontDualIterator EndDualFront() \
66
{ \
67
return ( FrontDualIterator(this, false) ); \
68
} \
69
\
70
virtual ConstFrontDualIterator EndDualFront() const \
71
{ return ( ConstFrontDualIterator(this, false) ); }
72
73
namespace
itk
74
{
88
template
<
typename
TMesh,
typename
TQE >
89
class
ITK_EXPORT
QuadEdgeMeshFrontBaseIterator
90
{
91
public
:
92
// Hierarchy typedefs & values.
93
typedef
QuadEdgeMeshFrontBaseIterator
Self
;
94
95
// Template types
96
typedef
TMesh
MeshType
;
97
typedef
TQE
QEType
;
98
99
protected
:
100
// Mesh types
101
typedef
typename
MeshType::CoordRepType
CoordRepType
;
102
// QE types
103
typedef
typename
QEType::OriginRefType
QEOriginType
;
104
114
class
FrontAtom
115
{
116
public
:
117
FrontAtom
(
QEType
*
e
= (
QEType
*)0,
const
CoordRepType
c = 0):
118
m_Edge(
e
), m_Cost(c)
119
{}
120
virtual
~FrontAtom
() {}
121
FrontAtom
& operator=(
const
FrontAtom
& r)
122
{ m_Edge = r.
m_Edge
; m_Cost = r.
m_Cost
;
return
*
this
; }
123
bool
operator==(
const
FrontAtom
& r)
const
124
{
return
( m_Edge == r.
m_Edge
); }
125
bool
operator!=
(
const
FrontAtom
& r)
const
126
{
return
( m_Edge != r.
m_Edge
); }
127
bool
operator<(
const
FrontAtom
& r)
const
128
{
return
( m_Cost < r.
m_Cost
); }
130
131
public
:
132
QEType
*
m_Edge
;
133
CoordRepType
m_Cost
;
134
};
135
139
typedef
std::list< FrontAtom >
FrontType
;
140
typedef
typename
FrontType::iterator
FrontTypeIterator
;
141
typedef
FrontType
*
FrontTypePointer
;
142
146
typedef
MapContainer< QEOriginType, bool >
IsVisitedContainerType
;
147
typedef
typename
IsVisitedContainerType::Pointer
IsVisitedPointerType
;
148
149
public
:
151
QuadEdgeMeshFrontBaseIterator
(
MeshType
*mesh = (
MeshType
*)0,
152
bool
start =
true
,
153
QEType
*seed = (
QEType
*)0);
154
virtual
~
QuadEdgeMeshFrontBaseIterator
();
156
157
Self
& operator=(
const
Self
& r)
158
{
159
if
(
this
!= &r)
160
{
161
m_Mesh = r.
m_Mesh
;
162
m_Start = r.
m_Start
;
163
m_Seed = r.
m_Seed
;
164
m_Front = r.
m_Front
;
165
m_IsPointVisited = r.
m_IsPointVisited
;
166
m_CurrentEdge = r.
m_CurrentEdge
;
167
}
168
return
( *
this
);
169
}
170
171
// Iteration methods.
172
bool
operator==(
Self
& r)
173
{
174
return
( m_Start == r.
m_Start
);
175
}
176
177
bool
operator==(
const
Self
& r)
const
178
{
179
return
( m_Start == r.
m_Start
);
180
}
181
182
bool
operator!=
(
Self
& r)
183
{
184
return
( !( this->
operator
==(r) ) );
185
}
186
187
bool
operator!=
(
const
Self
& r)
const
188
{
189
return
( !( this->
operator
==(r) ) );
190
}
191
192
Self & operator++();
193
194
Self
&
operator++
(
int
) {
return
( this->
operator
++() ); }
195
196
MeshType
*
GetMesh
()
const
{
return
this->m_Mesh; }
197
198
protected
:
202
QEType * FindDefaultSeed();
203
207
virtual
CoordRepType
GetCost
(
QEType
*edge){ (void)edge;
return
( 1 ); }
208
209
protected
:
211
MeshType
*
m_Mesh
;
212
214
QEType
*
m_Seed
;
215
217
bool
m_Start
;
218
220
FrontTypePointer
m_Front
;
221
223
IsVisitedPointerType
m_IsPointVisited
;
224
226
QEType
*
m_CurrentEdge
;
227
};
228
235
template
<
typename
TMesh,
typename
TQE >
236
class
ITK_EXPORT
QuadEdgeMeshFrontIterator
:
237
public
QuadEdgeMeshFrontBaseIterator
< TMesh, TQE >
238
{
239
public
:
240
242
typedef
QuadEdgeMeshFrontIterator
Self
;
243
typedef
QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
Superclass
;
244
typedef
typename
Superclass::MeshType
MeshType
;
245
typedef
typename
Superclass::QEType
QEType
;
246
247
public
:
249
QuadEdgeMeshFrontIterator
(
MeshType
*mesh = (
MeshType
*)0,
250
bool
start =
true
,
251
QEType
*seed = (
QEType
*)0):
252
Superclass
(mesh, start, seed) {}
253
virtual
~QuadEdgeMeshFrontIterator
() {}
254
QEType
*
Value
() {
return
( this->m_CurrentEdge ); }
255
};
257
264
template
<
class
TMesh,
class
TQE =
typename
TMesh::QEType >
265
class
ITK_EXPORT
QuadEdgeMeshConstFrontIterator
:
266
public
QuadEdgeMeshFrontBaseIterator
< TMesh, TQE >
267
{
268
public
:
269
271
typedef
QuadEdgeMeshConstFrontIterator
Self
;
272
typedef
QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
Superclass
;
273
typedef
typename
Superclass::QEType
QEType
;
274
typedef
typename
Superclass::MeshType
MeshType
;
275
typedef
QuadEdgeMeshFrontIterator< MeshType, QEType >
NoConstType
;
276
277
public
:
279
QuadEdgeMeshConstFrontIterator
(
const
MeshType
*mesh = (
MeshType
*)0,
280
bool
start =
true
,
281
QEType
*seed = (
QEType
*)0)
282
{
283
(void)mesh;
284
(void)start;
285
(void)seed;
286
}
288
290
virtual
~QuadEdgeMeshConstFrontIterator
() {}
291
Self
& operator=(
const
NoConstType
& r)
292
{
293
this->m_Mesh = r.
GetMesh
();
294
return
( *
this
);
295
}
297
298
const
QEType
*
Value
()
const
{
return
( this->m_CurrentEdge ); }
299
};
300
}
301
302
#include "itkQuadEdgeMeshFrontIterator.hxx"
303
304
#endif
305
Generated on Mon May 13 2013 01:04:54 for ITK by
1.8.3.1