00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freTransformFunctionAccessor_txx
00023 #define __freTransformFunctionAccessor_txx
00024
00025 #include "freTransformFunctionAccessor.h"
00026
00027 namespace FREE
00028 {
00029
00033
00034 template <class TTransformBase>
00035 typename TransformFunctionAccessor<TTransformBase>::TransformFunctionMediaPointer
00036 TransformFunctionAccessor<TTransformBase>::
00037 GetTransformationFunction(const TransformParametersType& parameters, const PointType& origin, const RegionType& region, const SpacingType& spacing)
00038 {
00039 TransformFunctionMediaPointer smpFunction = this->GetTransformationFunction(parameters);
00040 smpFunction->SetFieldOrigin(origin);
00041 smpFunction->SetFieldSpacing(spacing);
00042 smpFunction->SetFieldRegion(region);
00043
00044 return smpFunction;
00045 };
00046
00047 template <class TTransformBase>
00048 typename TransformFunctionAccessor<TTransformBase>::TransformFunctionMediaPointer
00049 TransformFunctionAccessor<TTransformBase>::
00050 GetTransformationFunction(const TransformParametersType& parameters)
00051 {
00052 const ITKTransformControllerInterfaceType* pController = 0;
00053 SessionComponentCache* pCache = 0;
00054
00055 GetTransformControllerAndCache(pController,pCache);
00056
00057 TransformFunctionMediaPointer smpFunction = pController->GenerateTransformationFunction(pCache,parameters);
00058 return smpFunction;
00059 };
00060
00061 template <class TTransformBase>
00062 typename TransformFunctionAccessor<TTransformBase>::TransformFunctionMediaPointer
00063 TransformFunctionAccessor<TTransformBase>::
00064 GetInverseTransformationFunction(const TransformParametersType& parameters, const PointType& origin, const RegionType& region, const SpacingType& spacing)
00065 {
00066 TransformFunctionMediaPointer smpFunction = this->GetInverseTransformationFunction(parameters);
00067 smpFunction->SetFieldOrigin(origin);
00068 smpFunction->SetFieldSpacing(spacing);
00069 smpFunction->SetFieldRegion(region);
00070
00071 return smpFunction;
00072 };
00073
00074 template <class TTransformBase>
00075 typename TransformFunctionAccessor<TTransformBase>::TransformFunctionMediaPointer
00076 TransformFunctionAccessor<TTransformBase>::
00077 GetInverseTransformationFunction(const TransformParametersType& parameters)
00078 {
00079 const ITKTransformControllerInterfaceType* pController = 0;
00080 SessionComponentCache* pCache = 0;
00081
00082 GetTransformControllerAndCache(pController,pCache);
00083
00084 TransformFunctionMediaPointer smpFunction = pController->GenerateInverseTransformationFunction(pCache,parameters);
00085 return smpFunction;
00086 };
00087
00088 template <class TTransformBase>
00089 TransformFunctionAccessor<TTransformBase>::
00090 TransformFunctionAccessor(SessionComponentCache& cache, const IDPath& transformID): m_Cache(cache)
00091 {
00092 m_TransformID = transformID;
00093 };
00094
00095 template <class TTransformBase>
00096 void
00097 TransformFunctionAccessor<TTransformBase>::
00098 GetTransformControllerAndCache(const ITKTransformControllerInterfaceType*& pController, SessionComponentCache*& pCache)
00099 {
00100 pCache = m_Cache.GetCacheByIDPath(m_TransformID);
00101
00102 if (!pCache) throwExceptionMacro("Cannot get transform function. Transform cache could not be found at specified IDPath. IDPath: "<< m_TransformID.ToStr());
00103
00104 if (!pCache->ControllerIsAssigned()) throwExceptionMacro("Cannot get transform function. No controller associated with cache specified by IDPath. IDPath: "<< m_TransformID.ToStr());
00105
00106 if (!pCache->Controller()->IsRelatedTo(ControllerID::ITKTransformControllerBase)) throwExceptionMacro("Cannot get transform function. Controller is not based on ITKTransformControllerBase, thus no transform function can be retrieved. Found ControllerID: "<< pCache->GetControllerID());
00107
00108 pController = dynamic_cast<const ITKTransformControllerInterfaceType*>(pCache->Controller());
00109 };
00110
00111 }
00112
00113 #endif