Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkChainCodePath2D_h
00018 #define __itkChainCodePath2D_h
00019
00020 #include "itkChainCodePath.h"
00021 #include "itkObjectFactory.h"
00022 #include "itkIndex.h"
00023 #include "itkOffset.h"
00024
00025 #include <vector>
00026 #include <string>
00027
00028
00029 namespace itk
00030 {
00031
00032
00053 class ITKCommon_EXPORT ChainCodePath2D : public
00054 ChainCodePath<2>
00055 {
00056 public:
00058 itkStaticConstMacro(Dimension, unsigned int, 2);
00059
00061 typedef ChainCodePath2D Self;
00062 typedef ChainCodePath<2> Superclass;
00063
00064 typedef SmartPointer<Self> Pointer;
00065 typedef SmartPointer<const Self> ConstPointer;
00066
00068 itkTypeMacro(ChainCodePath2D, ChainCodePath);
00069
00071 typedef Superclass::OutputType OutputType;
00072 typedef Superclass::InputType InputType;
00073
00075 typedef OutputType OffsetType;
00076 typedef Index<2> IndexType;
00077
00079 typedef Superclass::ChainCodeType ChainCodeType;
00080 typedef Superclass::ChainCodeSizeType ChainCodeSizeType;
00081
00083 typedef std::vector<int> ChainCode2DType;
00084
00085
00086
00088 virtual OutputType Evaluate( const InputType & input ) const;
00089
00091 virtual IndexType EvaluateToIndex( const InputType & input ) const;
00092
00097 virtual OffsetType IncrementInput(InputType & input) const;
00098
00099
00100
00102 itkNewMacro( Self );
00103
00105 inline ChainCodeSizeType NumberOfSteps() const { return m_Chain2D.size(); }
00106
00107
00109 inline void InsertStep( InputType position, int encodedStep )
00110 {
00111 m_Chain2D.insert( m_Chain2D.begin()+position, encodedStep );
00112 this->Modified();
00113 }
00114 inline void InsertStep( InputType position, OffsetType step )
00115 {
00116 m_Chain2D.insert( m_Chain2D.begin()+position, EncodeOffset(step) );
00117 this->Modified();
00118 }
00120
00122 inline void ChangeStep( InputType position, int encodedStep )
00123 {
00124 m_Chain2D[position]=encodedStep;
00125 this->Modified();
00126 }
00127 inline void ChangeStep( InputType position, OffsetType step )
00128 {
00129 m_Chain2D[position]=EncodeOffset(step);
00130 this->Modified();
00131 }
00133
00135 virtual inline void Clear()
00136 {
00137 m_Chain2D.clear();
00138 this->Modified();
00139 }
00141
00142 std::string GetChainCodeAsString(void) const;
00143
00144 protected:
00145 ChainCodePath2D();
00146 ~ChainCodePath2D();
00147 void PrintSelf(std::ostream& os, Indent indent) const;
00148
00150 inline int EncodeOffset( OffsetType step ) const
00151 {
00152 return m_FreemanCode[ step[0] + 1 ][ step[1] + 1 ];
00153 }
00154 inline OffsetType DecodeOffset( int encodedStep ) const
00155 {
00156 return m_ReverseFreemanCode[ encodedStep ];
00157 }
00159
00160
00161 private:
00162 ChainCodePath2D(const Self&);
00163 void operator=(const Self&);
00164
00165 ChainCode2DType m_Chain2D;
00166
00167
00168
00169
00170
00171
00172
00173
00174 int m_FreemanCode[3][3];
00175
00176
00177
00178 OffsetType m_ReverseFreemanCode[9];
00179 };
00180
00181 }
00182
00183 #endif
00184