Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkImageConstIteratorWithIndex.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkImageConstIteratorWithIndex.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:10 $ 00007 Version: $Revision: 1.18 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 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 00057 template<typename TImage> 00058 class ITK_EXPORT ImageConstIteratorWithIndex 00059 { 00060 public: 00062 typedef ImageConstIteratorWithIndex Self; 00063 00068 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension); 00069 00071 typedef typename TImage::IndexType IndexType; 00072 typedef typename IndexType::IndexValueType IndexValueType; 00073 00075 typedef typename TImage::SizeType SizeType; 00076 typedef typename SizeType::SizeValueType SizeValueType; 00077 00079 typedef typename TImage::RegionType RegionType; 00080 00082 typedef TImage ImageType; 00083 00087 typedef typename TImage::PixelContainer PixelContainer; 00088 typedef typename PixelContainer::Pointer PixelContainerPointer; 00089 00091 typedef typename TImage::InternalPixelType InternalPixelType; 00092 00094 typedef typename TImage::PixelType PixelType; 00095 00098 typedef typename TImage::AccessorType AccessorType; 00099 00101 typedef typename TImage::OffsetType OffsetType; 00102 typedef typename OffsetType::OffsetValueType OffsetValueType; 00103 00106 ImageConstIteratorWithIndex(); 00107 00110 ImageConstIteratorWithIndex(const Self& it); 00111 00114 ImageConstIteratorWithIndex( const TImage *ptr, 00115 const RegionType& region ); 00116 00119 Self &operator=(const Self& it); 00120 00122 static unsigned int GetImageDimension() 00123 {return ImageDimension;} 00124 00127 bool 00128 operator!=(const Self &it) const 00129 { 00130 // two iterators are the same if they "point to" the same memory location 00131 return (m_Position) != (it.m_Position); 00132 }; 00133 00136 bool 00137 operator==(const Self &it) const 00138 { 00139 // two iterators are the same if they "point to" the same memory location 00140 return (m_Position) == (it.m_Position); 00141 }; 00142 00145 bool 00146 operator<=(const Self &it) const 00147 { 00148 // an iterator is "less than" another if it "points to" a lower 00149 // memory location 00150 return (m_Position) <= (it.m_Position); 00151 }; 00152 00155 bool 00156 operator<(const Self &it) const 00157 { 00158 // an iterator is "less than" another if it "points to" a lower 00159 // memory location 00160 return (m_Position) < (it.m_Position); 00161 }; 00162 00165 bool 00166 operator>=(const Self &it) const 00167 { 00168 // an iterator is "greater than" another if it "points to" a higher 00169 // memory location 00170 return (m_Position) >= (it.m_Position); 00171 }; 00172 00175 bool 00176 operator>(const Self &it) const 00177 { 00178 // an iterator is "greater than" another if it "points to" a higher 00179 // memory location 00180 return (m_Position) > (it.m_Position); 00181 }; 00182 00185 const IndexType GetIndex() 00186 { return m_PositionIndex; } 00187 00190 const RegionType& GetRegion() const 00191 { return m_Region; }; 00192 00195 void SetIndex(const IndexType &ind) 00196 { m_Position = m_Begin + m_Image->ComputeOffset( ind ); 00197 m_PositionIndex = ind; } 00198 00200 PixelType Get(void) const 00201 { return m_PixelAccessor.Get(*m_Position); } 00202 00206 const PixelType & Value(void) const 00207 { return *m_Position; } 00208 00211 Self Begin(void) const; 00212 00214 void GoToBegin(void); 00215 00218 Self End(void) const; 00219 00221 void GoToReverseBegin(void); 00222 00224 bool IsAtReverseEnd(void) const 00225 { 00226 return !m_Remaining; 00227 } 00228 00230 bool IsAtEnd(void) const 00231 { 00232 return !m_Remaining; 00233 } 00234 00236 bool Remaining() 00237 { 00238 return m_Remaining; 00239 } 00240 00241 protected: //made protected so other iterators can access 00242 typename TImage::ConstPointer m_Image; 00243 00244 IndexType m_PositionIndex; // Index where we currently are 00245 IndexType m_BeginIndex; // Index to start iterating over 00246 IndexType m_EndIndex; // Index to finish iterating: 00247 // one pixel past the end of each 00248 // row, col, slice, etc.... 00249 00250 RegionType m_Region; // region to iterate over 00251 00252 unsigned long m_OffsetTable[ ImageDimension + 1 ]; 00253 00254 const InternalPixelType *m_Position; 00255 const InternalPixelType *m_Begin; 00256 const InternalPixelType *m_End; 00257 00258 bool m_Remaining; 00259 00260 AccessorType m_PixelAccessor; 00261 00262 }; 00263 00264 } // end namespace itk 00265 00266 #ifndef ITK_MANUAL_INSTANTIATION 00267 #include "itkImageConstIteratorWithIndex.txx" 00268 #endif 00269 00270 #endif

Generated at Sat Mar 31 02:20:55 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000