freShrinkImageFilterController.h

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: freShrinkImageFilterController.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 __freShrinkImageFilterController_h
00023 #define __freShrinkImageFilterController_h
00024 
00025 #include "freImageToImageFilterControllerBase.h"
00026 
00027 #include "itkShrinkImageFilter.h"
00028 
00029 namespace FREE
00030 {
00031 
00041   freControllerIDMacro(ShrinkImageFilterControllerBase, "ShrinkImageFilterBase");
00042 template <class TInputImage>
00043 class ShrinkImageFilterControllerBase : public ImageToImageFilterControllerBase< itk::ShrinkImageFilter<TInputImage, TInputImage> >
00044 {
00045 public:  
00046   typedef itk::ShrinkImageFilter<TInputImage, TInputImage> ComponentType;
00047   typedef ImageToImageFilterControllerBase<ComponentType> Superclass;
00048   typedef ShrinkImageFilterControllerBase<TInputImage> Self;
00049 
00050   typedef typename ComponentType::Pointer ComponentPointer;
00051   typedef typename Superclass::GenericComponentType GenericComponentType;
00052   typedef typename Superclass::GenericComponentPointer GenericComponentPointer;
00053   typedef typename Superclass::GenericMediaPointer GenericMediaPointer;
00054 
00055   itkTypeMacro(ShrinkImageFilterControllerBase, ImageToImageFilterControllerBase);
00056 
00057   DeclareParameterMacro(ShrinkFactor);
00058 
00059 protected:
00060   ShrinkImageFilterControllerBase()
00061   {
00062     //Profile settings
00063     this->UpdateControllerID(ControllerID::ShrinkImageFilterControllerBase);
00064     this->m_Description = "Basis for itk::ShrinkImageFilter";
00065   };
00066 
00067   virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00068                   const SessionComponentCache* pComponentCache,
00069                   bool bRegardOldSetup) const
00070   {
00071     Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00072 
00073     //Parameters
00074     profile.Parameters().AddParameter(cParam_ShrinkFactor,Parameter::PVTInteger,cParamDsc_ShrinkFactor,TInputImage::GetImageDimension(),"2");
00075   };
00076 
00077         virtual void ActualizeMainComponent(ComponentType* pMainComponent,
00078                                       SessionComponentCache* pComponentCache,
00079                                       SessionInfo* pSessionInfo,
00080                                                                                                                                                         const unsigned int& iActLevel) const
00081   {
00082     Superclass::ActualizeMainComponent(pMainComponent,pComponentCache, pSessionInfo, iActLevel);
00083 
00084           int iShrink;
00085 
00086     try
00087     {
00088       Parameter::Pointer smpShrinkParam = SessionAccessor::GetParameter(pComponentCache,cParam_ShrinkFactor);
00089       if (smpShrinkParam.IsNull()) throwCtrlExceptionMacro("","Error. Parameter "<<cParam_ShrinkFactor<<" is missing. Please check your setup.");
00090 
00091       for (unsigned int iIndex = 0; iIndex<TInputImage::GetImageDimension(); iIndex++)
00092       {
00093         smpShrinkParam->GetParameterValue(iShrink,iIndex);
00094         pMainComponent->SetShrinkFactor(iIndex,iShrink);
00095       }
00096     }
00097     catchAllNPassMacro("Error while setting shrink factor.");
00098   };
00099 
00100 };
00101 
00102 template <class TInputImage>
00103 const char* const ShrinkImageFilterControllerBase<TInputImage> :: cParam_ShrinkFactor = "ShrinkFactor";
00104 template <class TInputImage>
00105 const char* const ShrinkImageFilterControllerBase<TInputImage> :: cParamDsc_ShrinkFactor = "Shrink factor for each dimension.";
00106 
00112 freControllerIDMacro(Shrink2DImageFilterController, "Shrink 2D Image Filter");
00113 class Shrink2DImageFilterController : public ShrinkImageFilterControllerBase< ImageTypes<2>::InternalImageType >
00114 {
00115 public:  
00116   typedef ShrinkImageFilterControllerBase< ImageTypes<2>::InternalImageType > Superclass;
00117   typedef Shrink2DImageFilterController Self;
00118 
00119   typedef Superclass::ComponentType ComponentType;
00120   typedef ComponentType::Pointer ComponentPointer;
00121   typedef Superclass::GenericComponentType GenericComponentType;
00122   typedef Superclass::GenericComponentPointer GenericComponentPointer;
00123   typedef Superclass::GenericMediaPointer GenericMediaPointer;
00124 
00125   itkTypeMacro(Shrink2DImageFilterController, ShrinkImageFilterControllerBase);
00126 
00127   Shrink2DImageFilterController();
00128 };
00129 
00135 freControllerIDMacro(Shrink3DImageFilterController, "Shrink 3D Image Filter");
00136 class Shrink3DImageFilterController : public ShrinkImageFilterControllerBase< ImageTypes<3>::InternalImageType >
00137 {
00138 public:  
00139   typedef ShrinkImageFilterControllerBase< ImageTypes<3>::InternalImageType > Superclass;
00140   typedef Shrink3DImageFilterController Self;
00141 
00142   typedef Superclass::ComponentType ComponentType;
00143   typedef ComponentType::Pointer ComponentPointer;
00144   typedef Superclass::GenericComponentType GenericComponentType;
00145   typedef Superclass::GenericComponentPointer GenericComponentPointer;
00146   typedef Superclass::GenericMediaPointer GenericMediaPointer;
00147 
00148   itkTypeMacro(Shrink3DImageFilterController, ShrinkImageFilterControllerBase);
00149 
00150   Shrink3DImageFilterController();
00151 };
00152 
00153 } //end of namespace free
00154 
00155 #endif

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