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
00027
00028
00029 namespace itk
00030 {
00031
00039 template <
00040 class TScalarType=double,
00041 unsigned int NDimensions=3>
00042 class ITK_EXPORT TranslationTransform :
00043 public Transform< TScalarType, NDimensions, NDimensions >
00044 {
00045 public:
00047 typedef TranslationTransform Self;
00048 typedef Transform< TScalarType, NDimensions, NDimensions > Superclass;
00049 typedef SmartPointer<Self> Pointer;
00050 typedef SmartPointer<const Self> ConstPointer;
00051
00053 itkNewMacro( Self );
00054
00056 itkTypeMacro( TranslationTransform, Transform );
00057
00059 itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00060 itkStaticConstMacro(ParametersDimension, unsigned int, NDimensions);
00062
00064 typedef typename Superclass::ScalarType ScalarType;
00065
00067 typedef typename Superclass::ParametersType ParametersType;
00068
00070 typedef typename Superclass::JacobianType JacobianType;
00071
00073 typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVectorType;
00074 typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVectorType;
00076
00078 typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType;
00079 typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType;
00081
00083 typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
00084 typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
00086
00088 typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputPointType;
00089 typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
00091
00094 const OutputVectorType & GetOffset(void) const
00095 { return m_Offset; }
00096
00099 void SetParameters(const ParametersType & parameters);
00100
00102 virtual const ParametersType& GetParameters(void) const;
00103
00107 void SetOffset(const OutputVectorType &offset)
00108 { m_Offset = offset; return; }
00109
00111 void Compose(const Self * other, bool pre=0);
00112
00117 void Translate(const OutputVectorType &offset, bool pre=0);
00118
00123 OutputPointType TransformPoint(const InputPointType &point ) const;
00124 OutputVectorType TransformVector(const InputVectorType &vector) const;
00125 OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const;
00126 OutputCovariantVectorType TransformCovariantVector(
00127 const InputCovariantVectorType &vector) const;
00129
00133 inline InputPointType BackTransform(const OutputPointType &point ) const;
00134 inline InputVectorType BackTransform(const OutputVectorType &vector) const;
00135 inline InputVnlVectorType BackTransform(const OutputVnlVectorType &vector) const;
00136 inline InputCovariantVectorType BackTransform(
00137 const OutputCovariantVectorType &vector) const;
00139
00144 bool GetInverse(Self* inverse) const;
00145
00147 virtual const JacobianType & GetJacobian(const InputPointType &point ) const;
00148
00150 void SetIdentity(void);
00151
00153 virtual unsigned int GetNumberOfParameters(void) const
00154 { return NDimensions; }
00155
00161 virtual bool IsLinear() const { return true; }
00162
00166 virtual void SetFixedParameters( const ParametersType & )
00167 { };
00168
00172 virtual const ParametersType& GetFixedParameters(void) const
00173 {
00174 this->m_FixedParameters.SetSize(0);
00175 return this->m_FixedParameters;
00176 };
00178
00179 protected:
00180 TranslationTransform();
00181 ~TranslationTransform();
00183 void PrintSelf(std::ostream &os, Indent indent) const;
00184
00185 private:
00186 TranslationTransform(const Self&);
00187 void operator=(const Self&);
00188
00189 OutputVectorType m_Offset;
00190
00191
00192 };
00193
00194
00195
00196 template<class TScalarType, unsigned int NDimensions>
00197 inline
00198 typename TranslationTransform<TScalarType, NDimensions>::InputPointType
00199 TranslationTransform<TScalarType, NDimensions>::
00200 BackTransform(const OutputPointType &point) const {
00201 return point - m_Offset;
00202 }
00203
00204
00205
00206
00207
00208 template<class TScalarType, unsigned int NDimensions>
00209 inline
00210 typename TranslationTransform<TScalarType, NDimensions>::InputVectorType
00211 TranslationTransform<TScalarType, NDimensions>::
00212 BackTransform(const OutputVectorType &vect ) const
00213 {
00214 return vect;
00215 }
00216
00217
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