ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkImageRegionConstIterator.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 itkImageRegionConstIterator_h
19#define itkImageRegionConstIterator_h
20
21#include "itkImageIterator.h"
22#include <type_traits> // For remove_const_t.
23
24namespace itk
25{
109template <typename TImage>
110class ITK_TEMPLATE_EXPORT ImageRegionConstIterator : public ImageConstIterator<TImage>
111{
112public:
116
122
127
129 using typename Superclass::IndexType;
130 using typename Superclass::SizeType;
131 using typename Superclass::OffsetType;
132 using typename Superclass::RegionType;
133 using typename Superclass::ImageType;
134 using typename Superclass::PixelContainer;
136 using typename Superclass::InternalPixelType;
137 using typename Superclass::PixelType;
138 using typename Superclass::AccessorType;
139
141 itkOverrideGetNameOfClassMacro(ImageRegionConstIterator);
142
147
150 ImageRegionConstIterator(const TImage * ptr, const RegionType & region)
151 : ImageConstIterator<TImage>(ptr, region)
153 , m_SpanEndOffset(this->m_BeginOffset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]))
154 {}
155
163 {
165
166 IndexType ind = this->GetIndex();
167 m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
168 (ind[0] - this->m_Region.GetIndex()[0]);
169 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
170 }
171
179 {
181
182 IndexType ind = this->GetIndex();
183 m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
184 (ind[0] - this->m_Region.GetIndex()[0]);
185 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
186 }
187
190 void
192 {
194
195 // reset the span offsets
197 m_SpanEndOffset = this->m_BeginOffset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
198 }
199
202 void
204 {
206
207 // reset the span offsets
209 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
210 }
211
215 void
216 SetIndex(const IndexType & ind) override
217 {
219 m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
220 (ind[0] - this->m_Region.GetIndex()[0]);
221 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
222 }
223
231 Self &
233 {
234 if (++this->m_Offset >= m_SpanEndOffset)
235 {
236 this->Increment();
237 }
238 return *this;
239 }
240
248 Self &
250 {
251 if (--this->m_Offset < m_SpanBeginOffset)
252 {
253 this->Decrement();
254 }
255 return *this;
256 }
257
258protected:
259 OffsetValueType m_SpanBeginOffset{}; // one pixel before the beginning of the span
260 // (row)
261 OffsetValueType m_SpanEndOffset{}; // one pixel past the end of the span (row)
262
263private:
264 void
265 Increment(); // advance in a direction other than the fastest moving
266
267 void
268 Decrement(); // go back in a direction other than the fastest moving
269};
270
271// Deduction guide for class template argument deduction (CTAD).
272template <typename TImage>
273ImageRegionConstIterator(SmartPointer<TImage>, const typename TImage::RegionType &)
275
276} // end namespace itk
277
278#ifndef ITK_MANUAL_INSTANTIATION
279# include "itkImageRegionConstIterator.hxx"
280#endif
281
282#endif
typename TImage::IndexType IndexType
typename TImage::PixelContainer PixelContainer
virtual void SetIndex(const IndexType &ind)
typename TImage::SizeType SizeType
typename TImage::OffsetType OffsetType
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.
ImageRegionConstIterator(const ImageConstIterator< TImage > &it)
typename ImageType::IndexType IndexType
ImageRegionConstIterator(const TImage *ptr, const RegionType &region)
void SetIndex(const IndexType &ind) override
typename ImageType::RegionType RegionType
ImageRegionConstIterator(const ImageIterator< TImage > &it)
ImageConstIterator< TImage > Superclass
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
long OffsetValueType
Definition itkIntTypes.h:97
ImageRegionConstIterator(SmartPointer< TImage >, const typename TImage::RegionType &) -> ImageRegionConstIterator< std::remove_const_t< TImage > >