Orfeo Toolbox  3.16
itkImageRegionConstIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkImageRegionConstIterator.h,v $
5  Language: C++
6  Date: $Date: 2008-10-18 21:13:25 $
7  Version: $Revision: 1.23 $
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 __itkImageRegionConstIterator_h
18 #define __itkImageRegionConstIterator_h
19 
20 #include "itkImageConstIterator.h"
21 #include "itkImageIterator.h"
22 
23 #if defined(_MSC_VER) && !defined(ITK_LEAN_AND_MEAN)
24 #define ITK_LEAN_AND_MEAN
25 #endif
26 
27 namespace itk
28 {
29 
107 template<typename TImage>
109 {
110 public:
114 
119  itkStaticConstMacro(ImageIteratorDimension, unsigned int,
120  Superclass::ImageIteratorDimension);
121 
125 
128  typedef typename Superclass::SizeType SizeType;
129 
132 
136 
142 
145 
148 
152 
155 
158  {
159  m_SpanBeginOffset = 0;
160  m_SpanEndOffset = 0;
161  }
162 
166  const RegionType &region)
167  : ImageConstIterator<TImage>(ptr, region)
168  {
169  m_SpanBeginOffset = this->m_BeginOffset;
170  m_SpanEndOffset = this->m_BeginOffset + static_cast<long>(this->m_Region.GetSize()[0]);
171  }
172 
180  {
182  IndexType ind = this->GetIndex();
183  m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
184  - (ind[0] - this->m_Region.GetIndex()[0]);
185  m_SpanBeginOffset = m_SpanEndOffset
186  - static_cast<long>(this->m_Region.GetSize()[0]);
187  }
188 
196  {
198  IndexType ind = this->GetIndex();
199  m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
200  - (ind[0] - this->m_Region.GetIndex()[0]);
201  m_SpanBeginOffset = m_SpanEndOffset
202  - static_cast<long>(this->m_Region.GetSize()[0]);
203  }
204 
207  void GoToBegin()
208  {
209  Superclass::GoToBegin();
210 
211  // reset the span offsets
212  m_SpanBeginOffset = this->m_BeginOffset;
213  m_SpanEndOffset = this->m_BeginOffset + static_cast<long>(this->m_Region.GetSize()[0]);
214  }
215 
218  void GoToEnd()
219  {
220  Superclass::GoToEnd();
221 
222  // reset the span offsets
223  m_SpanEndOffset = this->m_EndOffset;
224  m_SpanBeginOffset = m_SpanEndOffset - static_cast<long>(this->m_Region.GetSize()[0]);
225  }
226 
230  Self Begin(void) const;
231 
235  Self End(void) const;
236 
237 
241  void SetIndex(const IndexType &ind)
242  {
243  Superclass::SetIndex(ind);
244  m_SpanEndOffset = this->m_Offset + static_cast<long>(this->m_Region.GetSize()[0])
245  - (ind[0] - this->m_Region.GetIndex()[0]);
246  m_SpanBeginOffset = m_SpanEndOffset - static_cast<long>(this->m_Region.GetSize()[0]);
247  }
248 
256  Self &
257  operator++()
258  {
259  if (++this->m_Offset >= m_SpanEndOffset)
260  {
261  this->Increment();
262  }
263  return *this;
264  }
265 
273  Self & operator--()
274  {
275  if (--this->m_Offset < m_SpanBeginOffset)
276  {
277  this->Decrement();
278  }
279  return *this;
280  }
281 
282 
283 protected:
284  unsigned long m_SpanBeginOffset; // one pixel before the beginning of the span (row)
285  unsigned long m_SpanEndOffset; // one pixel past the end of the span (row)
286 
287 private:
288  void Increment(); // advance in a direction other than the fastest moving
289  void Decrement(); // go back in a direction other than the fastest moving
290 
291 };
292 
293 } // end namespace itk
294 
295 // Define instantiation macro for this template.
296 #define ITK_TEMPLATE_ImageRegionConstIterator(_, EXPORT, x, y) namespace itk { \
297  _(1(class EXPORT ImageRegionConstIterator< ITK_TEMPLATE_1 x >)) \
298  namespace Templates { typedef ImageRegionConstIterator< ITK_TEMPLATE_1 x > ImageRegionConstIterator##y; } \
299  }
300 
301 
302 #if ITK_TEMPLATE_EXPLICIT
303 # include "Templates/itkImageRegionConstIterator+-.h"
304 #endif
305 
306 #if ITK_TEMPLATE_TXX
308 #endif
309 
310 #if defined(_MSC_VER)
311 #undef ITK_LEAN_AND_MEAN
312 #endif
313 
314 #endif

Generated at Sat Feb 2 2013 23:43:47 for Orfeo Toolbox with doxygen 1.8.1.1