ITK  4.2.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 // Define instantiation macro for this template.
161 #define ITK_TEMPLATE_ImageIterator(_, EXPORT, TypeX, TypeY) \
162  namespace itk \
163  { \
164  _( 1 ( class EXPORT ImageIterator< ITK_TEMPLATE_1 TypeX > ) ) \
165  namespace Templates \
166  { \
167  typedef ImageIterator< ITK_TEMPLATE_1 TypeX > \
168  ImageIterator##TypeY; \
169  } \
170  }
171 
172 #if ITK_TEMPLATE_EXPLICIT
173 #include "Templates/itkImageIterator+-.h"
174 #endif
175 
176 #if ITK_TEMPLATE_TXX
177 #include "itkImageIterator.hxx"
178 #endif
179 
180 #endif
181