ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkLineConstIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkLineConstIterator_h
19 #define itkLineConstIterator_h
20 
21 #include "itkIndex.h"
22 #include "itkImage.h"
23 
24 namespace itk
25 {
55 template< typename TImage >
57 {
58 public:
59 
62 
67  itkStaticConstMacro(ImageIteratorDimension, unsigned int,
68  TImage::ImageDimension);
69 
71  typedef typename TImage::IndexType IndexType;
72 
74  typedef typename TImage::OffsetType OffsetType;
75 
77  typedef typename TImage::SizeType SizeType;
78 
80  typedef typename TImage::RegionType RegionType;
81 
83  typedef typename TImage::SpacingType SpacingType;
84 
86  typedef typename TImage::PointType PointType;
87 
89  typedef TImage ImageType;
90 
94  typedef typename TImage::PixelContainer PixelContainer;
95  typedef typename PixelContainer::Pointer PixelContainerPointer;
96 
98  typedef typename TImage::InternalPixelType InternalPixelType;
99 
101  typedef typename TImage::PixelType PixelType;
102 
105  typedef typename TImage::AccessorType AccessorType;
106 
109 
111  static unsigned int GetImageIteratorDimension()
112  {
113  return TImage::ImageDimension;
114  }
115 
118  {
119  return m_CurrentImageIndex;
120  }
121 
123  const PixelType Get(void) const
124  {
125  return m_Image->GetPixel(m_CurrentImageIndex);
126  }
127 
129  bool IsAtEnd()
130  {
131  return m_IsAtEnd;
132  }
133 
135  void GoToBegin();
136 
138  void operator++();
139 
142  Self & operator=(const Self & it);
143 
145  LineConstIterator(const ImageType *imagePtr, const IndexType & firstIndex, const IndexType & lastIndex);
146 
148  virtual ~LineConstIterator() {}
149 
150 protected: //made protected so other iterators can access
152  typename ImageType::ConstWeakPointer m_Image;
153 
156 
158  bool m_IsAtEnd;
159 
164  IndexType m_EndIndex; // one past the end of the line in the m_MainDirection
165 
167  // The dimension with the largest difference between start and end
168  unsigned int m_MainDirection;
169 
170  // Accumulated error for the other dimensions
172 
173  // Increment for the error for each step. Two times the difference between
174  // start and end
176 
177  // If enough is accumulated for a dimension, the index has to be
178  // incremented. Will be the number of pixels in the line
180 
181  // Direction of increment. -1 or 1
183 
184  // After an overflow, the accumulated error is reduced again. Will be
185  // two times the number of pixels in the line
187 };
188 } // end namespace itk
189 
190 #ifndef ITK_MANUAL_INSTANTIATION
191 #include "itkLineConstIterator.hxx"
192 #endif
193 
194 #endif
Self & operator=(const Self &it)
PixelContainer::Pointer PixelContainerPointer
TImage::RegionType RegionType
An iterator that walks a Bresenham line through an ND image with read-only access to pixels...
TImage::AccessorType AccessorType
TImage::OffsetType OffsetType
TImage::SpacingType SpacingType
static unsigned int GetImageIteratorDimension()
ImageType::ConstWeakPointer m_Image
TImage::IndexType IndexType
LineConstIterator(const ImageType *imagePtr, const IndexType &firstIndex, const IndexType &lastIndex)
itkTypeMacroNoParent(LineConstIterator)
TImage::InternalPixelType InternalPixelType
TImage::PixelContainer PixelContainer
const PixelType Get(void) const
TImage::PointType PointType
static const unsigned int ImageIteratorDimension