cmtkXform.h

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //
00005 //  Copyright 2004-2010 SRI International
00006 //
00007 //  This file is part of the Computational Morphometry Toolkit.
00008 //
00009 //  http://www.nitrc.org/projects/cmtk/
00010 //
00011 //  The Computational Morphometry Toolkit is free software: you can
00012 //  redistribute it and/or modify it under the terms of the GNU General Public
00013 //  License as published by the Free Software Foundation, either version 3 of
00014 //  the License, or (at your option) any later version.
00015 //
00016 //  The Computational Morphometry Toolkit is distributed in the hope that it
00017 //  will be useful, but WITHOUT ANY WARRANTY; without even the implied
00018 //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //  GNU General Public License for more details.
00020 //
00021 //  You should have received a copy of the GNU General Public License along
00022 //  with the Computational Morphometry Toolkit.  If not, see
00023 //  <http://www.gnu.org/licenses/>.
00024 //
00025 //  $Revision: 2440 $
00026 //
00027 //  $LastChangedDate: 2010-10-13 10:57:59 -0700 (Wed, 13 Oct 2010) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
00030 //
00031 */
00032 
00033 #ifndef __cmtkXform_h_included_
00034 #define __cmtkXform_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Base/cmtkMetaInformationObject.h>
00039 #include <Base/cmtkAnatomicalOrientationBase.h>
00040 #include <Base/cmtkVector.h>
00041 #include <Base/cmtkFixedVector.h>
00042 #include <Base/cmtkBitVector.h>
00043 #include <Base/cmtkMatchedLandmarkList.h>
00044 
00045 #include <System/cmtkSmartPtr.h>
00046 
00047 namespace
00048 cmtk
00049 {
00050 
00053 
00056 class Xform :
00058   public MetaInformationObject
00059 {
00060 public:
00062   typedef Xform Self;
00063 
00065   typedef SmartPointer<Self> SmartPtr;
00066 
00068   typedef SmartConstPointer<Self> SmartConstPtr;
00069 
00071   typedef FixedVector<3,Types::Coordinate> SpaceVectorType;
00072 
00074   Types::Coordinate *m_Parameters;
00075 
00077   size_t m_NumberOfParameters;
00078 
00080   Xform( const Xform& other )
00081     : MetaInformationObject( other ),
00082       m_NumberOfParameters( other.m_NumberOfParameters ),
00083       m_ParameterVector( other.m_ParameterVector )
00084   {
00085     this->m_Parameters = this->m_ParameterVector->Elements;
00086     this->m_MetaInformation[cmtk::META_SPACE] = cmtk::AnatomicalOrientationBase::ORIENTATION_STANDARD;
00087   }
00088 
00090   Xform()
00091     : m_Parameters( NULL ),
00092       m_NumberOfParameters( 0 ) 
00093   {
00094     this->m_MetaInformation[cmtk::META_SPACE] = cmtk::AnatomicalOrientationBase::ORIENTATION_STANDARD;
00095   }
00096 
00098   virtual ~Xform() {}
00099   
00101   virtual bool InDomain( const Self::SpaceVectorType& ) const { return true; }
00102   
00104   virtual Types::Coordinate GetGlobalScaling() const { return 0.0; }
00105 
00107   virtual Self::SpaceVectorType Apply ( const Self::SpaceVectorType& ) const = 0;
00108 
00110   virtual void ApplyInPlace ( Self::SpaceVectorType& ) const = 0;
00111 
00114   virtual bool ApplyInverse ( const Self::SpaceVectorType&, Self::SpaceVectorType&, const Types::Coordinate = 0.01  ) const = 0;
00115 
00118   virtual bool ApplyInverseInPlace( Self::SpaceVectorType&, const Types::Coordinate = 0.01  ) const = 0;
00119 
00122   virtual bool ApplyInverseInPlaceWithInitial( Self::SpaceVectorType& v, const Self::SpaceVectorType&, const Types::Coordinate error = 0.01 ) const
00123   {
00124     return this->ApplyInverseInPlace( v, error );
00125   }
00126 
00128   Self::SmartPtr Clone () const 
00129   {
00130     return Self::SmartPtr( this->CloneVirtual() );
00131   }
00132 
00134   virtual size_t ParamVectorDim () const 
00135   {
00136     return this->m_NumberOfParameters;
00137   }
00138 
00144   virtual size_t VariableParamVectorDim () const
00145   {
00146     return this->ParamVectorDim();
00147   }
00148 
00154   virtual void SetParamVector ( CoordinateVector& v );
00155 
00159   virtual void CopyParamVector ( const Xform* other )
00160   {
00161     *(this->m_ParameterVector) = *(other->m_ParameterVector);
00162     this->m_Parameters = this->m_ParameterVector->Elements;
00163   }
00164 
00166   virtual void SetParamVector ( const CoordinateVector& v );
00167 
00169   virtual void SetParameter ( const size_t idx, const Types::Coordinate p )
00170   {
00171     this->m_Parameters[idx] = p;
00172   }
00173 
00175   virtual Types::Coordinate GetParameter ( const size_t idx ) const
00176   {
00177     return this->m_Parameters[idx];
00178   }
00179 
00181   virtual CoordinateVector& GetParamVector( CoordinateVector& v, const size_t targetOffset = 0 ) const;
00182 
00184   virtual Types::Coordinate GetParamStep( const size_t, const Self::SpaceVectorType&, const Types::Coordinate step_mm = 1 ) const
00185   { 
00186     return step_mm;
00187   }
00188   
00190   virtual Types::Coordinate GetJacobianDeterminant ( const Self::SpaceVectorType& ) const = 0;
00191   
00196   virtual Types::Coordinate GetLandmarksMSD( const MatchedLandmarkList* ll ) const;
00197   
00199   virtual void GetVolumeOfInfluence( const size_t idx, const Self::SpaceVectorType&, const Self::SpaceVectorType&, Self::SpaceVectorType&, Self::SpaceVectorType&, const int = -1 ) const;
00200   
00201 protected:
00207   CoordinateVector::SmartPtr m_ParameterVector;
00208 
00211   void AllocateParameterVector( const size_t numberOfParameters );
00212 
00214   virtual Self* CloneVirtual () const = 0;
00215 };
00216 
00218 
00219 } // namespace cmtk
00220 
00221 #endif // #ifdef __cmtkXform_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines