X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkImageCommon.cxx;h=cfcbbe34225b3034adab9770bf127e92bfeb1f69;hb=f425f2bbd6a8c36a91965bc5a6a6bc28a0912ce3;hp=d3cd8d897ac87ff6e7978f85a1bf1e0777662873;hpb=a7ed89032c981e479338f0ae67fbc625a478560c;p=clitk.git diff --git a/common/clitkImageCommon.cxx b/common/clitkImageCommon.cxx index d3cd8d8..cfcbbe3 100644 --- a/common/clitkImageCommon.cxx +++ b/common/clitkImageCommon.cxx @@ -14,32 +14,23 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ + ======================================================================-====*/ + #ifndef CLITKIMAGECOMMON_CXX #define CLITKIMAGECOMMON_CXX -/** - ------------------------------------------------= - * @file clitkImageCommon.cxx - * @author David Sarrut - * @date 02 Oct 2007 14:30:47 - * - * @brief - * - * - ------------------------------------------------=*/ #include "clitkImageCommon.h" +#include "clitkCommon.h" //-------------------------------------------------------------------- void clitk::ReadImageDimensionAndPixelType(const std::string & filename, - int & dimension, - std::string & pixeType) + int & dimension, + std::string & pixeType) { itk::ImageIOBase::Pointer genericReader = itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode); if (!genericReader) { - std::cerr << "Image file format unknown while reading file <" << filename << ">" << std::endl; - exit(0); + clitkExceptionMacro("Image file format unknown while reading file <" << filename << ">"); } genericReader->SetFileName(filename.c_str()); genericReader->ReadImageInformation(); @@ -51,14 +42,13 @@ void clitk::ReadImageDimensionAndPixelType(const std::string & filename, //-------------------------------------------------------------------- void clitk::ReadImageDimensionAndPixelType(const std::string & filename, - int & dimension, - std::string & pixeType, int & components) + int & dimension, + std::string & pixeType, int & components) { itk::ImageIOBase::Pointer genericReader = itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode); if (!genericReader) { - std::cerr << "Image file format unknown while reading " << filename << std::endl; - exit(0); + clitkExceptionMacro("Image file format unknown while reading file <" << filename << ">"); } genericReader->SetFileName(filename.c_str()); genericReader->ReadImageInformation(); @@ -91,10 +81,8 @@ itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename, b itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode); if (!reader) { if (exit_on_error) { //default behavior for tools who don't handle the problem - std::cerr << "Error reading file " << filename << ", exiting immediately" << std::endl; - std::exit(-1); - } else - return NULL; + clitkExceptionMacro("Error reading file " << filename << ", exiting immediately"); + } else return NULL; } reader->SetFileName(filename); reader->ReadImageInformation();