ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkImageConstIteratorWithIndex.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 itkImageConstIteratorWithIndex_h
19#define itkImageConstIteratorWithIndex_h
20
21#include "itkIndex.h"
22#include "itkImage.h"
23#include <memory>
24#include <type_traits> // For remove_const_t.
25
26namespace itk
27{
92template <typename TImage>
93class ITK_TEMPLATE_EXPORT ImageConstIteratorWithIndex
95public:
98
103 static constexpr unsigned int ImageDimension = TImage::ImageDimension;
104
106 using IndexType = typename TImage::IndexType;
107 using IndexValueType = typename IndexType::IndexValueType;
108
110 using SizeType = typename TImage::SizeType;
111 using SizeValueType = typename SizeType::SizeValueType;
112
114 using RegionType = typename TImage::RegionType;
115
117 using ImageType = TImage;
118
122 using PixelContainer = typename TImage::PixelContainer;
123 using PixelContainerPointer = typename PixelContainer::Pointer;
126 using InternalPixelType = typename TImage::InternalPixelType;
129 using PixelType = typename TImage::PixelType;
133 using AccessorType = typename TImage::AccessorType;
134 using AccessorFunctorType = typename TImage::AccessorFunctorType;
137 using OffsetType = typename TImage::OffsetType;
138 using OffsetValueType = typename OffsetType::OffsetValueType;
139
150 ImageConstIteratorWithIndex(const TImage * ptr, const RegionType & region);
153 virtual ~ImageConstIteratorWithIndex() = default;
154
157 Self &
158 operator=(const Self & it);
159
161 static constexpr unsigned int
163 {
164 return ImageDimension;
165 }
166
169 bool
170 operator==(const Self & it) const
171 {
172 // two iterators are the same if they "point to" the same memory location
173 return (m_Position) == (it.m_Position);
174 }
175
177
180 bool
181 operator<=(const Self & it) const
182 {
183 // an iterator is "less than" another if it "points to" a lower
184 // memory location
185 return (m_Position) <= (it.m_Position);
186 }
187
190 bool
191 operator<(const Self & it) const
192 {
193 // an iterator is "less than" another if it "points to" a lower
194 // memory location
195 return (m_Position) < (it.m_Position);
196 }
197
200 bool
201 operator>=(const Self & it) const
202 {
203 // an iterator is "greater than" another if it "points to" a higher
204 // memory location
205 return (m_Position) >= (it.m_Position);
206 }
207
210 bool
211 operator>(const Self & it) const
212 {
213 // an iterator is "greater than" another if it "points to" a higher
214 // memory location
215 return (m_Position) > (it.m_Position);
216 }
217
220 [[nodiscard]] const IndexType &
228 [[nodiscard]] const RegionType &
229 GetRegion() const
230 {
231 return m_Region;
232 }
233
236 void
237 SetIndex(const IndexType & ind)
238 {
239 m_Position = m_Image->GetBufferPointer() + m_Image->ComputeOffset(ind);
240 m_PositionIndex = ind;
241 }
242
244 [[nodiscard]] PixelType
245 Get() const
246 {
248 }
249
253 [[nodiscard]] const PixelType &
254 Value() const
255 {
256 return *m_Position;
257 }
258
260 void
262
264 void
266
268 [[nodiscard]] bool
270 {
271 return !m_Remaining;
272 }
273
275 [[nodiscard]] bool
276 IsAtEnd() const
277 {
278 return !m_Remaining;
279 }
280
282 bool
284 {
285 return m_Remaining;
286 }
287
288protected: // made protected so other iterators can access
289 typename TImage::ConstWeakPointer m_Image{};
290
291 IndexType m_PositionIndex{ { 0 } }; // Index where we currently are
292 IndexType m_BeginIndex{ { 0 } }; // Index to start iterating over
293 IndexType m_EndIndex{ { 0 } }; // Index to finish iterating:
294 // one pixel past the end of each
295 // row, col, slice, etc....
296
297 RegionType m_Region{}; // region to iterate over
298
300
301 const InternalPixelType * m_Position{ nullptr };
302 const InternalPixelType * m_Begin{ nullptr };
303 const InternalPixelType * m_End{ nullptr };
304
305 bool m_Remaining{ false };
306
309};
310
311// Deduction guide for class template argument deduction (CTAD).
312template <typename TImage>
313ImageConstIteratorWithIndex(SmartPointer<TImage>, const typename TImage::RegionType &)
315
316} // end namespace itk
317
318#ifndef ITK_MANUAL_INSTANTIATION
319# include "itkImageConstIteratorWithIndex.hxx"
320#endif
321
322#endif
A base class for multi-dimensional iterators templated over image type that are designed to efficient...
typename TImage::AccessorFunctorType AccessorFunctorType
typename OffsetType::OffsetValueType OffsetValueType
Self & operator=(const Self &it)
ImageConstIteratorWithIndex(const TImage *ptr, const RegionType &region)
typename SizeType::SizeValueType SizeValueType
static constexpr unsigned int GetImageDimension()
ImageConstIteratorWithIndex(const Self &it)
OffsetValueType m_OffsetTable[ImageDimension+1]
typename IndexType::IndexValueType IndexValueType
typename PixelContainer::Pointer PixelContainerPointer
typename TImage::InternalPixelType InternalPixelType
typename TImage::InternalPixelType InternalPixelType
typename TImage::PixelContainer PixelContainer
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ImageConstIteratorWithIndex(SmartPointer< TImage >, const typename TImage::RegionType &) -> ImageConstIteratorWithIndex< std::remove_const_t< TImage > >
long OffsetValueType
Definition itkIntTypes.h:97