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: 2007-11-08 22:28:20 $
00007   Version:   $Revision: 1.17 $
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 
00354   virtual bool IsLinear() const { return true; }
00355 
00356 protected:
00364   MatrixOffsetTransformBase(const MatrixType &matrix,
00365                             const OutputVectorType &offset);
00366   MatrixOffsetTransformBase(unsigned int outputDims,
00367                             unsigned int paramDims);
00368   MatrixOffsetTransformBase();      
00370 
00372   virtual ~MatrixOffsetTransformBase();
00373 
00375   void PrintSelf(std::ostream &s, Indent indent) const;
00376 
00377   const InverseMatrixType & GetVarInverseMatrix( void ) const
00378     { return m_InverseMatrix; };
00379   void SetVarInverseMatrix(const InverseMatrixType & matrix) const
00380     { m_InverseMatrix = matrix; m_InverseMatrixMTime.Modified(); };
00381   bool InverseMatrixIsOld(void) const
00382     { if(m_MatrixMTime != m_InverseMatrixMTime)
00383         { return true; } else { return false; } };
00384 
00385   virtual void ComputeMatrixParameters(void);
00386 
00387   virtual void ComputeMatrix(void);
00388   void SetVarMatrix(const MatrixType & matrix)
00389     { m_Matrix = matrix; m_MatrixMTime.Modified(); };
00390 
00391   virtual void ComputeTranslation(void);
00392   void SetVarTranslation(const OutputVectorType & translation)
00393     { m_Translation = translation; };
00394 
00395   virtual void ComputeOffset(void);
00396   void SetVarOffset(const OutputVectorType & offset)
00397     { m_Offset = offset; };
00398 
00399   void SetVarCenter(const InputPointType & center)
00400     { m_Center = center; };
00401 
00402 private:
00403 
00404   MatrixOffsetTransformBase(const Self & other);
00405   const Self & operator=( const Self & );
00406 
00407  
00408   MatrixType                  m_Matrix;         // Matrix of the transformation
00409   OutputVectorType            m_Offset;         // Offset of the transformation
00410   mutable InverseMatrixType   m_InverseMatrix;  // Inverse of the matrix
00411   mutable bool                m_Singular;       // Is m_Inverse singular?
00412 
00413   InputPointType              m_Center;
00414   OutputVectorType            m_Translation;
00415 
00417   TimeStamp                   m_MatrixMTime;
00418   mutable TimeStamp           m_InverseMatrixMTime;
00419 
00420 }; //class MatrixOffsetTransformBase
00421 
00422 }  // namespace itk
00423 
00424 // Define instantiation macro for this template.
00425 #define ITK_TEMPLATE_MatrixOffsetTransformBase(_, EXPORT, x, y) namespace itk { \
00426   _(3(class EXPORT MatrixOffsetTransformBase< ITK_TEMPLATE_3 x >)) \
00427   namespace Templates { typedef MatrixOffsetTransformBase< ITK_TEMPLATE_3 x > MatrixOffsetTransformBase##y; } \
00428   }
00429 
00430 #if ITK_TEMPLATE_EXPLICIT
00431 # include "Templates/itkMatrixOffsetTransformBase+-.h"
00432 #endif
00433 
00434 #if ITK_TEMPLATE_TXX
00435 # include "itkMatrixOffsetTransformBase.txx"
00436 #endif
00437 
00438 #endif /* __itkMatrixOffsetTransformBase_h */
00439 
00440 

Generated at Mon Apr 14 13:27:40 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000