freTransformFunctionAccessor.txx

Go to the documentation of this file.
00001 /*=========================================================================
00002  
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freTransformFunctionAccessor.h,v $
00007   Language:  C++
00008  
00009  
00010  
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016  
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
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 }//End of Namespace free
00112 
00113 #endif

Generated at Sat Oct 13 17:58:54 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000