ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkImageConstIteratorWithOnlyIndex.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 
25 namespace itk
26 {
94 template< typename TImage >
95 class ITK_TEMPLATE_EXPORT ImageConstIteratorWithOnlyIndex
96 {
97 public:
100 
105  static constexpr unsigned int ImageDimension = TImage::ImageDimension;
106 
108  using IndexType = typename TImage::IndexType;
110 
112  using SizeType = typename TImage::SizeType;
114 
116  using RegionType = typename TImage::RegionType;
117 
119  using ImageType = TImage;
120 
122  using OffsetType = typename TImage::OffsetType;
124 
128 
132 
135  ImageConstIteratorWithOnlyIndex(const TImage *ptr,const RegionType & region);
136 
138  virtual ~ImageConstIteratorWithOnlyIndex() = default;
139 
142  Self & operator=(const Self & it);
143 
145  static unsigned int GetImageDimension()
146  {
147  return ImageDimension;
148  }
149 
152  bool
153  operator!=(const Self & it) const
154  {
155  // two iterators are the same if they "point to" the same memory location
156  return ( m_PositionIndex ) != ( it.m_PositionIndex );
157  }
158 
161  bool
162  operator==(const Self & it) const
163  {
164  // two iterators are the same if they "point to" the same memory location
165  return ( m_PositionIndex ) == ( it.m_PositionIndex );
166  }
167 
170  bool
171  operator<=(const Self & it) const
172  {
173  // an iterator is "less than" another if it "points to" a lower
174  // memory location
175  return ( m_PositionIndex ) <= ( it.m_PositionIndex );
176  }
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_PositionIndex ) < ( it.m_PositionIndex );
186  }
187 
190  bool
191  operator>=(const Self & it) const
192  {
193  // an iterator is "greater than" another if it "points to" a higher
194  // memory location
195  return ( m_PositionIndex ) >= ( it.m_PositionIndex );
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_PositionIndex ) > ( it.m_PositionIndex );
206  }
207 
210  const IndexType & GetIndex() const
211  {
212  return m_PositionIndex;
213  }
214 
217  const RegionType & GetRegion() const
218  {
219  return m_Region;
220  }
221 
224  void SetIndex(const IndexType & ind)
225  {
226  m_PositionIndex = ind;
227  }
228 
230  void GoToBegin();
231 
233  void GoToReverseBegin();
234 
236  bool IsAtReverseEnd() const
237  {
238  return !m_Remaining;
239  }
240 
242  bool IsAtEnd() const
243  {
244  return !m_Remaining;
245  }
246 
248  bool Remaining()
249  {
250  return m_Remaining;
251  }
252 
253 protected: //made protected so other iterators can access
254  typename TImage::ConstPointer m_Image;
255 
256  IndexType m_PositionIndex; // Index where we currently are
257  IndexType m_BeginIndex; // Index to start iterating over
258  IndexType m_EndIndex; // Index to finish iterating:
259  // one pixel past the end of each
260  // row, col, slice, etc....
261 
262  RegionType m_Region; // region to iterate over
263 
264  OffsetValueType m_OffsetTable[ImageDimension + 1];
265 
267 
268 };
269 } // end namespace itk
270 
271 #ifndef ITK_MANUAL_INSTANTIATION
272 #include "itkImageConstIteratorWithOnlyIndex.hxx"
273 #endif
274 
275 #endif
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename OffsetType::OffsetValueType OffsetValueType
bool operator<=(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:514
A base class for multi-dimensional iterators templated over image type that are designed to provide o...
signed long IndexValueType
Definition: itkIntTypes.h:90
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:499
signed long OffsetValueType
Definition: itkIntTypes.h:94