Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

mitkTransform.h

00001 /*=========================================================================
00002 
00003   Program:   3DMed
00004   Date:      $Date: 2014-02-25 18:30:00 +0800 $
00005   Version:   $Version: 4.6.0 $
00006   Copyright: MIPG, Institute of Automation, Chinese Academy of Sciences
00007 
00008 =========================================================================*/
00009 
00010 
00011 #ifndef __mitkTransform_h
00012 #define __mitkTransform_h
00013 
00014 #include "mitkProcessObject.h"
00015 #include "mitkVolume.h"
00016 #include "mitkList.h"
00017 #include "mitkGlobalRegistrationFramework.h"
00018 #include "mitkRCPtr.h"
00019 
00020 #include "mitkOoCGlobalSettings.h"
00021 
00022 #define INVALID_COORDINATES 10e4
00023 
00024 // A LIST OF TRANSFORM METHODS IMPLEMENTED IN MITK                      RELATED CLASS
00025 //-------------------------------------------------------+------------------------------------------
00026 
00027 #define MITK_TRANSFORM_SCALE                        0               // mitkScaleTransform
00028 #define MITK_TRANSFORM_SCALE_LOGARITHMIC            1               // mitkScaleTransform
00029 #define MITK_TRANSFORM_ROTATION                     2               //   (scheduled)
00030 #define MITK_TRANSFORM_TRANSLATION                  3               // mitkTranslationTransform
00031 #define MITK_TRANSFORM_RIGID                        4               // mitkRigidTransform
00032 #define MITK_TRANSFORM_RIGID_CENTERED               5               //   (scheduled)
00033 #define MITK_TRANSFORM_SIMILARITY                   6               // mitkSimilarityTransform
00034 #define MITK_TRANSFORM_SIMILARITY_CENTERED          7               //   (scheduled)
00035 #define MITK_TRANSFORM_AFFINE                       8               // mitkAffineTransform
00036 #define MITK_TRANSFORM_AFFINE_CENTERED              9               //   (scheduled)
00037 #define MITK_TRANSFORM_VERSOR_RIGID_3D              10              // mitkVersorRigid3DTransform
00038 #define MITK_TRANSFORM_VERSOR_SIMILARITY_3D         11              // mitkVersorSimilarity3DTransform
00039 #define MITK_TRANSFORM_HOMOGRAPHY                   12              //   (scheduled)
00040 #define MITK_TRANSFORM_PROJECTIVE                   13              //   (scheduled)
00041 #define MITK_TRANSFORM_QUADRATIC                    14              //   (scheduled)
00042 #define MITK_TRANSFORM_POLYNOMIAL                   15              //   (scheduled)
00043 #define MITK_TRANSFORM_THINPLATESPLINE_R            21              // mitkThinPlateSplineTransform
00044 #define MITK_TRANSFORM_THINPLATESPLINE_R2LOGR       22              // mitkThinPlateSplineTransform
00045 #define MITK_TRANSFORM_ELASTICBODYSPLINE            23              //   (scheduled)
00046 #define MITK_TRANSFORM_VOLUMESPLINE                 24              //   (scheduled)
00047 #define MITK_TRANSFORM_FREEFORM_BSPLINE             31              // mitkBSplineFreeFormTransform
00048 #define MITK_TRANSFORM_FREEFORM_NURBS               32              //   (scheduled)
00049 
00050 //--------------------------------------------------------------------------------------------------
00051 
00052 
00053 class mitkPointSet;
00054 class mitkVolumeIteratorBase;
00055 
00061 class MITK_REGISTRATION_API mitkTransform : public mitkProcessObject
00062 {
00063 public:
00064     MITK_TYPE(mitkTransform, mitkProcessObject) 
00065     virtual void PrintSelf(ostream &os);
00066 
00071     virtual void SetParameters(const VectorParameterType& parameters);
00072 
00077     virtual VectorParameterType& GetParameters();
00078 
00085     void SetDimensions(int d[3]);
00086     
00093     const VectorIndexType& GetDimensions() const { return m_Dimensions; }
00094 
00099     unsigned int GetSpaceDimension() { return m_SpaceDimension; }
00100     
00107     void SetSpacings(float s[3]);
00108     
00118     const VectorParameterType& GetSpacings() const { return m_Spacings; }
00119         
00124     mitkVolume* GetOutput();
00125 
00130     unsigned int GetNumberOfParameters() {return m_NumberOfParameters;}
00131 
00132     void SetNumberOfParameters(unsigned n) { m_NumberOfParameters = n; }
00133 
00138     void SetCentreTransformFlag(bool flag) { m_IsCentreTransform = flag;} 
00139 
00149     void SetRegion(const VectorIndexType& r);
00150 
00154     virtual bool Update();
00155 
00163     //virtual vector<float>* GetJacobian(int &x, int &y, int &z);
00164     virtual const MatrixType & GetJacobian(const VectorParameterType& inPoint);
00165 
00174     virtual void TransformPoint(const ScalarIndexType &x, const ScalarIndexType &y,
00175                                 const ScalarIndexType &z, float* outPoint);
00176 
00185     virtual void TransformPoint(const ScalarParameterType &x, const ScalarParameterType &y, 
00186                                 const ScalarParameterType &z, ScalarParameterType* outPoint);
00187 
00188     virtual void TransformPoint(const VectorIndexType & inPoint, VectorParameterType & outPoint);
00189 
00190     virtual void TransformPoint(const VectorParameterType & inPoint,VectorParameterType & outPoint);
00191 
00192 //  virtual void TransformPointInverse(const VectorIndexType & inPoint,VectorParameterType & outPoint) {}
00193 
00194 //  virtual void TransformPointInverse(const VectorParameterType & inPoint,VectorParameterType & outPoint) {}
00195 
00199     void SetIdentityMatrix();
00200     
00205     virtual void ComputeTransformMatrix();
00206 
00211     void SetComputeMatrixFlag(bool flag) {m_FlagComputeTransform = flag;}
00212 
00217     void SetComputeJacobianFlag(bool flag) {m_FlagComputeJacobian = flag;}
00218 
00223     void SetComputeTransformParametersFlag(bool flag) { m_FlagUseTransformVector = flag; }
00224 
00229     void SetTransformMatrix(mitkMatrixScalarType* matrix, bool ToCentered = true);
00230 
00235     void SetTransformMatrix(mitkMatrixType* matrix, bool ToCentered = true);
00236 
00241     mitkMatrixType* GetTransformMatrix();
00242 
00243     mitkMatrixType* GetPreTransformMatrix();
00244 
00245     void GetUncenteredTransformMatrix(mitkMatrixType* mat);
00246 
00251     void ConcatenationTransform(mitkMatrixType* matrix, bool ToCentered = true);
00252 
00257     bool GetConcatenationTransformFlag() { return m_FlagConcatenationTransform; }
00258 
00263     virtual void SetTransformMode(int transformMode, unsigned int dim);
00264 
00269     int GetTransformMode() {return m_TransformMode;}
00270 
00274     virtual void ConvertTransformMaxtrixToVector();
00275 
00279     virtual void ConvertTransformVectorToMatrix();
00280 
00281     void ConvertMatrixToCentered(mitkMatrixType* mat);
00282 
00283     void ConvertMatrixToUncentered(mitkMatrixType* mat);
00284 
00290     bool TransformPointSet(mitkPointSet* p);
00291 
00298     bool TransformPointSet(mitkPointSet* p1, mitkPointSet* p2);
00299 
00300     bool IsLinear() { return m_IsLinear; }
00301 
00302     void SetRotationCenter(VectorParameterType& center);
00303 
00304     VectorParameterType& GetRotationCenter();
00305 
00310     void SetOutputDatatype(int dataType) {m_OutputDataType = dataType;}
00311 
00312     virtual void GetInverse();
00313 
00314     bool IsInversed() { return m_FlagInverseTransform; }
00315 
00316     inline void TransformIndexToPhysicalPoint(const VectorIndexType& idx_in,
00317                                               VectorParameterType& idx_out);
00318 
00319     void AddTransform(mitkTransform* transform);
00320 
00321     void RemoveTransform(mitkTransform* transform);
00322 
00323     void RemoveAllTransform();
00324 
00325 #ifdef MITK_REGISTRATION_VER_OOC
00326     void SetOoCSupport(char const *diskPath=mitkOoCGlobalSettings::DiskCachePath, unsigned int bufSliceNum = mitkOoCGlobalSettings::BufferedSliceNumber, bool supportOoC = true);
00327 #endif
00328 
00329 protected:
00330     mitkTransform();
00331     virtual ~mitkTransform();
00332     virtual bool Execute();
00333     virtual void _transform(const ScalarParameterType* inPoint, ScalarParameterType* outPoint);
00334 
00335     mitkRCPtr<mitkVolume>                       m_OutData;
00336 
00337     VectorIndexType                             m_Dimensions;
00338     VectorParameterType                         m_Spacings;
00339     VectorIndexType                             m_Region;
00340 
00341     unsigned int                                m_SpaceDimension;
00342     unsigned int                                m_NumberOfParameters;
00343 
00344     VectorParameterType                         m_Parameters;
00345     MatrixType                                  m_Jacobian;
00346     VectorParameterType                         m_RotationCenter;
00347     mitkMatrixType*                             m_TransformMatrix;
00348     mitkMatrixType*                             m_PreTransformMatrix;
00349 
00350     int                                         m_TransformMode;
00351     int                                         m_OutputDataType;
00352 
00353     mitkList*                                   m_BulkTransformList;
00354 
00355 // --------------- flags ---------------
00356     bool                                        m_IsCentreTransform;
00357     bool                                        m_IsLinear;
00358     bool                                        m_FlagUserDefinedCenter;
00359     bool                                        m_FlagComputeTransform;
00360     bool                                        m_FlagComputeJacobian;
00361     bool                                        m_FlagConcatenationTransform;
00362     bool                                        m_FlagUseTransformVector;
00363     bool                                        m_FlagInverseTransform;
00364     bool                                        m_FlagBulkTransform;
00365 
00366 #ifdef MITK_REGISTRATION_VER_OOC
00367     bool                                        m_NeedOoC;
00368     unsigned int                                m_BufferedSliceNum;
00369     mitkString*                                 m_DiskPath;
00370 #endif
00371     
00372 private:
00373     mitkTransform(const mitkTransform&);
00374     void operator = (const mitkTransform&);
00375 };
00376 //-------------------------------------------------------------------------
00377 inline void mitkTransform::TransformIndexToPhysicalPoint(const VectorIndexType& idx_in, VectorParameterType& idx_out)
00378 {
00379     for(unsigned int i=0;i<m_SpaceDimension;i++) 
00380         idx_out[i] = static_cast<ScalarParameterType>(idx_in[i]) * m_Spacings[i];
00381 }
00382 //-------------------------------------------------------------------------
00383 
00384 
00385 //#define DEFINED_mitkTransform
00386 
00387 
00388 
00389 #endif
00390 

Generated on Tue Feb 25 15:00:37 2014 for MITK (Medical Imaging ToolKit) by  doxygen 1.4.3