KWStyle - itkImageIterator.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkImageIterator.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:38 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 #ifndef __itkImageIterator_h
18 #define __itkImageIterator_h
19
20 #include "itkImageConstIterator.h"
21
22 namespace itk
23 {
24
25 /**
26  * \class ImageIterator
27  * \brief A multi-dimensional iterator templated over image type.
28  *
29  * This is a base class of ImageConstIterator that adds write-access
30  * functionality.  Please see ImageConstIterator for more information.
31  *
32  * \par MORE INFORMATION
33  * For a complete description of the ITK Image Iterators and their API, please
34  * see the Iterators chapter in the ITK Software Guide.  The ITK Software Guide
35  * is available in print and as a free .pdf download from http://www.itk.org.
36  *
37  * \ingroup ImageIterators
38  *
39  * \sa ImageConstIterator \sa ConditionalConstIterator
40  * \sa ConstNeighborhoodIterator \sa ConstShapedNeighborhoodIterator
41  * \sa ConstSliceIterator  \sa CorrespondenceDataStructureIterator 
42  * \sa FloodFilledFunctionConditionalConstIterator 
43  * \sa FloodFilledImageFunctionConditionalConstIterator 
44  * \sa FloodFilledImageFunctionConditionalIterator 
45  * \sa FloodFilledSpatialFunctionConditionalConstIterator 
46  * \sa FloodFilledSpatialFunctionConditionalIterator 
47  * \sa ImageConstIterator \sa ImageConstIteratorWithIndex 
48  * \sa ImageIterator \sa ImageIteratorWithIndex
49  * \sa ImageLinearConstIteratorWithIndex  \sa ImageLinearIteratorWithIndex 
50  * \sa ImageRandomConstIteratorWithIndex  \sa ImageRandomIteratorWithIndex 
51  * \sa ImageRegionConstIterator \sa ImageRegionConstIteratorWithIndex 
52  * \sa ImageRegionExclusionConstIteratorWithIndex 
53  * \sa ImageRegionExclusionIteratorWithIndex 
54  * \sa ImageRegionIterator  \sa ImageRegionIteratorWithIndex 
55  * \sa ImageRegionReverseConstIterator  \sa ImageRegionReverseIterator 
56  * \sa ImageReverseConstIterator  \sa ImageReverseIterator 
57  * \sa ImageSliceConstIteratorWithIndex  \sa ImageSliceIteratorWithIndex 
58  * \sa NeighborhoodIterator \sa PathConstIterator  \sa PathIterator 
59  * \sa ShapedNeighborhoodIterator  \sa SliceIterator 
60  *
61  *  */
62 template<typename TImage>
63 class ITK_EXPORT ImageIterator : public ImageConstIterator<TImage>
64 {
65 public:
66   /** Standard class typedefs. */
67   typedef ImageIterator Self;
68
69   /** Dimension of the image the iterator walks.  This constant is needed so
70    * functions that are templated over image iterator type (as opposed to
71    * being templated over pixel type and dimension) can have compile time
72    * access to the dimension of the image that the iterator walks. */
73   itkStaticConstMacro(ImageIteratorDimension, unsigned int,
74                       TImage::ImageDimension);
75
76   /** Define the superclass */
77   typedef ImageConstIterator<TImage> Superclass;
78
79   /** Inherit types from the superclass */
80   typedef typename Superclass::IndexType              IndexType;
81   typedef typename Superclass::IndexValueType         IndexValueType;
82   typedef typename Superclass::SizeType               SizeType;
83   typedef typename Superclass::SizeValueType          SizeValueType;
84   typedef typename Superclass::OffsetType             OffsetType;
85   typedef typename Superclass::OffsetValueType        OffsetValueType;
86   typedef typename Superclass::RegionType             RegionType;
87   typedef typename Superclass::ImageType              ImageType;
88   typedef typename Superclass::PixelContainer         PixelContainer;
89   typedef typename Superclass::PixelContainerPointer  PixelContainerPointer;
90   typedef typename Superclass::InternalPixelType      InternalPixelType;
91   typedef typename Superclass::PixelType              PixelType;
92   typedef typename Superclass::AccessorType           AccessorType;
93
94
95   /** Default Constructor. Need to provide a default constructor since we
96    * provide a copy constructor. */
97   ImageIterator();
98
99   /** Default Destructor */
100   ~ImageIterator() {};
101
102
103   /** Copy Constructor. The copy constructor is provided to make sure the
104    * handle to the image is properly reference counted. */
105   ImageIterator(const Self& it);
106
107   /** Constructor establishes an iterator to walk a particular image and a
108    * particular region of that image. */
109   ImageIterator(TImage *ptr, const RegionType& region);
110
111   /** operator= is provided to make sure the handle to the image is properly
112    * reference counted. */
113   Self &operator=(const Self& it);
114   
115   /** Set the pixel value */
116   void Set( const PixelType & value) const  
117     { 
118     this->m_PixelAccessorFunctor.Set(*(const_cast<InternalPixelType *>
119           (this->m_Buffer)+this->m_Offset), value); 
120     }
121
122   /** Return a reference to the pixel 
123    * This method will provide the fastest access to pixel
124    * data, but it will NOT support ImageAdaptors. */
125   PixelType & Value(void) 
126 LEN     { return *(const_cast<InternalPixelType *>(this->m_Buffer)+this->m_Offset); }
127
128   /** Return an iterator for the beginning of the region. "Begin"
129    * is defined as the first pixel in the region.
130    * \deprecated Use GoToBegin() instead */
131   Self Begin(void) const;
132
133 IND ***/** Return an iterator for the end of the region. "End" is defined
134    * as one pixel past the last pixel of the region. 
135    * \deprecated Use GoToEnd() instead */
136   Self End(void) const;
137
138   /** Get the image that this iterator walks. */
139   ImageType * GetImage() const
140     { return const_cast<ImageType *>( this->m_Image.GetPointer() ); };
141
142
143 protected:
144
145 LEN   /** This constructor is declared protected in order to enforce const-correctness */
146   ImageIterator(const ImageConstIterator<TImage> & it);
147   Self &operator=(const ImageConstIterator<TImage> & it);
148 };
149
150 // end namespace itk
151
152 #ifndef ITK_MANUAL_INSTANTIATION
153 #include "itkImageIterator.txx"
154 #endif
155
156 #endif 
157

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:13PM
© Kitware Inc.