freCenteredRigid2DTransformController.cxx

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: freCenteredRigid2DTransformController.cxx,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 
00023 #include "freCenteredRigid2DTransformController.h"
00024 #include "freTransformSetupAdaptor.h"
00025 
00026 namespace FREE
00027 {
00031 
00032 
00033 CenteredRigid2DTransformController::
00034 CenteredRigid2DTransformController()
00035 {
00036   this->UpdateControllerID(ControllerID::CenteredRigid2DTransformController);
00037   this->m_Description = "A combination of rotation and translation in 2 dimensions.";
00038 };
00039 
00040 void
00041 CenteredRigid2DTransformController::
00042 GenerateProfile(CtrlProfile::ControllerProfile& profile,
00043                 const SessionComponentCache* pComponentCache,
00044                 bool bRegardOldSetup) const
00045 {
00046   Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00047 
00048   //Parameters
00049   profile.Parameters().AddParameter(cParam_InitialTransformValues,CtrlProfile::Parameter::PVTDouble,"1: rotation angel (in radian)\n2: x center\n3: y center\n4: x translation\n5: y translation",5,"0");
00050   profile.Parameters().AddParameter(cParam_CurrentTransformValues,CtrlProfile::Parameter::PVTDouble,"1: rotation angel (in radian)\n2: x center\n3: y center\n4: x translation\n5: y translation",5,"0");
00051   profile.Parameters().AddParameter(cParam_TransformScale,CtrlProfile::Parameter::PVTDouble,"1: rotation angel (in radian)\n2: x center\n3: y center\n4: x translation\n5: y translation",5,"1",-1,true);
00052 };
00053 
00054 bool
00055 CenteredRigid2DTransformController::
00056 SetInitialTransformValues( ComponentType* pTransformComponent,
00057                            SessionComponentCache* pComponentCache,
00058                            SessionInfo* pSessionInfo,
00059                            const int& iInitializeByITV) const
00060 {
00061   //let the transform be initialized by MatrixOffsetTransformController
00062   Superclass::SetInitialTransformValues( pTransformComponent, pComponentCache, pSessionInfo, iInitializeByITV);
00063 
00064   int iCenterType;
00065 
00066   if (!pComponentCache->SetupIsAssigned()) throwCtrlExceptionMacro("","Cannot initialize transform values, transform setup is not assigned in cache.");
00067   ComponentSetup* pTransformSetup = pComponentCache->Setup();
00068 
00069   if (!pTransformSetup->Parameters().GetParameterValue(cParam_CenterInitializationType,iCenterType)) throwExceptionMacro("Missing parameter: " << "CenterType");
00070 
00071   TransformSetupAdaptor adaptor(pTransformSetup);
00072   ParameterArrayType itv = adaptor.GetInitialTransformParameters();
00073 
00074   //set current transform values to initial transform values by default
00075   for (int iIndex=0; iIndex<itv.Size(); iIndex++)
00076   {
00077     pTransformSetup->Parameters().SetParameterValue(cParam_CurrentTransformValues,itv[iIndex],iIndex);
00078   };
00079 
00080   if (iCenterType>0)
00081   { //the center was initialized by controller and not
00082     //defined by ITV so copy center to current transform values
00083     for (int iIndex=0; iIndex<2; iIndex++)
00084     {
00085       pTransformSetup->Parameters().SetParameterValue(cParam_CurrentTransformValues,pTransformComponent->GetCenter().GetElement(iIndex),iIndex+1);
00086     }
00087   }
00088 
00089   if (iCenterType>1)
00090   { //the translation was initialized by controller and not
00091     //defined by ITV so copy translation to current transform values
00092     for (int iIndex=0; iIndex<2; iIndex++)
00093     {
00094       pTransformSetup->Parameters().SetParameterValue(cParam_CurrentTransformValues,pTransformComponent->GetTranslation().GetElement(iIndex),iIndex+3);
00095     }
00096   }
00097 
00098   return true;
00099 };
00100 
00101 } //end of namespace free

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