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 itkImageRegionConstIteratorWithOnlyIndex_hxx 19 #define itkImageRegionConstIteratorWithOnlyIndex_hxx 20 21 #include "itkImageRegionConstIteratorWithOnlyIndex.h" 22 23 namespace itk 24 { 25 //---------------------------------------------------------------------- 26 // Advance along the line 27 //---------------------------------------------------------------------- 28 template< typename TImage > 29 ImageRegionConstIteratorWithOnlyIndex< TImage > & 30 ImageRegionConstIteratorWithOnlyIndex< TImage > operator ++()31::operator++() 32 { 33 this->m_Remaining = false; 34 for ( unsigned int in = 0; in < TImage::ImageDimension; in++ ) 35 { 36 this->m_PositionIndex[in]++; 37 if ( this->m_PositionIndex[in] < this->m_EndIndex[in] ) 38 { 39 this->m_Remaining = true; 40 break; 41 } 42 else 43 { 44 this->m_PositionIndex[in] = this->m_BeginIndex[in]; 45 } 46 } 47 48 return *this; 49 } 50 51 //---------------------------------------------------------------------- 52 // Advance along the line in reverse direction 53 //---------------------------------------------------------------------- 54 template< typename TImage > 55 ImageRegionConstIteratorWithOnlyIndex< TImage > & 56 ImageRegionConstIteratorWithOnlyIndex< TImage > operator --()57::operator--() 58 { 59 this->m_Remaining = false; 60 for ( unsigned int in = 0; in < TImage::ImageDimension; in++ ) 61 { 62 if ( this->m_PositionIndex[in] > this->m_BeginIndex[in] ) 63 { 64 this->m_PositionIndex[in]--; 65 this->m_Remaining = true; 66 break; 67 } 68 else 69 { 70 this->m_PositionIndex[in] = this->m_EndIndex[in] - 1; 71 } 72 } 73 74 return *this; 75 } 76 } // end namespace itk 77 78 #endif 79