Orfeo Toolbox  4.0
itkImageConstIteratorWithIndex.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 __itkImageConstIteratorWithIndex_h
19 #define __itkImageConstIteratorWithIndex_h
20 
21 #include "itkIndex.h"
22 #include "itkImage.h"
23 #include <memory>
24 
25 namespace itk
26 {
91 template< typename TImage >
93 {
94 public:
97 
102  itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
103 
105  typedef typename TImage::IndexType IndexType;
107 
109  typedef typename TImage::SizeType SizeType;
111 
113  typedef typename TImage::RegionType RegionType;
114 
116  typedef TImage ImageType;
117 
121  typedef typename TImage::PixelContainer PixelContainer;
122  typedef typename PixelContainer::Pointer PixelContainerPointer;
123 
125  typedef typename TImage::InternalPixelType InternalPixelType;
126 
128  typedef typename TImage::PixelType PixelType;
129 
132  typedef typename TImage::AccessorType AccessorType;
133  typedef typename TImage::AccessorFunctorType AccessorFunctorType;
134 
136  typedef typename TImage::OffsetType OffsetType;
138 
142 
145  ImageConstIteratorWithIndex(const Self & it);
146 
149  ImageConstIteratorWithIndex(const TImage *ptr,
150  const RegionType & region);
151 
154 
157  Self & operator=(const Self & it);
158 
160  static unsigned int GetImageDimension()
161  {
162  return ImageDimension;
163  }
164 
167  bool
168  operator!=(const Self & it) const
169  {
170  // two iterators are the same if they "point to" the same memory location
171  return ( m_Position ) != ( it.m_Position );
172  }
173 
176  bool
177  operator==(const Self & it) const
178  {
179  // two iterators are the same if they "point to" the same memory location
180  return ( m_Position ) == ( it.m_Position );
181  }
182 
185  bool
186  operator<=(const Self & it) const
187  {
188  // an iterator is "less than" another if it "points to" a lower
189  // memory location
190  return ( m_Position ) <= ( it.m_Position );
191  }
192 
195  bool
196  operator<(const Self & it) const
197  {
198  // an iterator is "less than" another if it "points to" a lower
199  // memory location
200  return ( m_Position ) < ( it.m_Position );
201  }
202 
205  bool
206  operator>=(const Self & it) const
207  {
208  // an iterator is "greater than" another if it "points to" a higher
209  // memory location
210  return ( m_Position ) >= ( it.m_Position );
211  }
212 
215  bool
216  operator>(const Self & it) const
217  {
218  // an iterator is "greater than" another if it "points to" a higher
219  // memory location
220  return ( m_Position ) > ( it.m_Position );
221  }
222 
225  const IndexType & GetIndex() const
226  {
227  return m_PositionIndex;
228  }
229 
232  const RegionType & GetRegion() const
233  {
234  return m_Region;
235  }
236 
239  void SetIndex(const IndexType & ind)
240  {
241  m_Position = m_Image->GetBufferPointer() + m_Image->ComputeOffset(ind);
242  m_PositionIndex = ind;
243  }
244 
246  PixelType Get(void) const
247  {
248  return m_PixelAccessorFunctor.Get(*m_Position);
249  }
250 
254  const PixelType & Value(void) const
255  {
256  return *m_Position;
257  }
258 
261  itkLegacyMacro(Self Begin(void) const);
262 
264  void GoToBegin(void);
265 
268  itkLegacyMacro(Self End(void) const);
269 
271  void GoToReverseBegin(void);
272 
274  bool IsAtReverseEnd(void) const
275  {
276  return !m_Remaining;
277  }
278 
280  bool IsAtEnd(void) const
281  {
282  return !m_Remaining;
283  }
284 
286  bool Remaining()
287  {
288  return m_Remaining;
289  }
290 
291 protected: //made protected so other iterators can access
292  typename TImage::ConstWeakPointer m_Image;
293 
294  IndexType m_PositionIndex; // Index where we currently are
295  IndexType m_BeginIndex; // Index to start iterating over
296  IndexType m_EndIndex; // Index to finish iterating:
297  // one pixel past the end of each
298  // row, col, slice, etc....
299 
300  RegionType m_Region; // region to iterate over
301 
303 
307 
309 
312 };
313 } // end namespace itk
314 
315 #ifndef ITK_MANUAL_INSTANTIATION
317 #endif
318 
319 #endif

Generated at Sat Mar 8 2014 14:50:04 for Orfeo Toolbox with doxygen 1.8.3.1