Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkQuadEdge.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdge.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-09-08 20:00:56 $
00007   Version:   $Revision: 1.20 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkQuadEdge_h
00019 #define __itkQuadEdge_h
00020 
00021 #include "itkQuadEdgeMeshBaseIterator.h"
00022 
00023 #include "itkMacro.h"
00024 
00025 // Debugging macros for classes that do not derive from the itkObject.
00026 // FIXME: Maybe variations of these macros should be moved into
00027 // itkMacro.h
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   // itkQEDefineIteratorMethodsMacro( Sym );
00236   // itkQEDefineIteratorMethodsMacro( Lnext );
00237   // itkQEDefineIteratorMethodsMacro( Rnext );
00238   // itkQEDefineIteratorMethodsMacro( Dnext );
00239   // itkQEDefineIteratorMethodsMacro( Oprev );
00240   // itkQEDefineIteratorMethodsMacro( Lprev );
00241   // itkQEDefineIteratorMethodsMacro( Rprev );
00242   // itkQEDefineIteratorMethodsMacro( Dprev );
00243   // itkQEDefineIteratorMethodsMacro( InvOnext );
00244   // itkQEDefineIteratorMethodsMacro( InvLnext );
00245   // itkQEDefineIteratorMethodsMacro( InvRnext );
00246   // itkQEDefineIteratorMethodsMacro( InvDnext );
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 
00284 // TODO fix this ref
00285 //   * \sa \ref DoxySurgeryConnectivity
00286    inline void Splice( Self* b )
00287     {
00288     Self * aNext     = this->GetOnext();
00289     Self * bNext     = b->GetOnext();
00290     Self * alpha     = aNext->GetRot();
00291     Self * beta      = bNext->GetRot();
00292     Self * alphaNext = alpha->GetOnext();
00293     Self * betaNext  = beta->GetOnext();
00295 
00296     this->SetOnext( bNext );
00297     b->SetOnext( aNext );
00298     alpha->SetOnext( betaNext );
00299     beta->SetOnext( alphaNext );
00300     }
00301 
00302 
00303   //  Second order accessors.
00304 
00307   inline Self* GetSym() 
00308     { 
00309     if(this->m_Rot) 
00310       {
00311       return( this->m_Rot->m_Rot );
00312       }
00313     return( this->m_Rot );
00314     }
00315   inline const Self* GetSym() const
00316     {
00317     if( this->m_Rot) 
00318       {
00319       return( this->m_Rot->m_Rot );
00320       }
00321     return( this->m_Rot );
00322     }
00324 
00327   Self* GetLnext(); 
00328   const Self* GetLnext() const;
00330 
00334   Self* GetRnext();
00335   const Self* GetRnext() const;
00337 
00341   Self* GetDnext();
00342   const Self* GetDnext() const;
00344 
00347   Self* GetOprev();
00348   const Self* GetOprev() const;
00350 
00354   Self* GetLprev();
00355   const Self* GetLprev() const;
00357 
00361   Self* GetRprev();
00362   const Self* GetRprev() const;
00364 
00368   Self* GetDprev();
00369   const Self* GetDprev() const;
00371 
00373   inline Self * GetInvRot() 
00374     {
00375 #ifdef NDEBUG
00376     return( this->GetRot()->GetRot()->GetRot() );
00377 #else
00378     Self * p1 = this->GetRot();
00379     if( !p1 ) return NULL;
00380     Self * p2 = p1->GetRot();
00381     if( !p2 ) return NULL;
00382     Self * p3 = p2->GetRot();
00383     if( !p3 ) return NULL;
00384     return p3;
00385 #endif
00386     }
00387   inline Self * GetInvOnext() { return this->GetOprev(); }
00388   inline Self * GetInvLnext() { return this->GetLprev(); }
00389   inline Self * GetInvRnext() { return this->GetRprev(); }
00390   inline Self * GetInvDnext() { return this->GetDprev(); }
00391   inline const Self * GetInvRot() const 
00392     {
00393 #ifdef NDEBUG
00394     return( this->GetRot()->GetRot()->GetRot() );
00395 #else
00396     const Self * p1 = this->GetRot();
00397     if( !p1 ) return NULL;
00398     const Self * p2 = p1->GetRot();
00399     if( !p2 ) return NULL;
00400     const Self * p3 = p2->GetRot();
00401     if( !p3 ) return NULL;
00402     return p3;
00403 #endif
00404     }
00405   inline const Self * GetInvOnext() const { return this->GetOprev(); }
00406   inline const Self * GetInvLnext() const { return this->GetLprev(); }
00407   inline const Self * GetInvRnext() const { return this->GetRprev(); }
00408   inline const Self * GetInvDnext() const { return this->GetDprev(); }
00410 
00412   inline bool IsHalfEdge() const { return( ( m_Onext == this ) || ( m_Rot == NULL ) ); }
00413   inline bool IsIsolated() const { return( this == this->GetOnext() ); }
00414   bool IsEdgeInOnextRing( Self* testEdge ) const;
00415   bool IsLnextGivenSizeCyclic( const int size ) const;
00416   unsigned int GetOrder() const;
00418 
00419 private: 
00420   Self* m_Onext; 
00421   Self* m_Rot;   
00422 };
00423 
00424 } 
00425 
00426 #endif 
00427 

Generated at Fri Apr 16 19:20:09 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000