ITK  6.0.0
Insight Toolkit
itkLineConstIterator.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
24namespace itk
25{
55template <typename TImage>
56class ITK_TEMPLATE_EXPORT LineConstIterator
57{
58public:
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
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;
95
97 using InternalPixelType = typename TImage::InternalPixelType;
98
100 using PixelType = typename TImage::PixelType;
101
104 using AccessorType = typename TImage::AccessorType;
105
107 itkVirtualGetNameOfClassMacro(LineConstIterator);
108
110 static unsigned int
112 {
113 return TImage::ImageDimension;
114 }
115
117 const IndexType
119 {
120 return m_CurrentImageIndex;
121 }
122
124 const PixelType
125 Get() const
126 {
127 return m_Image->GetPixel(m_CurrentImageIndex);
128 }
129
131 bool
132 IsAtEnd() const
133 {
134 return m_IsAtEnd;
135 }
136
138 void
140
142 void
144
147 Self &
148 operator=(const Self & it);
149
151 LineConstIterator(const ImageType * imagePtr, const IndexType & firstIndex, const IndexType & lastIndex);
152
154 virtual ~LineConstIterator() = default;
155
156protected: // made protected so other iterators can access
158 typename ImageType::ConstWeakPointer m_Image{};
159
161 RegionType m_Region{};
162
164 bool m_IsAtEnd{};
165
167 IndexType m_CurrentImageIndex{};
168 IndexType m_StartIndex{};
169 IndexType m_LastIndex{};
170 IndexType m_EndIndex{}; // one past the end of the line in the m_MainDirection
171
173 // The dimension with the largest difference between start and end
174 unsigned int m_MainDirection{};
175
176 // Accumulated error for the other dimensions
177 IndexType m_AccumulateError{};
178
179 // Increment for the error for each step. Two times the difference between
180 // start and end
181 IndexType m_IncrementError{};
182
183 // If enough is accumulated for a dimension, the index has to be
184 // incremented. Will be the number of pixels in the line
185 IndexType m_MaximalError{};
186
187 // Direction of increment. -1 or 1
188 IndexType m_OverflowIncrement{};
189
190 // After an overflow, the accumulated error is reduced again. Will be
191 // two times the number of pixels in the line
192 IndexType m_ReduceErrorAfterIncrement{};
193};
194} // end namespace itk
195
196#ifndef ITK_MANUAL_INSTANTIATION
197# include "itkLineConstIterator.hxx"
198#endif
199
200#endif
An iterator that walks a Bresenham line through an ND image with read-only access to pixels.
typename TImage::PixelType PixelType
typename TImage::SpacingType SpacingType
virtual ~LineConstIterator()=default
typename TImage::IndexType IndexType
typename PixelContainer::Pointer PixelContainerPointer
Self & operator=(const Self &it)
typename TImage::InternalPixelType InternalPixelType
LineConstIterator(const ImageType *imagePtr, const IndexType &firstIndex, const IndexType &lastIndex)
typename TImage::OffsetType OffsetType
typename TImage::SizeType SizeType
typename TImage::RegionType RegionType
typename TImage::PixelContainer PixelContainer
static unsigned int GetImageIteratorDimension()
typename TImage::PointType PointType
const PixelType Get() const
typename TImage::AccessorType AccessorType
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....