itkQuadEdgeMeshFrontIterator.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkQuadEdgeMeshFrontIterator_h
00018 #define __itkQuadEdgeMeshFrontIterator_h
00019
00020
00021 #define itkQEDefineFrontIteratorMethodsMacro( MeshTypeArg ) \
00022 \
00023 \
00024 \
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
00082 typedef QuadEdgeMeshFrontBaseIterator Self;
00083
00084
00085 typedef TMesh MeshType;
00086 typedef TQE QEType;
00087
00088 protected:
00089
00090 typedef typename MeshType::CoordRepType CoordRepType;
00091
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
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;
00198 QEType* m_Seed;
00200 bool m_Start;
00202 FrontTypePointer m_Front;
00204 IsVisitedPointerType m_IsPointVisited;
00206 QEType* m_CurrentEdge;
00207 };
00208
00214 template< typename TMesh, typename TQE >
00215 class QuadEdgeMeshFrontIterator
00216 : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
00217 {
00218 public:
00219
00221 typedef QuadEdgeMeshFrontIterator Self;
00222 typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass;
00223 typedef typename Superclass::MeshType MeshType;
00224 typedef typename Superclass::QEType QEType;
00225
00226 public:
00228 QuadEdgeMeshFrontIterator( MeshType* mesh = (MeshType*)0,
00229 bool start = true,
00230 QEType* seed = (QEType*)0 )
00231 : Superclass( mesh, start, seed ) { }
00232 virtual ~QuadEdgeMeshFrontIterator( ) { }
00233 QEType* Value( ) { return( this->m_CurrentEdge ); }
00234 };
00236
00242 template< class TMesh, class TQE = typename TMesh::QEType >
00243 class QuadEdgeMeshConstFrontIterator
00244 : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
00245 {
00246 public:
00247
00249 typedef QuadEdgeMeshConstFrontIterator Self;
00250 typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass;
00251 typedef typename Superclass::QEType QEType;
00252 typedef typename Superclass::MeshType MeshType;
00253 typedef QuadEdgeMeshFrontIterator< MeshType, QEType > NoConstType;
00254
00255 public:
00257 QuadEdgeMeshConstFrontIterator( const MeshType* mesh = (MeshType*)0,
00258 bool start = true,
00259 QEType* seed = (QEType*)0 )
00260 {
00261 (void)mesh;
00262 (void)start;
00263 (void)seed;
00264 }
00265
00267 virtual ~QuadEdgeMeshConstFrontIterator( ) { }
00268 Self& operator=( const NoConstType& r )
00269 {
00270 this->m_Mesh = r.GetMesh( );
00271 return( *this );
00272 }
00273 const QEType* Value( ) const { return( this->m_CurrentEdge ); }
00274 };
00276
00277 }
00278
00279 #include "itkQuadEdgeMeshFrontIterator.txx"
00280
00281 #endif
00282