00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageRegionConstIterator_h
00018 #define __itkImageRegionConstIterator_h
00019
00020 #include "itkImageConstIterator.h"
00021 #include "itkImageIterator.h"
00022
00023 #if defined(_MSC_VER) && !defined(ITK_LEAN_AND_MEAN)
00024 #define ITK_LEAN_AND_MEAN
00025 #endif
00026
00027 namespace itk
00028 {
00029
00107 template<typename TImage>
00108 class ITK_EXPORT ImageRegionConstIterator : public ImageConstIterator<TImage>
00109 {
00110 public:
00112 typedef ImageRegionConstIterator Self;
00113 typedef ImageConstIterator<TImage> Superclass;
00114
00119 itkStaticConstMacro(ImageIteratorDimension, unsigned int,
00120 Superclass::ImageIteratorDimension);
00121
00124 typedef typename Superclass::IndexType IndexType;
00125
00128 typedef typename Superclass::SizeType SizeType;
00129
00131 typedef typename Superclass::RegionType RegionType;
00132
00135 typedef typename Superclass::ImageType ImageType;
00136
00140 typedef typename Superclass::PixelContainer PixelContainer;
00141 typedef typename Superclass::PixelContainerPointer PixelContainerPointer;
00142
00144 typedef typename Superclass::InternalPixelType InternalPixelType;
00145
00147 typedef typename Superclass::PixelType PixelType;
00148
00151 typedef typename Superclass::AccessorType AccessorType;
00152
00154 itkTypeMacro(ImageRegionConstIterator, ImageIterator);
00155
00157 ImageRegionConstIterator() : ImageConstIterator<TImage>()
00158 {
00159 m_SpanBeginOffset = 0;
00160 m_SpanEndOffset = 0;
00161 }
00162
00165 ImageRegionConstIterator(const ImageType *ptr,
00166 const RegionType ®ion)
00167 : ImageConstIterator<TImage>(ptr, region)
00168 {
00169 m_SpanBeginOffset = this->m_BeginOffset;
00170 m_SpanEndOffset = this->m_BeginOffset + static_cast<long>(this->m_Region.GetSize()[0]);
00171 }
00172
00179 ImageRegionConstIterator( const ImageIterator<TImage> &it)
00180 {
00181 this->ImageIterator<TImage>::operator=(it);
00182 IndexType ind = this->GetIndex();
00183 m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
00184 - (ind[0] - this->m_Region.GetIndex()[0]);
00185 m_SpanBeginOffset = m_SpanEndOffset
00186 - static_cast<long>(this->m_Region.GetSize()[0]);
00187 }
00188
00195 ImageRegionConstIterator( const ImageConstIterator<TImage> &it)
00196 {
00197 this->ImageConstIterator<TImage>::operator=(it);
00198 IndexType ind = this->GetIndex();
00199 m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
00200 - (ind[0] - this->m_Region.GetIndex()[0]);
00201 m_SpanBeginOffset = m_SpanEndOffset
00202 - static_cast<long>(this->m_Region.GetSize()[0]);
00203 }
00204
00207 void GoToBegin()
00208 {
00209 Superclass::GoToBegin();
00210
00211
00212 m_SpanBeginOffset = this->m_BeginOffset;
00213 m_SpanEndOffset = this->m_BeginOffset
00214 + static_cast<long>(this->m_Region.GetSize()[0]);
00215 };
00216
00219 void GoToEnd()
00220 {
00221 Superclass::GoToEnd();
00222
00223
00224 m_SpanEndOffset = this->m_EndOffset;
00225 m_SpanBeginOffset = m_SpanEndOffset
00226 - static_cast<long>(this->m_Region.GetSize()[0]);
00227 };
00228
00232 Self Begin(void) const;
00233
00237 Self End(void) const;
00238
00239
00243 void SetIndex(const IndexType &ind)
00244 { Superclass::SetIndex(ind);
00245 m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
00246 - (ind[0] - this->m_Region.GetIndex()[0]);
00247 m_SpanBeginOffset = m_SpanEndOffset
00248 - static_cast<long>(this->m_Region.GetSize()[0]);
00249 }
00250
00258 Self &
00259 operator++()
00260 {
00261 if (++this->m_Offset >= m_SpanEndOffset)
00262 {
00263 this->Increment();
00264 }
00265 return *this;
00266 }
00267
00275 Self & operator--()
00276 {
00277 if (--this->m_Offset < m_SpanBeginOffset)
00278 {
00279 this->Decrement();
00280 }
00281 return *this;
00282 }
00283
00284 private:
00285 void Increment();
00286 void Decrement();
00287
00288 protected:
00289 unsigned long m_SpanBeginOffset;
00290 unsigned long m_SpanEndOffset;
00291
00292 };
00293
00294 }
00295
00296 #ifndef ITK_MANUAL_INSTANTIATION
00297 #include "itkImageRegionConstIterator.txx"
00298 #endif
00299
00300 #if defined(_MSC_VER)
00301 #undef ITK_LEAN_AND_MEAN
00302 #endif
00303
00304 #endif