ITK  4.9.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 >
96 {
97 public:
100 
105  itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
106 
108  typedef typename TImage::IndexType IndexType;
110 
112  typedef typename TImage::SizeType SizeType;
114 
116  typedef typename TImage::RegionType RegionType;
117 
119  typedef TImage ImageType;
120 
122  typedef typename TImage::OffsetType OffsetType;
124 
128 
132 
135  ImageConstIteratorWithOnlyIndex(const TImage *ptr,const RegionType & region);
136 
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 
231  itkLegacyMacro(Self Begin(void) const);
232 
234  void GoToBegin();
235 
238  itkLegacyMacro(Self End(void) const);
239 
241  void GoToReverseBegin();
242 
244  bool IsAtReverseEnd(void) const
245  {
246  return !m_Remaining;
247  }
248 
250  bool IsAtEnd(void) const
251  {
252  return !m_Remaining;
253  }
254 
256  bool Remaining()
257  {
258  return m_Remaining;
259  }
260 
261 protected: //made protected so other iterators can access
262  typename TImage::ConstPointer m_Image;
263 
264  IndexType m_PositionIndex; // Index where we currently are
265  IndexType m_BeginIndex; // Index to start iterating over
266  IndexType m_EndIndex; // Index to finish iterating:
267  // one pixel past the end of each
268  // row, col, slice, etc....
269 
270  RegionType m_Region; // region to iterate over
271 
273 
275 
276 };
277 } // end namespace itk
278 
279 #ifndef ITK_MANUAL_INSTANTIATION
280 #include "itkImageConstIteratorWithOnlyIndex.hxx"
281 #endif
282 
283 #endif
Self & operator=(const Self &it)
signed long OffsetValueType
Definition: itkIntTypes.h:154
itkLegacyMacro(Self Begin(void) const)
signed long IndexValueType
Definition: itkIntTypes.h:150
unsigned long SizeValueType
Definition: itkIntTypes.h:143
A base class for multi-dimensional iterators templated over image type that are designed to provide o...