itkTranslationTransform.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkTranslationTransform_h
00019 #define __itkTranslationTransform_h
00020
00021 #include <iostream>
00022 #include "itkTransform.h"
00023 #include "itkExceptionObject.h"
00024 #include "itkMatrix.h"
00025
00026 namespace itk
00027 {
00028
00037 template <
00038 class TScalarType=double,
00039 unsigned int NDimensions=3>
00040 class ITK_EXPORT TranslationTransform :
00041 public Transform< TScalarType, NDimensions, NDimensions >
00042 {
00043 public:
00045 typedef TranslationTransform Self;
00046 typedef Transform< TScalarType, NDimensions, NDimensions > Superclass;
00047 typedef SmartPointer<Self> Pointer;
00048 typedef SmartPointer<const Self> ConstPointer;
00049
00051 itkNewMacro( Self );
00052
00054 itkTypeMacro( TranslationTransform, Transform );
00055
00057 itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00058 itkStaticConstMacro(ParametersDimension, unsigned int, NDimensions);
00060
00062 typedef typename Superclass::ScalarType ScalarType;
00063
00065 typedef typename Superclass::ParametersType ParametersType;
00066
00068 typedef typename Superclass::JacobianType JacobianType;
00069
00071 typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVectorType;
00072 typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVectorType;
00074
00076 typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType;
00077 typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType;
00079
00081 typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
00082 typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
00084
00086 typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputPointType;
00087 typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
00089
00092 typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
00093 typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
00094
00097 const OutputVectorType & GetOffset(void) const
00098 { return m_Offset; }
00099
00102 void SetParameters(const ParametersType & parameters);
00103
00105 virtual const ParametersType& GetParameters(void) const;
00106
00110 void SetOffset(const OutputVectorType &offset)
00111 { m_Offset = offset; return; }
00112
00114 void Compose(const Self * other, bool pre=0);
00115
00120 void Translate(const OutputVectorType &offset, bool pre=0);
00121
00126 OutputPointType TransformPoint(const InputPointType &point ) const;
00127 OutputVectorType TransformVector(const InputVectorType &vector) const;
00128 OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const;
00129 OutputCovariantVectorType TransformCovariantVector(
00130 const InputCovariantVectorType &vector) const;
00132
00136 inline InputPointType BackTransform(const OutputPointType &point ) const;
00137 inline InputVectorType BackTransform(const OutputVectorType &vector) const;
00138 inline InputVnlVectorType BackTransform(const OutputVnlVectorType &vector) const;
00139 inline InputCovariantVectorType BackTransform(
00140 const OutputCovariantVectorType &vector) const;
00142
00147 bool GetInverse(Self* inverse) const;
00148
00150 virtual InverseTransformBasePointer GetInverseTransform() const;
00151
00153 virtual const JacobianType & GetJacobian(const InputPointType &point ) const;
00154
00156 void SetIdentity(void);
00157
00159 virtual unsigned int GetNumberOfParameters(void) const
00160 { return NDimensions; }
00161
00167 virtual bool IsLinear() const { return true; }
00168
00172 virtual void SetFixedParameters( const ParametersType & )
00173 {}
00174
00178 virtual const ParametersType& GetFixedParameters(void) const
00179 {
00180 this->m_FixedParameters.SetSize(0);
00181 return this->m_FixedParameters;
00182 }
00184
00185 protected:
00186 TranslationTransform();
00187 ~TranslationTransform();
00189 void PrintSelf(std::ostream &os, Indent indent) const;
00190
00191 private:
00192 TranslationTransform(const Self&);
00193 void operator=(const Self&);
00194
00195 OutputVectorType m_Offset;
00196
00197
00198 };
00199
00200
00201
00202 template<class TScalarType, unsigned int NDimensions>
00203 inline
00204 typename TranslationTransform<TScalarType, NDimensions>::InputPointType
00205 TranslationTransform<TScalarType, NDimensions>::
00206 BackTransform(const OutputPointType &point) const {
00207 return point - m_Offset;
00208 }
00209
00210
00211 template<class TScalarType, unsigned int NDimensions>
00212 inline
00213 typename TranslationTransform<TScalarType, NDimensions>::InputVectorType
00214 TranslationTransform<TScalarType, NDimensions>::
00215 BackTransform(const OutputVectorType &vect ) const
00216 {
00217 return vect;
00218 }
00219
00220
00221 template<class TScalarType, unsigned int NDimensions>
00222 inline
00223 typename TranslationTransform<TScalarType, NDimensions>::InputVnlVectorType
00224 TranslationTransform<TScalarType, NDimensions>::
00225 BackTransform(const OutputVnlVectorType &vect ) const
00226 {
00227 return vect;
00228 }
00229
00230
00231
00232 template<class TScalarType, unsigned int NDimensions>
00233 inline
00234 typename TranslationTransform<TScalarType, NDimensions>::InputCovariantVectorType
00235 TranslationTransform<TScalarType, NDimensions>::
00236 BackTransform(const OutputCovariantVectorType &vect) const
00237 {
00238 return vect;
00239 }
00240
00241 }
00242
00243
00244 #define ITK_TEMPLATE_TranslationTransform(_, EXPORT, x, y) namespace itk { \
00245 _(2(class EXPORT TranslationTransform< ITK_TEMPLATE_2 x >)) \
00246 namespace Templates { typedef TranslationTransform< ITK_TEMPLATE_2 x > TranslationTransform##y; } \
00247 }
00248
00249 #if ITK_TEMPLATE_EXPLICIT
00250 # include "Templates/itkTranslationTransform+-.h"
00251 #endif
00252
00253 #if ITK_TEMPLATE_TXX
00254 # include "itkTranslationTransform.txx"
00255 #endif
00256
00257 #endif
00258