00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkImageConstIteratorWithIndex_h
00018 #define __itkImageConstIteratorWithIndex_h
00019
00020 #include "itkIndex.h"
00021 #include "itkImage.h"
00022 #include <memory>
00023
00024 namespace itk
00025 {
00026
00090 template<typename TImage>
00091 class ITK_EXPORT ImageConstIteratorWithIndex
00092 {
00093 public:
00095 typedef ImageConstIteratorWithIndex Self;
00096
00101 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
00102
00104 typedef typename TImage::IndexType IndexType;
00105 typedef typename IndexType::IndexValueType IndexValueType;
00106
00108 typedef typename TImage::SizeType SizeType;
00109 typedef typename SizeType::SizeValueType SizeValueType;
00110
00112 typedef typename TImage::RegionType RegionType;
00113
00115 typedef TImage ImageType;
00116
00120 typedef typename TImage::PixelContainer PixelContainer;
00121 typedef typename PixelContainer::Pointer PixelContainerPointer;
00122
00124 typedef typename TImage::InternalPixelType InternalPixelType;
00125
00127 typedef typename TImage::PixelType PixelType;
00128
00131 typedef typename TImage::AccessorType AccessorType;
00132 typedef typename TImage::AccessorFunctorType AccessorFunctorType;
00133
00135 typedef typename TImage::OffsetType OffsetType;
00136 typedef typename OffsetType::OffsetValueType OffsetValueType;
00137
00140 ImageConstIteratorWithIndex();
00141
00144 ImageConstIteratorWithIndex(const Self& it);
00145
00148 ImageConstIteratorWithIndex( const TImage *ptr,
00149 const RegionType& region );
00150
00153 Self &operator=(const Self& it);
00154
00156 static unsigned int GetImageDimension()
00157 {return ImageDimension;}
00158
00161 bool
00162 operator!=(const Self &it) const
00163 {
00164
00165 return (m_Position) != (it.m_Position);
00166 };
00167
00170 bool
00171 operator==(const Self &it) const
00172 {
00173
00174 return (m_Position) == (it.m_Position);
00175 };
00176
00179 bool
00180 operator<=(const Self &it) const
00181 {
00182
00183
00184 return (m_Position) <= (it.m_Position);
00185 };
00186
00189 bool
00190 operator<(const Self &it) const
00191 {
00192
00193
00194 return (m_Position) < (it.m_Position);
00195 };
00196
00199 bool
00200 operator>=(const Self &it) const
00201 {
00202
00203
00204 return (m_Position) >= (it.m_Position);
00205 };
00206
00209 bool
00210 operator>(const Self &it) const
00211 {
00212
00213
00214 return (m_Position) > (it.m_Position);
00215 };
00216
00219 const IndexType & GetIndex() const
00220 { return m_PositionIndex; }
00221
00224 const RegionType& GetRegion() const
00225 { return m_Region; };
00226
00229 void SetIndex(const IndexType &ind)
00230 { m_Position = m_Image->GetBufferPointer() + m_Image->ComputeOffset( ind );
00231 m_PositionIndex = ind; }
00232
00234 PixelType Get(void) const
00235 { return m_PixelAccessorFunctor.Get(*m_Position); }
00236
00240 const PixelType & Value(void) const
00241 { return *m_Position; }
00242
00245 Self Begin(void) const;
00246
00248 void GoToBegin(void);
00249
00252 Self End(void) const;
00253
00255 void GoToReverseBegin(void);
00256
00258 bool IsAtReverseEnd(void) const
00259 {
00260 return !m_Remaining;
00261 }
00262
00264 bool IsAtEnd(void) const
00265 {
00266 return !m_Remaining;
00267 }
00268
00270 bool Remaining()
00271 {
00272 return m_Remaining;
00273 }
00274
00275 protected:
00276 typename TImage::ConstWeakPointer m_Image;
00277
00278 IndexType m_PositionIndex;
00279 IndexType m_BeginIndex;
00280 IndexType m_EndIndex;
00281
00282
00283
00284 RegionType m_Region;
00285
00286 unsigned long m_OffsetTable[ ImageDimension + 1 ];
00287
00288 const InternalPixelType *m_Position;
00289 const InternalPixelType *m_Begin;
00290 const InternalPixelType *m_End;
00291
00292 bool m_Remaining;
00293
00294 AccessorType m_PixelAccessor;
00295 AccessorFunctorType m_PixelAccessorFunctor;
00296
00297 };
00298
00299 }
00300
00301 #ifndef ITK_MANUAL_INSTANTIATION
00302 #include "itkImageConstIteratorWithIndex.txx"
00303 #endif
00304
00305 #endif