X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=filters%2FclitkImageConvertGenericFilter.cxx;h=c6afba85cb7cb0c6b97129f4baade53a17b7e431;hb=e7f88877b4e3d136e9cfa08613490df94e2728d7;hp=b4b8bc466bf0d0a07ac9c6a543e9fe9733b2bc4c;hpb=9bcf64b7f7c5a7f0a39843df634c05b5d9e4e237;p=clitk.git diff --git a/filters/clitkImageConvertGenericFilter.cxx b/filters/clitkImageConvertGenericFilter.cxx index b4b8bc4..c6afba8 100644 --- a/filters/clitkImageConvertGenericFilter.cxx +++ b/filters/clitkImageConvertGenericFilter.cxx @@ -1,23 +1,32 @@ +/*========================================================================= + 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 + ======================================================================-====*/ #ifndef CLITKIMAGECONVERTGENERICFILTER_CXX #define CLITKIMAGECONVERTGENERICFILTER_CXX -/** - ------------------------------------------------- - * @file clitkImageConvertGenericFilter.cxx - * @author David Sarrut - * @date 05 May 2008 10:57:19 - * - * @brief - * - * - -------------------------------------------------*/ - #include "clitkImageConvertGenericFilter.h" //-------------------------------------------------------------------- clitk::ImageConvertGenericFilter::ImageConvertGenericFilter(): clitk::ImageToImageGenericFilter("ImageConvert") { mOutputPixelTypeName = "NotSpecified"; + mWarningOccur = false; + mWarning = ""; + mDisplayWarning = true; InitializeImageType<2>(); InitializeImageType<3>(); InitializeImageType<4>(); @@ -28,12 +37,7 @@ clitk::ImageConvertGenericFilter::ImageConvertGenericFilter(): //-------------------------------------------------------------------- template void clitk::ImageConvertGenericFilter::InitializeImageType() { - ADD_IMAGE_TYPE(Dim, char); - ADD_IMAGE_TYPE(Dim, short); - ADD_IMAGE_TYPE(Dim, unsigned short); - ADD_IMAGE_TYPE(Dim, int); - ADD_IMAGE_TYPE(Dim, float); - ADD_IMAGE_TYPE(Dim, double); + ADD_DEFAULT_IMAGE_TYPES(Dim); } //-------------------------------------------------------------------- @@ -68,10 +72,10 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() { this->SetNextOutput(input); } else { -#define TRY_TYPE(TYPE) \ +#define TRY_TYPE(TYPE) \ if (IsSameType(mOutputPixelTypeName)) { UpdateWithOutputType(); return; } TRY_TYPE(char); - // TRY_TYPE(signed char); + // TRY_TYPE(signed char); TRY_TYPE(uchar); TRY_TYPE(short); TRY_TYPE(ushort); @@ -98,29 +102,39 @@ void clitk::ImageConvertGenericFilter::UpdateWithOutputType() { typedef typename InputImageType::PixelType PixelType; // Warning + std::ostringstream osstream; if (std::numeric_limits::is_signed) { if (!std::numeric_limits::is_signed) { - std::cerr << "Warning, input type is signed (" << mPixelTypeName << ") while output type is not (" - << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + osstream << "Warning, input type is signed (" << mPixelTypeName << ") while output type is not (" + << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + mWarningOccur = true; } } if (!std::numeric_limits::is_integer) { if (std::numeric_limits::is_integer) { - std::cerr << "Warning, input type is not integer (" << mPixelTypeName << ") while output type is (" - << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + osstream << "Warning, input type is not integer (" << mPixelTypeName << ") while output type is (" + << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + mWarningOccur = true; } } // DD(std::numeric_limits::digits10); // DD(std::numeric_limits::digits10); if (!std::numeric_limits::is_integer) { if (std::numeric_limits::is_integer) { - std::cerr << "Warning, input type is not integer (" << mPixelTypeName << ") while output type is (" - << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + osstream << "Warning, input type is not integer (" << mPixelTypeName << ") while output type is (" + << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + mWarningOccur = true; } } if (std::numeric_limits::digits10 > std::numeric_limits::digits10) { - std::cerr << "Warning, possible loss of precision : input type is (" << mPixelTypeName << ") while output type is (" - << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + osstream << "Warning, possible loss of precision : input type is (" << mPixelTypeName << ") while output type is (" + << mOutputPixelTypeName << "), use at your own responsability." << std::endl; + mWarningOccur = true; + } + + mWarning = osstream.str(); + if (mDisplayWarning) { + std::cerr << mWarning; } // Cast