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
00024 #include <vector>
00025
00026 namespace itk
00027 {
00028
00029
00048 template <unsigned int VDimension>
00049 class ITK_EXPORT ChainCodePath : public
00050 Path< unsigned int, Offset< VDimension >, VDimension >
00051 {
00052 public:
00054 itkStaticConstMacro(Dimension, unsigned int, VDimension);
00055
00057 typedef ChainCodePath<VDimension> Self;
00058 typedef Path< unsigned int, Offset< VDimension >, VDimension > Superclass;
00059
00060 typedef SmartPointer<Self> Pointer;
00061 typedef SmartPointer<const Self> ConstPointer;
00062
00064 itkTypeMacro(ChainCodePath, Path);
00065
00066
00068 typedef typename Superclass::OutputType OutputType;
00069 typedef typename Superclass::InputType InputType;
00070
00072 typedef OutputType OffsetType;
00073 typedef Index<VDimension> IndexType;
00074
00075 typedef std::vector<OffsetType> ChainCodeType;
00076
00077
00078
00080 virtual OutputType Evaluate( const InputType & input ) const
00081 {
00082 return m_Chain[input];
00083 }
00084
00086 virtual IndexType EvaluateToIndex( const InputType & input ) const;
00087
00092 virtual OffsetType IncrementInput(InputType & input) const;
00093
00095 virtual inline InputType EndOfInput() const
00096 {
00097 return NumberOfSteps();
00098 }
00099
00100
00101
00102
00103
00105 itkNewMacro( Self );
00106
00108 itkSetMacro( Start, IndexType );
00109 itkGetConstReferenceMacro( Start, IndexType );
00111
00113 virtual inline void InsertStep( InputType position, OffsetType step )
00114 {
00115 m_Chain.insert( m_Chain.begin()+position, step );
00116 this->Modified();
00117 }
00119
00121 virtual inline void ChangeStep( InputType position, OffsetType step )
00122 {
00123 m_Chain[position]=step;
00124 this->Modified();
00125 }
00127
00129 virtual inline void Clear()
00130 {
00131 m_Chain.clear();
00132 this->Modified();
00133 }
00135
00137 virtual inline unsigned int NumberOfSteps() const
00138 {
00139 return m_Chain.size();
00140 }
00141
00143 virtual void Initialize(void)
00144 {
00145 m_Start = this->GetZeroIndex();
00146 this->Clear();
00147 }
00149
00150 protected:
00151 ChainCodePath();
00152 ~ChainCodePath() {}
00153 void PrintSelf(std::ostream& os, Indent indent) const;
00154
00155
00156 private:
00157 ChainCodePath(const Self&);
00158 void operator=(const Self&);
00159
00160 IndexType m_Start;
00161 ChainCodeType m_Chain;
00162 };
00163
00164 }
00165
00166 #ifndef ITK_MANUAL_INSTANTIATION
00167 #include "itkChainCodePath.txx"
00168 #endif
00169
00170 #endif
00171