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/01/30 20:56:07 $
00007   Version:   $Revision: 1.10 $
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   // Functions inherited from Path
00079   
00081   virtual OutputType Evaluate( const InputType & input ) const
00082     {
00083     return m_Chain[input];
00084     }
00085 
00087   virtual IndexType EvaluateToIndex( const InputType & input ) const;
00088 
00093   virtual OffsetType IncrementInput(InputType & input) const;
00094 
00096   virtual inline InputType EndOfInput() const
00097     {
00098     return NumberOfSteps();  // 0 is before the first step, 1 is after it
00099     }
00100 
00102   itkNewMacro( Self );
00103 
00105   itkSetMacro( Start, IndexType );
00106   itkGetConstReferenceMacro( Start, IndexType );
00108 
00110   virtual inline void InsertStep( InputType position, OffsetType step )
00111     {
00112     m_Chain.insert( m_Chain.begin()+position, step );
00113     this->Modified();
00114     }
00116 
00118   virtual inline void ChangeStep( InputType position, OffsetType step )
00119     {
00120     m_Chain[position]=step;
00121     this->Modified();
00122     }
00124 
00126   virtual inline void Clear()
00127     {
00128     m_Chain.clear();
00129     this->Modified();
00130     }
00132 
00134   virtual inline unsigned int NumberOfSteps() const
00135     {
00136     return m_Chain.size();
00137     }
00138 
00140   virtual void Initialize(void)
00141     {
00142     m_Start = this->GetZeroIndex();
00143     this->Clear();
00144     }
00146 
00147 protected:
00148   ChainCodePath();
00149   ~ChainCodePath() {}
00150   void PrintSelf(std::ostream& os, Indent indent) const;
00151 
00152 
00153 private:
00154   ChainCodePath(const Self&); //purposely not implemented
00155   void operator=(const Self&); //purposely not implemented
00156   
00157   IndexType     m_Start;            // origin image index for the path
00158   ChainCodeType m_Chain;            // the chain code (vector of offsets)
00159 };
00160 
00161 } // end namespace itk
00162 
00163 // Define instantiation macro for this template.
00164 #define ITK_TEMPLATE_ChainCodePath(_, EXPORT, x, y) namespace itk { \
00165   _(1(class EXPORT ChainCodePath< ITK_TEMPLATE_1 x >)) \
00166   namespace Templates { typedef ChainCodePath< ITK_TEMPLATE_1 x > \
00167                                ChainCodePath##y; } \
00168   }
00169 
00170 #if ITK_TEMPLATE_EXPLICIT
00171 # include "Templates/itkChainCodePath+-.h"
00172 #endif
00173 
00174 #if ITK_TEMPLATE_TXX
00175 # include "itkChainCodePath.txx"
00176 #endif
00177 
00178 #endif
00179 

Generated at Sun Sep 23 12:09:48 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000