Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkLineConstIterator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkLineConstIterator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007-01-30 20:56:09 $
00007   Version:   $Revision: 1.5 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkLineConstIterator_h
00018 #define __itkLineConstIterator_h
00019 
00020 #include "itkIndex.h"
00021 #include "itkImage.h"
00022 
00023 namespace itk
00024 {
00025 
00049 template<class TImage>
00050 class ITK_EXPORT LineConstIterator
00051 {
00052 public:
00053 
00055   typedef LineConstIterator Self;
00056 
00061   itkStaticConstMacro(ImageIteratorDimension, unsigned int,
00062                       TImage::ImageDimension);
00063 
00065   typedef typename TImage::IndexType          IndexType;
00066   typedef typename TImage::IndexValueType     IndexValueType;
00067 
00069   typedef typename TImage::OffsetType         OffsetType;
00070   typedef typename TImage::OffsetValueType    OffsetValueType;
00071 
00073   typedef typename TImage::SizeType           SizeType;
00074   typedef typename TImage::SizeValueType      SizeValueType;
00075 
00077   typedef typename TImage::RegionType         RegionType;
00078 
00080   typedef typename TImage::SpacingType        SpacingType;
00081 
00083   typedef typename TImage::PointType          PointType;
00084 
00086   typedef TImage                              ImageType;
00087 
00091   typedef typename TImage::PixelContainer     PixelContainer;
00092   typedef typename PixelContainer::Pointer    PixelContainerPointer;
00093 
00095   typedef typename TImage::InternalPixelType  InternalPixelType;
00096 
00098   typedef typename TImage::PixelType          PixelType;
00099 
00102   typedef typename TImage::AccessorType       AccessorType;
00103 
00105   itkTypeMacro(LineConstIterator, None);
00106 
00108   static unsigned int GetImageIteratorDimension() 
00109     {
00110     return TImage::ImageDimension;
00111     }
00112 
00114   const IndexType GetIndex()
00115     {
00116     return m_CurrentImageIndex;
00117     }
00118 
00120   const PixelType & Get(void) const
00121     {
00122     return m_Image->GetPixel(m_CurrentImageIndex );
00123     }
00124 
00126   bool IsAtEnd()
00127     {
00128     return m_IsAtEnd;
00129     }
00130 
00132   void GoToBegin();
00133 
00135   void operator++();
00136 
00139   Self &operator=(const Self& it);
00140 
00142   LineConstIterator(const ImageType *imagePtr, const IndexType &firstIndex, const IndexType &lastIndex);
00143 
00145   virtual ~LineConstIterator() {};
00146 
00147 
00148 protected: //made protected so other iterators can access 
00150   typename ImageType::ConstWeakPointer m_Image;
00151 
00153   RegionType m_Region;
00154 
00156   bool m_IsAtEnd;
00157 
00159   IndexType m_CurrentImageIndex;
00160   IndexType m_StartIndex;
00161   IndexType m_LastIndex;
00162   IndexType m_EndIndex;  // one past the end of the line in the m_MainDirection
00163 
00165   // The dimension with the largest difference between start and end
00166   unsigned int m_MainDirection; 
00167 
00168   // Accumulated error for the other dimensions
00169   IndexType m_AccumulateError;
00170 
00171   // Increment for the error for each step. Two times the difference between
00172   // start and end
00173   IndexType m_IncrementError;
00174 
00175   // If enough is accumulated for a dimension, the index has to be
00176   // incremented. Will be the number of pixels in the line
00177   IndexType m_MaximalError; 
00178 
00179   // Direction of increment. -1 or 1
00180   IndexType m_OverflowIncrement; 
00181 
00182   // After an overflow, the accumulated error is reduced again. Will be
00183   // two times the number of pixels in the line
00184   IndexType m_ReduceErrorAfterIncrement; 
00185 };
00186 
00187 } // end namespace itk
00188 
00189 // Define instantiation macro for this template.
00190 #define ITK_TEMPLATE_LineConstIterator(_, EXPORT, x, y) namespace itk { \
00191   _(1(class EXPORT LineConstIterator< ITK_TEMPLATE_1 x >)) \
00192   namespace Templates { typedef LineConstIterator< ITK_TEMPLATE_1 x > \
00193                                                   LineConstIterator##y; } \
00194   }
00195 
00196 #if ITK_TEMPLATE_EXPLICIT
00197 # include "Templates/itkLineConstIterator+-.h"
00198 #endif
00199 
00200 #if ITK_TEMPLATE_TXX
00201 # include "itkLineConstIterator.txx"
00202 #endif
00203 
00204 
00205 #endif 
00206 

Generated at Mon Jul 12 2010 19:03:53 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000