Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __cmtkDeformationField_h_included_
00034 #define __cmtkDeformationField_h_included_
00035
00036 #include <cmtkconfig.h>
00037
00038 #include <Base/cmtkWarpXform.h>
00039 #include <Base/cmtkMacros.h>
00040 #include <Base/cmtkVector.h>
00041 #include <Base/cmtkUniformVolume.h>
00042 #include <Base/cmtkAffineXform.h>
00043
00044 #include <System/cmtkSmartPtr.h>
00045
00046 namespace
00047 cmtk
00048 {
00049
00052
00057 class DeformationField :
00059 public WarpXform
00060 {
00061 public:
00063 typedef DeformationField Self;
00064
00066 typedef WarpXform Superclass;
00067
00069 typedef SmartPointer<Self> SmartPtr;
00070
00071 public:
00073 DeformationField( const UniformVolume* volume )
00074 {
00075 this->InitGrid( volume->Size, volume->m_Dims );
00076 this->m_Offset = volume->m_Offset;
00077 }
00078
00080 DeformationField( const FixedVector<3,Types::Coordinate>& domain, const DataGrid::IndexType& dims, const Types::Coordinate* offset = NULL )
00081 {
00082 this->InitGrid( domain, dims );
00083 if ( offset )
00084 {
00085 for ( int dim = 0; dim < 3; ++dim )
00086 this->m_Offset[dim] = offset[dim];
00087 }
00088 }
00089
00091 virtual ~DeformationField () {}
00092
00094 virtual void InitGrid( const FixedVector<3,Types::Coordinate>& domain, const DataGrid::IndexType& dims )
00095 {
00096 this->Superclass::InitGrid( domain, dims );
00097 for ( int dim = 0; dim < 3; ++dim )
00098 {
00099 if ( dims[dim] > 1 )
00100 this->Spacing[dim] = domain[dim] / (dims[dim]-1);
00101 else
00102 this->Spacing[dim] = 1.0;
00103 this->InverseSpacing[dim] = 1.0 / this->Spacing[dim];
00104 }
00105 this->InverseAffineScaling[0] = this->InverseAffineScaling[1] = this->InverseAffineScaling[2] = this->GlobalScaling = 1.0;
00106 }
00107
00109 void InitControlPoints( const AffineXform* affineXform = NULL );
00110
00112 virtual void ApplyInPlace ( Self::SpaceVectorType& ) const;
00113
00116 virtual bool ApplyInverse ( const Self::SpaceVectorType&, Self::SpaceVectorType&, const Types::Coordinate = 0.01 ) const
00117 {
00118
00119 return false;
00120 }
00121
00124 virtual bool ApplyInverseInPlace( Self::SpaceVectorType&, const Types::Coordinate = 0.01 ) const
00125 {
00126
00127 return false;
00128 }
00129
00131 virtual void GetTransformedGrid( Self::SpaceVectorType& v, const int idxX, const int idxY, const int idxZ ) const;
00132
00134 virtual void GetTransformedGridRow( Self::SpaceVectorType *const v, const int numPoints, const int idxX, const int idxY, const int idxZ ) const;
00135
00137 virtual void GetJacobian( const Self::SpaceVectorType& v, CoordinateMatrix3x3& J ) const;
00138
00140 virtual Types::Coordinate GetJacobianDeterminant ( const Self::SpaceVectorType& v ) const
00141 {
00142 CoordinateMatrix3x3 J;
00143 this->GetJacobian( v, J );
00144 return J.Determinant();
00145 }
00146
00148 virtual Types::Coordinate GetParamStep( const size_t, const Self::SpaceVectorType&, const Types::Coordinate mmStep = 1 ) const
00149 {
00150 return mmStep;
00151 }
00152
00153 protected:
00157 virtual Self* CloneVirtual () const { return NULL; }
00158 };
00159
00161
00162 }
00163
00164 #endif // #ifndef __cmtkDeformationField_h_included_