Orfeo Toolbox  3.16
itkImageConstIteratorWithIndex.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkImageConstIteratorWithIndex.h,v $
5  Language: C++
6  Date: $Date: 2008-10-17 01:41:59 $
7  Version: $Revision: 1.25 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkImageConstIteratorWithIndex_h
18 #define __itkImageConstIteratorWithIndex_h
19 
20 #include "itkIndex.h"
21 #include "itkImage.h"
22 #include <memory>
23 
24 namespace itk
25 {
26 
90 template<typename TImage>
92 {
93 public:
96 
101  itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
102 
104  typedef typename TImage::IndexType IndexType;
105  typedef typename IndexType::IndexValueType IndexValueType;
106 
108  typedef typename TImage::SizeType SizeType;
109  typedef typename SizeType::SizeValueType SizeValueType;
110 
112  typedef typename TImage::RegionType RegionType;
113 
115  typedef TImage ImageType;
116 
120  typedef typename TImage::PixelContainer PixelContainer;
121  typedef typename PixelContainer::Pointer PixelContainerPointer;
122 
124  typedef typename TImage::InternalPixelType InternalPixelType;
125 
127  typedef typename TImage::PixelType PixelType;
128 
131  typedef typename TImage::AccessorType AccessorType;
132  typedef typename TImage::AccessorFunctorType AccessorFunctorType;
133 
135  typedef typename TImage::OffsetType OffsetType;
136  typedef typename OffsetType::OffsetValueType OffsetValueType;
137 
141 
145 
148  ImageConstIteratorWithIndex( const TImage *ptr,
149  const RegionType& region );
150 
153  Self &operator=(const Self& it);
154 
156  static unsigned int GetImageDimension()
157  {return ImageDimension;}
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_Position) != (it.m_Position);
166  }
167 
170  bool
171  operator==(const Self &it) const
172  {
173  // two iterators are the same if they "point to" the same memory location
174  return (m_Position) == (it.m_Position);
175  }
176 
179  bool
180  operator<=(const Self &it) const
181  {
182  // an iterator is "less than" another if it "points to" a lower
183  // memory location
184  return (m_Position) <= (it.m_Position);
185  }
186 
189  bool
190  operator<(const Self &it) const
191  {
192  // an iterator is "less than" another if it "points to" a lower
193  // memory location
194  return (m_Position) < (it.m_Position);
195  }
196 
199  bool
200  operator>=(const Self &it) const
201  {
202  // an iterator is "greater than" another if it "points to" a higher
203  // memory location
204  return (m_Position) >= (it.m_Position);
205  }
206 
209  bool
210  operator>(const Self &it) const
211  {
212  // an iterator is "greater than" another if it "points to" a higher
213  // memory location
214  return (m_Position) > (it.m_Position);
215  }
216 
219  const IndexType & GetIndex() const
220  { return m_PositionIndex; }
221 
224  const RegionType& GetRegion() const
225  { return m_Region; }
226 
229  void SetIndex(const IndexType &ind)
230  {
231  m_Position = m_Image->GetBufferPointer() + m_Image->ComputeOffset( ind );
232  m_PositionIndex = ind;
233  }
234 
236  PixelType Get(void) const
237  { return m_PixelAccessorFunctor.Get(*m_Position); }
238 
242  const PixelType & Value(void) const
243  { return *m_Position; }
244 
247  Self Begin(void) const;
248 
250  void GoToBegin(void);
251 
254  Self End(void) const;
255 
257  void GoToReverseBegin(void);
258 
260  bool IsAtReverseEnd(void) const
261  {
262  return !m_Remaining;
263  }
264 
266  bool IsAtEnd(void) const
267  {
268  return !m_Remaining;
269  }
270 
272  bool Remaining()
273  {
274  return m_Remaining;
275  }
276 
277 protected: //made protected so other iterators can access
278  typename TImage::ConstWeakPointer m_Image;
279 
280  IndexType m_PositionIndex; // Index where we currently are
281  IndexType m_BeginIndex; // Index to start iterating over
282  IndexType m_EndIndex; // Index to finish iterating:
283  // one pixel past the end of each
284  // row, col, slice, etc....
285 
286  RegionType m_Region; // region to iterate over
287 
288  unsigned long m_OffsetTable[ ImageDimension + 1 ];
289 
290  const InternalPixelType *m_Position;
291  const InternalPixelType *m_Begin;
292  const InternalPixelType *m_End;
293 
295 
296  AccessorType m_PixelAccessor;
297  AccessorFunctorType m_PixelAccessorFunctor;
298 
299 };
300 
301 } // end namespace itk
302 
303 // Define instantiation macro for this template.
304 #define ITK_TEMPLATE_ImageConstIteratorWithIndex(_, EXPORT, x, y) namespace itk { \
305  _(1(class EXPORT ImageConstIteratorWithIndex< ITK_TEMPLATE_1 x >)) \
306  namespace Templates { typedef ImageConstIteratorWithIndex< ITK_TEMPLATE_1 x > ImageConstIteratorWithIndex##y; } \
307  }
308 
309 
310 #if ITK_TEMPLATE_EXPLICIT
311 # include "Templates/itkImageConstIteratorWithIndex+-.h"
312 #endif
313 
314 #if ITK_TEMPLATE_TXX
316 #endif
317 
318 #endif

Generated at Sat Jun 15 2013 23:43:40 for Orfeo Toolbox with doxygen 1.8.3.1