X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=filters%2FclitkImageConvertGenericFilter.cxx;h=c6afba85cb7cb0c6b97129f4baade53a17b7e431;hb=5a80d16b4dc2ad2d825c443f39ae6276786e72e4;hp=326f06f14f202ba3be38f2da62b03e7a9d6753a4;hpb=0b7c9b1e1215634b02cbd38d4e4ba101d6111ba8;p=clitk.git diff --git a/filters/clitkImageConvertGenericFilter.cxx b/filters/clitkImageConvertGenericFilter.cxx index 326f06f..c6afba8 100644 --- a/filters/clitkImageConvertGenericFilter.cxx +++ b/filters/clitkImageConvertGenericFilter.cxx @@ -14,19 +14,9 @@ - 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" @@ -34,6 +24,9 @@ clitk::ImageConvertGenericFilter::ImageConvertGenericFilter(): clitk::ImageToImageGenericFilter("ImageConvert") { mOutputPixelTypeName = "NotSpecified"; + mWarningOccur = false; + mWarning = ""; + mDisplayWarning = true; InitializeImageType<2>(); InitializeImageType<3>(); InitializeImageType<4>(); @@ -44,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); } //-------------------------------------------------------------------- @@ -84,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); @@ -114,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