ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkImageScanlineConstIterator.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 itkImageScanlineConstIterator_h
19#define itkImageScanlineConstIterator_h
20
21#include "itkImageIterator.h"
22#include <type_traits> // For remove_const_t.
23
24namespace itk
25{
63template <typename TImage>
64class ITK_TEMPLATE_EXPORT ImageScanlineConstIterator : public ImageConstIterator<TImage>
65{
66public:
70
76
81
83 using typename Superclass::IndexType;
84 using typename Superclass::SizeType;
85 using typename Superclass::OffsetType;
86 using typename Superclass::RegionType;
87 using typename Superclass::ImageType;
88 using typename Superclass::PixelContainer;
90 using typename Superclass::InternalPixelType;
91 using typename Superclass::PixelType;
92 using typename Superclass::AccessorType;
93
95 itkOverrideGetNameOfClassMacro(ImageScanlineConstIterator);
96
101
104 ImageScanlineConstIterator(const TImage * ptr, const RegionType & region)
105 : ImageConstIterator<TImage>(ptr, region)
107 , m_SpanEndOffset(this->m_BeginOffset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]))
108 {}
109
117 {
119
120 IndexType ind = this->GetIndex();
121 m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
122 (ind[0] - this->m_Region.GetIndex()[0]);
123 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
124 }
125
133 {
135
136 IndexType ind = this->GetIndex();
137 m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
138 (ind[0] - this->m_Region.GetIndex()[0]);
139 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
140 }
141
144 void
146 {
148
149 // reset the span offsets
151 m_SpanEndOffset = this->m_BeginOffset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
152 }
153
159 void
161 {
163
164 // reset the span offsets
166 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
167 }
168
176 void
178 {
180 }
181
190 void
192 {
194 }
195
198 [[nodiscard]] inline bool
200 {
201 return this->m_Offset >= m_SpanEndOffset;
202 }
203
204
210 void
211 SetIndex(const IndexType & ind) override
212 {
214 m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
215 (ind[0] - this->m_Region.GetIndex()[0]);
216 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
217 }
218
227 void
229
237 Self &
239 {
240 itkAssertInDebugAndIgnoreInReleaseMacro(!this->IsAtEndOfLine());
241 ++this->m_Offset;
242 return *this;
243 }
244
248 Self &
250 {
251 itkAssertInDebugAndIgnoreInReleaseMacro(!this->IsAtEndOfLine());
252 --this->m_Offset;
253 return *this;
254 }
255
256protected:
257 OffsetValueType m_SpanBeginOffset{}; // one pixel the beginning of the scanline
258 OffsetValueType m_SpanEndOffset{}; // one pixel past the end of the scanline
259};
260
261// Deduction guide for class template argument deduction (CTAD).
262template <typename TImage>
263ImageScanlineConstIterator(SmartPointer<TImage>, const typename TImage::RegionType &)
265
266} // end namespace itk
267
268#ifndef ITK_MANUAL_INSTANTIATION
269# include "itkImageScanlineConstIterator.hxx"
270#endif
271
272#endif
typename TImage::IndexType IndexType
typename TImage::PixelContainer PixelContainer
virtual void SetIndex(const IndexType &ind)
typename TImage::SizeType SizeType
typename TImage::OffsetType OffsetType
const IndexType GetIndex() const
typename TImage::InternalPixelType InternalPixelType
typename PixelContainer::Pointer PixelContainerPointer
typename TImage::AccessorType AccessorType
typename TImage::RegionType RegionType
Self & operator=(const Self &it)
typename TImage::PixelType PixelType
static constexpr unsigned int ImageIteratorDimension
A multi-dimensional iterator templated over image type.
A multi-dimensional iterator templated over image type that walks a region of pixels,...
typename InputImageType::IndexType IndexType
ImageScanlineConstIterator(const ImageConstIterator< TImage > &it)
typename InputImageType::RegionType RegionType
ImageScanlineConstIterator(const ImageIterator< TImage > &it)
ImageScanlineConstIterator(const TImage *ptr, const RegionType &region)
void SetIndex(const IndexType &ind) override
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ImageScanlineConstIterator(SmartPointer< TImage >, const typename TImage::RegionType &) -> ImageScanlineConstIterator< std::remove_const_t< TImage > >
long OffsetValueType
Definition itkIntTypes.h:97