]> Creatis software - clitk.git/blobdiff - common/clitkImageToImageGenericFilter.txx
- add other types/dim (warning still bugs ! do not use)
[clitk.git] / common / clitkImageToImageGenericFilter.txx
index 0ecaf50a0618f6ae825c9fbdb867ec71b5f3042e..2592c98c9a5e1fb64ae5bfe619a6dc898611e923 100644 (file)
@@ -1,3 +1,20 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to: 
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+======================================================================-====*/
 template<class FilterType>
 clitk::ImageToImageGenericFilter<FilterType>::ImageToImageGenericFilter(std::string filterName) :
   ImageToImageGenericFilterBase(filterName), 
@@ -27,9 +44,13 @@ bool clitk::ImageToImageGenericFilter<FilterType>::Update() {
 
 //--------------------------------------------------------------------
 template<class FilterType>
-bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype)
-{
-  return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[dim][ncomp][pixeltype]);
+bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType(unsigned int dim, unsigned int ncomp, std::string pixeltype)
+{ //SR: commented line creates an element in mMapOfImageTypeToFunction which, even if 0, is confusing, e.g. for GetAvailableImageTypes
+  //return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[dim][ncomp][pixeltype]);
+  typename ImageTypesManager<FilterType>::MapOfImageDimensionToFunctionType &m = mImageTypesManager.mMapOfImageTypeToFunction;
+  return (m            .find(dim)       != m.end()      &&
+          m[dim]       .find(ncomp)     != m[dim].end() &&
+          m[dim][ncomp].find(pixeltype) != m[dim][ncomp].end());
 }
 //--------------------------------------------------------------------
 
@@ -38,7 +59,7 @@ bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType(unsigned int d
 template<class FilterType>
 bool clitk::ImageToImageGenericFilter<FilterType>::CheckImageType()
 {
-  return static_cast<bool>(mImageTypesManager.mMapOfImageTypeToFunction[mDim][mNbOfComponents][mPixelTypeName]);
+  return CheckImageType(mDim, mNbOfComponents, mPixelTypeName);
 }
 //--------------------------------------------------------------------