ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkQuadEdgeMeshFrontIterator.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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 using QEDualType = typename MeshTypeArg::QEDual; \
29 using QEPrimalType = typename MeshTypeArg::QEPrimal; \
30 using FrontDualIterator = QuadEdgeMeshFrontIterator<MeshTypeArg, QEDualType>; \
31 using ConstFrontDualIterator = QuadEdgeMeshConstFrontIterator<MeshTypeArg, QEDualType>; \
32 using FrontIterator = QuadEdgeMeshFrontIterator<MeshTypeArg, QEPrimalType>; \
33 using ConstFrontIterator = QuadEdgeMeshConstFrontIterator<MeshTypeArg, QEPrimalType>; \
34 \
35 virtual FrontIterator BeginFront(QEPrimalType * seed = nullptr) { return (FrontIterator(this, true, seed)); } \
36 \
37 virtual ConstFrontIterator BeginFront(QEPrimalType * seed) const { return (ConstFrontIterator(this, true, seed)); } \
38 \
39 virtual FrontIterator EndFront() { return (FrontIterator(this, false)); } \
40 \
41 virtual ConstFrontIterator EndFront() const { return (ConstFrontIterator(this, false)); } \
42 \
43 virtual FrontDualIterator BeginDualFront(QEDualType * seed = (QEDualType *)0) \
44 { \
45 return (FrontDualIterator(this, true, seed)); \
46 } \
47 \
48 virtual ConstFrontDualIterator BeginDualFront(QEDualType * seed) const \
49 { \
50 return (ConstFrontDualIterator(this, true, seed)); \
51 } \
52 \
53 virtual FrontDualIterator EndDualFront() { return (FrontDualIterator(this, false)); } \
54 \
55 virtual ConstFrontDualIterator EndDualFront() const { return (ConstFrontDualIterator(this, false)); } \
56 \
57 ITK_MACROEND_NOOP_STATEMENT
58
59namespace itk
60{
74template <typename TMesh, typename TQE>
75class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontBaseIterator
76{
77public:
78 // Hierarchy type alias & values.
80
81 // Template types
82 using MeshType = TMesh;
83 using QEType = TQE;
84
85protected:
86 // Mesh types
87 using CoordinateType = typename MeshType::CoordinateType;
88#ifndef ITK_FUTURE_LEGACY_REMOVE
89 using CoordRepType ITK_FUTURE_DEPRECATED(
90 "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
91#endif
92 // QE types
93 using QEOriginType = typename QEType::OriginRefType;
94
105 {
106 public:
107 FrontAtom(QEType * e = (QEType *)0, const CoordinateType c = 0)
108 : m_Edge(e)
109 , m_Cost(c)
110 {}
111 virtual ~FrontAtom() = default;
112 FrontAtom &
114 {
115 m_Edge = r.m_Edge;
116 m_Cost = r.m_Cost;
117 return *this;
118 }
119 bool
120 operator==(const FrontAtom & r) const
121 {
122 return (m_Edge == r.m_Edge);
123 }
124
125
127
128 bool
129 operator<(const FrontAtom & r) const
130 {
131 return (m_Cost < r.m_Cost);
132 }
133
134 public:
137 };
138
142 using FrontType = std::list<FrontAtom>;
143 using FrontTypeIterator = typename FrontType::iterator;
145
151
152public:
154 QuadEdgeMeshFrontBaseIterator(MeshType * mesh = nullptr, bool start = true, QEType * seed = nullptr);
155
157
158 Self &
159 operator=(const Self & r)
160 {
161 if (this != &r)
162 {
163 m_Mesh = r.m_Mesh;
164 m_Start = r.m_Start;
165 m_Seed = r.m_Seed;
166 m_Front = r.m_Front;
169 }
170 return (*this);
171 }
172
173 // Iteration methods.
174 bool
175 operator==(const Self & r) const
176 {
177 return (m_Start == r.m_Start);
178 }
179
181
182 Self &
184
185 Self &
187 {
188 return (this->operator++());
189 }
190
191 MeshType *
192 GetMesh() const
193 {
194 return this->m_Mesh;
195 }
196
197protected:
201 QEType *
203
207 virtual CoordinateType
208 GetCost(QEType * itkNotUsed(edge))
209 {
210 return (1);
211 }
212
213protected:
216
219
221 bool m_Start{};
222
225
228
231};
232
239template <typename TMesh, typename TQE>
240class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
241{
242public:
243
247 using typename Superclass::MeshType;
248 using typename Superclass::QEType;
249
250public:
252 QuadEdgeMeshFrontIterator(MeshType * mesh = (MeshType *)0, bool start = true, QEType * seed = nullptr)
253 : Superclass(mesh, start, seed)
254 {}
255
256 ~QuadEdgeMeshFrontIterator() override = default;
257
258 QEType *
260 {
261 return (this->m_CurrentEdge);
262 }
263};
264
271template <typename TMesh, typename TQE = typename TMesh::QEType>
272class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
273{
274public:
275
279 using typename Superclass::QEType;
280 using typename Superclass::MeshType;
282
283public:
285 QuadEdgeMeshConstFrontIterator(const MeshType * itkNotUsed(mesh) = (MeshType *)0,
286 bool itkNotUsed(start) = true,
287 QEType * itkNotUsed(seed) = (QEType *)nullptr)
288 {}
289
292 Self &
294 {
295 this->m_Mesh = r.GetMesh();
296 return (*this);
297 }
298
299
300 const QEType *
301 Value() const
302 {
303 return (this->m_CurrentEdge);
304 }
305};
306} // namespace itk
307
308#include "itkQuadEdgeMeshFrontIterator.hxx"
309
310#endif
A wrapper of the STL "map" container.
QuadEdgeMeshConstFrontIterator(const MeshType *mesh=(MeshType *) 0, bool start=true, QEType *seed=(QEType *) nullptr)
~QuadEdgeMeshConstFrontIterator() override=default
QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass
QuadEdgeMeshFrontIterator< MeshType, QEType > NoConstType
FrontAtom(QEType *e=(QEType *) 0, const CoordinateType c=0)
typename MeshType::CoordinateType CoordinateType
MapContainer< QEOriginType, bool > IsVisitedContainerType
typename IsVisitedContainerType::Pointer IsVisitedPointerType
typename QEType::OriginRefType QEOriginType
virtual CoordinateType GetCost(QEType *edge)
QuadEdgeMeshFrontBaseIterator(MeshType *mesh=nullptr, bool start=true, QEType *seed=nullptr)
Non const quad edge front iterator.
QuadEdgeMeshFrontIterator(MeshType *mesh=(MeshType *) 0, bool start=true, QEType *seed=nullptr)
QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass
~QuadEdgeMeshFrontIterator() override=default
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....