00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkQuadEdge_h
00019 #define __itkQuadEdge_h
00020
00021 #include "itkQuadEdgeMeshBaseIterator.h"
00022
00023 #include "itkMacro.h"
00024
00025
00026
00027
00028
00029 #define itkQEDebugMacro( x ) \
00030 { \
00031 OStringStream itkmsg; \
00032 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
00033 << " (" << this << "): " x \
00034 << "\n\n"; \
00035 OutputWindowDisplayDebugText( itkmsg.str( ).c_str( ) ); \
00036 }
00037 #define itkQEWarningMacro( x ) \
00038 { \
00039 OStringStream itkmsg; \
00040 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
00041 << " (" << this << "): " x \
00042 << "\n\n"; \
00043 OutputWindowDisplayWarningText( itkmsg.str( ).c_str( ) ); \
00044 }
00045
00046
00047
00056 #define itkQEAccessorsMacro( st, pt, dt ) \
00057 pt* GetOnext() \
00058 { \
00059 return( dynamic_cast< pt* >( this->st::GetOnext() ) ); \
00060 } \
00061 \
00062 dt* GetRot() \
00063 { \
00064 return( dynamic_cast< dt* >( this->st::GetRot() ) ); \
00065 } \
00066 \
00067 pt* GetSym() \
00068 { \
00069 return( dynamic_cast< pt* >( this->st::GetSym() ) ); \
00070 } \
00071 \
00072 pt* GetLnext() \
00073 { \
00074 return( dynamic_cast< pt* >( this->st::GetLnext() ) ); \
00075 } \
00076 \
00077 pt* GetRnext() \
00078 { \
00079 return( dynamic_cast< pt* >( this->st::GetRnext() ) ); \
00080 } \
00081 \
00082 pt* GetDnext() \
00083 { \
00084 return( dynamic_cast< pt* >( this->st::GetDnext() ) ); \
00085 } \
00086 \
00087 pt* GetOprev() \
00088 { \
00089 return( dynamic_cast< pt* >( this->st::GetOprev() ) ); \
00090 } \
00091 \
00092 pt* GetLprev() \
00093 { \
00094 return( dynamic_cast< pt* >( this->st::GetLprev() ) ); \
00095 } \
00096 \
00097 pt* GetRprev() \
00098 { \
00099 return( dynamic_cast< pt* >( this->st::GetRprev() ) ); \
00100 } \
00101 \
00102 pt* GetDprev() \
00103 { \
00104 return( dynamic_cast< pt* >( this->st::GetDprev() ) ); \
00105 } \
00106 \
00107 dt* GetInvRot() \
00108 { \
00109 return( dynamic_cast< dt* >( this->st::GetInvRot() ) ); \
00110 } \
00111 \
00112 pt* GetInvOnext() \
00113 { \
00114 return( dynamic_cast< pt* >( this->st::GetInvOnext() ) ); \
00115 } \
00116 \
00117 pt* GetInvLnext() \
00118 { \
00119 return( dynamic_cast< pt* >( this->st::GetInvLnext() ) ); \
00120 } \
00121 \
00122 pt* GetInvRnext() \
00123 { \
00124 return( dynamic_cast< pt* >( this->st::GetInvRnext() ) ); \
00125 } \
00126 \
00127 pt* GetInvDnext() \
00128 { \
00129 return( dynamic_cast< pt* >( this->st::GetInvDnext() ) ); \
00130 } \
00131 const pt* GetOnext() const \
00132 { \
00133 return( dynamic_cast< const pt* >( this->st::GetOnext() ) ); \
00134 } \
00135 \
00136 const dt* GetRot() const \
00137 { \
00138 return( dynamic_cast< const dt* >( this->st::GetRot() ) ); \
00139 } \
00140 \
00141 const pt* GetSym() const \
00142 { \
00143 return( dynamic_cast< const pt* >( this->st::GetSym() ) ); \
00144 } \
00145 \
00146 const pt* GetLnext() const \
00147 { \
00148 return( dynamic_cast< const pt* >( this->st::GetLnext() ) ); \
00149 } \
00150 \
00151 const pt* GetRnext() const \
00152 { \
00153 return( dynamic_cast< const pt* >( this->st::GetRnext() ) ); \
00154 } \
00155 \
00156 const pt* GetDnext() const \
00157 { \
00158 return( dynamic_cast< const pt* >( this->st::GetDnext() ) ); \
00159 } \
00160 \
00161 const pt* GetOprev() const \
00162 { \
00163 return( dynamic_cast< const pt* >( this->st::GetOprev() ) ); \
00164 } \
00165 \
00166 const pt* GetLprev() const \
00167 { \
00168 return( dynamic_cast< const pt* >( this->st::GetLprev() ) ); \
00169 } \
00170 \
00171 const pt* GetRprev() const \
00172 { \
00173 return( dynamic_cast< const pt* >( this->st::GetRprev() ) ); \
00174 } \
00175 \
00176 const pt* GetDprev() const \
00177 { \
00178 return( dynamic_cast< const pt* >( this->st::GetDprev() ) ); \
00179 } \
00180 \
00181 const dt* GetInvRot() const \
00182 { \
00183 return( dynamic_cast< const dt* >( this->st::GetInvRot() ) ); \
00184 } \
00185 \
00186 const pt* GetInvOnext() const \
00187 { \
00188 return( dynamic_cast< const pt* >( this->st::GetInvOnext() ) ); \
00189 } \
00190 \
00191 const pt* GetInvLnext() const \
00192 { \
00193 return( dynamic_cast< const pt* >( this->st::GetInvLnext() ) ); \
00194 } \
00195 \
00196 const pt* GetInvRnext() const \
00197 { \
00198 return( dynamic_cast< const pt* >( this->st::GetInvRnext() ) ); \
00199 } \
00200 \
00201 const pt* GetInvDnext() const \
00202 { \
00203 return( dynamic_cast< const pt* >( this->st::GetInvDnext() ) ); \
00204 }
00205
00206
00207 namespace itk
00208 {
00209
00223 class QuadEdge
00224 {
00225 public:
00227 typedef QuadEdge Self;
00228
00230 typedef QuadEdgeMeshIterator< Self > Iterator;
00231 typedef QuadEdgeMeshConstIterator< Self > ConstIterator;
00232
00234 inline itkQEDefineIteratorMethodsMacro( Onext );
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00248
00250 QuadEdge();
00251 virtual ~QuadEdge();
00253
00255 inline void SetOnext( Self* onext ) { this->m_Onext = onext; }
00256 inline void SetRot( Self* rot ) { this->m_Rot = rot; }
00258
00262 inline Self* GetOnext() {return this->m_Onext;}
00263 inline Self* GetRot() {return this->m_Rot;}
00264 inline const Self* GetOnext() const {return this->m_Onext;}
00265 inline const Self* GetRot() const {return this->m_Rot;}
00267
00285 inline void Splice( Self* b )
00286 {
00287 Self * aNext = this->GetOnext();
00288 Self * bNext = b->GetOnext();
00289 Self * alpha = aNext->GetRot();
00290 Self * beta = bNext->GetRot();
00291 Self * alphaNext = alpha->GetOnext();
00292 Self * betaNext = beta->GetOnext();
00294
00295 this->SetOnext( bNext );
00296 b->SetOnext( aNext );
00297 alpha->SetOnext( betaNext );
00298 beta->SetOnext( alphaNext );
00299 }
00300
00301
00302
00303
00306 inline Self* GetSym()
00307 {
00308 if(this->m_Rot)
00309 {
00310 return( this->m_Rot->m_Rot );
00311 }
00312 return( this->m_Rot );
00313 }
00314 inline const Self* GetSym() const
00315 {
00316 if( this->m_Rot)
00317 {
00318 return( this->m_Rot->m_Rot );
00319 }
00320 return( this->m_Rot );
00321 }
00323
00326 Self* GetLnext();
00327 const Self* GetLnext() const;
00329
00333 Self* GetRnext();
00334 const Self* GetRnext() const;
00336
00340 Self* GetDnext();
00341 const Self* GetDnext() const;
00343
00346 Self* GetOprev();
00347 const Self* GetOprev() const;
00349
00353 Self* GetLprev();
00354 const Self* GetLprev() const;
00356
00360 Self* GetRprev();
00361 const Self* GetRprev() const;
00363
00367 Self* GetDprev();
00368 const Self* GetDprev() const;
00370
00372 inline Self * GetInvRot()
00373 {
00374 #ifdef NDEBUG
00375 return( this->GetRot()->GetRot()->GetRot() );
00376 #else
00377 Self * p1 = this->GetRot();
00378 if( !p1 ) return NULL;
00379 Self * p2 = p1->GetRot();
00380 if( !p2 ) return NULL;
00381 Self * p3 = p2->GetRot();
00382 if( !p3 ) return NULL;
00383 return p3;
00384 #endif
00385 }
00386 inline Self * GetInvOnext() { return this->GetOprev(); }
00387 inline Self * GetInvLnext() { return this->GetLprev(); }
00388 inline Self * GetInvRnext() { return this->GetRprev(); }
00389 inline Self * GetInvDnext() { return this->GetDprev(); }
00390 inline const Self * GetInvRot() const
00391 {
00392 #ifdef NDEBUG
00393 return( this->GetRot()->GetRot()->GetRot() );
00394 #else
00395 const Self * p1 = this->GetRot();
00396 if( !p1 ) return NULL;
00397 const Self * p2 = p1->GetRot();
00398 if( !p2 ) return NULL;
00399 const Self * p3 = p2->GetRot();
00400 if( !p3 ) return NULL;
00401 return p3;
00402 #endif
00403 }
00404 inline const Self * GetInvOnext() const { return this->GetOprev(); }
00405 inline const Self * GetInvLnext() const { return this->GetLprev(); }
00406 inline const Self * GetInvRnext() const { return this->GetRprev(); }
00407 inline const Self * GetInvDnext() const { return this->GetDprev(); }
00409
00411 inline bool IsHalfEdge() const { return( ( m_Onext == this ) || ( m_Rot == NULL ) ); }
00412 inline bool IsIsolated() const { return( this == this->GetOnext() ); }
00413 bool IsEdgeInOnextRing( Self* testEdge ) const;
00414 bool IsLnextGivenSizeCyclic( const int size ) const;
00415 unsigned int GetOrder() const;
00417
00418 private:
00419 Self* m_Onext;
00420 Self* m_Rot;
00421 };
00422
00423 }
00424
00425 #endif
00426