freTransformControllerBase.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: freTransformControllerBase.txx,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 __freTransformControllerBase_txx
00023 #define __freTransformControllerBase_txx
00024 
00025 #include "freTransformControllerBase.h"
00026 #include "freMediaControllerBase.h"
00027 
00028 #include "freReferencePointsAccessor.h"
00029 
00030 namespace FREE
00031 {
00032 
00033 
00037 
00038 template <class TControlledTransform, int iDimension>
00039 TransformControllerBase<TControlledTransform, iDimension>::
00040 TransformControllerBase():ComponentControllerBase<TControlledTransform>()
00041 {
00042   this->UpdateControllerID(ControllerID::TransformControllerBase);
00043   this->m_Description = "Base class for transform controller; not for practical use.";
00044 
00045 };
00046 
00047 template <class TControlledTransform, int iDimension>
00048 void
00049 TransformControllerBase<TControlledTransform, iDimension>::
00050 GenerateProfile(CtrlProfile::ControllerProfile& profile, 
00051                 const SessionComponentCache* pComponentCache,
00052                 bool bRegardOldSetup) const
00053 {
00054   Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00055 
00056   profile.Parameters().AddParameter(cParam_InitialisationMethod,Parameter::PVTInteger,cParamDsc_InitialisationMethod,1,"1");
00057 
00058   //Media
00059   std::string sPointControllerID = "Point Set 2D Media";
00060   if (iDimension == 3)
00061   {
00062     sPointControllerID = "Point Set 3D Media";
00063   }
00064   
00065   profile.MediaMap().AddMedia(cParam_MovingReferencePoints,sPointControllerID,DASet,iDimension);
00066   profile.MediaMap().AddMedia(cParam_FixedReferencePoints,sPointControllerID,DASet,iDimension);
00067 
00068   //These media links are not for public use. They allow the recognition of the transform dimensionality
00069   //e.g. The are specified as requirements of registration controllers to ensure that suitable transformation
00070   //will be set as sub component
00071   profile.MediaMap().AddMedia("movingMedia",ControllerID::MediaControllerBase,DASet,iDimension,1,true);
00072   profile.MediaMap().AddMedia("fixedMedia",ControllerID::MediaControllerBase,DASet,iDimension,1,true);
00073 };
00074 
00075 template <class TControlledTransform, int iDimension>
00076 bool
00077 TransformControllerBase<TControlledTransform, iDimension>::
00078 SetInitialTransformValues( ComponentType* pTransformComponent,
00079                            SessionComponentCache* pComponentCache,
00080                            SessionInfo* pSessionInfo,
00081                            const int& iInitializeByITV) const
00082 {
00083   return false;
00087 };
00088 
00089 template <class TControlledTransform, int iDimension>
00090 void
00091 TransformControllerBase<TControlledTransform, iDimension>::
00092 ActualizeMainComponent(ComponentType* pMainComponent,
00093                        SessionComponentCache* pComponentCache, SessionInfo* pSessionInfo,
00094                                                                                          const unsigned int& iActLevel) const
00095 {
00096   if(iActLevel==0)
00097   {
00098     if (!pComponentCache->Setup()) throwCtrlExceptionMacro("","Error; passed component setup is null.");
00099 
00100     int iInitializeByITV;
00101 
00102     try
00103     {
00104       SessionAccessor::GetParameterValue(pComponentCache,cParam_InitialisationMethod,iInitializeByITV);
00105     }
00106     catchAllNPassMacro("Error while retrieving initialisation method.");
00107 
00108     if (!pMainComponent) throwCtrlExceptionMacro("","Error; passed transform component is null.");
00109     if (!pComponentCache) throwCtrlExceptionMacro("","Error; passed component cache is null.");
00110     if (!pSessionInfo) throwCtrlExceptionMacro("","Error; passed session info is null.");
00111 
00112     //Create cParam_CurrentTransformValues if not yet existant.
00113     Parameter::Pointer smpInitialValues;
00114     try
00115     {
00116       smpInitialValues = SessionAccessor::GetParameter(pComponentCache,cParam_InitialTransformValues);
00117     }
00118     catchAllNPassMacro("Error while retrieving initial transformation values.");
00119     Parameter::Pointer smpCurrentValues = pComponentCache->Setup()->Parameters().GetParameter(cParam_CurrentTransformValues);
00120     if (smpCurrentValues.IsNull())
00121     {
00122       smpCurrentValues = pComponentCache->Setup()->Parameters().AddParameter(cParam_CurrentTransformValues, smpInitialValues->ParameterSize(), 1);
00123     }
00124     *(smpCurrentValues.GetPointer()) = *(smpInitialValues.GetPointer());
00125     //have to reset parameter name because assignment operator overrides it
00126     smpCurrentValues->SetParameterName(cParam_CurrentTransformValues);
00127 
00128     //Set initial values
00129           SetInitialTransformValues(pMainComponent,pComponentCache, pSessionInfo, iInitializeByITV);
00130   }
00131 
00134 };
00135 
00136 template <class TControlledTransform, int iDimension>
00137 void
00138 TransformControllerBase<TControlledTransform, iDimension>::
00139 SetMediaCasted(const MediaID& mediaID, GenericMediaType* pMedia, ComponentType* pComponent, SessionComponentCache* pComponentCache,
00140                SessionInfo* pSessionInfo) const
00141 {
00142   if (mediaID == cParam_MovingReferencePoints)
00143         {
00144     ReferencePointsAccessor<iDimension> pointAccessor(pComponentCache);
00145                 PointSetType* pPointSet =  dynamic_cast<PointSetType*>(pMedia);
00146     pointAccessor.SetMovingPoints(pPointSet);
00147         }
00148   else if (mediaID == cParam_FixedReferencePoints)
00149         {
00150     ReferencePointsAccessor<iDimension> pointAccessor(pComponentCache);
00151                 PointSetType* pPointSet =  dynamic_cast<PointSetType*>(pMedia);
00152     pointAccessor.SetFixedPoints(pPointSet);
00153         }
00154   else Superclass::SetMediaCasted(mediaID, pMedia, pComponent, pComponentCache, pSessionInfo);
00155 }; 
00156 
00157 } //end of namespace FREE
00158 
00159 #endif

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