+/*=========================================================================
+ 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 <david.sarrut@creatis.insa-lyon.fr>
- * @date 05 May 2008 10:57:19
- *
- * @brief
- *
- *
- -------------------------------------------------*/
#include "clitkImageConvertGenericFilter.h"
clitk::ImageConvertGenericFilter::ImageConvertGenericFilter():
clitk::ImageToImageGenericFilter<Self>("ImageConvert") {
mOutputPixelTypeName = "NotSpecified";
+ mWarningOccur = false;
+ mWarning = "";
+ mDisplayWarning = true;
InitializeImageType<2>();
InitializeImageType<3>();
InitializeImageType<4>();
//--------------------------------------------------------------------
template<unsigned int Dim>
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);
}
//--------------------------------------------------------------------
this->SetNextOutput<InputImageType>(input);
}
else {
-#define TRY_TYPE(TYPE) \
+#define TRY_TYPE(TYPE) \
if (IsSameType<TYPE>(mOutputPixelTypeName)) { UpdateWithOutputType<InputImageType, TYPE>(); return; }
TRY_TYPE(char);
- // TRY_TYPE(signed char);
+ // TRY_TYPE(signed char);
TRY_TYPE(uchar);
TRY_TYPE(short);
TRY_TYPE(ushort);
typedef typename InputImageType::PixelType PixelType;
// Warning
+ std::ostringstream osstream;
if (std::numeric_limits<PixelType>::is_signed) {
if (!std::numeric_limits<OutputPixelType>::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<PixelType>::is_integer) {
if (std::numeric_limits<OutputPixelType>::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<PixelType>::digits10);
// DD(std::numeric_limits<OutputPixelType>::digits10);
if (!std::numeric_limits<PixelType>::is_integer) {
if (std::numeric_limits<OutputPixelType>::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<PixelType>::digits10 > std::numeric_limits<OutputPixelType>::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