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
23namespace itk
24{
108template <typename TImage>
109class ITK_TEMPLATE_EXPORT ImageRegionConstIterator : public ImageConstIterator<TImage>
110{
111public:
115
121
126
128 using typename Superclass::IndexType;
129 using typename Superclass::SizeType;
130 using typename Superclass::OffsetType;
131 using typename Superclass::RegionType;
132 using typename Superclass::ImageType;
133 using typename Superclass::PixelContainer;
135 using typename Superclass::InternalPixelType;
136 using typename Superclass::PixelType;
137 using typename Superclass::AccessorType;
138
140 itkOverrideGetNameOfClassMacro(ImageRegionConstIterator);
141
146
149 ImageRegionConstIterator(const ImageType * ptr, const RegionType & region)
150 : ImageConstIterator<TImage>(ptr, region)
152 , m_SpanEndOffset(this->m_BeginOffset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]))
153 {}
154
162 {
164
165 IndexType ind = this->GetIndex();
166 m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
167 (ind[0] - this->m_Region.GetIndex()[0]);
168 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
169 }
170
178 {
180
181 IndexType ind = this->GetIndex();
182 m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
183 (ind[0] - this->m_Region.GetIndex()[0]);
184 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
185 }
186
189 void
191 {
193
194 // reset the span offsets
196 m_SpanEndOffset = this->m_BeginOffset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
197 }
198
201 void
203 {
205
206 // reset the span offsets
208 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
209 }
210
214 void
215 SetIndex(const IndexType & ind) override
216 {
218 m_SpanEndOffset = this->m_Offset + static_cast<OffsetValueType>(this->m_Region.GetSize()[0]) -
219 (ind[0] - this->m_Region.GetIndex()[0]);
220 m_SpanBeginOffset = m_SpanEndOffset - static_cast<OffsetValueType>(this->m_Region.GetSize()[0]);
221 }
222
230 Self &
232 {
233 if (++this->m_Offset >= m_SpanEndOffset)
234 {
235 this->Increment();
236 }
237 return *this;
238 }
239
247 Self &
249 {
250 if (--this->m_Offset < m_SpanBeginOffset)
251 {
252 this->Decrement();
253 }
254 return *this;
255 }
256
257protected:
258 OffsetValueType m_SpanBeginOffset{}; // one pixel before the beginning of the span
259 // (row)
260 OffsetValueType m_SpanEndOffset{}; // one pixel past the end of the span (row)
261
262private:
263 void
264 Increment(); // advance in a direction other than the fastest moving
265
266 void
267 Decrement(); // go back in a direction other than the fastest moving
268};
269} // end namespace itk
270
271#ifndef ITK_MANUAL_INSTANTIATION
272# include "itkImageRegionConstIterator.hxx"
273#endif
274
275#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.
ImageRegionConstIterator(const ImageConstIterator< TImage > &it)
typename ImageType::IndexType IndexType
void SetIndex(const IndexType &ind) override
ImageRegionConstIterator(const ImageType *ptr, const RegionType &region)
typename ImageType::RegionType RegionType
ImageRegionConstIterator(const ImageIterator< TImage > &it)
ImageConstIterator< TImage > Superclass
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
long OffsetValueType
Definition itkIntTypes.h:97