KWStyle - itkImageIteratorWithIndex.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkImageIteratorWithIndex.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 __itkImageIteratorWithIndex_h
18 #define __itkImageIteratorWithIndex_h
19
20 #include "itkImageConstIteratorWithIndex.h"
21
22 namespace itk
23 {
24
25 /**
26  * \class ImageIteratorWithIndex
27  * \brief A base class for multi-dimensional iterators templated over image
28  * type that are designed to efficiently keep track of the iterator
29  * position.
30  *
31  * This class inherits from ImageConstIteratorWithIndex and only adds
32  * write-access functionality.  See ImageConstIteratorWithIndex for more
33  * information.
34  *
35  * \par MORE INFORMATION
36  * For a complete description of the ITK Image Iterators and their API, please
37  * see the Iterators chapter in the ITK Software Guide.  The ITK Software Guide
38  * is available in print and as a free .pdf download from http://www.itk.org.
39  *
40  * \ingroup ImageIterators
41  *
42  * \sa ImageConstIterator \sa ConditionalConstIterator
43  * \sa ConstNeighborhoodIterator \sa ConstShapedNeighborhoodIterator
44  * \sa ConstSliceIterator  \sa CorrespondenceDataStructureIterator 
45  * \sa FloodFilledFunctionConditionalConstIterator 
46  * \sa FloodFilledImageFunctionConditionalConstIterator 
47  * \sa FloodFilledImageFunctionConditionalIterator 
48  * \sa FloodFilledSpatialFunctionConditionalConstIterator 
49  * \sa FloodFilledSpatialFunctionConditionalIterator 
50  * \sa ImageConstIterator \sa ImageConstIteratorWithIndex 
51  * \sa ImageIterator \sa ImageIteratorWithIndex
52  * \sa ImageLinearConstIteratorWithIndex  \sa ImageLinearIteratorWithIndex 
53  * \sa ImageRandomConstIteratorWithIndex  \sa ImageRandomIteratorWithIndex 
54  * \sa ImageRegionConstIterator \sa ImageRegionConstIteratorWithIndex 
55  * \sa ImageRegionExclusionConstIteratorWithIndex 
56  * \sa ImageRegionExclusionIteratorWithIndex 
57  * \sa ImageRegionIterator  \sa ImageRegionIteratorWithIndex 
58  * \sa ImageRegionReverseConstIterator  \sa ImageRegionReverseIterator 
59  * \sa ImageReverseConstIterator  \sa ImageReverseIterator 
60  * \sa ImageSliceConstIteratorWithIndex  \sa ImageSliceIteratorWithIndex 
61  * \sa NeighborhoodIterator \sa PathConstIterator  \sa PathIterator 
62  * \sa ShapedNeighborhoodIterator  \sa SliceIterator 
63  * \sa ImageConstIteratorWithIndex
64  *
65  *  */
66 template<typename TImage>
67 LEN class ITK_EXPORT ImageIteratorWithIndex : public ImageConstIteratorWithIndex<TImage>
68 {
69 public:
70   /** Standard class typedefs. */
71   typedef ImageIteratorWithIndex Self;
72
73   /** Dimension of the image the iterator walks.  This constant is needed so
74    * functions that are templated over image iterator type (as opposed to
75    * being templated over pixel type and dimension) can have compile time
76    * access to the dimension of the image that the iterator walks. */
77   itkStaticConstMacro(ImageIteratorDimension, unsigned int,
78                       TImage::ImageDimension);
79
80   /** Define the superclass */
81   typedef ImageConstIteratorWithIndex<TImage> Superclass;
82
83   /** Inherit types from the superclass */
84   typedef typename Superclass::IndexType              IndexType;
85   typedef typename Superclass::IndexValueType         IndexValueType;
86   typedef typename Superclass::SizeType               SizeType;
87   typedef typename Superclass::SizeValueType          SizeValueType;
88   typedef typename Superclass::OffsetType             OffsetType;
89   typedef typename Superclass::OffsetValueType        OffsetValueType;
90   typedef typename Superclass::RegionType             RegionType;
91   typedef typename Superclass::ImageType              ImageType;
92   typedef typename Superclass::PixelContainer         PixelContainer;
93   typedef typename Superclass::PixelContainerPointer  PixelContainerPointer;
94   typedef typename Superclass::InternalPixelType      InternalPixelType;
95   typedef typename Superclass::PixelType              PixelType;
96   typedef typename Superclass::AccessorType           AccessorType;
97
98
99   /** Default Constructor. Need to provide a default constructor since we
100    * provide a copy constructor. */
101   ImageIteratorWithIndex();
102
103   /** Default Destructor */
104   ~ImageIteratorWithIndex() {};
105
106
107   /** Copy Constructor. The copy constructor is provided to make sure the
108    * handle to the image is properly reference counted. */
109   ImageIteratorWithIndex(const Self& it);
110
111   /** Constructor establishes an iterator to walk a particular image and a
112    * particular region of that image. */
113   ImageIteratorWithIndex(TImage *ptr, const RegionType& region);
114
115   /** operator= is provided to make sure the handle to the image is properly
116    * reference counted. */
117   Self &operator=(const Self& it);
118   
119   /** Set the pixel value */
120   void Set( const PixelType & value) const  
121 LEN     { this->m_PixelAccessor.Set(*(const_cast<InternalPixelType *>(this->m_Position)),value); }
122
123   /** Return a reference to the pixel 
124    * This method will provide the fastest access to pixel
125    * data, but it will NOT support ImageAdaptors. */
126   PixelType & Value(void) 
127     { return *(const_cast<InternalPixelType *>(this->m_Position)); }
128  
129 protected:
130
131 LEN   /** This constructor is declared protected in order to enforce const-correctness */
132   ImageIteratorWithIndex(const ImageConstIteratorWithIndex<TImage> & it);
133   Self &operator=(const ImageConstIteratorWithIndex<TImage> & it);
134 };
135
136 // end namespace itk
137
138 #ifndef ITK_MANUAL_INSTANTIATION
139 #include "itkImageIteratorWithIndex.txx"
140 #endif
141
142 #endif 
143

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