ITK  6.0.0
Insight Toolkit
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 }
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);
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;
167 m_IsPointVisited = r.m_IsPointVisited;
168 m_CurrentEdge = r.m_CurrentEdge;
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:
215 MeshType * m_Mesh{};
216
218 QEType * m_Seed{};
219
221 bool m_Start{};
222
225
227 IsVisitedPointerType m_IsPointVisited{};
228
230 QEType * m_CurrentEdge{};
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 ~QuadEdgeMeshFrontIterator() override = default;
256 QEType *
258 {
259 return (this->m_CurrentEdge);
260 }
261};
270template <typename TMesh, typename TQE = typename TMesh::QEType>
271class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
272{
273public:
274
278 using typename Superclass::QEType;
279 using typename Superclass::MeshType;
281
282public:
284 QuadEdgeMeshConstFrontIterator(const MeshType * itkNotUsed(mesh) = (MeshType *)0,
285 bool itkNotUsed(start) = true,
286 QEType * itkNotUsed(seed) = (QEType *)nullptr)
287 {}
288
291 Self &
293 {
294 this->m_Mesh = r.GetMesh();
295 return (*this);
296 }
299 const QEType *
300 Value() const
301 {
302 return (this->m_CurrentEdge);
303 }
304};
305} // namespace itk
306
307#include "itkQuadEdgeMeshFrontIterator.hxx"
308
309#endif
A wrapper of the STL "map" container.
Const quad edge mesh front iterator.
~QuadEdgeMeshConstFrontIterator() override=default
QuadEdgeMeshConstFrontIterator(const MeshType *=(MeshType *) 0, bool=true, QEType *=(QEType *) nullptr)
Atomic information associated to each edge of the front.
FrontAtom(QEType *e=(QEType *) 0, const CoordinateType c=0)
typename FrontType::iterator FrontTypeIterator
typename MeshType::CoordinateType CoordinateType
typename IsVisitedContainerType::Pointer IsVisitedPointerType
typename QEType::OriginRefType QEOriginType
virtual CoordinateType GetCost(QEType *)
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)
~QuadEdgeMeshFrontIterator() override=default
SmartPointer< Self > Pointer
static constexpr double e
Definition: itkMath.h:56
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:566