]> Creatis software - clitk.git/blobdiff - common/clitkImageCommon.cxx
revived old fast_make script / clean some dependencies
[clitk.git] / common / clitkImageCommon.cxx
index d2ab8673778dc1b92fb3b618430df840cce21766..cfcbbe34225b3034adab9770bf127e92bfeb1f69 100644 (file)
 
   - 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 <david.sarrut@creatis.insa-lyon.fr>
-   * @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();
@@ -82,7 +72,7 @@ gdcm::File * clitk::readDicomHeader(const std::string & filename,
   header->Load();
   return header;
 }
-//--------------------------------------------------------------------
+///--------------------------------------------------------------------
 
 //--------------------------------------------------------------------
 itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename, bool exit_on_error)
@@ -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();