KWStyle - itkPathIterator.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkPathIterator.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:43 $
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 __itkPathIterator_h
18 #define __itkPathIterator_h
19
20 #include "itkIndex.h"
21 #include "itkImage.h"
22 #include "itkPath.h"
23 #include "itkPathConstIterator.h"
24
25 namespace itk
26 {
27
28 /**
29  * \class PathIterator
30  * \brief PathIterator iterates (traces) over a path through an image.
31  *
32  * This iterator visits only those indices of the image which are overlapped by
33  * the path.  All indicies are visited in path order.  If a path crosses itself
34  * at an index, that index of the image will be visited twice.  This class add
35  * write-access to the functionality of the PathConstIterator.
36  *
37  * \par MORE INFORMATION
38  * For a complete description of the ITK Image Iterators and their API, please
39  * see the Iterators chapter in the ITK Software Guide.  The ITK Software Guide
40  * is available in print and as a free .pdf download from http://www.itk.org.
41  *
42  * \ingroup ImageIterators
43  *
44  * \sa ImageConstIterator \sa ConditionalConstIterator
45  * \sa ConstNeighborhoodIterator \sa ConstShapedNeighborhoodIterator
46  * \sa ConstSliceIterator  \sa CorrespondenceDataStructureIterator 
47  * \sa FloodFilledFunctionConditionalConstIterator 
48  * \sa FloodFilledImageFunctionConditionalConstIterator 
49  * \sa FloodFilledImageFunctionConditionalIterator 
50  * \sa FloodFilledSpatialFunctionConditionalConstIterator 
51  * \sa FloodFilledSpatialFunctionConditionalIterator 
52  * \sa ImageConstIterator \sa ImageConstIteratorWithIndex 
53  * \sa ImageIterator \sa ImageIteratorWithIndex
54  * \sa ImageLinearConstIteratorWithIndex  \sa ImageLinearIteratorWithIndex 
55  * \sa ImageRandomConstIteratorWithIndex  \sa ImageRandomIteratorWithIndex 
56  * \sa ImageRegionConstIterator \sa ImageRegionConstIteratorWithIndex 
57  * \sa ImageRegionExclusionConstIteratorWithIndex 
58  * \sa ImageRegionExclusionIteratorWithIndex 
59  * \sa ImageRegionIterator  \sa ImageRegionIteratorWithIndex 
60  * \sa ImageRegionReverseConstIterator  \sa ImageRegionReverseIterator 
61  * \sa ImageReverseConstIterator  \sa ImageReverseIterator 
62  * \sa ImageSliceConstIteratorWithIndex  \sa ImageSliceIteratorWithIndex 
63  * \sa NeighborhoodIterator \sa PathConstIterator 
64  * \sa ShapedNeighborhoodIterator  \sa SliceIterator 
65  * \sa ImageConstIteratorWithIndex
66  *
67  * \ingroup PathObjects*/
68 template<class TImage, class TPath>
69 class ITK_EXPORT PathIterator : public PathConstIterator<TImage, TPath>
70 {
71 public:
72   /** Standard class typedefs. */
73   typedef PathIterator Self;
74
75   /** Dimension of the image the iterator walks.  This constant is needed so 
76    * that functions that are templated over image iterator type (as opposed to
77    * being templated over pixel type and dimension) can have compile time
78    * access to the dimension of the image that the iterator walks. */
79   itkStaticConstMacro(ImageIteratorDimension, unsigned int,
80                       TImage::ImageDimension);
81
82   /** Define the superclass */
83   typedef PathConstIterator<TImage,TPath> Superclass;
84
85   /** Inherit types from the superclass */
86   typedef typename Superclass::IndexType              IndexType;
87   typedef typename Superclass::IndexValueType         IndexValueType;
88   typedef typename Superclass::OffsetType             OffsetType;
89   typedef typename Superclass::OffsetValueType        OffsetValueType;
90   typedef typename Superclass::SizeType               SizeType;
91   typedef typename Superclass::SizeValueType          SizeValueType;
92   typedef typename Superclass::RegionType             RegionType;
93   typedef typename Superclass::ImageType              ImageType;
94   typedef typename Superclass::PixelContainer         PixelContainer;
95   typedef typename Superclass::PixelContainerPointer  PixelContainerPointer;
96   typedef typename Superclass::InternalPixelType      InternalPixelType;
97   typedef typename Superclass::PixelType              PixelType;
98   typedef typename Superclass::AccessorType           AccessorType;
99   typedef typename Superclass::PathType               PathType;
100   typedef typename Superclass::PathInputType          PathInputType;
101   typedef typename Superclass::PathOutputType         PathOutputType;
102
103   /** Run-time type information (and related methods). */
104   itkTypeMacro(PathIterator, PathConstIterator);
105   
106   
107   
108   /** Set the pixel value */
109   void Set( const PixelType & value)
110     {
111     // Normally, this would just be the following:
112     //   m_Image->SetPixel(m_CurrentImageIndex,value);
113     // However, we don't want a warning about m_Image being a ConstPointer
114     // in the Superclass.
115     const_cast<ImageType *>(this->m_Image.GetPointer())->
116 IND ******SetPixel(this->m_CurrentImageIndex,value);
117     }
118
119   /** Return a reference to the pixel 
120    * This method will provide the fastest access to pixel
121    * data, but it will NOT support ImageAdaptors. */
122   PixelType & Value(void) 
123     {
124     return this->GetImage()->GetPixel(this->m_ImageIndex);
125     }
126
127   /** operator= is provided to make sure the handles to the image and path are
128    * properly reference counted. */
129   Self &operator=(const Self& it);
130
131   /** Constructor establishes an iterator to walk along a path */
132   PathIterator(ImageType *imagePtr, const PathType  *pathPtr);
133
134   /** Default Destructor. */
135   virtual ~PathIterator() {};
136 };
137
138 // end namespace itk
139
140 #ifndef ITK_MANUAL_INSTANTIATION
141 #include "itkPathIterator.txx"
142 #endif
143
144 #endif 
145

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