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 #include "cmtkXform.h"
00034
00035 #include <Base/cmtkVolume.h>
00036
00037 #include <math.h>
00038 #include <stdio.h>
00039
00040 namespace
00041 cmtk
00042 {
00043
00046
00047 void
00048 Xform::AllocateParameterVector
00049 ( const size_t numberOfParameters )
00050 {
00051 this->m_NumberOfParameters = numberOfParameters;
00052 if ( this->m_NumberOfParameters )
00053 {
00054 this->m_ParameterVector = CoordinateVector::SmartPtr( new CoordinateVector( this->m_NumberOfParameters ) );
00055 this->m_Parameters = this->m_ParameterVector->Elements;
00056 }
00057 else
00058 {
00059 this->m_ParameterVector = CoordinateVector::SmartPtr::Null;
00060 this->m_Parameters = NULL;
00061 }
00062 }
00063
00064 void
00065 Xform::SetParamVector ( CoordinateVector& v )
00066 {
00067 if ( this->m_ParameterVector )
00068 {
00069 *this->m_ParameterVector = v;
00070 }
00071 else
00072 {
00073 this->m_ParameterVector = CoordinateVector::SmartPtr( new CoordinateVector( v ) );
00074 }
00075 this->m_Parameters = this->m_ParameterVector->Elements;
00076 }
00077
00078 void
00079 Xform::SetParamVector ( const CoordinateVector& v )
00080 {
00081 if ( this->m_ParameterVector )
00082 {
00083 *this->m_ParameterVector = v;
00084 }
00085 else
00086 {
00087 this->m_ParameterVector = CoordinateVector::SmartPtr( new CoordinateVector( v ) );
00088 }
00089 this->m_Parameters = this->m_ParameterVector->Elements;
00090 }
00091
00092 CoordinateVector&
00093 Xform::GetParamVector
00094 ( CoordinateVector& v, const size_t targetOffset ) const
00095 {
00096 v.AdjustDimension( std::max<int>( v.Dim, targetOffset + this->ParamVectorDim() ) );
00097 v.CopyToOffset( *this->m_ParameterVector, targetOffset, this->ParamVectorDim() );
00098 return v;
00099 }
00100
00101 void
00102 Xform::GetVolumeOfInfluence
00103 ( const size_t, const Self::SpaceVectorType& fromVol, const Self::SpaceVectorType& toVol, Self::SpaceVectorType& fromVOI, Self::SpaceVectorType& toVOI, const int ) const
00104 {
00105 fromVOI = fromVol;
00106 toVOI = toVol;
00107 }
00108
00109 Types::Coordinate
00110 Xform::GetLandmarksMSD( const MatchedLandmarkList* ll ) const
00111 {
00112 double MSD = 0;
00113
00114 MatchedLandmarkList::const_iterator it = ll->begin();
00115 while ( it != ll->end() )
00116 {
00117 Self::SpaceVectorType source( (*it)->GetLocation() );
00118 Self::SpaceVectorType target( (*it)->GetTargetLocation() );
00119 this->ApplyInPlace( source );
00120 MSD += (source - target).SumOfSquares();
00121 ++it;
00122 }
00123
00124 MSD /= ll->size();
00125
00126 return MSD;
00127 }
00128
00129 }