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-11-28 15:58:04 $
00007   Version:   $Revision: 1.25 $
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   typedef typename Superclass::ParametersValueType             ParametersValueType;
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;
00120   typedef typename OutputVectorType::ValueType                 OutputVectorValueType;
00122 
00124   typedef CovariantVector<TScalarType,
00125                           itkGetStaticConstMacro(InputSpaceDimension)>  
00126                                                     InputCovariantVectorType;
00127   typedef CovariantVector<TScalarType,
00128                           itkGetStaticConstMacro(OutputSpaceDimension)>  
00129                                                     OutputCovariantVectorType;
00131 
00133   typedef vnl_vector_fixed<TScalarType,
00134                            itkGetStaticConstMacro(InputSpaceDimension)> 
00135                                                     InputVnlVectorType;
00136   typedef vnl_vector_fixed<TScalarType,
00137                            itkGetStaticConstMacro(OutputSpaceDimension)> 
00138                                                     OutputVnlVectorType;
00140 
00142   typedef Point<TScalarType,
00143                 itkGetStaticConstMacro(InputSpaceDimension)>   
00144                                                     InputPointType;
00145   typedef typename InputPointType::ValueType        InputPointValueType;
00146   typedef Point<TScalarType,
00147                 itkGetStaticConstMacro(OutputSpaceDimension)>  
00148                                                     OutputPointType;
00149   typedef typename OutputPointType::ValueType       OutputPointValueType;
00151 
00153   typedef Matrix<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension),
00154                  itkGetStaticConstMacro(InputSpaceDimension)>  
00155                                                     MatrixType;
00156   typedef typename MatrixType::ValueType            MatrixValueType;
00158 
00160   typedef Matrix<TScalarType, itkGetStaticConstMacro(InputSpaceDimension),
00161                  itkGetStaticConstMacro(OutputSpaceDimension)> 
00162                                                     InverseMatrixType;
00163 
00164   typedef InputPointType                            CenterType;
00165 
00166   typedef OutputVectorType                          OffsetType;
00167   typedef typename OffsetType::ValueType            OffsetValueType;
00168 
00169   typedef OutputVectorType                          TranslationType;
00170 
00171   typedef typename TranslationType::ValueType       TranslationValueType;
00172 
00175   typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
00176   typedef typename InverseTransformBaseType::Pointer    InverseTransformBasePointer;
00177 
00181   virtual void SetIdentity( void );
00182 
00194   virtual void SetMatrix(const MatrixType &matrix)
00195     {
00196     m_Matrix = matrix; this->ComputeOffset();
00197     this->ComputeMatrixParameters();
00198     m_MatrixMTime.Modified(); this->Modified(); return;
00199     }
00201 
00208   const MatrixType & GetMatrix() const
00209     { return m_Matrix; }
00210 
00219   void SetOffset(const OutputVectorType &offset)
00220     {
00221     m_Offset = offset; this->ComputeTranslation();
00222     this->Modified(); return;
00223     }
00225 
00231   const OutputVectorType & GetOffset(void) const
00232     { return m_Offset; }
00233 
00256   void SetCenter(const InputPointType & center)
00257     {
00258     m_Center = center; this->ComputeOffset();
00259     this->Modified(); return;
00260     }
00262 
00269   const InputPointType & GetCenter() const
00270     { return m_Center; }
00271 
00278   void SetTranslation(const OutputVectorType & translation)
00279     {
00280     m_Translation = translation; this->ComputeOffset();
00281     this->Modified(); return;
00282     }
00284 
00291   const OutputVectorType & GetTranslation(void) const
00292     {
00293     return m_Translation;
00294     }
00295 
00300   void SetParameters( const ParametersType & parameters );
00301 
00303   const ParametersType& GetParameters(void) const;
00304 
00306   virtual void SetFixedParameters( const ParametersType & );
00307 
00309   virtual const ParametersType& GetFixedParameters(void) const;
00310 
00311 
00323   void Compose(const Self * other, bool pre=0);
00324 
00332   OutputPointType     TransformPoint(const InputPointType & point) const;
00333   OutputVectorType    TransformVector(const InputVectorType & vector) const;
00334   OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const;
00335   OutputCovariantVectorType TransformCovariantVector(
00336                                 const InputCovariantVectorType &vector) const;
00338 
00345   const JacobianType & GetJacobian(const InputPointType & point ) const;
00346 
00365   bool GetInverse(Self * inverse) const;
00367 
00369   virtual InverseTransformBasePointer GetInverseTransform() const;
00370 
00374   const InverseMatrixType & GetInverseMatrix( void ) const;
00375 
00381   virtual bool IsLinear() const { return true; }
00382 
00383 protected:
00391   MatrixOffsetTransformBase(const MatrixType &matrix,
00392                             const OutputVectorType &offset);
00393   MatrixOffsetTransformBase(unsigned int outputDims,
00394                             unsigned int paramDims);
00395   MatrixOffsetTransformBase();
00397 
00399   virtual ~MatrixOffsetTransformBase();
00400 
00402   void PrintSelf(std::ostream &s, Indent indent) const;
00403 
00404   const InverseMatrixType & GetVarInverseMatrix( void ) const
00405     { return m_InverseMatrix; }
00406   void SetVarInverseMatrix(const InverseMatrixType & matrix) const
00407     { m_InverseMatrix = matrix; m_InverseMatrixMTime.Modified(); }
00408   bool InverseMatrixIsOld(void) const
00409     {
00410     if(m_MatrixMTime != m_InverseMatrixMTime)
00411       {
00412       return true;
00413       }
00414     else
00415       {
00416       return false;
00417       }
00418     }
00419 
00420   virtual void ComputeMatrixParameters(void);
00421 
00422   virtual void ComputeMatrix(void);
00423   void SetVarMatrix(const MatrixType & matrix)
00424     { m_Matrix = matrix; m_MatrixMTime.Modified(); }
00425 
00426   virtual void ComputeTranslation(void);
00427   void SetVarTranslation(const OutputVectorType & translation)
00428     { m_Translation = translation; }
00429 
00430   virtual void ComputeOffset(void);
00431   void SetVarOffset(const OutputVectorType & offset)
00432     { m_Offset = offset; }
00433 
00434   void SetVarCenter(const InputPointType & center)
00435     { m_Center = center; }
00436 
00437 private:
00438 
00439   MatrixOffsetTransformBase(const Self & other);
00440   const Self & operator=( const Self & );
00441 
00442  
00443   MatrixType                  m_Matrix;         // Matrix of the transformation
00444   OutputVectorType            m_Offset;         // Offset of the transformation
00445   mutable InverseMatrixType   m_InverseMatrix;  // Inverse of the matrix
00446   mutable bool                m_Singular;       // Is m_Inverse singular?
00447 
00448   InputPointType              m_Center;
00449   OutputVectorType            m_Translation;
00450 
00452   TimeStamp                   m_MatrixMTime;
00453   mutable TimeStamp           m_InverseMatrixMTime;
00454 
00455 }; //class MatrixOffsetTransformBase
00456 
00457 }  // namespace itk
00458 
00459 // Define instantiation macro for this template.
00460 #define ITK_TEMPLATE_MatrixOffsetTransformBase(_, EXPORT, x, y) namespace itk { \
00461   _(3(class EXPORT MatrixOffsetTransformBase< ITK_TEMPLATE_3 x >)) \
00462   namespace Templates { typedef MatrixOffsetTransformBase< ITK_TEMPLATE_3 x > MatrixOffsetTransformBase##y; } \
00463   }
00464 
00465 #if ITK_TEMPLATE_EXPLICIT
00466 # include "Templates/itkMatrixOffsetTransformBase+-.h"
00467 #endif
00468 
00469 #if ITK_TEMPLATE_TXX
00470 # include "itkMatrixOffsetTransformBase.txx"
00471 #endif
00472 
00473 #endif /* __itkMatrixOffsetTransformBase_h */
00474 

Generated at Fri Apr 16 18:59:48 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000