ITK  5.0.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 >
56 class ITK_TEMPLATE_EXPORT LineConstIterator
57 {
58 public:
59 
62 
67  static constexpr unsigned int ImageIteratorDimension = TImage::ImageDimension;
68 
70  using IndexType = typename TImage::IndexType;
71 
73  using OffsetType = typename TImage::OffsetType;
74 
76  using SizeType = typename TImage::SizeType;
77 
79  using RegionType = typename TImage::RegionType;
80 
82  using SpacingType = typename TImage::SpacingType;
83 
85  using PointType = typename TImage::PointType;
86 
88  using ImageType = TImage;
89 
93  using PixelContainer = typename TImage::PixelContainer;
94  using PixelContainerPointer = typename PixelContainer::Pointer;
95 
97  using InternalPixelType = typename TImage::InternalPixelType;
98 
100  using PixelType = typename TImage::PixelType;
101 
104  using AccessorType = typename TImage::AccessorType;
105 
107  itkTypeMacroNoParent(LineConstIterator);
108 
110  static unsigned int GetImageIteratorDimension()
111  {
112  return TImage::ImageDimension;
113  }
114 
117  {
118  return m_CurrentImageIndex;
119  }
120 
122  const PixelType Get() const
123  {
124  return m_Image->GetPixel(m_CurrentImageIndex);
125  }
126 
128  bool IsAtEnd() const
129  {
130  return m_IsAtEnd;
131  }
132 
134  void GoToBegin();
135 
137  void operator++();
138 
141  Self & operator=(const Self & it);
142 
144  LineConstIterator(const ImageType *imagePtr, const IndexType & firstIndex, const IndexType & lastIndex);
145 
147  virtual ~LineConstIterator() = default;
148 
149 protected: //made protected so other iterators can access
151  typename ImageType::ConstWeakPointer m_Image;
152 
155 
157  bool m_IsAtEnd;
158 
163  IndexType m_EndIndex; // one past the end of the line in the m_MainDirection
164 
166  // The dimension with the largest difference between start and end
167  unsigned int m_MainDirection;
168 
169  // Accumulated error for the other dimensions
171 
172  // Increment for the error for each step. Two times the difference between
173  // start and end
175 
176  // If enough is accumulated for a dimension, the index has to be
177  // incremented. Will be the number of pixels in the line
179 
180  // Direction of increment. -1 or 1
182 
183  // After an overflow, the accumulated error is reduced again. Will be
184  // two times the number of pixels in the line
186 };
187 } // end namespace itk
188 
189 #ifndef ITK_MANUAL_INSTANTIATION
190 #include "itkLineConstIterator.hxx"
191 #endif
192 
193 #endif
typename PixelContainer::Pointer PixelContainerPointer
typename TImage::PixelType PixelType
An iterator that walks a Bresenham line through an ND image with read-only access to pixels...
typename TImage::SpacingType SpacingType
typename TImage::PointType PointType
static unsigned int GetImageIteratorDimension()
ImageType::ConstWeakPointer m_Image
typename TImage::PixelContainer PixelContainer
typename TImage::OffsetType OffsetType
typename TImage::IndexType IndexType
typename TImage::RegionType RegionType
typename TImage::InternalPixelType InternalPixelType
typename TImage::SizeType SizeType
const PixelType Get() const
typename TImage::AccessorType AccessorType