00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
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();
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&);
00155 void operator=(const Self&);
00156
00157 IndexType m_Start;
00158 ChainCodeType m_Chain;
00159 };
00160
00161 }
00162
00163
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