00001 /* 00002 // 00003 // Copyright 1997-2009 Torsten Rohlfing 00004 // 00005 // Copyright 2004-2011 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: 2752 $ 00026 // 00027 // $LastChangedDate: 2011-01-17 11:33:31 -0800 (Mon, 17 Jan 2011) $ 00028 // 00029 // $LastChangedBy: torstenrohlfing $ 00030 // 00031 */ 00032 00033 #ifndef __cmtkVoxelMatchingFunctional_h_included_ 00034 #define __cmtkVoxelMatchingFunctional_h_included_ 00035 00036 #include <cmtkconfig.h> 00037 00038 #include <Base/cmtkMathUtil.h> 00039 #include <Base/cmtkTypes.h> 00040 #include <Base/cmtkFunctional.h> 00041 #include <Base/cmtkVector.h> 00042 #include <Base/cmtkVolume.h> 00043 #include <Base/cmtkUniformVolume.h> 00044 #include <Base/cmtkMatchedLandmarkList.h> 00045 00046 #include <System/cmtkException.h> 00047 00048 #if defined(CMTK_BUILD_SMP) 00049 # include <System/cmtkLockingPtr.h> 00050 #endif 00051 00052 #include <cassert> 00053 00054 namespace 00055 cmtk 00056 { 00057 00060 00067 class VoxelMatchingFunctional : 00069 public Functional 00070 { 00071 public: 00073 typedef VoxelMatchingFunctional Self; 00074 00076 typedef Functional Superclass; 00077 00078 protected: 00080 UniformVolume::SmartPtr ReferenceGrid; 00081 00083 UniformVolume::SmartPtr FloatingGrid; 00084 00086 DataClass ReferenceDataClass; 00087 00089 DataClass FloatingDataClass; 00090 00092 DataGrid::RegionType m_ReferenceCropRegion; 00093 00095 cmtkGetSetMacro(MatchedLandmarkList::SmartPtr,MatchedLandmarkList); 00096 00098 cmtkGetSetMacro(Self::ReturnType,LandmarkErrorWeight); 00099 00100 public: 00107 VoxelMatchingFunctional( UniformVolume::SmartPtr& reference, UniformVolume::SmartPtr& floating ) 00108 : m_MatchedLandmarkList( NULL ) 00109 { 00110 this->InitFloating( floating ); 00111 this->InitReference( reference ); 00112 this->m_LandmarkErrorWeight = 0; 00113 } 00114 00117 virtual ~VoxelMatchingFunctional() {} 00118 00119 protected: 00121 DataGrid::IndexType FloatingDims; 00122 00124 UniformVolume::CoordinateVectorType FloatingSize; 00125 00127 Vector3D FloatingInverseDelta; 00128 00130 UniformVolume::CoordinateRegionType m_FloatingCropRegionCoordinates; 00131 00133 UniformVolume::CoordinateRegionType m_FloatingCropRegionFractional; 00134 00136 DataGrid::IndexType ReferenceDims; 00137 00139 UniformVolume::CoordinateVectorType ReferenceSize; 00140 00142 UniformVolume::CoordinateVectorType ReferenceInvDelta; 00143 00150 const DataGrid::RegionType GetReferenceGridRange ( const Vector3D& fromVOI, const Vector3D& toVOI ); 00151 00152 private: 00154 VoxelMatchingFunctional ( const VoxelMatchingFunctional& ) {} 00155 00157 void InitFloating( UniformVolume::SmartPtr& floating ); 00158 00160 void InitReference( UniformVolume::SmartPtr& reference ); 00161 }; 00162 00176 template<class VM> 00177 class VoxelMatchingFunctional_Template 00178 { 00179 protected: 00181 SmartPointer<VM> Metric; 00182 00183 public: 00190 VoxelMatchingFunctional_Template 00191 ( UniformVolume::SmartPtr& reference, 00192 UniformVolume::SmartPtr& floating ) 00193 { Metric = SmartPointer<VM>( new VM( reference, floating ) ); } 00194 00198 virtual ~VoxelMatchingFunctional_Template () {} 00199 00200 #if defined(CMTK_BUILD_SMP) 00201 protected: 00211 MutexLock MetricMutex; 00212 #endif 00213 }; 00214 00216 00217 } // namespace cmtk 00218 00219 #endif // __cmtkVoxelMatchingFunctional_h_included_