ITK  5.4.0
Insight Toolkit
itkQuadEdge.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 itkQuadEdge_h
19#define itkQuadEdge_h
20
22#include "ITKQuadEdgeMeshExport.h"
23
24#include "itkMacro.h"
25
26// Debugging macros for classes that do not derive from the itkObject.
27// FIXME: Maybe variations of these macros should be moved into
28// itkMacro.h
29//
30#define itkQEDebugMacro(x) \
31 { \
32 std::ostringstream itkmsg; \
33 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << '\n' << " (" << this << "): " x << "\n\n"; \
34 OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
35 } \
36 ITK_MACROEND_NOOP_STATEMENT
37#define itkQEWarningMacro(x) \
38 { \
39 std::ostringstream itkmsg; \
40 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << '\n' << " (" << this << "): " x << "\n\n"; \
41 OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
42 } \
43 ITK_MACROEND_NOOP_STATEMENT
44
45// -------------------------------------------------------------------------
55#define itkQEAccessorsMacro(st, pt, dt) \
56 pt * GetOnext() { return (dynamic_cast<pt *>(this->st::GetOnext())); } \
57 \
58 dt * GetRot() { return (dynamic_cast<dt *>(this->st::GetRot())); } \
59 \
60 pt * GetSym() { return (dynamic_cast<pt *>(this->st::GetSym())); } \
61 \
62 pt * GetLnext() { return (dynamic_cast<pt *>(this->st::GetLnext())); } \
63 \
64 pt * GetRnext() { return (dynamic_cast<pt *>(this->st::GetRnext())); } \
65 \
66 pt * GetDnext() { return (dynamic_cast<pt *>(this->st::GetDnext())); } \
67 \
68 pt * GetOprev() { return (dynamic_cast<pt *>(this->st::GetOprev())); } \
69 \
70 pt * GetLprev() { return (dynamic_cast<pt *>(this->st::GetLprev())); } \
71 \
72 pt * GetRprev() { return (dynamic_cast<pt *>(this->st::GetRprev())); } \
73 \
74 pt * GetDprev() { return (dynamic_cast<pt *>(this->st::GetDprev())); } \
75 \
76 dt * GetInvRot() { return (dynamic_cast<dt *>(this->st::GetInvRot())); } \
77 \
78 pt * GetInvOnext() { return (dynamic_cast<pt *>(this->st::GetInvOnext())); } \
79 \
80 pt * GetInvLnext() { return (dynamic_cast<pt *>(this->st::GetInvLnext())); } \
81 \
82 pt * GetInvRnext() { return (dynamic_cast<pt *>(this->st::GetInvRnext())); } \
83 \
84 pt * GetInvDnext() { return (dynamic_cast<pt *>(this->st::GetInvDnext())); } \
85 const pt * GetOnext() const { return (dynamic_cast<const pt *>(this->st::GetOnext())); } \
86 \
87 const dt * GetRot() const { return (dynamic_cast<const dt *>(this->st::GetRot())); } \
88 \
89 const pt * GetSym() const { return (dynamic_cast<const pt *>(this->st::GetSym())); } \
90 \
91 const pt * GetLnext() const { return (dynamic_cast<const pt *>(this->st::GetLnext())); } \
92 \
93 const pt * GetRnext() const { return (dynamic_cast<const pt *>(this->st::GetRnext())); } \
94 \
95 const pt * GetDnext() const { return (dynamic_cast<const pt *>(this->st::GetDnext())); } \
96 \
97 const pt * GetOprev() const { return (dynamic_cast<const pt *>(this->st::GetOprev())); } \
98 \
99 const pt * GetLprev() const { return (dynamic_cast<const pt *>(this->st::GetLprev())); } \
100 \
101 const pt * GetRprev() const { return (dynamic_cast<const pt *>(this->st::GetRprev())); } \
102 \
103 const pt * GetDprev() const { return (dynamic_cast<const pt *>(this->st::GetDprev())); } \
104 \
105 const dt * GetInvRot() const { return (dynamic_cast<const dt *>(this->st::GetInvRot())); } \
106 \
107 const pt * GetInvOnext() const { return (dynamic_cast<const pt *>(this->st::GetInvOnext())); } \
108 \
109 const pt * GetInvLnext() const { return (dynamic_cast<const pt *>(this->st::GetInvLnext())); } \
110 \
111 const pt * GetInvRnext() const { return (dynamic_cast<const pt *>(this->st::GetInvRnext())); } \
112 \
113 const pt * GetInvDnext() const { return (dynamic_cast<const pt *>(this->st::GetInvDnext())); }
116namespace itk
117{
134class ITKQuadEdgeMesh_EXPORT QuadEdge
135{
136public:
138 using Self = QuadEdge;
139
143
146 // itkQEDefineIteratorMethodsMacro( Sym );
147 // itkQEDefineIteratorMethodsMacro( Lnext );
148 // itkQEDefineIteratorMethodsMacro( Rnext );
149 // itkQEDefineIteratorMethodsMacro( Dnext );
150 // itkQEDefineIteratorMethodsMacro( Oprev );
151 // itkQEDefineIteratorMethodsMacro( Lprev );
152 // itkQEDefineIteratorMethodsMacro( Rprev );
153 // itkQEDefineIteratorMethodsMacro( Dprev );
154 // itkQEDefineIteratorMethodsMacro( InvOnext );
155 // itkQEDefineIteratorMethodsMacro( InvLnext );
156 // itkQEDefineIteratorMethodsMacro( InvRnext );
157 // itkQEDefineIteratorMethodsMacro( InvDnext );
162 QuadEdge(const QuadEdge &) = default;
163 QuadEdge(QuadEdge &&) = default;
164 QuadEdge &
165 operator=(const QuadEdge &) = default;
166 QuadEdge &
167 operator=(QuadEdge &&) = default;
168 virtual ~QuadEdge();
172 inline void
173 SetOnext(Self * onext)
174 {
175 this->m_Onext = onext;
176 }
177 inline void
179 {
180 this->m_Rot = rot;
181 }
187 inline Self *
189 {
190 return this->m_Onext;
191 }
192 inline Self *
194 {
195 return this->m_Rot;
196 }
197 inline const Self *
198 GetOnext() const
199 {
200 return this->m_Onext;
201 }
202 inline const Self *
203 GetRot() const
204 {
205 return this->m_Rot;
206 }
225 // TODO fix this ref
226 // * \sa \ref DoxySurgeryConnectivity
227 inline void
229 {
230 Self * aNext = this->GetOnext();
231 Self * bNext = b->GetOnext();
232 Self * alpha = aNext->GetRot();
233 Self * beta = bNext->GetRot();
234 Self * alphaNext = alpha->GetOnext();
235 Self * betaNext = beta->GetOnext();
238 this->SetOnext(bNext);
239 b->SetOnext(aNext);
240 alpha->SetOnext(betaNext);
241 beta->SetOnext(alphaNext);
242 }
243
244 // Second order accessors.
245
248 inline Self *
250 {
251 if (this->m_Rot)
252 {
253 return (this->m_Rot->m_Rot);
254 }
255 return (this->m_Rot);
256 }
259 inline const Self *
260 GetSym() const
261 {
262 if (this->m_Rot)
263 {
264 return (this->m_Rot->m_Rot);
265 }
266 return (this->m_Rot);
267 }
268
271 Self *
273
274 const Self *
275 GetLnext() const;
276
280 Self *
282
283 const Self *
284 GetRnext() const;
285
289 Self *
291
292 const Self *
293 GetDnext() const;
294
297 Self *
299
300 const Self *
301 GetOprev() const;
302
306 Self *
308
309 const Self *
310 GetLprev() const;
311
315 Self *
317
318 const Self *
319 GetRprev() const;
320
324 Self *
326
327 const Self *
328 GetDprev() const;
329
331 inline Self *
333 {
334#ifdef NDEBUG
335 return (this->GetRot()->GetRot()->GetRot());
336#else
337 Self * p1 = this->GetRot();
338 if (!p1)
339 {
340 return nullptr;
341 }
342 Self * p2 = p1->GetRot();
343 if (!p2)
344 {
345 return nullptr;
346 }
347 Self * p3 = p2->GetRot();
348 if (!p3)
349 {
350 return nullptr;
351 }
352 return p3;
353#endif
354 }
357 inline Self *
359 {
360 return this->GetOprev();
361 }
362 inline Self *
364 {
365 return this->GetLprev();
366 }
367 inline Self *
369 {
370 return this->GetRprev();
371 }
372 inline Self *
374 {
375 return this->GetDprev();
376 }
377 inline const Self *
378 GetInvRot() const
379 {
380#ifdef NDEBUG
381 return (this->GetRot()->GetRot()->GetRot());
382#else
383 const Self * p1 = this->GetRot();
384 if (!p1)
385 {
386 return nullptr;
387 }
388 const Self * p2 = p1->GetRot();
389 if (!p2)
390 {
391 return nullptr;
392 }
393 const Self * p3 = p2->GetRot();
394 if (!p3)
395 {
396 return nullptr;
397 }
398 return p3;
399#endif
400 }
401
402 inline const Self *
404 {
405 return this->GetOprev();
406 }
407 inline const Self *
409 {
410 return this->GetLprev();
411 }
412 inline const Self *
414 {
415 return this->GetRprev();
416 }
417 inline const Self *
419 {
420 return this->GetDprev();
421 }
422
424 inline bool
426 {
427 return ((m_Onext == this) || (m_Rot == nullptr));
428 }
429 inline bool
431 {
432 return (this == this->GetOnext());
433 }
434 bool
435 IsEdgeInOnextRing(Self * testEdge) const;
438 bool
439 IsLnextGivenSizeCyclic(const int size) const;
440
441 unsigned int
442 GetOrder() const;
443
444private:
448};
449} // namespace itk
450
451#endif
Pixel-wise addition of two images.
Const iterator for QuadEdgeMesh.
Non const iterator for QuadMesh.
Base class for the implementation of a quad-edge data structure as proposed in "Guibas and Stolfi 198...
Definition: itkQuadEdge.h:135
const Self * GetOnext() const
Definition: itkQuadEdge.h:198
const Self * GetRnext() const
bool IsHalfEdge() const
Definition: itkQuadEdge.h:425
Self * GetOprev()
Self * GetSym()
Definition: itkQuadEdge.h:249
QuadEdge(QuadEdge &&)=default
void SetOnext(Self *onext)
Definition: itkQuadEdge.h:173
virtual ~QuadEdge()
void Splice(Self *b)
Basic quad-edge topological method.
Definition: itkQuadEdge.h:228
const Self * GetRot() const
Definition: itkQuadEdge.h:203
Self * GetRnext()
const Self * GetLnext() const
const Self * GetRprev() const
Self * GetInvRot()
Definition: itkQuadEdge.h:332
Self * GetInvDnext()
Definition: itkQuadEdge.h:373
Self * GetRot()
Definition: itkQuadEdge.h:193
Self * GetRprev()
unsigned int GetOrder() const
Self * GetOnext()
Definition: itkQuadEdge.h:188
const Self * GetDprev() const
const Self * GetInvRot() const
Definition: itkQuadEdge.h:378
Self * GetInvRnext()
Definition: itkQuadEdge.h:368
const Self * GetInvLnext() const
Definition: itkQuadEdge.h:408
itkQEDefineIteratorMethodsMacro(Onext)
bool IsIsolated() const
Definition: itkQuadEdge.h:430
const Self * GetOprev() const
void SetRot(Self *rot)
Definition: itkQuadEdge.h:178
Self * GetDnext()
const Self * GetSym() const
Definition: itkQuadEdge.h:260
const Self * GetLprev() const
Self * GetInvLnext()
Definition: itkQuadEdge.h:363
bool IsEdgeInOnextRing(Self *testEdge) const
Self * GetDprev()
QuadEdge(const QuadEdge &)=default
QuadEdge & operator=(QuadEdge &&)=default
const Self * GetInvOnext() const
Definition: itkQuadEdge.h:403
QuadEdge & operator=(const QuadEdge &)=default
const Self * GetDnext() const
const Self * GetInvDnext() const
Definition: itkQuadEdge.h:418
Self * GetLnext()
const Self * GetInvRnext() const
Definition: itkQuadEdge.h:413
Self * GetLprev()
bool IsLnextGivenSizeCyclic(const int size) const
Self * GetInvOnext()
Definition: itkQuadEdge.h:358
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....