ITK  6.0.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())); } \
114 \
115 ITK_MACROEND_NOOP_STATEMENT
118namespace itk
119{
136class ITKQuadEdgeMesh_EXPORT QuadEdge
137{
138public:
140 using Self = QuadEdge;
141
145
148 // itkQEDefineIteratorMethodsMacro( Sym );
149 // itkQEDefineIteratorMethodsMacro( Lnext );
150 // itkQEDefineIteratorMethodsMacro( Rnext );
151 // itkQEDefineIteratorMethodsMacro( Dnext );
152 // itkQEDefineIteratorMethodsMacro( Oprev );
153 // itkQEDefineIteratorMethodsMacro( Lprev );
154 // itkQEDefineIteratorMethodsMacro( Rprev );
155 // itkQEDefineIteratorMethodsMacro( Dprev );
156 // itkQEDefineIteratorMethodsMacro( InvOnext );
157 // itkQEDefineIteratorMethodsMacro( InvLnext );
158 // itkQEDefineIteratorMethodsMacro( InvRnext );
159 // itkQEDefineIteratorMethodsMacro( InvDnext );
164 QuadEdge(const QuadEdge &) = default;
165 QuadEdge(QuadEdge &&) = default;
166 QuadEdge &
167 operator=(const QuadEdge &) = default;
168 QuadEdge &
169 operator=(QuadEdge &&) = default;
170 virtual ~QuadEdge();
174 inline void
175 SetOnext(Self * onext)
176 {
177 this->m_Onext = onext;
178 }
179 inline void
181 {
182 this->m_Rot = rot;
183 }
189 inline Self *
191 {
192 return this->m_Onext;
193 }
194 inline Self *
196 {
197 return this->m_Rot;
198 }
199 inline const Self *
200 GetOnext() const
201 {
202 return this->m_Onext;
203 }
204 inline const Self *
205 GetRot() const
206 {
207 return this->m_Rot;
208 }
227 // TODO fix this ref
228 // * \sa \ref DoxySurgeryConnectivity
229 inline void
231 {
232 Self * aNext = this->GetOnext();
233 Self * bNext = b->GetOnext();
234 Self * alpha = aNext->GetRot();
235 Self * beta = bNext->GetRot();
236 Self * alphaNext = alpha->GetOnext();
237 Self * betaNext = beta->GetOnext();
240 this->SetOnext(bNext);
241 b->SetOnext(aNext);
242 alpha->SetOnext(betaNext);
243 beta->SetOnext(alphaNext);
244 }
245
246 // Second order accessors.
247
250 inline Self *
252 {
253 if (this->m_Rot)
254 {
255 return (this->m_Rot->m_Rot);
256 }
257 return (this->m_Rot);
258 }
261 inline const Self *
262 GetSym() const
263 {
264 if (this->m_Rot)
265 {
266 return (this->m_Rot->m_Rot);
267 }
268 return (this->m_Rot);
269 }
270
273 Self *
275
276 const Self *
277 GetLnext() const;
278
282 Self *
284
285 const Self *
286 GetRnext() const;
287
291 Self *
293
294 const Self *
295 GetDnext() const;
296
299 Self *
301
302 const Self *
303 GetOprev() const;
304
308 Self *
310
311 const Self *
312 GetLprev() const;
313
317 Self *
319
320 const Self *
321 GetRprev() const;
322
326 Self *
328
329 const Self *
330 GetDprev() const;
331
333 inline Self *
335 {
336#ifdef NDEBUG
337 return (this->GetRot()->GetRot()->GetRot());
338#else
339 Self * p1 = this->GetRot();
340 if (!p1)
341 {
342 return nullptr;
343 }
344 Self * p2 = p1->GetRot();
345 if (!p2)
346 {
347 return nullptr;
348 }
349 Self * p3 = p2->GetRot();
350 if (!p3)
351 {
352 return nullptr;
353 }
354 return p3;
355#endif
356 }
359 inline Self *
361 {
362 return this->GetOprev();
363 }
364 inline Self *
366 {
367 return this->GetLprev();
368 }
369 inline Self *
371 {
372 return this->GetRprev();
373 }
374 inline Self *
376 {
377 return this->GetDprev();
378 }
379 inline const Self *
380 GetInvRot() const
381 {
382#ifdef NDEBUG
383 return (this->GetRot()->GetRot()->GetRot());
384#else
385 const Self * p1 = this->GetRot();
386 if (!p1)
387 {
388 return nullptr;
389 }
390 const Self * p2 = p1->GetRot();
391 if (!p2)
392 {
393 return nullptr;
394 }
395 const Self * p3 = p2->GetRot();
396 if (!p3)
397 {
398 return nullptr;
399 }
400 return p3;
401#endif
402 }
403
404 inline const Self *
406 {
407 return this->GetOprev();
408 }
409 inline const Self *
411 {
412 return this->GetLprev();
413 }
414 inline const Self *
416 {
417 return this->GetRprev();
418 }
419 inline const Self *
421 {
422 return this->GetDprev();
423 }
424
426 inline bool
428 {
429 return ((m_Onext == this) || (m_Rot == nullptr));
430 }
431 inline bool
433 {
434 return (this == this->GetOnext());
435 }
436 bool
437 IsEdgeInOnextRing(Self * testEdge) const;
440 bool
441 IsLnextGivenSizeCyclic(const int size) const;
442
443 unsigned int
444 GetOrder() const;
445
446private:
450};
451} // namespace itk
452
453#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:137
const Self * GetOnext() const
Definition: itkQuadEdge.h:200
const Self * GetRnext() const
bool IsHalfEdge() const
Definition: itkQuadEdge.h:427
Self * GetOprev()
Self * GetSym()
Definition: itkQuadEdge.h:251
QuadEdge(QuadEdge &&)=default
void SetOnext(Self *onext)
Definition: itkQuadEdge.h:175
virtual ~QuadEdge()
void Splice(Self *b)
Basic quad-edge topological method.
Definition: itkQuadEdge.h:230
const Self * GetRot() const
Definition: itkQuadEdge.h:205
Self * GetRnext()
const Self * GetLnext() const
const Self * GetRprev() const
Self * GetInvRot()
Definition: itkQuadEdge.h:334
Self * GetInvDnext()
Definition: itkQuadEdge.h:375
Self * GetRot()
Definition: itkQuadEdge.h:195
Self * GetRprev()
unsigned int GetOrder() const
Self * GetOnext()
Definition: itkQuadEdge.h:190
const Self * GetDprev() const
const Self * GetInvRot() const
Definition: itkQuadEdge.h:380
Self * GetInvRnext()
Definition: itkQuadEdge.h:370
const Self * GetInvLnext() const
Definition: itkQuadEdge.h:410
itkQEDefineIteratorMethodsMacro(Onext)
bool IsIsolated() const
Definition: itkQuadEdge.h:432
const Self * GetOprev() const
void SetRot(Self *rot)
Definition: itkQuadEdge.h:180
Self * GetDnext()
const Self * GetSym() const
Definition: itkQuadEdge.h:262
const Self * GetLprev() const
Self * GetInvLnext()
Definition: itkQuadEdge.h:365
bool IsEdgeInOnextRing(Self *testEdge) const
Self * GetDprev()
QuadEdge(const QuadEdge &)=default
QuadEdge & operator=(QuadEdge &&)=default
const Self * GetInvOnext() const
Definition: itkQuadEdge.h:405
QuadEdge & operator=(const QuadEdge &)=default
const Self * GetDnext() const
const Self * GetInvDnext() const
Definition: itkQuadEdge.h:420
Self * GetLnext()
const Self * GetInvRnext() const
Definition: itkQuadEdge.h:415
Self * GetLprev()
bool IsLnextGivenSizeCyclic(const int size) const
Self * GetInvOnext()
Definition: itkQuadEdge.h:360
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....