ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkImageIterator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkImageIterator_h
00019 #define __itkImageIterator_h
00020 
00021 #include "itkImageConstIterator.h"
00022 
00023 namespace itk
00024 {
00064 template< typename TImage >
00065 class ITK_EXPORT ImageIterator:public ImageConstIterator< TImage >
00066 {
00067 public:
00068 
00070   typedef ImageIterator Self;
00071 
00076   itkStaticConstMacro(ImageIteratorDimension, unsigned int,
00077                       TImage::ImageDimension);
00078 
00080   typedef ImageConstIterator< TImage > Superclass;
00081 
00083   typedef typename Superclass::IndexType             IndexType;
00084   typedef typename Superclass::SizeType              SizeType;
00085   typedef typename Superclass::OffsetType            OffsetType;
00086   typedef typename Superclass::RegionType            RegionType;
00087   typedef typename Superclass::ImageType             ImageType;
00088   typedef typename Superclass::PixelContainer        PixelContainer;
00089   typedef typename Superclass::PixelContainerPointer PixelContainerPointer;
00090   typedef typename Superclass::InternalPixelType     InternalPixelType;
00091   typedef typename Superclass::PixelType             PixelType;
00092   typedef typename Superclass::AccessorType          AccessorType;
00093 
00096   ImageIterator();
00097 
00099   ~ImageIterator() {}
00100 
00103   ImageIterator(const Self & it);
00104 
00107   ImageIterator(TImage *ptr, const RegionType & region);
00108 
00111   Self & operator=(const Self & it);
00112 
00114   void Set(const PixelType & value) const
00115   {
00116     // const_cast is needed here because m_Buffer is declared as a const
00117     // pointer in the superclass which is the ConstIterator.
00118     this->m_PixelAccessorFunctor.Set(
00119       *( const_cast< InternalPixelType * >( this->m_Buffer ) + this->m_Offset ), value);
00120   }
00121 
00125   PixelType & Value(void)
00126   {
00127     // const_cast is needed here because m_Buffer is declared as a const
00128     // pointer in the superclass which is the ConstIterator.
00129     return *( const_cast< InternalPixelType * >( this->m_Buffer ) + this->m_Offset );
00130   }
00131 
00135   Self Begin(void) const;
00136 
00140   Self End(void) const;
00141 
00143   ImageType * GetImage() const
00144   {
00145     // const_cast is needed here because m_Image is declared as a const pointer
00146     // in the base class which is the ConstIterator.
00147     return const_cast< ImageType * >( this->m_Image.GetPointer() );
00148   }
00149 
00150 protected:
00151 
00154   ImageIterator(const ImageConstIterator< TImage > & it);
00155   Self & operator=(const ImageConstIterator< TImage > & it);
00156 };
00157 } // end namespace itk
00159 
00160 // Define instantiation macro for this template.
00161 #define ITK_TEMPLATE_ImageIterator(_, EXPORT, TypeX, TypeY)     \
00162   namespace itk                                                 \
00163   {                                                             \
00164   _( 1 ( class EXPORT ImageIterator< ITK_TEMPLATE_1 TypeX > ) ) \
00165   namespace Templates                                           \
00166   {                                                             \
00167   typedef ImageIterator< ITK_TEMPLATE_1 TypeX >                 \
00168   ImageIterator##TypeY;                                       \
00169   }                                                             \
00170   }
00171 
00172 #if ITK_TEMPLATE_EXPLICIT
00173 #include "Templates/itkImageIterator+-.h"
00174 #endif
00175 
00176 #if ITK_TEMPLATE_TXX
00177 #include "itkImageIterator.hxx"
00178 #endif
00179 
00180 #endif
00181