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 &
113 operator=(const FrontAtom & r) = default;
114 bool
115 operator==(const FrontAtom & r) const
116 {
117 return (m_Edge == r.m_Edge);
118 }
119
121
122 bool
123 operator<(const FrontAtom & r) const
124 {
125 return (m_Cost < r.m_Cost);
126 }
127
128 public:
131 };
132
136 using FrontType = std::list<FrontAtom>;
137 using FrontTypeIterator = typename FrontType::iterator;
139
145
146public:
148 QuadEdgeMeshFrontBaseIterator(MeshType * mesh = nullptr, bool start = true, QEType * seed = nullptr);
149
151
152 Self &
153 operator=(const Self & r)
154 {
155 if (this != &r)
156 {
157 m_Mesh = r.m_Mesh;
158 m_Start = r.m_Start;
159 m_Seed = r.m_Seed;
160 m_Front = r.m_Front;
163 }
164 return (*this);
165 }
166
167 // Iteration methods.
168 bool
169 operator==(const Self & r) const
170 {
171 return (m_Start == r.m_Start);
172 }
173
175
176 Self &
178
179 Self &
181 {
182 return (this->operator++());
183 }
184
185 [[nodiscard]] MeshType *
186 GetMesh() const
187 {
188 return this->m_Mesh;
189 }
190
191protected:
195 QEType *
197
201 virtual CoordinateType
202 GetCost(QEType * itkNotUsed(edge))
203 {
204 return (1);
205 }
206
207protected:
210
213
215 bool m_Start{};
216
219
222
225};
226
233template <typename TMesh, typename TQE>
234class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
235{
236public:
240 using typename Superclass::MeshType;
241 using typename Superclass::QEType;
242
243public:
245 QuadEdgeMeshFrontIterator(MeshType * mesh = (MeshType *)0, bool start = true, QEType * seed = nullptr)
246 : Superclass(mesh, start, seed)
247 {}
248
249 ~QuadEdgeMeshFrontIterator() override = default;
250
251 QEType *
253 {
254 return (this->m_CurrentEdge);
255 }
256};
257
264template <typename TMesh, typename TQE = typename TMesh::QEType>
265class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
266{
267public:
271 using typename Superclass::QEType;
272 using typename Superclass::MeshType;
274
275public:
277 QuadEdgeMeshConstFrontIterator(const MeshType * itkNotUsed(mesh) = (MeshType *)0,
278 bool itkNotUsed(start) = true,
279 QEType * itkNotUsed(seed) = (QEType *)nullptr)
280 {}
281
284 Self &
286 {
287 this->m_Mesh = r.GetMesh();
288 return (*this);
289 }
290
291 [[nodiscard]] const QEType *
292 Value() const
293 {
294 return (this->m_CurrentEdge);
295 }
296};
297} // namespace itk
298
299#include "itkQuadEdgeMeshFrontIterator.hxx"
300
301#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 & operator=(const FrontAtom &r)=default
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....