ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkImageConstIteratorWithOnlyIndex.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 itkImageConstIteratorWithOnlyIndex_h
19#define itkImageConstIteratorWithOnlyIndex_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{
95template <typename TImage>
96class ITK_TEMPLATE_EXPORT ImageConstIteratorWithOnlyIndex
97{
98public:
100
103
108 static constexpr unsigned int ImageDimension = TImage::ImageDimension;
109
111 using IndexType = typename TImage::IndexType;
112 using IndexValueType = typename IndexType::IndexValueType;
113
115 using SizeType = typename TImage::SizeType;
116 using SizeValueType = typename SizeType::SizeValueType;
117
119 using RegionType = typename TImage::RegionType;
120
122 using ImageType = TImage;
123
125 using OffsetType = typename TImage::OffsetType;
126 using OffsetValueType = typename OffsetType::OffsetValueType;
127
131
134 ImageConstIteratorWithOnlyIndex(const TImage * ptr, const RegionType & region);
135
138
140 static constexpr unsigned int
142 {
143 return ImageDimension;
144 }
145
148 bool
149 operator==(const Self & it) const
150 {
151 // two iterators are the same if they "point to" the same memory location
152 return (m_PositionIndex) == (it.m_PositionIndex);
153 }
154
156
159 bool
160 operator<=(const Self & it) const
161 {
162 // an iterator is "less than" another if it "points to" a lower
163 // memory location
164 return (m_PositionIndex) <= (it.m_PositionIndex);
165 }
166
169 bool
170 operator<(const Self & it) const
171 {
172 // an iterator is "less than" another if it "points to" a lower
173 // memory location
174 return (m_PositionIndex) < (it.m_PositionIndex);
175 }
176
179 bool
180 operator>=(const Self & it) const
181 {
182 // an iterator is "greater than" another if it "points to" a higher
183 // memory location
184 return (m_PositionIndex) >= (it.m_PositionIndex);
185 }
186
189 bool
190 operator>(const Self & it) const
191 {
192 // an iterator is "greater than" another if it "points to" a higher
193 // memory location
194 return (m_PositionIndex) > (it.m_PositionIndex);
195 }
196
199 [[nodiscard]] const IndexType &
200 GetIndex() const
201 {
202 return m_PositionIndex;
203 }
204
207 [[nodiscard]] const RegionType &
208 GetRegion() const
209 {
210 return m_Region;
211 }
212
215 void
216 SetIndex(const IndexType & ind)
217 {
218 m_PositionIndex = ind;
219 }
220
222 void
224
226 void
228
230 [[nodiscard]] bool
232 {
233 return !m_Remaining;
234 }
235
237 [[nodiscard]] bool
238 IsAtEnd() const
239 {
240 return !m_Remaining;
241 }
242
244 bool
246 {
247 return m_Remaining;
248 }
249
250protected: // made protected so other iterators can access
251 IndexType m_PositionIndex{ { 0 } }; // Index where we currently are
252 IndexType m_BeginIndex{ { 0 } }; // Index to start iterating over
253 IndexType m_EndIndex{ { 0 } }; // Index to finish iterating:
254 // one pixel past the end of each
255 // row, col, slice, etc....
256
257 RegionType m_Region{}; // region to iterate over
258
259 bool m_Remaining{ false };
260};
261
262// Deduction guide for class template argument deduction (CTAD).
263template <typename TImage>
264ImageConstIteratorWithOnlyIndex(SmartPointer<TImage>, const typename TImage::RegionType &)
266
267} // end namespace itk
268
269#ifndef ITK_MANUAL_INSTANTIATION
270# include "itkImageConstIteratorWithOnlyIndex.hxx"
271#endif
272
273#endif
A base class for multi-dimensional iterators templated over image type that are designed to provide o...
ImageConstIteratorWithOnlyIndex(const TImage *ptr, const RegionType &region)
virtual ~ImageConstIteratorWithOnlyIndex()=default
typename OffsetType::OffsetValueType OffsetValueType
ITK_DEFAULT_COPY_AND_MOVE(ImageConstIteratorWithOnlyIndex)
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ImageConstIteratorWithOnlyIndex(SmartPointer< TImage >, const typename TImage::RegionType &) -> ImageConstIteratorWithOnlyIndex< std::remove_const_t< TImage > >