KWStyle - itkLineIterator.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkLineIterator.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:41 $
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 __itkLineIterator_h
18 #define __itkLineIterator_h
19
20 #include "itkIndex.h"
21 #include "itkImage.h"
22 #include "itkLineConstIterator.h"
23
24 namespace itk
25 {
26
27 /**
28  * \class LineIterator
29  * \brief Iterator that walks a Bresenham line through an ND image.
30  *
31  * LineIterator is an iterator that walks a Bresenham line
32  * through an image.  The iterator is constructed similar to other
33  * image iterators except for instead of specifying a region to
34  * traverse, you specify two indices. The interval specified by
35  * the two indices is closed.  So, a line iterator specified with
36  * the same start and end index will visit exactly one pixel.
37  *
38  * \code
39  * LineConstIterator<ImageType> it(image, I1, I2);
40  * while (!it.IsAtEnd())
41  * {
42 IND **    // visits at least 1 pixel
43 IND ** }
44  * \endcode
45  *
46  * This class was contributed by Benjamin King, Experimentelle
47  * Radiologie, Medizinische Hochschule Hannover.
48  *
49  * \sa LineConstIterator
50  */
51 template<class TImage>
52 class ITK_EXPORT LineIterator : public LineConstIterator<TImage>
53 {
54 public:
55   /** Standard class typedefs. */
56   typedef LineIterator Self;
57
58   /** Dimension of the image the iterator walks.  This constant is needed so 
59    * that functions that are templated over image iterator type (as opposed to
60    * being templated over pixel type and dimension) can have compile time
61    * access to the dimension of the image that the iterator walks. */
62   itkStaticConstMacro(ImageIteratorDimension, unsigned int,
63                       TImage::ImageDimension);
64
65   /** Define the superclass */
66   typedef LineConstIterator<TImage> Superclass;
67
68   /** Inherit types from the superclass */
69   typedef typename Superclass::IndexType              IndexType;
70   typedef typename Superclass::IndexValueType         IndexValueType;
71   typedef typename Superclass::OffsetType             OffsetType;
72   typedef typename Superclass::OffsetValueType        OffsetValueType;
73   typedef typename Superclass::SizeType               SizeType;
74   typedef typename Superclass::SizeValueType          SizeValueType;
75   typedef typename Superclass::RegionType             RegionType;
76   typedef typename Superclass::ImageType              ImageType;
77   typedef typename Superclass::PixelContainer         PixelContainer;
78   typedef typename Superclass::PixelContainerPointer  PixelContainerPointer;
79   typedef typename Superclass::InternalPixelType      InternalPixelType;
80   typedef typename Superclass::PixelType              PixelType;
81   typedef typename Superclass::AccessorType           AccessorType;
82
83   /** Run-time type information (and related methods). */
84   itkTypeMacro(LineIterator, LineConstIterator);
85   
86   /** Set the pixel value */
87   void Set( const PixelType & value)
88     {
89     // Normally, this would just be the following:
90     //   m_Image->SetPixel(m_CurrentImageIndex,value);
91     // However, we don't want a warning about m_Image being a ConstPointer
92     // in the Superclass.
93     const_cast<ImageType *>(this->m_Image.GetPointer())->
94 IND ******SetPixel(this->m_CurrentImageIndex,value);
95     }
96
97   /** Return a reference to the pixel 
98    * This method will provide the fastest access to pixel
99    * data, but it will NOT support ImageAdaptors. */
100   PixelType & Value(void) 
101     {
102     return this->GetImage()->GetPixel(this->m_ImageIndex);
103     }
104
105   /** operator= is provided to make sure the handle to the image is properly
106    * reference counted. */
107   Self &operator=(const Self& it);
108
109   /** Constructor establishes an iterator to walk along a path */
110   LineIterator(ImageType *imagePtr, const IndexType &firstIndex,
111                const IndexType &lastIndex);
112
113   /** Default Destructor. */
114   virtual ~LineIterator() {};
115 };
116
117 // end namespace itk
118
119 #ifndef ITK_MANUAL_INSTANTIATION
120 #include "itkLineIterator.txx"
121 #endif
122
123 #endif 
124

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