/*========================================================================= Program: clitk Module: $RCSfile: clitkCommonGenericFilter.h,v $ Language: C++ Date: $Date: 2010/01/29 08:48:42 $ Version: $Revision: 1.1 $ Author : Joel Schaerer David Sarrut Copyright (C) 2008 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr CREATIS-LRMN http://www.creatis.insa-lyon.fr This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . =========================================================================*/ #ifndef CLITKCOMMONGENERICFILTER_H #define CLITKCOMMONGENERICFILTER_H // clitk include #include "clitkCommon.h" /*-------------------------------------------------------------------- DISCLAIMER : I obviously know how to make this mess much clearer and shorter, but I fear its being too long to put in this margin ... D.S. -------------------------------------------------------------------- */ namespace clitk { //-------------------------------------------------------------------- template class GenericFilterFunctorBase { public: GenericFilterFunctorBase(FilterType * f) { mFilter = f; } virtual void DoIt()= 0; FilterType * mFilter; }; //-------------------------------------------------------------------- template class GenericFilterFunctorWithDimAndPixelType: public GenericFilterFunctorBase { public: GenericFilterFunctorWithDimAndPixelType(FilterType * f): GenericFilterFunctorBase(f) {} virtual void DoIt() { //GenericFilterFunctorBase::mFilter->template UpdateWithDimAndPixelType(); typedef itk::Image InputImageType; GenericFilterFunctorBase::mFilter->template UpdateWithInputImageType(); } }; //-------------------------------------------------------------------- template class ImageTypesManager { public: typedef std::map*> MapOfPixelTypeToFunctionType; std::map mMapOfImageTypeToFunction; ImageTypesManager(FilterType * f) { mFilter = f; } virtual void DoIt(int dim, std::string pixelname) { // std::cout << "ImageTypesManager DoIt " << dim << " " << pixelname << std::endl; if (mMapOfImageTypeToFunction[dim][pixelname]) mMapOfImageTypeToFunction[dim][pixelname]->DoIt(); } template void AddNewDimensionAndPixelType() { // std::cout << "Adding Dim=" << Dim << " and PT = " << GetTypeAsString() << std::endl; mFilter->AddImageType(Dim, GetTypeAsString()); mMapOfImageTypeToFunction[Dim][ GetTypeAsString() ] = new GenericFilterFunctorWithDimAndPixelType(mFilter); } FilterType * mFilter; }; //-------------------------------------------------------------------- } // end namespace #endif // end CLITKCOMMONGENERICFILTER_H