ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkImageIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkImageIterator_h
19 #define __itkImageIterator_h
20 
21 #include "itkImageConstIterator.h"
22 
23 namespace itk
24 {
64 template< typename TImage >
65 class ITK_EXPORT ImageIterator:public ImageConstIterator< TImage >
66 {
67 public:
68 
71 
76  itkStaticConstMacro(ImageIteratorDimension, unsigned int,
77  TImage::ImageDimension);
78 
81 
83  typedef typename Superclass::IndexType IndexType;
84  typedef typename Superclass::SizeType SizeType;
87  typedef typename Superclass::ImageType ImageType;
91  typedef typename Superclass::PixelType PixelType;
93 
96  ImageIterator();
97 
100 
103  ImageIterator(const Self & it);
104 
107  ImageIterator(TImage *ptr, const RegionType & region);
108 
111  Self & operator=(const Self & it);
112 
114  void Set(const PixelType & value) const
115  {
116  // const_cast is needed here because m_Buffer is declared as a const
117  // pointer in the superclass which is the ConstIterator.
118  this->m_PixelAccessorFunctor.Set(
119  *( const_cast< InternalPixelType * >( this->m_Buffer ) + this->m_Offset ), value);
120  }
121 
125  PixelType & Value(void)
126  {
127  // const_cast is needed here because m_Buffer is declared as a const
128  // pointer in the superclass which is the ConstIterator.
129  return *( const_cast< InternalPixelType * >( this->m_Buffer ) + this->m_Offset );
130  }
131 
135  itkLegacyMacro(Self Begin(void) const);
136 
140  itkLegacyMacro(Self End(void) const);
141 
143  ImageType * GetImage() const
144  {
145  // const_cast is needed here because m_Image is declared as a const pointer
146  // in the base class which is the ConstIterator.
147  return const_cast< ImageType * >( this->m_Image.GetPointer() );
148  }
149 
150 protected:
151 
155  Self & operator=(const ImageConstIterator< TImage > & it);
156 };
157 } // end namespace itk
159 
160 #ifndef ITK_MANUAL_INSTANTIATION
161 #include "itkImageIterator.hxx"
162 #endif
163 
164 #endif
165