Orfeo Toolbox  4.0
itkImageRegionConstIterator.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 __itkImageRegionConstIterator_h
19 #define __itkImageRegionConstIterator_h
20 
21 #include "itkImageIterator.h"
22 
23 namespace itk
24 {
106 template< typename TImage >
108 {
109 public:
113 
118  itkStaticConstMacro(ImageIteratorDimension, unsigned int,
120 
127  typedef typename Superclass::SizeType SizeType;
136 
139 
142  {
143  m_SpanBeginOffset = 0;
144  m_SpanEndOffset = 0;
145  }
146 
150  const RegionType & region):
151  ImageConstIterator< TImage >(ptr, region)
152  {
154  m_SpanEndOffset = this->m_BeginOffset + static_cast< OffsetValueType >( this->m_Region.GetSize()[0] );
155  }
156 
164  {
166 
167  IndexType ind = this->GetIndex();
168  m_SpanEndOffset = this->m_Offset + static_cast< OffsetValueType >( this->m_Region.GetSize()[0] )
169  - ( ind[0] - this->m_Region.GetIndex()[0] );
171  - static_cast< OffsetValueType >( this->m_Region.GetSize()[0] );
172  }
173 
181  {
183 
184  IndexType ind = this->GetIndex();
185  m_SpanEndOffset = this->m_Offset + static_cast< OffsetValueType >( this->m_Region.GetSize()[0] )
186  - ( ind[0] - this->m_Region.GetIndex()[0] );
188  - static_cast< OffsetValueType >( this->m_Region.GetSize()[0] );
189  }
190 
193  void GoToBegin()
194  {
196 
197  // reset the span offsets
199  m_SpanEndOffset = this->m_BeginOffset + static_cast< OffsetValueType >( this->m_Region.GetSize()[0] );
200  }
201 
204  void GoToEnd()
205  {
207 
208  // reset the span offsets
210  m_SpanBeginOffset = m_SpanEndOffset - static_cast< OffsetValueType >( this->m_Region.GetSize()[0] );
211  }
212 
216  itkLegacyMacro(Self Begin(void) const);
217 
221  itkLegacyMacro(Self End(void) const);
222 
226  void SetIndex(const IndexType & ind)
227  {
229  m_SpanEndOffset = this->m_Offset + static_cast< OffsetValueType >( this->m_Region.GetSize()[0] )
230  - ( ind[0] - this->m_Region.GetIndex()[0] );
231  m_SpanBeginOffset = m_SpanEndOffset - static_cast< OffsetValueType >( this->m_Region.GetSize()[0] );
232  }
233 
241  Self &
243  {
244  if ( ++this->m_Offset >= m_SpanEndOffset )
245  {
246  this->Increment();
247  }
248  return *this;
249  }
250 
259  {
260  if ( --this->m_Offset < m_SpanBeginOffset )
261  {
262  this->Decrement();
263  }
264  return *this;
265  }
266 
267 protected:
268  OffsetValueType m_SpanBeginOffset; // one pixel before the beginning of the span
269  // (row)
270  OffsetValueType m_SpanEndOffset; // one pixel past the end of the span (row)
271 
272 private:
273  void Increment(); // advance in a direction other than the fastest moving
274 
275  void Decrement(); // go back in a direction other than the fastest moving
276 };
277 } // end namespace itk
278 
279 #ifndef ITK_MANUAL_INSTANTIATION
281 #endif
282 
283 #endif

Generated at Sat Mar 8 2014 14:52:03 for Orfeo Toolbox with doxygen 1.8.3.1