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 }
00173
00180 ImageRegionConstIterator( const ImageIterator<TImage> &it)
00181 {
00182 this->ImageConstIterator<TImage>::operator=(it);
00183 IndexType ind = this->GetIndex();
00184 m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
00185 - (ind[0] - this->m_Region.GetIndex()[0]);
00186 m_SpanBeginOffset = m_SpanEndOffset
00187 - static_cast<long>(this->m_Region.GetSize()[0]);
00188 }
00190
00197 ImageRegionConstIterator( const ImageConstIterator<TImage> &it)
00198 {
00199 this->ImageConstIterator<TImage>::operator=(it);
00200 IndexType ind = this->GetIndex();
00201 m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
00202 - (ind[0] - this->m_Region.GetIndex()[0]);
00203 m_SpanBeginOffset = m_SpanEndOffset
00204 - static_cast<long>(this->m_Region.GetSize()[0]);
00205 }
00207
00210 void GoToBegin()
00211 {
00212 Superclass::GoToBegin();
00213
00214
00215 m_SpanBeginOffset = this->m_BeginOffset;
00216 m_SpanEndOffset = this->m_BeginOffset
00217 + static_cast<long>(this->m_Region.GetSize()[0]);
00218 };
00219
00222 void GoToEnd()
00223 {
00224 Superclass::GoToEnd();
00225
00226
00227 m_SpanEndOffset = this->m_EndOffset;
00228 m_SpanBeginOffset = m_SpanEndOffset
00229 - static_cast<long>(this->m_Region.GetSize()[0]);
00230 };
00231
00235 Self Begin(void) const;
00236
00240 Self End(void) const;
00241
00242
00246 void SetIndex(const IndexType &ind)
00247 { Superclass::SetIndex(ind);
00248 m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
00249 - (ind[0] - this->m_Region.GetIndex()[0]);
00250 m_SpanBeginOffset = m_SpanEndOffset
00251 - static_cast<long>(this->m_Region.GetSize()[0]);
00252 }
00254
00262 Self &
00263 operator++()
00264 {
00265 if (++this->m_Offset >= m_SpanEndOffset)
00266 {
00267 this->Increment();
00268 }
00269 return *this;
00270 }
00272
00280 Self & operator--()
00281 {
00282 if (--this->m_Offset < m_SpanBeginOffset)
00283 {
00284 this->Decrement();
00285 }
00286 return *this;
00287 }
00289
00290
00291 void increment()
00292 {
00293 this->operator++();
00294 }
00295 void decrement()
00296 {
00297 this->operator--();
00298 }
00299
00300 private:
00301 void Increment();
00302 void Decrement();
00303
00304 protected:
00305 unsigned long m_SpanBeginOffset;
00306 unsigned long m_SpanEndOffset;
00307
00308 };
00309
00310 }
00311
00312 #ifndef ITK_MANUAL_INSTANTIATION
00313 #include "itkImageRegionConstIterator.txx"
00314 #endif
00315
00316 #if defined(_MSC_VER)
00317 #undef ITK_LEAN_AND_MEAN
00318 #endif
00319
00320 #endif
00321