freCheckerBoardImageFilterController.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: freCheckerBoardImageFilterController.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 __freCheckerBoardImageFilterController_h
00023 #define __freCheckerBoardImageFilterController_h
00024 
00025 #include "freImageToImageFilterControllerBase.h"
00026 
00027 #include "itkCheckerBoardImageFilter.h"
00028 
00029 namespace FREE
00030 {
00031 
00041   freControllerIDMacro(CheckerBoardImageFilterControllerBase, "CheckerBoardImageFilterBase");
00042 template <class TInputImage>
00043 class CheckerBoardImageFilterControllerBase : public ImageToImageFilterControllerBase< itk::CheckerBoardImageFilter<TInputImage> >
00044 {
00045 public:  
00046   typedef itk::CheckerBoardImageFilter<TInputImage> ComponentType;
00047   typedef ImageToImageFilterControllerBase<ComponentType> Superclass;
00048   typedef CheckerBoardImageFilterControllerBase<ComponentType> 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   typedef typename ComponentType::OutputImageType       OutputImageType;
00055   typedef typename ComponentType::OutputImagePointer    OutputImagePointer;
00056 
00057   DeclareParameterMacro(CheckerPattern);
00058 
00059   itkTypeMacro(CheckerBoardImageFilterControllerBase, ImageToImageFilterControllerBase);
00060 
00061   virtual ValidityTag::Pointer GetMediaValidityTagRequirement(const MediaID& mediaID, SessionComponentCache* pComponentCache) const
00062   {
00063     if (mediaID == "output")
00064     {
00065       ValidityTag::Pointer smpReq = ValidityTag::New(this->GetMediaValidityTag(mediaID,pComponentCache)->GetTimeStamp());
00066       this->CompareValidityTagRequirement("input",smpReq,pComponentCache);
00067       this->CompareValidityTagRequirement("input2",smpReq,pComponentCache);
00068       return smpReq;
00069     }
00070 
00071     return Superclass::GetMediaValidityTagRequirement(mediaID, pComponentCache);
00072   }; 
00073 
00074 protected:
00075   CheckerBoardImageFilterControllerBase()
00076   {
00077     //Profile settings
00078     this->UpdateControllerID(ControllerID::CheckerBoardImageFilterControllerBase);
00079     this->m_Description = "Basic class for controller of itk based binary functor image filters.";
00080   };
00081 
00082   virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00083                   const SessionComponentCache* pComponentCache,
00084                   bool bRegardOldSetup) const
00085   {
00086     Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00087 
00088     //Parameters
00089     profile.Parameters().AddParameter(cParam_CheckerPattern, Parameter::PVTInteger, cParamDsc_CheckerPattern, ComponentType::InputImageType::ImageDimension, "1");
00090 
00091     //Media
00092     profile.MediaMap().AddMedia("input2", ControllerID::IntensityImageMediaControllerBase, DASet, ComponentType::InputImageType::ImageDimension);
00093   };
00094 
00095   virtual void SetMediaCasted(const MediaID& mediaID, GenericMediaType* pMedia, ComponentType* pComponent, SessionComponentCache* pComponentCache,
00096                               SessionInfo* pSessionInfo) const
00097   {
00098     if (mediaID == "input2")
00099     {
00100       pComponent->SetInput2(dynamic_cast<typename ComponentType::InputImageType*>(pMedia));
00101     }
00102     else Superclass::SetMediaCasted(mediaID, pMedia, pComponent, pComponentCache, pSessionInfo);
00103   }; 
00104 
00105         virtual void ActualizeMainComponent(ComponentType* pMainComponent,
00106                                       SessionComponentCache* pComponentCache,
00107                                       SessionInfo* pSessionInfo,
00108                                                                                                                                                         const unsigned int& iActLevel) const
00109   {
00110     Superclass::ActualizeMainComponent(pMainComponent,pComponentCache, pSessionInfo, iActLevel);
00111 
00112 
00113           int iPatternSize;
00114     typename ComponentType::PatternArrayType pattern;
00115 
00116     try
00117     {
00118       Parameter::Pointer smpPatternParam = SessionAccessor::GetParameter(pComponentCache,cParam_CheckerPattern);
00119       if (smpPatternParam.IsNull()) throwCtrlExceptionMacro("","Error. Parameter "<<cParam_CheckerPattern<<" is missing. Please check your setup.");
00120 
00121       for (unsigned int iIndex = 0; iIndex<TInputImage::GetImageDimension(); iIndex++)
00122       {
00123         smpPatternParam->GetParameterValue(iPatternSize,iIndex);
00124         pattern[iIndex] = iPatternSize;
00125       }
00126     }
00127     catchAllNPassMacro("Error while setting checker pattern.");
00128 
00129     pMainComponent->SetCheckerPattern(pattern);
00130   };
00131 };
00132 
00133 template <class TInputImage>
00134 const char* const CheckerBoardImageFilterControllerBase<TInputImage> :: cParam_CheckerPattern = "CheckerPattern";
00135 template <class TInputImage>
00136 const char* const CheckerBoardImageFilterControllerBase<TInputImage> :: cParamDsc_CheckerPattern = "Indicates the pattern size of the checker board. It is the size of on field in pixel per dimension for all dimensions.";
00137 
00143 freControllerIDMacro(CheckerBoard2DImageFilterController, "Checker Board 2D Image Filter");
00144 class CheckerBoard2DImageFilterController : public CheckerBoardImageFilterControllerBase< ImageTypes<2>::InternalImageType >
00145 {
00146 public:  
00147   typedef CheckerBoardImageFilterControllerBase< ImageTypes<2>::InternalImageType > Superclass;
00148   typedef CheckerBoard2DImageFilterController Self;
00149 
00150   typedef Superclass::ComponentType ComponentType;
00151   typedef ComponentType::Pointer ComponentPointer;
00152   typedef Superclass::GenericComponentType GenericComponentType;
00153   typedef Superclass::GenericComponentPointer GenericComponentPointer;
00154   typedef Superclass::GenericMediaPointer GenericMediaPointer;
00155 
00156   itkTypeMacro(CheckerBoard2DImageFilterController, CheckerBoardImageFilterControllerBase);
00157 
00158   CheckerBoard2DImageFilterController();
00159 };
00160 
00166 freControllerIDMacro(CheckerBoard3DImageFilterController, "Checker Board 3D Image Filter");
00167 class CheckerBoard3DImageFilterController : public CheckerBoardImageFilterControllerBase< ImageTypes<3>::InternalImageType >
00168 {
00169 public:  
00170   typedef CheckerBoardImageFilterControllerBase< ImageTypes<3>::InternalImageType > Superclass;
00171   typedef CheckerBoard3DImageFilterController Self;
00172 
00173   typedef Superclass::ComponentType ComponentType;
00174   typedef ComponentType::Pointer ComponentPointer;
00175   typedef Superclass::GenericComponentType GenericComponentType;
00176   typedef Superclass::GenericComponentPointer GenericComponentPointer;
00177   typedef Superclass::GenericMediaPointer GenericMediaPointer;
00178 
00179   itkTypeMacro(CheckerBoard3DImageFilterController, CheckerBoardImageFilterControllerBase);
00180 
00181   CheckerBoard3DImageFilterController();
00182 };
00183 
00184 } //end of namespace free
00185 #endif

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