]> Creatis software - clitk.git/blob - common/clitkImageToImageGenericFilter.txx
added the new headers
[clitk.git] / common / clitkImageToImageGenericFilter.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
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
8
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.
12
13   It is distributed under dual licence
14
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))
22 {
23 }
24 //--------------------------------------------------------------------
25
26
27 //--------------------------------------------------------------------
28 template<class FilterType>
29 bool clitk::ImageToImageGenericFilter<FilterType>::Update() {
30   GetInputImageDimensionAndPixelType(mDim,mPixelTypeName,mNbOfComponents);    
31   
32   // Check ImageType
33   if (!CheckImageType()) {
34     if (mFailOnImageTypeError) ImageTypeError();
35     else SetImageTypeError();
36     return false;
37   }
38
39   // Go ! Call the right templatized function
40   mImageTypesManager.DoIt(mDim, mNbOfComponents, mPixelTypeName);
41   return true;
42 }
43 //--------------------------------------------------------------------
44
45 //--------------------------------------------------------------------
46 template<class FilterType>
47 bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype)
48 {
49   return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[dim][ncomp][pixeltype]);
50 }
51 //--------------------------------------------------------------------
52
53
54 //--------------------------------------------------------------------
55 template<class FilterType>
56 bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType()
57 {
58   return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[mDim][mNbOfComponents][mPixelTypeName]);
59 }
60 //--------------------------------------------------------------------
61
62
63 //--------------------------------------------------------------------
64 template<class FilterType>
65 std::string clitk::ImageToImageGenericFilter<FilterType>::GetAvailableImageTypes() {
66   std::ostringstream oss;
67   oss << "The filter <" << mFilterName << "> manages:" << std::endl;
68     
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();
74        i++) {
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;
80       }
81     }
82   }
83   return oss.str();
84 }
85 //--------------------------------------------------------------------
86