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

itkChainCodePath.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkChainCodePath.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007-12-23 17:59:28 $
00007   Version:   $Revision: 1.11 $
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 __itkChainCodePath_h
00018 #define __itkChainCodePath_h
00019 
00020 #include "itkPath.h"
00021 #include "itkIndex.h"
00022 #include "itkOffset.h"
00023 #include "itkObjectFactory.h"
00024 
00025 #include <vector>
00026 
00027 namespace itk
00028 {
00029 
00030 
00049 template <unsigned int VDimension>
00050 class ITK_EXPORT ChainCodePath : public
00051 Path< unsigned int, Offset< VDimension >, VDimension >
00052 {
00053 public:
00055   itkStaticConstMacro(Dimension, unsigned int, VDimension);
00056 
00058   typedef ChainCodePath<VDimension>                               Self;
00059   typedef Path< unsigned int, Offset< VDimension >, VDimension >  Superclass;
00060 
00061   typedef SmartPointer<Self>        Pointer;
00062   typedef SmartPointer<const Self>  ConstPointer;
00063   
00065   itkTypeMacro(ChainCodePath, Path);
00066 
00067   
00069   typedef typename Superclass::OutputType   OutputType;
00070   typedef typename Superclass::InputType    InputType;
00071 
00073   typedef OutputType               OffsetType;
00074   typedef Index<VDimension>        IndexType;
00075 
00076   typedef std::vector<OffsetType>  ChainCodeType;
00077 
00078   typedef typename ChainCodeType::size_type ChainCodeSizeType;
00079 
00080   // Functions inherited from Path
00081   
00083   virtual OutputType Evaluate( const InputType & input ) const
00084     {
00085     return m_Chain[input];
00086     }
00087 
00089   virtual IndexType EvaluateToIndex( const InputType & input ) const;
00090 
00095   virtual OffsetType IncrementInput(InputType & input) const;
00096 
00098   virtual inline InputType EndOfInput() const
00099     {
00100     return NumberOfSteps();  // 0 is before the first step, 1 is after it
00101     }
00102 
00104   itkNewMacro( Self );
00105 
00107   itkSetMacro( Start, IndexType );
00108   itkGetConstReferenceMacro( Start, IndexType );
00110 
00112   virtual inline void InsertStep( InputType position, OffsetType step )
00113     {
00114     m_Chain.insert( m_Chain.begin()+position, step );
00115     this->Modified();
00116     }
00118 
00120   virtual inline void ChangeStep( InputType position, OffsetType step )
00121     {
00122     m_Chain[position]=step;
00123     this->Modified();
00124     }
00126 
00128   virtual inline void Clear()
00129     {
00130     m_Chain.clear();
00131     this->Modified();
00132     }
00134 
00136   virtual inline ChainCodeSizeType NumberOfSteps() const
00137     {
00138     return m_Chain.size();
00139     }
00140 
00142   virtual void Initialize(void)
00143     {
00144     m_Start = this->GetZeroIndex();
00145     this->Clear();
00146     }
00148 
00149 protected:
00150   ChainCodePath();
00151   ~ChainCodePath() {}
00152   void PrintSelf(std::ostream& os, Indent indent) const;
00153 
00154 
00155 private:
00156   ChainCodePath(const Self&); //purposely not implemented
00157   void operator=(const Self&); //purposely not implemented
00158   
00159   IndexType     m_Start;            // origin image index for the path
00160   ChainCodeType m_Chain;            // the chain code (vector of offsets)
00161 };
00162 
00163 } // end namespace itk
00164 
00165 // Define instantiation macro for this template.
00166 #define ITK_TEMPLATE_ChainCodePath(_, EXPORT, x, y) namespace itk { \
00167   _(1(class EXPORT ChainCodePath< ITK_TEMPLATE_1 x >)) \
00168   namespace Templates { typedef ChainCodePath< ITK_TEMPLATE_1 x > \
00169                                ChainCodePath##y; } \
00170   }
00171 
00172 #if ITK_TEMPLATE_EXPLICIT
00173 # include "Templates/itkChainCodePath+-.h"
00174 #endif
00175 
00176 #if ITK_TEMPLATE_TXX
00177 # include "itkChainCodePath.txx"
00178 #endif
00179 
00180 #endif
00181 

Generated at Mon Jul 12 2010 18:02:08 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000