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 __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
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();
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&);
00157 void operator=(const Self&);
00158
00159 IndexType m_Start;
00160 ChainCodeType m_Chain;
00161 };
00162
00163 }
00164
00165
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