ITK  6.0.0
Insight Toolkit
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
25namespace itk
26{
94template <typename TImage>
95class ITK_TEMPLATE_EXPORT ImageConstIteratorWithOnlyIndex
96{
97public:
99
102
107 static constexpr unsigned int ImageDimension = TImage::ImageDimension;
108
110 using IndexType = typename TImage::IndexType;
112
114 using SizeType = typename TImage::SizeType;
116
119
121 using ImageType = TImage;
122
124 using OffsetType = typename TImage::OffsetType;
126
130
133 ImageConstIteratorWithOnlyIndex(const TImage * ptr, const RegionType & region);
134
137
139 static constexpr unsigned int
141 {
142 return ImageDimension;
143 }
144
147 bool
148 operator==(const Self & it) const
149 {
150 // two iterators are the same if they "point to" the same memory location
151 return (m_PositionIndex) == (it.m_PositionIndex);
152 }
153
155
158 bool
159 operator<=(const Self & it) const
160 {
161 // an iterator is "less than" another if it "points to" a lower
162 // memory location
163 return (m_PositionIndex) <= (it.m_PositionIndex);
164 }
165
168 bool
169 operator<(const Self & it) const
170 {
171 // an iterator is "less than" another if it "points to" a lower
172 // memory location
173 return (m_PositionIndex) < (it.m_PositionIndex);
174 }
175
178 bool
179 operator>=(const Self & it) const
180 {
181 // an iterator is "greater than" another if it "points to" a higher
182 // memory location
183 return (m_PositionIndex) >= (it.m_PositionIndex);
184 }
185
188 bool
189 operator>(const Self & it) const
190 {
191 // an iterator is "greater than" another if it "points to" a higher
192 // memory location
193 return (m_PositionIndex) > (it.m_PositionIndex);
194 }
195
198 const IndexType &
199 GetIndex() const
200 {
201 return m_PositionIndex;
202 }
203
206 const RegionType &
207 GetRegion() const
208 {
209 return m_Region;
210 }
211
214 void
215 SetIndex(const IndexType & ind)
216 {
217 m_PositionIndex = ind;
218 }
219
221 void
223
225 void
227
229 bool
231 {
232 return !m_Remaining;
233 }
234
236 bool
237 IsAtEnd() const
238 {
239 return !m_Remaining;
240 }
241
243 bool
245 {
246 return m_Remaining;
247 }
248
249protected: // made protected so other iterators can access
250 typename TImage::ConstPointer m_Image{};
251
252 IndexType m_PositionIndex{ { 0 } }; // Index where we currently are
253 IndexType m_BeginIndex{ { 0 } }; // Index to start iterating over
254 IndexType m_EndIndex{ { 0 } }; // Index to finish iterating:
255 // one pixel past the end of each
256 // row, col, slice, etc....
257
258 RegionType m_Region{}; // region to iterate over
259
260 OffsetValueType m_OffsetTable[ImageDimension + 1]{};
261
262 bool m_Remaining{ false };
263};
264} // end namespace itk
265
266#ifndef ITK_MANUAL_INSTANTIATION
267# include "itkImageConstIteratorWithOnlyIndex.hxx"
268#endif
269
270#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)
SmartPointer< const Self > ConstPointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
bool operator<=(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:571
long IndexValueType
Definition: itkIntTypes.h:93
unsigned long SizeValueType
Definition: itkIntTypes.h:86
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:557
long OffsetValueType
Definition: itkIntTypes.h:97