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
00134 typedef typename TImage::OffsetType OffsetType;
00135 typedef typename OffsetType::OffsetValueType OffsetValueType;
00136
00139 ImageConstIteratorWithIndex();
00140
00143 ImageConstIteratorWithIndex(const Self& it);
00144
00147 ImageConstIteratorWithIndex( const TImage *ptr,
00148 const RegionType& region );
00149
00152 Self &operator=(const Self& it);
00153
00155 static unsigned int GetImageDimension()
00156 {return ImageDimension;}
00157
00160 bool
00161 operator!=(const Self &it) const
00162 {
00163
00164 return (m_Position) != (it.m_Position);
00165 };
00166
00169 bool
00170 operator==(const Self &it) const
00171 {
00172
00173 return (m_Position) == (it.m_Position);
00174 };
00175
00178 bool
00179 operator<=(const Self &it) const
00180 {
00181
00182
00183 return (m_Position) <= (it.m_Position);
00184 };
00185
00188 bool
00189 operator<(const Self &it) const
00190 {
00191
00192
00193 return (m_Position) < (it.m_Position);
00194 };
00195
00198 bool
00199 operator>=(const Self &it) const
00200 {
00201
00202
00203 return (m_Position) >= (it.m_Position);
00204 };
00205
00208 bool
00209 operator>(const Self &it) const
00210 {
00211
00212
00213 return (m_Position) > (it.m_Position);
00214 };
00215
00218 const IndexType GetIndex()
00219 { return m_PositionIndex; }
00220
00223 const RegionType& GetRegion() const
00224 { return m_Region; };
00225
00228 void SetIndex(const IndexType &ind)
00229 { m_Position = m_Begin + m_Image->ComputeOffset( ind );
00230 m_PositionIndex = ind; }
00231
00233 PixelType Get(void) const
00234 { return m_PixelAccessor.Get(*m_Position); }
00235
00239 const PixelType & Value(void) const
00240 { return *m_Position; }
00241
00244 Self Begin(void) const;
00245
00247 void GoToBegin(void);
00248
00251 Self End(void) const;
00252
00254 void GoToReverseBegin(void);
00255
00257 bool IsAtReverseEnd(void) const
00258 {
00259 return !m_Remaining;
00260 }
00261
00263 bool IsAtEnd(void) const
00264 {
00265 return !m_Remaining;
00266 }
00267
00269 bool Remaining()
00270 {
00271 return m_Remaining;
00272 }
00273
00274 protected:
00275 typename TImage::ConstWeakPointer m_Image;
00276
00277 IndexType m_PositionIndex;
00278 IndexType m_BeginIndex;
00279 IndexType m_EndIndex;
00280
00281
00282
00283 RegionType m_Region;
00284
00285 unsigned long m_OffsetTable[ ImageDimension + 1 ];
00286
00287 const InternalPixelType *m_Position;
00288 const InternalPixelType *m_Begin;
00289 const InternalPixelType *m_End;
00290
00291 bool m_Remaining;
00292
00293 AccessorType m_PixelAccessor;
00294
00295 };
00296
00297 }
00298
00299 #ifndef ITK_MANUAL_INSTANTIATION
00300 #include "itkImageConstIteratorWithIndex.txx"
00301 #endif
00302
00303 #endif