ITK  5.4.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:
100
105 static constexpr unsigned int ImageDimension = TImage::ImageDimension;
106
108 using IndexType = typename TImage::IndexType;
110
112 using SizeType = typename TImage::SizeType;
114
117
119 using ImageType = TImage;
120
122 using OffsetType = typename TImage::OffsetType;
124
128
132
135 ImageConstIteratorWithOnlyIndex(const TImage * ptr, const RegionType & region);
136
139
142 Self &
143 operator=(const Self & it);
144
146 static unsigned int
148 {
149 return ImageDimension;
150 }
151
154 bool
155 operator==(const Self & it) const
156 {
157 // two iterators are the same if they "point to" the same memory location
158 return (m_PositionIndex) == (it.m_PositionIndex);
159 }
160
162
165 bool
166 operator<=(const Self & it) const
167 {
168 // an iterator is "less than" another if it "points to" a lower
169 // memory location
170 return (m_PositionIndex) <= (it.m_PositionIndex);
171 }
172
175 bool
176 operator<(const Self & it) const
177 {
178 // an iterator is "less than" another if it "points to" a lower
179 // memory location
180 return (m_PositionIndex) < (it.m_PositionIndex);
181 }
182
185 bool
186 operator>=(const Self & it) const
187 {
188 // an iterator is "greater than" another if it "points to" a higher
189 // memory location
190 return (m_PositionIndex) >= (it.m_PositionIndex);
191 }
192
195 bool
196 operator>(const Self & it) const
197 {
198 // an iterator is "greater than" another if it "points to" a higher
199 // memory location
200 return (m_PositionIndex) > (it.m_PositionIndex);
201 }
202
205 const IndexType &
206 GetIndex() const
207 {
208 return m_PositionIndex;
209 }
210
213 const RegionType &
214 GetRegion() const
215 {
216 return m_Region;
217 }
218
221 void
222 SetIndex(const IndexType & ind)
223 {
224 m_PositionIndex = ind;
225 }
226
228 void
230
232 void
234
236 bool
238 {
239 return !m_Remaining;
240 }
241
243 bool
244 IsAtEnd() const
245 {
246 return !m_Remaining;
247 }
248
250 bool
252 {
253 return m_Remaining;
254 }
255
256protected: // made protected so other iterators can access
257 typename TImage::ConstPointer m_Image{};
258
259 IndexType m_PositionIndex{ { 0 } }; // Index where we currently are
260 IndexType m_BeginIndex{ { 0 } }; // Index to start iterating over
261 IndexType m_EndIndex{ { 0 } }; // Index to finish iterating:
262 // one pixel past the end of each
263 // row, col, slice, etc....
264
265 RegionType m_Region{}; // region to iterate over
266
267 OffsetValueType m_OffsetTable[ImageDimension + 1]{};
268
269 bool m_Remaining{ false };
270};
271} // end namespace itk
272
273#ifndef ITK_MANUAL_INSTANTIATION
274# include "itkImageConstIteratorWithOnlyIndex.hxx"
275#endif
276
277#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)
ImageConstIteratorWithOnlyIndex(const Self &it)
virtual ~ImageConstIteratorWithOnlyIndex()=default
typename OffsetType::OffsetValueType OffsetValueType
Self & operator=(const Self &it)
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:573
long IndexValueType
Definition: itkIntTypes.h:90
unsigned long SizeValueType
Definition: itkIntTypes.h:83
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:559
long OffsetValueType
Definition: itkIntTypes.h:94