]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of tux.creatis.insa-lyon.fr:clitk
authorVivien Delmon <vivien.delmon@creatis.insa-lyon.fr>
Mon, 7 May 2012 11:38:23 +0000 (13:38 +0200)
committerVivien Delmon <vivien.delmon@creatis.insa-lyon.fr>
Mon, 7 May 2012 11:38:23 +0000 (13:38 +0200)
common/clitkGateAsciiImageIO.cxx
common/clitkGateAsciiImageIO.h
common/clitkMemoryUsage.cxx
common/clitkXdrImageIOWriter.cxx

index 589c30cfb783b0a9d0ae7d43a1a3609e1a7d8a8b..99520ee4241268c4a089712881fbfde4508e809e 100644 (file)
@@ -252,9 +252,49 @@ void clitk::GateAsciiImageIO::Write(const void* abstract_buffer)
   stream << "# nbVal      = " << nb_value << endl;
   stream << "######################" << endl;
 
-  const double* buffer = static_cast<const double*>(abstract_buffer);
-  for (unsigned long kk=0; kk<nb_value; kk++) {
-    stream << buffer[kk] << endl;
+  if(this->GetComponentType()==itk::ImageIOBase::UCHAR) {
+    const unsigned char* buffer = static_cast<const unsigned char*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else if(this->GetComponentType()==itk::ImageIOBase::CHAR) {
+    const char* buffer = static_cast<const char*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else if(this->GetComponentType()==itk::ImageIOBase::USHORT) {
+    const unsigned short* buffer = static_cast<const unsigned short*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else if(this->GetComponentType()==itk::ImageIOBase::SHORT) {
+    const short* buffer = static_cast<const short*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else if(this->GetComponentType()==itk::ImageIOBase::UINT) {
+    const unsigned int* buffer = static_cast<const unsigned int*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else if(this->GetComponentType()==itk::ImageIOBase::INT) {
+    const int* buffer = static_cast<const int*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else if(this->GetComponentType()==itk::ImageIOBase::ULONG) {
+    const unsigned long* buffer = static_cast<const unsigned long*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else if(this->GetComponentType()==itk::ImageIOBase::LONG) {
+    const long* buffer = static_cast<const long*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else if(this->GetComponentType()==itk::ImageIOBase::FLOAT) {
+    const float* buffer = static_cast<const float*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else if(this->GetComponentType()==itk::ImageIOBase::DOUBLE) {
+    const double* buffer = static_cast<const double*>(abstract_buffer);
+    for (unsigned long kk=0; kk<nb_value; kk++)
+      stream << buffer[kk] << endl;
+  } else {
+    itkGenericExceptionMacro(<< "Unhandled pixel type: " << this->GetComponentTypeAsString(this->GetComponentType()));
+    return;
   }
 
   FILE* handle = fopen(m_FileName.c_str(),"w");
@@ -264,6 +304,5 @@ void clitk::GateAsciiImageIO::Write(const void* abstract_buffer)
   }
 
   fwrite(stream.str().c_str(),1,stream.str().size(),handle);
-
   fclose(handle);
 }
index 7d174f82ed01e164ef3d9d241af455b046f00428..7d134de7030ac61afdea880fde62abb2d74dd92a 100644 (file)
@@ -42,7 +42,6 @@ public:
   typedef GateAsciiImageIO        Self;
   typedef itk::ImageIOBase        Superclass;
   typedef itk::SmartPointer<Self> Pointer;
-  typedef signed short int        PixelType;
 
   struct GateAsciiHeader {
     double matrix_size[3];
index c0b78ce4ddee203a40a0e216a1ffca69d80d0af9..e2a095dab5e080dae4e058b2517be8233c450a45 100644 (file)
@@ -19,7 +19,9 @@
 // clitk include
 #include "clitkCommon.h"
 #include "clitkMemoryUsage.h"
-#include <unistd.h>
+#ifndef _WIN32
+#  include <unistd.h>
+#endif
 
 void clitk::PrintMemory(bool verbose, std::string s) 
 {
index 1e826db7d6ab07b49142085d84d2ce6180069fba..af50b0ea0dfe3399c3eec82424f810c1dc2f9e5f 100644 (file)
@@ -97,7 +97,9 @@ void clitk::XdrImageIO::Write(const void* buffer)
 #include <math.h>
 #include <stdlib.h>
 #include <limits.h>
-#include <unistd.h>
+#ifndef _WIN32
+#  include <unistd.h>
+#endif
 #if !defined(unix) && !defined(__APPLE__)
 #include <io.h>
 #endif