00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkRigid2DTransform_h
00018 #define __itkRigid2DTransform_h
00019
00020 #include <iostream>
00021 #include "itkMatrixOffsetTransformBase.h"
00022 #include "itkExceptionObject.h"
00023
00024 namespace itk
00025 {
00026
00056 template < class TScalarType=double >
00057 class ITK_EXPORT Rigid2DTransform :
00058 public MatrixOffsetTransformBase< TScalarType, 2, 2>
00059 {
00060 public:
00062 typedef Rigid2DTransform Self;
00063 typedef MatrixOffsetTransformBase< TScalarType, 2, 2 > Superclass;
00064 typedef SmartPointer<Self> Pointer;
00065 typedef SmartPointer<const Self> ConstPointer;
00066
00068 itkTypeMacro( Rigid2DTransform, MatrixOffsetTransformBase );
00069
00071 itkNewMacro( Self );
00072
00074 itkStaticConstMacro(InputSpaceDimension, unsigned int, 2);
00075 itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2);
00076 itkStaticConstMacro(ParametersDimension, unsigned int, 3);
00078
00080 typedef typename Superclass::ScalarType ScalarType;
00081
00083 typedef typename Superclass::ParametersType ParametersType;
00084
00086 typedef typename Superclass::JacobianType JacobianType;
00087
00089 typedef typename Superclass::MatrixType MatrixType;
00090
00092 typedef typename Superclass::OffsetType OffsetType;
00093
00095 typedef typename Superclass::InputVectorType InputVectorType;
00096 typedef typename Superclass::OutputVectorType OutputVectorType;
00097
00099 typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
00100 typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
00101
00103 typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
00104 typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
00105
00107 typedef typename Superclass::InputPointType InputPointType;
00108 typedef typename Superclass::OutputPointType OutputPointType;
00109
00122 virtual void SetMatrix( const MatrixType & matrix );
00123
00129 virtual void SetRotationMatrix(const MatrixType &matrix)
00130 { this->SetMatrix( matrix ); }
00131 const MatrixType & GetRotationMatrix() const
00132 { return this->GetMatrix(); }
00134
00135
00143 void Translate(const OffsetType &offset, bool pre=false);
00144
00153 inline InputPointType BackTransform(const OutputPointType &point ) const;
00154 inline InputVectorType BackTransform(const OutputVectorType &vector) const;
00155 inline InputVnlVectorType BackTransform(const OutputVnlVectorType &vector) const;
00157
00158 inline InputCovariantVectorType BackTransform(
00159 const OutputCovariantVectorType &vector) const;
00160
00162 void SetAngle(TScalarType angle);
00163 itkGetConstReferenceMacro( Angle, TScalarType );
00165
00167 void SetAngleInDegrees(TScalarType angle);
00168
00172 void SetRotation(TScalarType angle)
00173 { this->SetAngle(angle); }
00174 virtual const TScalarType & GetRotation() const
00175 { return m_Angle; }
00177
00186 void SetParameters( const ParametersType & parameters );
00187
00196 const ParametersType & GetParameters( void ) const;
00197
00202 const JacobianType & GetJacobian(const InputPointType &point ) const;
00203
00208 void CloneInverseTo( Pointer & newinverse ) const;
00209
00214 void CloneTo( Pointer & clone ) const;
00215
00217 virtual void SetIdentity(void);
00218
00219 protected:
00220 Rigid2DTransform();
00221 Rigid2DTransform( unsigned int outputSpaceDimension,
00222 unsigned int parametersDimension);
00223
00224 ~Rigid2DTransform();
00225
00229 void PrintSelf(std::ostream &os, Indent indent) const;
00230
00234 virtual void ComputeMatrix(void);
00235
00240 virtual void ComputeMatrixParameters(void);
00241
00243 void SetVarAngle( TScalarType angle )
00244 { m_Angle = angle; }
00245
00246 private:
00247 Rigid2DTransform(const Self&);
00248 void operator=(const Self&);
00249
00250 TScalarType m_Angle;
00251
00252 };
00253
00254
00255
00256 template<class TScalarType>
00257 typename Rigid2DTransform<TScalarType>::InputPointType
00258 inline
00259 Rigid2DTransform<TScalarType>::
00260 BackTransform(const OutputPointType &point) const
00261 {
00262 itkWarningMacro(<<"BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform.");
00263 return this->GetInverseMatrix() * (point - this->GetOffset());
00264 }
00265
00266
00267 template<class TScalarType>
00268 inline
00269 typename Rigid2DTransform<TScalarType>::InputVectorType
00270 Rigid2DTransform<TScalarType>::
00271 BackTransform(const OutputVectorType &vect ) const
00272 {
00273 itkWarningMacro(<<"BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform.");
00274 return this->GetInverseMatrix() * vect;
00275 }
00276
00277
00278 template<class TScalarType>
00279 inline
00280 typename Rigid2DTransform<TScalarType>::InputVnlVectorType
00281 Rigid2DTransform<TScalarType>::
00282 BackTransform(const OutputVnlVectorType &vect ) const
00283 {
00284 itkWarningMacro(<<"BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform.");
00285 return this->GetInverseMatrix() * vect;
00286 }
00287
00288
00289
00290 template<class TScalarType>
00291 inline
00292 typename Rigid2DTransform<TScalarType>::InputCovariantVectorType
00293 Rigid2DTransform<TScalarType>::
00294 BackTransform(const OutputCovariantVectorType &vect) const
00295 {
00296 itkWarningMacro(<<"BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform.");
00297 return this->GetMatrix() * vect;
00298 }
00299
00300 }
00301
00302
00303
00304 #define ITK_TEMPLATE_Rigid2DTransform(_, EXPORT, x, y) namespace itk { \
00305 _(1(class EXPORT Rigid2DTransform< ITK_TEMPLATE_1 x >)) \
00306 namespace Templates { typedef Rigid2DTransform< ITK_TEMPLATE_1 x > Rigid2DTransform##y; } \
00307 }
00308
00309 #if ITK_TEMPLATE_EXPLICIT
00310 # include "Templates/itkRigid2DTransform+-.h"
00311 #endif
00312
00313 #if ITK_TEMPLATE_TXX
00314 # include "itkRigid2DTransform.txx"
00315 #endif
00316
00317 #endif
00318