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 = (QEPrimalType *)nullptr) \
36 { \
37 return (FrontIterator(this, true, seed)); \
38 } \
39 \
40 virtual ConstFrontIterator BeginFront(QEPrimalType * seed) const { return (ConstFrontIterator(this, true, seed)); } \
41 \
42 virtual FrontIterator EndFront() { return (FrontIterator(this, false)); } \
43 \
44 virtual ConstFrontIterator EndFront() const { return (ConstFrontIterator(this, false)); } \
45 \
46 virtual FrontDualIterator BeginDualFront(QEDualType * seed = (QEDualType *)0) \
47 { \
48 return (FrontDualIterator(this, true, seed)); \
49 } \
50 \
51 virtual ConstFrontDualIterator BeginDualFront(QEDualType * seed) const \
52 { \
53 return (ConstFrontDualIterator(this, true, seed)); \
54 } \
55 \
56 virtual FrontDualIterator EndDualFront() { return (FrontDualIterator(this, false)); } \
57 \
58 virtual ConstFrontDualIterator EndDualFront() const { return (ConstFrontDualIterator(this, false)); }
59
60namespace itk
61{
75template <typename TMesh, typename TQE>
76class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontBaseIterator
77{
78public:
79 // Hierarchy type alias & values.
81
82 // Template types
83 using MeshType = TMesh;
84 using QEType = TQE;
85
86protected:
87 // Mesh types
88 using CoordRepType = typename MeshType::CoordRepType;
89 // QE types
90 using QEOriginType = typename QEType::OriginRefType;
91
102 {
103 public:
104 FrontAtom(QEType * e = (QEType *)0, const CoordRepType c = 0)
105 : m_Edge(e)
106 , m_Cost(c)
107 {}
108 virtual ~FrontAtom() = default;
109 FrontAtom &
111 {
112 m_Edge = r.m_Edge;
113 m_Cost = r.m_Cost;
114 return *this;
115 }
116 bool
117 operator==(const FrontAtom & r) const
118 {
119 return (m_Edge == r.m_Edge);
120 }
124
125 bool
126 operator<(const FrontAtom & r) const
127 {
128 return (m_Cost < r.m_Cost);
129 }
130
131 public:
134 };
135
139 using FrontType = std::list<FrontAtom>;
140 using FrontTypeIterator = typename FrontType::iterator;
142
148
149public:
152 bool start = true,
153 QEType * seed = (QEType *)nullptr);
157 Self &
158 operator=(const Self & r)
159 {
160 if (this != &r)
161 {
162 m_Mesh = r.m_Mesh;
163 m_Start = r.m_Start;
164 m_Seed = r.m_Seed;
165 m_Front = r.m_Front;
166 m_IsPointVisited = r.m_IsPointVisited;
167 m_CurrentEdge = r.m_CurrentEdge;
168 }
169 return (*this);
170 }
171
172 // Iteration methods.
173 bool
174 operator==(const Self & r) const
175 {
176 return (m_Start == r.m_Start);
177 }
178
180
181 Self &
183
184 Self &
186 {
187 return (this->operator++());
188 }
189
190 MeshType *
191 GetMesh() const
192 {
193 return this->m_Mesh;
194 }
195
196protected:
200 QEType *
202
206 virtual CoordRepType
207 GetCost(QEType * itkNotUsed(edge))
208 {
209 return (1);
210 }
211
212protected:
214 MeshType * m_Mesh{};
215
217 QEType * m_Seed{};
218
220 bool m_Start{};
221
224
226 IsVisitedPointerType m_IsPointVisited{};
227
229 QEType * m_CurrentEdge{};
230};
231
238template <typename TMesh, typename TQE>
239class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
240{
241public:
242
246 using typename Superclass::MeshType;
247 using typename Superclass::QEType;
248
249public:
251 QuadEdgeMeshFrontIterator(MeshType * mesh = (MeshType *)0, bool start = true, QEType * seed = (QEType *)nullptr)
252 : Superclass(mesh, start, seed)
253 {}
254 ~QuadEdgeMeshFrontIterator() override = default;
255 QEType *
257 {
258 return (this->m_CurrentEdge);
259 }
260};
269template <typename TMesh, typename TQE = typename TMesh::QEType>
270class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstFrontIterator : public QuadEdgeMeshFrontBaseIterator<TMesh, TQE>
271{
272public:
273
277 using typename Superclass::QEType;
278 using typename Superclass::MeshType;
280
281public:
283 QuadEdgeMeshConstFrontIterator(const MeshType * itkNotUsed(mesh) = (MeshType *)0,
284 bool itkNotUsed(start) = true,
285 QEType * itkNotUsed(seed) = (QEType *)nullptr)
286 {}
287
290 Self &
292 {
293 this->m_Mesh = r.GetMesh();
294 return (*this);
295 }
298 const QEType *
299 Value() const
300 {
301 return (this->m_CurrentEdge);
302 }
303};
304} // namespace itk
305
306#include "itkQuadEdgeMeshFrontIterator.hxx"
307
308#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 CoordRepType c=0)
QuadEdgeMeshFrontBaseIterator(MeshType *mesh=(MeshType *) nullptr, bool start=true, QEType *seed=(QEType *) nullptr)
typename FrontType::iterator FrontTypeIterator
typename MeshType::CoordRepType CoordRepType
typename IsVisitedContainerType::Pointer IsVisitedPointerType
typename QEType::OriginRefType QEOriginType
Non const quad edge front iterator.
QuadEdgeMeshFrontIterator(MeshType *mesh=(MeshType *) 0, bool start=true, QEType *seed=(QEType *) 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:557