ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkRLEImageScanlineConstIterator.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 itkRLEImageScanlineConstIterator_h
19#define itkRLEImageScanlineConstIterator_h
20
23
24namespace itk
25{
33template <typename TPixel, unsigned int VImageDimension, typename CounterType>
34class ImageScanlineConstIterator<RLEImage<TPixel, VImageDimension, CounterType>>
35 : public ImageRegionConstIterator<RLEImage<TPixel, VImageDimension, CounterType>>
36{
37public:
41
46 static constexpr unsigned int ImageIteratorDimension = VImageDimension;
47
53 using IndexType = typename Superclass::IndexType;
54 using SizeType = typename Superclass::SizeType;
55 using OffsetType = typename Superclass::OffsetType;
56 using RegionType = typename Superclass::RegionType;
57 using ImageType = typename Superclass::ImageType;
59 using PixelType = typename Superclass::PixelType;
60
62 itkOverrideGetNameOfClassMacro(ImageScanlineConstIterator);
63
67 {}
68
71 ImageScanlineConstIterator(const ImageType * ptr, const RegionType & region)
73 {}
74
83 {}
84
92 {
94 }
95
97 void
99 {
100 this->m_Index0 = this->m_BeginIndex0;
101 this->m_RealIndex = 0;
102 this->m_SegmentRemainder = (*this->m_RunLengthLine)[this->m_RealIndex].first;
103 }
104
106 void
108 {
109 this->m_Index0 = this->m_EndIndex0;
110 this->m_RealIndex = this->m_RunLengthLine->size() - 1;
111 this->m_SegmentRemainder = 0;
112 }
113
115 bool
117 {
118 return this->m_Index0 == this->m_EndIndex0;
119 }
120
122 void
123 NextLine()
124 {
125 ++(this->m_BI);
126 if (!this->m_BI.IsAtEnd())
127 {
128 this->SetIndexInternal(this->m_BeginIndex0);
129 }
130 else
131 {
132 this->m_Index0 = this->m_BeginIndex0; // make this iterator at end too
133 }
134 }
135
143 Self &
144 operator++()
145 {
146 itkAssertInDebugAndIgnoreInReleaseMacro(!this->IsAtEndOfLine());
147 this->m_Index0++;
148 this->m_SegmentRemainder--;
149 if (this->m_SegmentRemainder > 0)
150 {
151 return *this;
152 }
153
154 if (this->IsAtEndOfLine())
155 {
156 return *this;
157 }
158 this->m_RealIndex++;
159 this->m_SegmentRemainder = (*this->m_RunLengthLine)[this->m_RealIndex].first;
160 return *this;
161 } // ++
162
166 Self &
167 operator--()
168 {
169 this->m_Index0--;
170 this->m_SegmentRemainder++;
171 if (this->m_SegmentRemainder <= (*this->m_RunLengthLine)[this->m_RealIndex].first)
172 {
173 return *this;
174 }
175
176 this->m_RealIndex--;
177 this->m_SegmentRemainder = 1;
178 return *this;
179 }
180};
181
182// Deduction guide for class template argument deduction (CTAD).
183template <typename TPixel, unsigned int VImageDimension, typename CounterType>
187
188template <typename TPixel, unsigned int VImageDimension, typename CounterType>
192
193} // end namespace itk
194
195#endif // itkRLEImageScanlineConstIterator_h
Self & operator=(const Self &)=default
detail::IteratorImageType_t< TImage > ImageType
static constexpr unsigned int ImageIteratorDimension
typename TImage::OffsetType OffsetType
typename TImage::InternalPixelType InternalPixelType
typename TImage::IndexType IndexType
typename TImage::SizeType SizeType
typename TImage::RegionType RegionType
friend class ImageIterator
typename TImage::PixelType PixelType
Read-only ImageRegionIterator: ImageRegionConstIterator<TImage> behaves as ImageRegionIterator<const ...
Read-only ImageScanlineIterator: ImageScanlineConstIterator<TImage> behaves as ImageScanlineIterator<...
ImageScanlineIterator< std::add_const_t< TImage > > Superclass
detail::IteratorImageType_t< TImage > ImageType
typename TImage::InternalPixelType InternalPixelType
Run-Length Encoded image. It saves memory for label images at the expense of processing times....
Definition itkRLEImage.h:53
typename Superclass::RegionType RegionType
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ImageScanlineConstIterator(const TImage *, const typename TImage::RegionType &) -> ImageScanlineConstIterator< TImage >
ImageConstIterator(const TImage *, const typename TImage::RegionType &) -> ImageConstIterator< TImage >
ImageRegionConstIterator(const TImage *, const typename TImage::RegionType &) -> ImageRegionConstIterator< TImage >