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: 2005/08/11 16:44:08 $
00007   Version:   $Revision: 1.13 $
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 
00018 #ifndef __itkMatrixOffsetTransformBase_h
00019 #define __itkMatrixOffsetTransformBase_h
00020 
00021 #include <iostream>
00022 
00023 #include "itkMatrix.h"
00024 #include "itkTransform.h"
00025 #include "itkExceptionObject.h"
00026 #include "itkMacro.h"
00027 
00028 namespace itk
00029 {
00030 
00031 
00076 template <
00077   class TScalarType=double,         // Data type for scalars 
00078   unsigned int NInputDimensions=3,  // Number of dimensions in the input space
00079   unsigned int NOutputDimensions=3> // Number of dimensions in the output space
00080 class MatrixOffsetTransformBase 
00081   : public Transform< TScalarType, NInputDimensions, NOutputDimensions >
00082 {
00083 public:
00085   typedef MatrixOffsetTransformBase             Self;
00086   typedef Transform< TScalarType,
00087                      NInputDimensions,
00088                      NOutputDimensions >        Superclass;
00089   typedef SmartPointer<Self>                    Pointer;
00090   typedef SmartPointer<const Self>              ConstPointer;
00091 
00093   itkTypeMacro( MatrixOffsetTransformBase, Transform );
00094 
00096   itkNewMacro( Self );
00097 
00099   itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions);
00100   itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
00101   itkStaticConstMacro(ParametersDimension, unsigned int,
00102                       NOutputDimensions*(NInputDimensions+1));
00104 
00105   
00107   typedef typename Superclass::ParametersType                  ParametersType;
00108 
00110   typedef typename Superclass::JacobianType                    JacobianType;
00111 
00113   typedef typename Superclass::ScalarType                      ScalarType;
00114 
00116   typedef Vector<TScalarType,
00117                  itkGetStaticConstMacro(InputSpaceDimension)>  InputVectorType;
00118   typedef Vector<TScalarType,
00119                  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
00121 
00123   typedef CovariantVector<TScalarType,
00124                           itkGetStaticConstMacro(InputSpaceDimension)>  
00125                                                     InputCovariantVectorType;
00126   typedef CovariantVector<TScalarType,
00127                           itkGetStaticConstMacro(OutputSpaceDimension)>  
00128                                                     OutputCovariantVectorType;
00130 
00132   typedef vnl_vector_fixed<TScalarType,
00133                            itkGetStaticConstMacro(InputSpaceDimension)> 
00134                                                     InputVnlVectorType;
00135   typedef vnl_vector_fixed<TScalarType,
00136                            itkGetStaticConstMacro(OutputSpaceDimension)> 
00137                                                     OutputVnlVectorType;
00139 
00141   typedef Point<TScalarType,
00142                 itkGetStaticConstMacro(InputSpaceDimension)>   
00143                                                     InputPointType;
00144   typedef Point<TScalarType,
00145                 itkGetStaticConstMacro(OutputSpaceDimension)>  
00146                                                     OutputPointType;
00148 
00150   typedef Matrix<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension),
00151                  itkGetStaticConstMacro(InputSpaceDimension)>  
00152                                                     MatrixType;
00153 
00155   typedef Matrix<TScalarType, itkGetStaticConstMacro(InputSpaceDimension),
00156                  itkGetStaticConstMacro(OutputSpaceDimension)> 
00157                                                     InverseMatrixType;
00158 
00159   typedef InputPointType                            CenterType;
00160 
00161   typedef OutputVectorType                          OffsetType;
00162 
00163   typedef OutputVectorType                          TranslationType;
00164 
00168   virtual void SetIdentity( void );
00169 
00181   virtual void SetMatrix(const MatrixType &matrix)
00182     { m_Matrix = matrix; this->ComputeOffset();
00183       this->ComputeMatrixParameters();
00184       m_MatrixMTime.Modified(); this->Modified(); return; }
00186 
00193   const MatrixType & GetMatrix() const
00194       { return m_Matrix; }
00195 
00204   void SetOffset(const OutputVectorType &offset)
00205       { m_Offset = offset; this->ComputeTranslation();
00206         this->Modified(); return; }
00208 
00214   const OutputVectorType & GetOffset(void) const
00215       { return m_Offset; }
00216 
00239   void SetCenter(const InputPointType & center)
00240       { m_Center = center; this->ComputeOffset();
00241         this->Modified(); return; }
00243 
00250   const InputPointType & GetCenter() const
00251       { return m_Center; }
00252 
00259   void SetTranslation(const OutputVectorType & translation)
00260       { m_Translation = translation; this->ComputeOffset();
00261         this->Modified(); return; }
00263 
00270   const OutputVectorType & GetTranslation(void) const
00271       { return m_Translation; }
00272 
00273 
00278   void SetParameters( const ParametersType & parameters );
00279 
00281   const ParametersType& GetParameters(void) const;
00282 
00284   virtual void SetFixedParameters( const ParametersType & );
00285 
00287   virtual const ParametersType& GetFixedParameters(void) const;
00288 
00289 
00301   void Compose(const Self * other, bool pre=0);
00302 
00310   OutputPointType     TransformPoint(const InputPointType & point) const;
00311   OutputVectorType    TransformVector(const InputVectorType & vector) const;
00312   OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const;
00313   OutputCovariantVectorType TransformCovariantVector(
00314                                 const InputCovariantVectorType &vector) const;
00316 
00323   const JacobianType & GetJacobian(const InputPointType & point ) const;
00324 
00341   bool GetInverse(Self * inverse) const;
00343 
00347   const InverseMatrixType & GetInverseMatrix( void ) const;
00348 
00349 protected:
00357   MatrixOffsetTransformBase(const MatrixType &matrix,
00358                             const OutputVectorType &offset);
00359   MatrixOffsetTransformBase(unsigned int outputDims,
00360                             unsigned int paramDims);
00361   MatrixOffsetTransformBase();      
00363 
00365   virtual ~MatrixOffsetTransformBase();
00366 
00368   void PrintSelf(std::ostream &s, Indent indent) const;
00369 
00370   InverseMatrixType GetVarInverseMatrix( void ) const
00371     { return m_InverseMatrix; };
00372   void SetVarInverseMatrix(const InverseMatrixType & matrix) const
00373     { m_InverseMatrix = matrix; m_InverseMatrixMTime.Modified(); };
00374   bool InverseMatrixIsOld(void) const
00375     { if(m_MatrixMTime != m_InverseMatrixMTime)
00376         { return true; } else { return false; } };
00377 
00378   virtual void ComputeMatrixParameters(void);
00379 
00380   virtual void ComputeMatrix(void);
00381   void SetVarMatrix(const MatrixType & matrix)
00382     { m_Matrix = matrix; m_MatrixMTime.Modified(); };
00383 
00384   virtual void ComputeTranslation(void);
00385   void SetVarTranslation(const OutputVectorType & translation)
00386     { m_Translation = translation; };
00387 
00388   virtual void ComputeOffset(void);
00389   void SetVarOffset(const OutputVectorType & offset)
00390     { m_Offset = offset; };
00391 
00392   void SetVarCenter(const InputPointType & center)
00393     { m_Center = center; };
00394 
00395 private:
00396 
00397   MatrixOffsetTransformBase(const Self & other);
00398   const Self & operator=( const Self & );
00399 
00400  
00401   MatrixType                  m_Matrix;         // Matrix of the transformation
00402   OutputVectorType            m_Offset;         // Offset of the transformation
00403   mutable InverseMatrixType   m_InverseMatrix;  // Inverse of the matrix
00404   mutable bool                m_Singular;       // Is m_Inverse singular?
00405 
00406   InputPointType              m_Center;
00407   OutputVectorType            m_Translation;
00408 
00410   TimeStamp                   m_MatrixMTime;
00411   mutable TimeStamp           m_InverseMatrixMTime;
00412 
00413 }; //class MatrixOffsetTransformBase
00414 
00415 }  // namespace itk
00416 
00417 
00418 #ifndef ITK_MANUAL_INSTANTIATION
00419 #include "itkMatrixOffsetTransformBase.txx"
00420 #endif
00421 
00422 #endif /* __itkMatrixOffsetTransformBase_h */
00423 
00424 

Generated at Sat Sep 2 20:49:37 2006 for ITK by doxygen 1.4.7 written by Dimitri van Heesch, © 1997-2000