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: 2010-06-14 15:02:34 $
00007   Version:   $Revision: 1.10 $
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 #ifndef __itkQuadEdgeMeshFrontIterator_h
00018 #define __itkQuadEdgeMeshFrontIterator_h
00019 
00020 // -------------------------------------------------------------------------
00021 #define itkQEDefineFrontIteratorMethodsMacro( MeshTypeArg )                  \
00022     /* Dual definition placed before others because of .NET that cannot */   \
00023     /* cope with definition of FrontIterator (that further hides the    */   \
00024     /* defintion of the template).                                      */   \
00025     typedef typename MeshTypeArg::QEDual QEDualType;                         \
00026     typedef typename MeshTypeArg::QEPrimal QEPrimalType;                     \
00027     typedef QuadEdgeMeshFrontIterator< MeshTypeArg,                          \
00028                                              QEDualType > FrontDualIterator; \
00029     typedef QuadEdgeMeshConstFrontIterator< MeshTypeArg,                     \
00030                                                   QEDualType >               \
00031                                                      ConstFrontDualIterator; \
00032     typedef QuadEdgeMeshFrontIterator< MeshTypeArg,                          \
00033                                              QEPrimalType >   FrontIterator; \
00034     typedef QuadEdgeMeshConstFrontIterator< MeshTypeArg,                     \
00035                                                   QEPrimalType >             \
00036                                                          ConstFrontIterator; \
00037                                                                              \
00038     virtual FrontIterator BeginFront( QEPrimalType* seed =(QEPrimalType*)0 ) \
00039     { return( FrontIterator( this, true, seed ) ); }                         \
00040                                                                              \
00041     virtual ConstFrontIterator BeginFront( QEPrimalType* seed ) const        \
00042     { return( ConstFrontIterator( this, true, seed ) ); }                    \
00043                                                                              \
00044     virtual FrontIterator EndFront( )                                        \
00045     { return( FrontIterator( this, false ) ); }                              \
00046                                                                              \
00047     virtual ConstFrontIterator EndFront( ) const                             \
00048     { return( ConstFrontIterator( this, false ) ); }                         \
00049                                                                              \
00050     virtual FrontDualIterator BeginDualFront( QEDualType* seed =(QEDualType*) 0 )    \
00051     { return( FrontDualIterator( this, true, seed ) ); }                     \
00052                                                                              \
00053     virtual ConstFrontDualIterator BeginDualFront( QEDualType* seed ) const      \
00054     { return( ConstFrontDualIterator( this, true, seed ) ); }                \
00055                                                                              \
00056     virtual FrontDualIterator EndDualFront( )                                \
00057     { return( FrontDualIterator( this, false ) ); }                          \
00058                                                                              \
00059     virtual ConstFrontDualIterator EndDualFront( ) const                     \
00060     { return( ConstFrontDualIterator( this, false ) ); }
00061 
00062 namespace itk
00063 {
00064 
00077 template< typename TMesh, typename TQE >
00078 class QuadEdgeMeshFrontBaseIterator
00079 {
00080 public:
00081   // Hierarchy typedefs & values.
00082   typedef QuadEdgeMeshFrontBaseIterator Self;
00083 
00084   // Template types
00085   typedef TMesh  MeshType;
00086   typedef TQE    QEType;
00087 
00088 protected:
00089   // Mesh types
00090   typedef typename MeshType::CoordRepType    CoordRepType;
00091   // QE types
00092   typedef typename QEType::OriginRefType     QEOriginType;
00093 
00102   class FrontAtom
00103     {
00104     public:
00105     FrontAtom( QEType* e = (QEType*)0, const CoordRepType c = 0 )
00106       : m_Edge( e ), m_Cost( c )
00107       { }
00108       virtual ~FrontAtom( ) { }
00109       FrontAtom& operator=( const FrontAtom& r )
00110       { m_Edge = r.m_Edge; m_Cost = r.m_Cost; return *this; }
00111       bool operator==( const FrontAtom& r ) const
00112       { return( m_Edge == r.m_Edge ); }
00113       bool operator!=( const FrontAtom& r ) const
00114       { return( m_Edge != r.m_Edge ); }
00115       bool operator<( const FrontAtom& r ) const
00116       { return( m_Cost < r.m_Cost ); }
00118 
00119     public:
00120       QEType*      m_Edge;
00121       CoordRepType m_Cost;
00122   };
00123 
00127   typedef std::list< FrontAtom >       FrontType;
00128   typedef typename FrontType::iterator FrontTypeIterator;
00129   typedef FrontType*                   FrontTypePointer;
00130 
00134   typedef MapContainer< QEOriginType, bool >       IsVisitedContainerType;
00135   typedef typename IsVisitedContainerType::Pointer IsVisitedPointerType;
00136 
00137 public:
00139   QuadEdgeMeshFrontBaseIterator( MeshType* mesh  = (MeshType*)0,
00140                                  bool      start = true,
00141                                  QEType*   seed  = (QEType*)0 );
00142   virtual ~QuadEdgeMeshFrontBaseIterator( );
00144 
00145   Self& operator=( const Self& r )
00146     {
00147     m_Mesh  = r.m_Mesh;
00148     m_Start = r.m_Start;
00149     m_Seed  = r.m_Seed;
00150     m_Front = r.m_Front;
00151     m_IsPointVisited = r.m_IsPointVisited;
00152     m_CurrentEdge = r.m_CurrentEdge;
00153     return( *this );
00154     }
00155 
00156   // Iteration methods.
00157   bool operator==( Self & r )
00158     {
00159     return( m_Start == r.m_Start );
00160     }
00161 
00162   bool operator==( const Self & r ) const
00163     {
00164     return( m_Start == r.m_Start );
00165     }
00166 
00167   bool operator!=( Self & r )
00168     {
00169     return( !( this->operator==( r ) ) );
00170     }
00171 
00172   bool operator!=( const Self & r ) const
00173     {
00174     return( !( this->operator==( r ) ) );
00175     }
00176 
00177   Self & operator++( );
00178 
00179   Self & operator++( int ) { return( this->operator++( ) ); }
00180   
00181   MeshType* GetMesh() const { return this->m_Mesh; }
00182 
00183 protected:
00187   QEType* FindDefaultSeed( );
00188 
00192   virtual CoordRepType GetCost( QEType* edge ){ (void)edge; return( 1 ); }
00193 
00194 protected:
00196   MeshType* m_Mesh;
00197 
00199   QEType* m_Seed;
00200 
00202   bool m_Start;
00203 
00205   FrontTypePointer m_Front;
00206 
00208   IsVisitedPointerType m_IsPointVisited;
00209 
00211   QEType* m_CurrentEdge;
00212 };
00213 
00219 template< typename TMesh, typename TQE >
00220 class QuadEdgeMeshFrontIterator
00221   : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE  >
00222 {
00223 public:
00224 
00226   typedef QuadEdgeMeshFrontIterator                   Self;
00227   typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass;
00228   typedef typename Superclass::MeshType               MeshType;
00229   typedef typename Superclass::QEType                 QEType;
00230 
00231 public:
00233   QuadEdgeMeshFrontIterator( MeshType* mesh = (MeshType*)0,
00234                              bool      start = true,
00235                              QEType*   seed  = (QEType*)0 )
00236     : Superclass( mesh, start, seed ) { }
00237   virtual ~QuadEdgeMeshFrontIterator( ) { }
00238   QEType* Value( ) { return( this->m_CurrentEdge ); }
00239 };
00241 
00247 template< class TMesh, class TQE = typename TMesh::QEType >
00248 class QuadEdgeMeshConstFrontIterator
00249   : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
00250 {
00251 public:
00252 
00254   typedef QuadEdgeMeshConstFrontIterator                Self;
00255   typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE >   Superclass;
00256   typedef typename Superclass::QEType                   QEType;
00257   typedef typename Superclass::MeshType                 MeshType;
00258   typedef QuadEdgeMeshFrontIterator< MeshType, QEType > NoConstType;
00259 
00260 public:
00262   QuadEdgeMeshConstFrontIterator( const MeshType* mesh = (MeshType*)0,
00263                                   bool     start = true,
00264                                   QEType*  seed  = (QEType*)0 )
00265     {
00266     (void)mesh;
00267     (void)start;
00268     (void)seed;
00269     }
00270 
00272   virtual ~QuadEdgeMeshConstFrontIterator( ) { }
00273   Self& operator=( const NoConstType& r )
00274     {
00275     this->m_Mesh  = r.GetMesh( );
00276     return( *this );
00277     }
00278   const QEType* Value( ) const { return( this->m_CurrentEdge ); }
00279 };
00281 
00282 } 
00283 
00284 #include "itkQuadEdgeMeshFrontIterator.txx"
00285 
00286 #endif 
00287 

Generated at Mon Jul 12 2010 19:31:49 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000