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

itkQuadEdgeMeshFrontIterator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdgeMeshFrontIterator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/06/27 19:06:04 $
00007   Version:   $Revision: 1.4 $
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 // This code is an implementation of the well known quad edge (QE) data
00019 // structure in the ITK library. Although the original QE can handle non
00020 // orientable 2-manifolds and its dual and its mirror, this implementation
00021 // is specifically dedicated to handle orientable 2-manifolds along with
00022 // their dual.
00023 //
00024 // Any comment, criticism and/or donation is welcome.
00025 //
00026 // Please contact any member of the team:
00027 //
00028 // - The frog master (Eric Boix)       eboix@ens-lyon.fr
00029 // - The duck master (Alex Gouaillard) alexandre.gouaillard@sun.com
00030 // - The cow  master (Leonardo Florez) florez@creatis.insa-lyon.fr
00031 // -------------------------------------------------------------------------
00032 
00033 #ifndef __itkQuadEdgeMeshFrontIterator_h
00034 #define __itkQuadEdgeMeshFrontIterator_h
00035 
00036 // -------------------------------------------------------------------------
00037 #define itkQEDefineFrontIteratorMethodsMacro( MeshTypeArg )                  \
00038     /* Dual definition placed before others because of .NET that cannot */   \
00039     /* cope with definition of FrontIterator (that further hides the    */   \
00040     /* defintion of the template).                                      */   \
00041     typedef typename MeshTypeArg::QEDual QEDualType;                         \
00042     typedef typename MeshTypeArg::QEPrimal QEPrimalType;                     \
00043     typedef QuadEdgeMeshFrontIterator< MeshTypeArg,                          \
00044                                              QEDualType > FrontDualIterator; \
00045     typedef QuadEdgeMeshConstFrontIterator< MeshTypeArg,                     \
00046                                                   QEDualType >               \
00047                                                      ConstFrontDualIterator; \
00048     typedef QuadEdgeMeshFrontIterator< MeshTypeArg,                          \
00049                                              QEPrimalType >   FrontIterator; \
00050     typedef QuadEdgeMeshConstFrontIterator< MeshTypeArg,                     \
00051                                                   QEPrimalType >             \
00052                                                          ConstFrontIterator; \
00053                                                                              \
00054     virtual FrontIterator BeginFront( QEPrimalType* seed =(QEPrimalType*)0 ) \
00055     { return( FrontIterator( this, true, seed ) ); }                         \
00056                                                                              \
00057     virtual ConstFrontIterator BeginFront( QEPrimalType* seed ) const        \
00058     { return( ConstFrontIterator( this, true, seed ) ); }                    \
00059                                                                              \
00060     virtual FrontIterator EndFront( )                                        \
00061     { return( FrontIterator( this, false ) ); }                              \
00062                                                                              \
00063     virtual ConstFrontIterator EndFront( ) const                             \
00064     { return( ConstFrontIterator( this, false ) ); }                         \
00065                                                                              \
00066     virtual FrontDualIterator BeginDualFront( QEDualType* seed =(QEDualType*) 0 )    \
00067     { return( FrontDualIterator( this, true, seed ) ); }                     \
00068                                                                              \
00069     virtual ConstFrontDualIterator BeginDualFront( QEDualType* seed ) const      \
00070     { return( ConstFrontDualIterator( this, true, seed ) ); }                \
00071                                                                              \
00072     virtual FrontDualIterator EndDualFront( )                                \
00073     { return( FrontDualIterator( this, false ) ); }                          \
00074                                                                              \
00075     virtual ConstFrontDualIterator EndDualFront( ) const                     \
00076     { return( ConstFrontDualIterator( this, false ) ); }
00077 
00078 namespace itk
00079 {
00080 
00093 template< typename TMesh, typename TQE >
00094 class QuadEdgeMeshFrontBaseIterator
00095 {
00096 public:
00097   // Hierarchy typedefs & values.
00098   typedef QuadEdgeMeshFrontBaseIterator Self;
00099 
00100   // Template types
00101   typedef TMesh  MeshType;
00102   typedef TQE    QEType;
00103 
00104 protected:
00105   // Mesh types
00106   typedef typename MeshType::CoordRepType    CoordRepType;
00107   // QE types
00108   typedef typename QEType::OriginRefType     QEOriginType;
00109 
00118   class FrontAtom
00119     {
00120     public:
00121     FrontAtom( QEType* e = (QEType*)0, const CoordRepType c = 0 )
00122       : m_Edge( e ), m_Cost( c )
00123       { }
00124       virtual ~FrontAtom( ) { }
00125       FrontAtom& operator=( const FrontAtom& r )
00126       { m_Edge = r.m_Edge; m_Cost = r.m_Cost; }
00127       bool operator==( const FrontAtom& r ) const
00128       { return( m_Edge == r.m_Edge ); }
00129       bool operator!=( const FrontAtom& r ) const
00130       { return( m_Edge != r.m_Edge ); }
00131       bool operator<( const FrontAtom& r ) const
00132       { return( m_Cost < r.m_Cost ); }
00134 
00135     public:
00136       QEType*      m_Edge;
00137       CoordRepType m_Cost;
00138   };
00139 
00143   typedef std::list< FrontAtom >       FrontType;
00144   typedef typename FrontType::iterator FrontTypeIterator;
00145   typedef FrontType*                   FrontTypePointer;
00146 
00150   typedef MapContainer< QEOriginType, bool >       IsVisitedContainerType;
00151   typedef typename IsVisitedContainerType::Pointer IsVisitedPointerType;
00152 
00153 public:
00155   QuadEdgeMeshFrontBaseIterator( MeshType* mesh  = (MeshType*)0,
00156                                  bool      start = true,
00157                                  QEType*   seed  = (QEType*)0 );
00158   virtual ~QuadEdgeMeshFrontBaseIterator( ) { }
00159 
00160   Self& operator=( const Self& r )
00161     {
00162     m_Mesh  = r.m_Mesh;
00163     m_Start = r.m_Start;
00164     m_Seed  = r.m_Seed;
00165     m_Front = r.m_Front;
00166     m_IsPointVisited = r.m_IsPointVisited;
00167     m_CurrentEdge = r.m_CurrentEdge;
00168     return( *this );
00169     }
00170 
00171   // Iteration methods.
00172   bool operator==( Self & r )
00173     {
00174     return( m_Start == r.m_Start );
00175     }
00176 
00177   bool operator==( const Self & r ) const
00178     {
00179     return( m_Start == r.m_Start );
00180     }
00181 
00182   bool operator!=( Self & r )
00183     {
00184     return( !( this->operator==( r ) ) );
00185     }
00186 
00187   bool operator!=( const Self & r ) const
00188     {
00189     return( !( this->operator==( r ) ) );
00190     }
00191 
00192   Self & operator++( );
00193 
00194   Self & operator++( int ) { return( this->operator++( ) ); }
00195 
00196 protected:
00200   QEType* FindDefaultSeed( );
00201 
00205   virtual CoordRepType GetCost( QEType* edge ){ (void)edge; return( 1 ); }
00206 
00207 protected:
00209   MeshType* m_Mesh;
00211   QEType* m_Seed;
00213   bool m_Start;
00215   FrontTypePointer m_Front;
00217   IsVisitedPointerType m_IsPointVisited;
00219   QEType* m_CurrentEdge;
00220 };
00221 
00227 template< typename TMesh, typename TQE >
00228 class QuadEdgeMeshFrontIterator
00229   : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE  >
00230 {
00231 public:
00232 
00234   typedef QuadEdgeMeshFrontIterator                   Self;
00235   typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass;
00236   typedef typename Superclass::MeshType               MeshType;
00237   typedef typename Superclass::QEType                 QEType;
00238 
00239 public:
00241   QuadEdgeMeshFrontIterator( MeshType* mesh = (MeshType*)0,
00242                              bool      start = true,
00243                              QEType*   seed  = (QEType*)0 )
00244     : Superclass( mesh, start, seed ) { }
00245   virtual ~QuadEdgeMeshFrontIterator( ) { }
00246   QEType* Value( ) { return( this->m_CurrentEdge ); }
00247 };
00249 
00255 template< class TMesh, class TQE = typename TMesh::QEType >
00256 class QuadEdgeMeshConstFrontIterator
00257   : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
00258 {
00259 public:
00260 
00262   typedef QuadEdgeMeshConstFrontIterator                Self;
00263   typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE >   Superclass;
00264   typedef typename Superclass::QEType                   QEType;
00265   typedef typename Superclass::MeshType                 MeshType;
00266   typedef QuadEdgeMeshFrontIterator< MeshType, QEType > NoConstType;
00267 
00268 public:
00270   QuadEdgeMeshConstFrontIterator( const MeshType* mesh = (MeshType*)0,
00271                                   bool     start = true,
00272                                   QEType*  seed  = (QEType*)0 )
00273     {
00274     (void)mesh;
00275     (void)start;
00276     (void)seed;
00277     }
00278 
00280   virtual ~QuadEdgeMeshConstFrontIterator( ) { }
00281   Self& operator=( const NoConstType& r )
00282     {
00283     this->m_Mesh  = r.GetMesh( );
00284     return( *this );
00285     }
00286   const QEType* Value( ) const { return( this->m_CurrentEdge ); }
00287 };
00289 
00290 } 
00291 
00292 #include "itkQuadEdgeMeshFrontIterator.txx"
00293 
00294 #endif 
00295 

Generated at Wed Nov 5 23:42:00 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000