00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __itkQuadEdgeMeshFrontIterator_h
00034 #define __itkQuadEdgeMeshFrontIterator_h
00035
00036
00037 #define itkQEDefineFrontIteratorMethodsMacro( MeshTypeArg ) \
00038 \
00039 \
00040 \
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
00086 template< typename TMesh, typename TQE >
00087 class QuadEdgeMeshFrontBaseIterator
00088 {
00089 public:
00090
00091 typedef QuadEdgeMeshFrontBaseIterator Self;
00092
00093
00094 typedef TMesh MeshType;
00095 typedef TQE QEType;
00096
00097 protected:
00098
00099 typedef typename MeshType::CoordRepType CoordRepType;
00100
00101 typedef typename QEType::OriginRefType QEOriginType;
00102
00111 class FrontAtom
00112 {
00113 public:
00114 FrontAtom( QEType* e = (QEType*)0, const CoordRepType c = 0 )
00115 : m_Edge( e ), m_Cost( c )
00116 { }
00117 virtual ~FrontAtom( ) { }
00118 FrontAtom& operator=( const FrontAtom& r )
00119 { m_Edge = r.m_Edge; m_Cost = r.m_Cost; }
00120 bool operator==( const FrontAtom& r ) const
00121 { return( m_Edge == r.m_Edge ); }
00122 bool operator!=( const FrontAtom& r ) const
00123 { return( m_Edge != r.m_Edge ); }
00124 bool operator<( const FrontAtom& r ) const
00125 { return( m_Cost < r.m_Cost ); }
00127
00128 public:
00129 QEType* m_Edge;
00130 CoordRepType m_Cost;
00131 };
00132
00136 typedef std::list< FrontAtom > FrontType;
00137 typedef typename FrontType::iterator FrontTypeIterator;
00138 typedef FrontType* FrontTypePointer;
00139
00143 typedef MapContainer< QEOriginType, bool > IsVisitedContainerType;
00144 typedef typename IsVisitedContainerType::Pointer IsVisitedPointerType;
00145
00146 public:
00148 QuadEdgeMeshFrontBaseIterator( MeshType* mesh = (MeshType*)0,
00149 bool start = true,
00150 QEType* seed = (QEType*)0 );
00151 virtual ~QuadEdgeMeshFrontBaseIterator( ) { }
00152
00153 Self& operator=( const Self& r )
00154 {
00155 m_Mesh = r.m_Mesh;
00156 m_Start = r.m_Start;
00157 m_Seed = r.m_Seed;
00158 m_Front = r.m_Front;
00159 m_IsPointVisited = r.m_IsPointVisited;
00160 m_CurrentEdge = r.m_CurrentEdge;
00161 return( *this );
00162 }
00163
00164
00165 bool operator==( Self & r )
00166 {
00167 return( m_Start == r.m_Start );
00168 }
00169
00170 bool operator==( const Self & r ) const
00171 {
00172 return( m_Start == r.m_Start );
00173 }
00174
00175 bool operator!=( Self & r )
00176 {
00177 return( !( this->operator==( r ) ) );
00178 }
00179
00180 bool operator!=( const Self & r ) const
00181 {
00182 return( !( this->operator==( r ) ) );
00183 }
00184
00185 Self & operator++( );
00186
00187 Self & operator++( int ) { return( this->operator++( ) ); }
00188
00189 protected:
00193 QEType* FindDefaultSeed( );
00194
00198 virtual CoordRepType GetCost( QEType* edge ){ (void)edge; return( 1 ); }
00199
00200 protected:
00202 MeshType* m_Mesh;
00204 QEType* m_Seed;
00206 bool m_Start;
00208 FrontTypePointer m_Front;
00210 IsVisitedPointerType m_IsPointVisited;
00212 QEType* m_CurrentEdge;
00213 };
00214
00220 template< typename TMesh, typename TQE >
00221 class QuadEdgeMeshFrontIterator
00222 : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
00223 {
00224 public:
00225
00227 typedef QuadEdgeMeshFrontIterator Self;
00228 typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass;
00229 typedef typename Superclass::MeshType MeshType;
00230 typedef typename Superclass::QEType QEType;
00231
00232 public:
00234 QuadEdgeMeshFrontIterator( MeshType* mesh = (MeshType*)0,
00235 bool start = true,
00236 QEType* seed = (QEType*)0 )
00237 : Superclass( mesh, start, seed ) { }
00238 virtual ~QuadEdgeMeshFrontIterator( ) { }
00239 QEType* Value( ) { return( this->m_CurrentEdge ); }
00240 };
00242
00248 template< class TMesh, class TQE = typename TMesh::QEType >
00249 class QuadEdgeMeshConstFrontIterator
00250 : public QuadEdgeMeshFrontBaseIterator< TMesh, TQE >
00251 {
00252 public:
00253
00255 typedef QuadEdgeMeshConstFrontIterator Self;
00256 typedef QuadEdgeMeshFrontBaseIterator< TMesh, TQE > Superclass;
00257 typedef typename Superclass::QEType QEType;
00258 typedef typename Superclass::MeshType MeshType;
00259 typedef QuadEdgeMeshFrontIterator< MeshType, QEType > NoConstType;
00260
00261 public:
00263 QuadEdgeMeshConstFrontIterator( const MeshType* mesh = (MeshType*)0,
00264 bool start = true,
00265 QEType* seed = (QEType*)0 )
00266 {
00267 (void)mesh;
00268 (void)start;
00269 (void)seed;
00270 }
00271
00273 virtual ~QuadEdgeMeshConstFrontIterator( ) { }
00274 Self& operator=( const NoConstType& r )
00275 {
00276 this->m_Mesh = r.GetMesh( );
00277 return( *this );
00278 }
00279 const QEType* Value( ) const { return( this->m_CurrentEdge ); }
00280 };
00282
00283 }
00284
00285 #include "itkQuadEdgeMeshFrontIterator.txx"
00286
00287 #endif
00288