1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 template<class FilterType>
19 clitk::ImageToImageGenericFilter<FilterType>::ImageToImageGenericFilter(std::string filterName) :
20 ImageToImageGenericFilterBase(filterName),
21 mImageTypesManager(static_cast<FilterType*>(this))
24 //--------------------------------------------------------------------
27 //--------------------------------------------------------------------
28 template<class FilterType>
29 bool clitk::ImageToImageGenericFilter<FilterType>::Update() {
30 GetInputImageDimensionAndPixelType(mDim,mPixelTypeName,mNbOfComponents);
33 if (!CheckImageType()) {
34 if (mFailOnImageTypeError) ImageTypeError();
35 else SetImageTypeError();
39 // Go ! Call the right templatized function
40 mImageTypesManager.DoIt(mDim, mNbOfComponents, mPixelTypeName);
43 //--------------------------------------------------------------------
45 //--------------------------------------------------------------------
46 template<class FilterType>
47 bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype)
49 return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[dim][ncomp][pixeltype]);
51 //--------------------------------------------------------------------
54 //--------------------------------------------------------------------
55 template<class FilterType>
56 bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType()
58 return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[mDim][mNbOfComponents][mPixelTypeName]);
60 //--------------------------------------------------------------------
63 //--------------------------------------------------------------------
64 template<class FilterType>
65 std::string clitk::ImageToImageGenericFilter<FilterType>::GetAvailableImageTypes() {
66 std::ostringstream oss;
67 oss << "The filter <" << mFilterName << "> manages:" << std::endl;
69 typedef typename ImageTypesManager<FilterType>::MapOfImageComponentsToFunctionType::const_iterator MCompItType;
70 typedef typename ImageTypesManager<FilterType>::MapOfImageDimensionToFunctionType::const_iterator MDimItType;
71 typedef typename ImageTypesManager<FilterType>::MapOfPixelTypeToFunctionType::const_iterator MPixelItType;
72 for (MDimItType i=mImageTypesManager.mMapOfImageTypeToFunction.begin();
73 i!=mImageTypesManager.mMapOfImageTypeToFunction.end();
75 for (MCompItType j=(*i).second.begin(); j!= (*i).second.end(); j++) {
76 for (MPixelItType k=(*j).second.begin(); k!= (*j).second.end(); k++) {
77 oss << "Dim: " << (*i).first;
78 if ((*j).first != 1) oss << ", Components: " << (*j).first;
79 oss << ", Type: " << (*k).first << std::endl;
85 //--------------------------------------------------------------------