Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkMatrixOffsetTransformBase.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMatrixOffsetTransformBase.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-02-05 22:04:02 $
00007   Version:   $Revision: 1.21 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkMatrixOffsetTransformBase_h
00018 #define __itkMatrixOffsetTransformBase_h
00019 
00020 #include <iostream>
00021 
00022 #include "itkMatrix.h"
00023 #include "itkTransform.h"
00024 #include "itkExceptionObject.h"
00025 #include "itkMacro.h"
00026 
00027 namespace itk
00028 {
00029 
00030 
00075 template <
00076   class TScalarType=double,         // Data type for scalars 
00077   unsigned int NInputDimensions=3,  // Number of dimensions in the input space
00078   unsigned int NOutputDimensions=3> // Number of dimensions in the output space
00079 class MatrixOffsetTransformBase 
00080   : public Transform< TScalarType, NInputDimensions, NOutputDimensions >
00081 {
00082 public:
00084   typedef MatrixOffsetTransformBase             Self;
00085   typedef Transform< TScalarType,
00086                      NInputDimensions,
00087                      NOutputDimensions >        Superclass;
00088   typedef SmartPointer<Self>                    Pointer;
00089   typedef SmartPointer<const Self>              ConstPointer;
00090 
00092   itkTypeMacro( MatrixOffsetTransformBase, Transform );
00093 
00095   itkNewMacro( Self );
00096 
00098   itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions);
00099   itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
00100   itkStaticConstMacro(ParametersDimension, unsigned int,
00101                       NOutputDimensions*(NInputDimensions+1));
00103 
00104   
00106   typedef typename Superclass::ParametersType                  ParametersType;
00107 
00109   typedef typename Superclass::JacobianType                    JacobianType;
00110 
00112   typedef typename Superclass::ScalarType                      ScalarType;
00113 
00115   typedef Vector<TScalarType,
00116                  itkGetStaticConstMacro(InputSpaceDimension)>  InputVectorType;
00117   typedef Vector<TScalarType,
00118                  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
00120 
00122   typedef CovariantVector<TScalarType,
00123                           itkGetStaticConstMacro(InputSpaceDimension)>  
00124                                                     InputCovariantVectorType;
00125   typedef CovariantVector<TScalarType,
00126                           itkGetStaticConstMacro(OutputSpaceDimension)>  
00127                                                     OutputCovariantVectorType;
00129 
00131   typedef vnl_vector_fixed<TScalarType,
00132                            itkGetStaticConstMacro(InputSpaceDimension)> 
00133                                                     InputVnlVectorType;
00134   typedef vnl_vector_fixed<TScalarType,
00135                            itkGetStaticConstMacro(OutputSpaceDimension)> 
00136                                                     OutputVnlVectorType;
00138 
00140   typedef Point<TScalarType,
00141                 itkGetStaticConstMacro(InputSpaceDimension)>   
00142                                                     InputPointType;
00143   typedef Point<TScalarType,
00144                 itkGetStaticConstMacro(OutputSpaceDimension)>  
00145                                                     OutputPointType;
00147 
00149   typedef Matrix<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension),
00150                  itkGetStaticConstMacro(InputSpaceDimension)>  
00151                                                     MatrixType;
00152 
00154   typedef Matrix<TScalarType, itkGetStaticConstMacro(InputSpaceDimension),
00155                  itkGetStaticConstMacro(OutputSpaceDimension)> 
00156                                                     InverseMatrixType;
00157 
00158   typedef InputPointType                            CenterType;
00159 
00160   typedef OutputVectorType                          OffsetType;
00161 
00162   typedef OutputVectorType                          TranslationType;
00163 
00167   virtual void SetIdentity( void );
00168 
00180   virtual void SetMatrix(const MatrixType &matrix)
00181     {
00182     m_Matrix = matrix; this->ComputeOffset();
00183     this->ComputeMatrixParameters();
00184     m_MatrixMTime.Modified(); this->Modified(); return;
00185     }
00187 
00194   const MatrixType & GetMatrix() const
00195     { return m_Matrix; }
00196 
00205   void SetOffset(const OutputVectorType &offset)
00206     {
00207     m_Offset = offset; this->ComputeTranslation();
00208     this->Modified(); return;
00209     }
00211 
00217   const OutputVectorType & GetOffset(void) const
00218     { return m_Offset; }
00219 
00242   void SetCenter(const InputPointType & center)
00243     {
00244     m_Center = center; this->ComputeOffset();
00245     this->Modified(); return;
00246     }
00248 
00255   const InputPointType & GetCenter() const
00256     { return m_Center; }
00257 
00264   void SetTranslation(const OutputVectorType & translation)
00265     {
00266     m_Translation = translation; this->ComputeOffset();
00267     this->Modified(); return;
00268     }
00270 
00277   const OutputVectorType & GetTranslation(void) const
00278     {
00279     return m_Translation;
00280     }
00281 
00286   void SetParameters( const ParametersType & parameters );
00287 
00289   const ParametersType& GetParameters(void) const;
00290 
00292   virtual void SetFixedParameters( const ParametersType & );
00293 
00295   virtual const ParametersType& GetFixedParameters(void) const;
00296 
00297 
00309   void Compose(const Self * other, bool pre=0);
00310 
00318   OutputPointType     TransformPoint(const InputPointType & point) const;
00319   OutputVectorType    TransformVector(const InputVectorType & vector) const;
00320   OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const;
00321   OutputCovariantVectorType TransformCovariantVector(
00322                                 const InputCovariantVectorType &vector) const;
00324 
00331   const JacobianType & GetJacobian(const InputPointType & point ) const;
00332 
00351   bool GetInverse(Self * inverse) const;
00353 
00354 
00358   const InverseMatrixType & GetInverseMatrix( void ) const;
00359 
00365   virtual bool IsLinear() const { return true; }
00366 
00367 protected:
00375   MatrixOffsetTransformBase(const MatrixType &matrix,
00376                             const OutputVectorType &offset);
00377   MatrixOffsetTransformBase(unsigned int outputDims,
00378                             unsigned int paramDims);
00379   MatrixOffsetTransformBase();
00381 
00383   virtual ~MatrixOffsetTransformBase();
00384 
00386   void PrintSelf(std::ostream &s, Indent indent) const;
00387 
00388   const InverseMatrixType & GetVarInverseMatrix( void ) const
00389     { return m_InverseMatrix; }
00390   void SetVarInverseMatrix(const InverseMatrixType & matrix) const
00391     { m_InverseMatrix = matrix; m_InverseMatrixMTime.Modified(); }
00392   bool InverseMatrixIsOld(void) const
00393     {
00394     if(m_MatrixMTime != m_InverseMatrixMTime)
00395       {
00396       return true;
00397       }
00398     else
00399       {
00400       return false;
00401       }
00402     }
00403 
00404   virtual void ComputeMatrixParameters(void);
00405 
00406   virtual void ComputeMatrix(void);
00407   void SetVarMatrix(const MatrixType & matrix)
00408     { m_Matrix = matrix; m_MatrixMTime.Modified(); }
00409 
00410   virtual void ComputeTranslation(void);
00411   void SetVarTranslation(const OutputVectorType & translation)
00412     { m_Translation = translation; }
00413 
00414   virtual void ComputeOffset(void);
00415   void SetVarOffset(const OutputVectorType & offset)
00416     { m_Offset = offset; }
00417 
00418   void SetVarCenter(const InputPointType & center)
00419     { m_Center = center; }
00420 
00421 private:
00422 
00423   MatrixOffsetTransformBase(const Self & other);
00424   const Self & operator=( const Self & );
00425 
00426  
00427   MatrixType                  m_Matrix;         // Matrix of the transformation
00428   OutputVectorType            m_Offset;         // Offset of the transformation
00429   mutable InverseMatrixType   m_InverseMatrix;  // Inverse of the matrix
00430   mutable bool                m_Singular;       // Is m_Inverse singular?
00431 
00432   InputPointType              m_Center;
00433   OutputVectorType            m_Translation;
00434 
00436   TimeStamp                   m_MatrixMTime;
00437   mutable TimeStamp           m_InverseMatrixMTime;
00438 
00439 }; //class MatrixOffsetTransformBase
00440 
00441 }  // namespace itk
00442 
00443 // Define instantiation macro for this template.
00444 #define ITK_TEMPLATE_MatrixOffsetTransformBase(_, EXPORT, x, y) namespace itk { \
00445   _(3(class EXPORT MatrixOffsetTransformBase< ITK_TEMPLATE_3 x >)) \
00446   namespace Templates { typedef MatrixOffsetTransformBase< ITK_TEMPLATE_3 x > MatrixOffsetTransformBase##y; } \
00447   }
00448 
00449 #if ITK_TEMPLATE_EXPLICIT
00450 # include "Templates/itkMatrixOffsetTransformBase+-.h"
00451 #endif
00452 
00453 #if ITK_TEMPLATE_TXX
00454 # include "itkMatrixOffsetTransformBase.txx"
00455 #endif
00456 
00457 #endif /* __itkMatrixOffsetTransformBase_h */
00458 

Generated at Sat Feb 28 12:58:07 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000