ITK  5.0.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_TEMPLATE_EXPORT ImageIterator:public ImageConstIterator< TImage >
66 {
67 public:
68 
71 
76  static constexpr unsigned int ImageIteratorDimension = TImage::ImageDimension;
77 
80 
82  using IndexType = typename Superclass::IndexType;
83  using SizeType = typename Superclass::SizeType;
86  using ImageType = typename Superclass::ImageType;
90  using PixelType = typename Superclass::PixelType;
92 
95  ImageIterator() = default;
96 
98  ~ImageIterator() override = default;
99 
102  ImageIterator(const Self & it);
103 
106  ImageIterator(TImage *ptr, const RegionType & region);
107 
110  Self & operator=(const Self & it);
111 
113  void Set(const PixelType & value) const
114  {
115  // const_cast is needed here because m_Buffer is declared as a const
116  // pointer in the superclass which is the ConstIterator.
117  this->m_PixelAccessorFunctor.Set(
118  *( const_cast< InternalPixelType * >( this->m_Buffer ) + this->m_Offset ), value);
119  }
120 
125  {
126  // const_cast is needed here because m_Buffer is declared as a const
127  // pointer in the superclass which is the ConstIterator.
128  return *( const_cast< InternalPixelType * >( this->m_Buffer ) + this->m_Offset );
129  }
130 
132  ImageType * GetImage() const
133  {
134  // const_cast is needed here because m_Image is declared as a const pointer
135  // in the base class which is the ConstIterator.
136  return const_cast< ImageType * >( this->m_Image.GetPointer() );
137  }
138 
139 protected:
140 
144  Self & operator=(const ImageConstIterator< TImage > & it);
145 };
146 } // end namespace itk
148 
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "itkImageIterator.hxx"
151 #endif
152 
153 #endif
typename TImage::OffsetType OffsetType
ImageType * GetImage() const
typename TImage::InternalPixelType InternalPixelType
A multi-dimensional iterator templated over image type.
typename PixelContainer::Pointer PixelContainerPointer
typename TImage::PixelType PixelType
typename TImage::PixelContainer PixelContainer
A multi-dimensional image iterator templated over image type.
void Set(const PixelType &value) const
typename TImage::IndexType IndexType
typename TImage::SizeType SizeType
typename TImage::AccessorType AccessorType
typename TImage::RegionType RegionType