[clitk-commits-list] Clitk software branch master updated. v1.2.0-588-gfe401a1

root root at tux.creatis.insa-lyon.fr
Thu Dec 8 11:05:52 CET 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Clitk software".

The branch, master has been updated
       via  fe401a1eebf96ce5a94c424d53d7c58486f4bf55 (commit)
       via  13c3d27643a3200f3751ab3c391ba36a32a1293c (commit)
      from  9e137f701e07fdd5aef6982e6f1ce3153977c3f6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.creatis.insa-lyon.fr/pubgit/?p=clitk.git;a=commitdiff;h=fe401a1eebf96ce5a94c424d53d7c58486f4bf55

commit fe401a1eebf96ce5a94c424d53d7c58486f4bf55
Author: Simon Rit <simon.rit at creatis.insa-lyon.fr>
Date:   Thu Dec 8 11:05:30 2011 +0100

    Applied clitk indentation

diff --git a/common/clitkGateAsciiImageIO.cxx b/common/clitkGateAsciiImageIO.cxx
index dd47ef4..589c30c 100644
--- a/common/clitkGateAsciiImageIO.cxx
+++ b/common/clitkGateAsciiImageIO.cxx
@@ -32,106 +32,110 @@ using std::endl;
 
 std::ostream& operator<<(std::ostream& os, const clitk::GateAsciiImageIO::GateAsciiHeader& header)
 {
-    os << "matrix_size=[" << header.matrix_size[0] << "," << header.matrix_size[1] << "," << header.matrix_size[2] << "]" << endl;
-    os << "resolution=[" << header.resolution[0] << "," << header.resolution[1] << "," << header.resolution[2] << "]" << endl;
-    os << "voxel_size=[" << header.voxel_size[0] << "," << header.voxel_size[1] << "," << header.voxel_size[2] << "]" << endl;
-    os << "nb_value=" << header.nb_value << endl;
-    return os;
+  os << "matrix_size=[" << header.matrix_size[0] << "," << header.matrix_size[1] << "," << header.matrix_size[2] << "]" << endl;
+  os << "resolution=[" << header.resolution[0] << "," << header.resolution[1] << "," << header.resolution[2] << "]" << endl;
+  os << "voxel_size=[" << header.voxel_size[0] << "," << header.voxel_size[1] << "," << header.voxel_size[2] << "]" << endl;
+  os << "nb_value=" << header.nb_value << endl;
+  return os;
 }
 
 //--------------------------------------------------------------------
 // Read Image Information
 void clitk::GateAsciiImageIO::ReadImageInformation()
 {
-    FILE* handle = fopen(m_FileName.c_str(),"r");
-    if (!handle) {
-	itkGenericExceptionMacro(<< "Could not open file (for reading): " << m_FileName);
-	return;
-    }
-
-    GateAsciiHeader header;
-    if (!ReadHeader(handle,header)) {
-	itkGenericExceptionMacro(<< "Could not read header: " << m_FileName);
-	fclose(handle);
-	return;
-    }
+  FILE* handle = fopen(m_FileName.c_str(),"r");
+  if (!handle) {
+    itkGenericExceptionMacro(<< "Could not open file (for reading): " << m_FileName);
+    return;
+  }
+
+  GateAsciiHeader header;
+  if (!ReadHeader(handle,header)) {
+    itkGenericExceptionMacro(<< "Could not read header: " << m_FileName);
     fclose(handle);
-
-    int real_length = -1;
-    double real_spacing = 0;
-    for (int kk=0; kk<3; kk++) {
-	if (header.resolution[kk]>1) {
-	    if (real_length>0) {
-		itkGenericExceptionMacro(<< "Could not image dimension: " << m_FileName);
-		return;
-	    }
-	    real_length = header.resolution[kk];
-	    real_spacing = header.voxel_size[kk];
-	}
+    return;
+  }
+  fclose(handle);
+
+  int real_length = -1;
+  double real_spacing = 0;
+  for (int kk=0; kk<3; kk++) {
+    if (header.resolution[kk]>1) {
+      if (real_length>0) {
+        itkGenericExceptionMacro(<< "Could not image dimension: " << m_FileName);
+        return;
+      }
+      real_length = header.resolution[kk];
+      real_spacing = header.voxel_size[kk];
     }
-    assert(real_length == header.nb_value);
-
-    // Set image information
-    SetNumberOfDimensions(2);
-    SetDimensions(0, real_length);
-    SetDimensions(1, 1);
-    SetSpacing(0, real_spacing);
-    SetSpacing(1, 1);
-    SetOrigin(0, 0);
-    SetOrigin(1, 0);
-    SetComponentType(itk::ImageIOBase::DOUBLE);
+  }
+  assert(real_length == header.nb_value);
+
+  // Set image information
+  SetNumberOfDimensions(2);
+  SetDimensions(0, real_length);
+  SetDimensions(1, 1);
+  SetSpacing(0, real_spacing);
+  SetSpacing(1, 1);
+  SetOrigin(0, 0);
+  SetOrigin(1, 0);
+  SetComponentType(itk::ImageIOBase::DOUBLE);
 }
 
 //--------------------------------------------------------------------
 bool clitk::GateAsciiImageIO::CanReadFile(const char* FileNameToRead)
 {
-    std::string filename(FileNameToRead);
+  std::string filename(FileNameToRead);
 
-    { // check extension
-	std::string filenameext = GetExtension(filename);
-	if (filenameext != "txt") return false;
-    }
+  {
+    // check extension
+    std::string filenameext = GetExtension(filename);
+    if (filenameext != "txt") return false;
+  }
 
-    { // check header
-	FILE* handle = fopen(filename.c_str(),"r");
-	if (!handle) return false;
+  {
+    // check header
+    FILE* handle = fopen(filename.c_str(),"r");
+    if (!handle) return false;
 
-	GateAsciiHeader header;
-	if (!ReadHeader(handle,header)) { fclose(handle); return false; }
-	fclose(handle);
+    GateAsciiHeader header;
+    if (!ReadHeader(handle,header)) {
+      fclose(handle);
+      return false;
     }
+    fclose(handle);
+  }
 
-    return true;
+  return true;
 }
 
 //--------------------------------------------------------------------
 // Read Line in file
 bool clitk::GateAsciiImageIO::ReadLine(FILE* handle, std::string& line)
 {
-    std::stringstream stream;
-    while (true)
-    {
-	char item;
-	if (ferror(handle)) return false;
-	if (fread(&item,1,1,handle) != 1) return false;
-
-	if (item=='\n' || feof(handle)) {
-	    line = stream.str();
-	    return true;
-	}
-
-	stream << item;
+  std::stringstream stream;
+  while (true) {
+    char item;
+    if (ferror(handle)) return false;
+    if (fread(&item,1,1,handle) != 1) return false;
+
+    if (item=='\n' || feof(handle)) {
+      line = stream.str();
+      return true;
     }
+
+    stream << item;
+  }
 }
 
 template <typename T>
 T ConvertFromString(const std::string& value)
 {
-    std::stringstream stream;
-    stream << value;
-    T converted;
-    stream >> converted;
-    return converted;
+  std::stringstream stream;
+  stream << value;
+  T converted;
+  stream >> converted;
+  return converted;
 }
 
 bool
@@ -147,14 +151,15 @@ clitk::GateAsciiImageIO::FindRegularExpressionNextLine(itksys::RegularExpression
 // Read Image Header
 bool clitk::GateAsciiImageIO::ReadHeader(FILE* handle, GateAsciiHeader& header)
 {
-    assert(handle);
+  assert(handle);
 
-  std::string regexstr[6] =
-    {"^#.+$",
-     "^# +Matrix *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",
-     "^# +Resol *= +\\(([0-9]+),([0-9]+),([0-9]+)\\)$",
-     "^# +Voxel *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",
-     "^# +nbVal *= +([0-9]+)$"};
+  std::string regexstr[6] = {
+    "^#.+$",
+    "^# +Matrix *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",
+    "^# +Resol *= +\\(([0-9]+),([0-9]+),([0-9]+)\\)$",
+    "^# +Voxel *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",
+    "^# +nbVal *= +([0-9]+)$"
+  };
 
   itksys::RegularExpression regex;
 
@@ -187,76 +192,78 @@ bool clitk::GateAsciiImageIO::ReadHeader(FILE* handle, GateAsciiHeader& header)
 // Read Image Content
 void clitk::GateAsciiImageIO::Read(void* abstract_buffer)
 {
-    FILE* handle = fopen(m_FileName.c_str(),"r");
-    if (!handle) {
-	itkGenericExceptionMacro(<< "Could not open file (for reading): " << m_FileName);
-	return;
-    }
-
-    GateAsciiHeader header;
-    if (!ReadHeader(handle,header)) {
-	itkGenericExceptionMacro(<< "Could not read header: " << m_FileName);
-	fclose(handle);
-	return;
-    }
-
-    {
-	double* buffer = static_cast<double*>(abstract_buffer);
-	int read_count = 0;
-	while (true) { 
-	    std::string line;
-	    if (!ReadLine(handle,line)) break;
-	    *buffer = ConvertFromString<double>(line);
-	    read_count++;
-	    buffer++;
-	}
-	assert(read_count == header.nb_value);
+  FILE* handle = fopen(m_FileName.c_str(),"r");
+  if (!handle) {
+    itkGenericExceptionMacro(<< "Could not open file (for reading): " << m_FileName);
+    return;
+  }
+
+  GateAsciiHeader header;
+  if (!ReadHeader(handle,header)) {
+    itkGenericExceptionMacro(<< "Could not read header: " << m_FileName);
+    fclose(handle);
+    return;
+  }
+
+  {
+    double* buffer = static_cast<double*>(abstract_buffer);
+    int read_count = 0;
+    while (true) {
+      std::string line;
+      if (!ReadLine(handle,line)) break;
+      *buffer = ConvertFromString<double>(line);
+      read_count++;
+      buffer++;
     }
+    assert(read_count == header.nb_value);
+  }
 
-    fclose(handle);
+  fclose(handle);
 }
 
 //--------------------------------------------------------------------
 bool clitk::GateAsciiImageIO::CanWriteFile(const char* FileNameToWrite)
 {
-    if (GetExtension(std::string(FileNameToWrite)) != "txt") return false;
-    return true;
+  if (GetExtension(std::string(FileNameToWrite)) != "txt") return false;
+  return true;
 }
 
 void clitk::GateAsciiImageIO::WriteImageInformation()
 {
-    cout << GetNumberOfDimensions() << endl;
+  cout << GetNumberOfDimensions() << endl;
 }
 
 bool clitk::GateAsciiImageIO::SupportsDimension(unsigned long dim)
 {
-    if (dim==2) return true;
-    return false;
+  if (dim==2) return true;
+  return false;
 }
 
 //--------------------------------------------------------------------
 // Write Image
 void clitk::GateAsciiImageIO::Write(const void* abstract_buffer)
 {
-    const unsigned long nb_value = GetDimensions(0)*GetDimensions(1);
-    std::stringstream stream;
-    stream << "######################" << endl;
-    stream << "# Matrix Size= (" << GetSpacing(0)*GetDimensions(0) << "," << GetSpacing(1)*GetDimensions(1) << ",1)" << endl;
-    stream << "# Resol      = (" << GetDimensions(0) << "," << GetDimensions(1) << ",1)" << endl;
-    stream << "# VoxelSize  = (" << GetSpacing(0) << "," << GetSpacing(1) << ",1)" << endl;
-    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; }
-
-    FILE* handle = fopen(m_FileName.c_str(),"w");
-    if (!handle) {
-	itkGenericExceptionMacro(<< "Could not open file (for writing): " << m_FileName);
-	return;
-    }
-
-    fwrite(stream.str().c_str(),1,stream.str().size(),handle);
-
-    fclose(handle);
+  const unsigned long nb_value = GetDimensions(0)*GetDimensions(1);
+  std::stringstream stream;
+  stream << "######################" << endl;
+  stream << "# Matrix Size= (" << GetSpacing(0)*GetDimensions(0) << "," << GetSpacing(1)*GetDimensions(1) << ",1)" << endl;
+  stream << "# Resol      = (" << GetDimensions(0) << "," << GetDimensions(1) << ",1)" << endl;
+  stream << "# VoxelSize  = (" << GetSpacing(0) << "," << GetSpacing(1) << ",1)" << endl;
+  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;
+  }
+
+  FILE* handle = fopen(m_FileName.c_str(),"w");
+  if (!handle) {
+    itkGenericExceptionMacro(<< "Could not open file (for writing): " << m_FileName);
+    return;
+  }
+
+  fwrite(stream.str().c_str(),1,stream.str().size(),handle);
+
+  fclose(handle);
 }
diff --git a/common/clitkGateAsciiImageIO.h b/common/clitkGateAsciiImageIO.h
index ddcd00f..7d174f8 100644
--- a/common/clitkGateAsciiImageIO.h
+++ b/common/clitkGateAsciiImageIO.h
@@ -1,7 +1,7 @@
 /*=========================================================================
   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
 
-  Authors belong to: 
+  Authors belong to:
   - University of LYON              http://www.universite-lyon.fr/
   - Léon Bérard cancer center       http://www.centreleonberard.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
@@ -30,52 +30,53 @@ typedef unsigned int uint32_t;
 #include <stdint.h>
 #endif
 
-namespace clitk {
-
-    //====================================================================
-    // Class for reading gate ascii Image file format
-    class GateAsciiImageIO: public itk::ImageIOBase
-    {
-	public: 
-	    /** Standard class typedefs. */
-	    typedef GateAsciiImageIO        Self;
-	    typedef itk::ImageIOBase        Superclass;
-	    typedef itk::SmartPointer<Self> Pointer;	
-	    typedef signed short int        PixelType;
-
-	    struct GateAsciiHeader {
-		double matrix_size[3];
-		int resolution[3];
-		double voxel_size[3];
-		int nb_value;
-	    };
-
-	    GateAsciiImageIO():Superclass() {;}
-
-	    /** Method for creation through the object factory. */
-	    itkNewMacro(Self);
-
-	    /** Run-time type information (and related methods). */
-	    itkTypeMacro(GateAsciiImageIO, ImageIOBase);
-
-	    /*-------- This part of the interface deals with reading data. ------ */
-	    virtual void ReadImageInformation();
-	    virtual bool CanReadFile( const char* FileNameToRead );
-	    virtual void Read(void * buffer);
-
-	    /*-------- This part of the interfaces deals with writing data. ----- */
-	    virtual void WriteImageInformation();
-	    virtual bool CanWriteFile(const char* filename);
-	    virtual void Write(const void* buffer);
-
-	    virtual bool SupportsDimension(unsigned long dim);
-
-	protected:
-            static bool ReadHeader(FILE* handle, GateAsciiHeader& header);
-	    static bool ReadLine(FILE* handle, std::string& line);
-            static bool FindRegularExpressionNextLine(itksys::RegularExpression &reg, std::string &s, FILE* handle);
-
-    }; // end class GateAsciiImageIO
+namespace clitk
+{
+
+//====================================================================
+// Class for reading gate ascii Image file format
+class GateAsciiImageIO: public itk::ImageIOBase
+{
+public:
+  /** Standard class typedefs. */
+  typedef GateAsciiImageIO        Self;
+  typedef itk::ImageIOBase        Superclass;
+  typedef itk::SmartPointer<Self> Pointer;
+  typedef signed short int        PixelType;
+
+  struct GateAsciiHeader {
+    double matrix_size[3];
+    int resolution[3];
+    double voxel_size[3];
+    int nb_value;
+  };
+
+  GateAsciiImageIO():Superclass() {}
+
+  /** Method for creation through the object factory. */
+  itkNewMacro(Self);
+
+  /** Run-time type information (and related methods). */
+  itkTypeMacro(GateAsciiImageIO, ImageIOBase);
+
+  /*-------- This part of the interface deals with reading data. ------ */
+  virtual void ReadImageInformation();
+  virtual bool CanReadFile( const char* FileNameToRead );
+  virtual void Read(void * buffer);
+
+  /*-------- This part of the interfaces deals with writing data. ----- */
+  virtual void WriteImageInformation();
+  virtual bool CanWriteFile(const char* filename);
+  virtual void Write(const void* buffer);
+
+  virtual bool SupportsDimension(unsigned long dim);
+
+protected:
+  static bool ReadHeader(FILE* handle, GateAsciiHeader& header);
+  static bool ReadLine(FILE* handle, std::string& line);
+  static bool FindRegularExpressionNextLine(itksys::RegularExpression &reg, std::string &s, FILE* handle);
+
+}; // end class GateAsciiImageIO
 } // end namespace
 
 // explicit template instantiation

http://git.creatis.insa-lyon.fr/pubgit/?p=clitk.git;a=commitdiff;h=13c3d27643a3200f3751ab3c391ba36a32a1293c

commit 13c3d27643a3200f3751ab3c391ba36a32a1293c
Author: Simon Rit <simon.rit at creatis.insa-lyon.fr>
Date:   Thu Dec 8 11:03:15 2011 +0100

    GateAsciiImageIO is now cross-platform using itksys::RegularExpression

diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 380ce41..6026b72 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -13,6 +13,8 @@ SET(clitkCommon_SRC
   clitkImageCommon.cxx
   clitkTransformUtilities.cxx
   clitkIO.cxx
+  clitkGateAsciiImageIO.cxx
+  clitkGateAsciiImageIOFactory.cxx
   clitkVoxImageIO.cxx  
   clitkVoxImageIOFactory.cxx
   clitkVfImageIO.cxx  
@@ -36,14 +38,6 @@ SET(clitkCommon_SRC
   vvImageWriter.cxx
 )
 
-IF(UNIX)
-  SET(clitkCommon_SRC
-    ${clitkCommon_SRC}
-    clitkGateAsciiImageIO.cxx
-    clitkGateAsciiImageIOFactory.cxx
-  )
-ENDIF(UNIX)
-
 ### Declare clitkCommon library
 ADD_LIBRARY(clitkCommon STATIC ${clitkCommon_SRC})
 
diff --git a/common/clitkGateAsciiImageIO.cxx b/common/clitkGateAsciiImageIO.cxx
index 744f413..dd47ef4 100644
--- a/common/clitkGateAsciiImageIO.cxx
+++ b/common/clitkGateAsciiImageIO.cxx
@@ -17,7 +17,6 @@
 ===========================================================================**/
 
 // std include
-#include <regex.h>
 #include <cstdio>
 #include <sstream>
 #include <iostream>
@@ -116,7 +115,7 @@ bool clitk::GateAsciiImageIO::ReadLine(FILE* handle, std::string& line)
 	if (ferror(handle)) return false;
 	if (fread(&item,1,1,handle) != 1) return false;
 
-	if (item=='\n' or feof(handle)) {
+	if (item=='\n' || feof(handle)) {
 	    line = stream.str();
 	    return true;
 	}
@@ -125,11 +124,6 @@ bool clitk::GateAsciiImageIO::ReadLine(FILE* handle, std::string& line)
     }
 }
 
-std::string ExtractMatch(const std::string& base, const regmatch_t& match) 
-{
-    return base.substr(match.rm_so,match.rm_eo-match.rm_so);
-}
-
 template <typename T>
 T ConvertFromString(const std::string& value)
 {
@@ -140,57 +134,53 @@ T ConvertFromString(const std::string& value)
     return converted;
 }
 
+bool
+clitk::GateAsciiImageIO::FindRegularExpressionNextLine(itksys::RegularExpression &reg, std::string &s, FILE* handle)
+{
+  std::string line;
+  if(!ReadLine(handle,line))  return false;
+  if(!reg.compile(s.c_str())) return false;
+  return reg.find(line.c_str());
+}
+
 //--------------------------------------------------------------------
 // Read Image Header
 bool clitk::GateAsciiImageIO::ReadHeader(FILE* handle, GateAsciiHeader& header)
 {
     assert(handle);
-    std::string line;
-
-    regex_t re_comment;
-    regex_t re_matrix_size;
-    regex_t re_resol;
-    regex_t re_voxel_size;
-    regex_t re_nb_value;
-    regmatch_t matches[4];
-
-    { // build regex
-	assert(regcomp(&re_comment,"^#.+$",REG_EXTENDED|REG_NEWLINE) == 0);
-	assert(regcomp(&re_matrix_size,"^# +Matrix *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",REG_EXTENDED|REG_NEWLINE) == 0);
-	assert(regcomp(&re_resol,"^# +Resol *= +\\(([0-9]+),([0-9]+),([0-9]+)\\)$",REG_EXTENDED|REG_NEWLINE) == 0);
-	assert(regcomp(&re_voxel_size,"^# +Voxel *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",REG_EXTENDED|REG_NEWLINE) == 0);
-	assert(regcomp(&re_nb_value,"^# +nbVal *= +([0-9]+)$",REG_EXTENDED|REG_NEWLINE) == 0);
-    }
 
-    if (!ReadLine(handle,line)) return false;
-    if (regexec(&re_comment,line.c_str(),1,matches,0) == REG_NOMATCH) return false;
+  std::string regexstr[6] =
+    {"^#.+$",
+     "^# +Matrix *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",
+     "^# +Resol *= +\\(([0-9]+),([0-9]+),([0-9]+)\\)$",
+     "^# +Voxel *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",
+     "^# +nbVal *= +([0-9]+)$"};
 
-    if (!ReadLine(handle,line)) return false;
-    if (regexec(&re_matrix_size,line.c_str(),4,matches,0) == REG_NOMATCH) return false;
-    header.matrix_size[0] = ConvertFromString<double>(ExtractMatch(line,matches[1]));
-    header.matrix_size[1] = ConvertFromString<double>(ExtractMatch(line,matches[2]));
-    header.matrix_size[2] = ConvertFromString<double>(ExtractMatch(line,matches[3]));
+  itksys::RegularExpression regex;
 
-    if (!ReadLine(handle,line)) return false;
-    if (regexec(&re_resol,line.c_str(),4,matches,0) == REG_NOMATCH) return false;
-    header.resolution[0] = ConvertFromString<int>(ExtractMatch(line,matches[1]));
-    header.resolution[1] = ConvertFromString<int>(ExtractMatch(line,matches[2]));
-    header.resolution[2] = ConvertFromString<int>(ExtractMatch(line,matches[3]));
+  if(!FindRegularExpressionNextLine(regex, regexstr[0], handle)) return false;
 
-    if (!ReadLine(handle,line)) return false;
-    if (regexec(&re_voxel_size,line.c_str(),4,matches,0) == REG_NOMATCH) return false;
-    header.voxel_size[0] = ConvertFromString<double>(ExtractMatch(line,matches[1]));
-    header.voxel_size[1] = ConvertFromString<double>(ExtractMatch(line,matches[2]));
-    header.voxel_size[2] = ConvertFromString<double>(ExtractMatch(line,matches[3]));
+  if(!FindRegularExpressionNextLine(regex, regexstr[1], handle)) return false;
+  header.matrix_size[0] = ConvertFromString<double>(regex.match(1));
+  header.matrix_size[1] = ConvertFromString<double>(regex.match(2));
+  header.matrix_size[2] = ConvertFromString<double>(regex.match(3));
 
-    if (!ReadLine(handle,line)) return false;
-    if (regexec(&re_nb_value,line.c_str(),2,matches,0) == REG_NOMATCH) return false;
-    header.nb_value = ConvertFromString<int>(ExtractMatch(line,matches[1]));
+  if(!FindRegularExpressionNextLine(regex, regexstr[2], handle)) return false;
+  header.resolution[0] = ConvertFromString<int>(regex.match(1));
+  header.resolution[1] = ConvertFromString<int>(regex.match(2));
+  header.resolution[2] = ConvertFromString<int>(regex.match(3));
 
-    if (!ReadLine(handle,line)) return false;
-    if (regexec(&re_comment,line.c_str(),1,matches,0) == REG_NOMATCH) return false;
+  if(!FindRegularExpressionNextLine(regex, regexstr[3], handle)) return false;
+  header.voxel_size[0] = ConvertFromString<double>(regex.match(1));
+  header.voxel_size[1] = ConvertFromString<double>(regex.match(2));
+  header.voxel_size[2] = ConvertFromString<double>(regex.match(3));
 
-    return true;
+  if(!FindRegularExpressionNextLine(regex, regexstr[4], handle)) return false;
+  header.nb_value = ConvertFromString<int>(regex.match(1));
+
+  if(!FindRegularExpressionNextLine(regex, regexstr[0], handle)) return false;
+
+  return true;
 }
 
 //--------------------------------------------------------------------
diff --git a/common/clitkGateAsciiImageIO.h b/common/clitkGateAsciiImageIO.h
index d0abbea..ddcd00f 100644
--- a/common/clitkGateAsciiImageIO.h
+++ b/common/clitkGateAsciiImageIO.h
@@ -19,7 +19,8 @@
 #define CLITKGATEASCIIIMAGEIO_H
 
 // itk include
-#include "itkImageIOBase.h"
+#include <itkImageIOBase.h>
+#include <itksys/RegularExpression.hxx>
 
 #if defined (_MSC_VER) && (_MSC_VER < 1600)
 //SR: taken from
@@ -70,9 +71,9 @@ namespace clitk {
 	    virtual bool SupportsDimension(unsigned long dim);
 
 	protected:
-
-	    static bool ReadHeader(FILE* handle, GateAsciiHeader& header);
+            static bool ReadHeader(FILE* handle, GateAsciiHeader& header);
 	    static bool ReadLine(FILE* handle, std::string& line);
+            static bool FindRegularExpressionNextLine(itksys::RegularExpression &reg, std::string &s, FILE* handle);
 
     }; // end class GateAsciiImageIO
 } // end namespace
diff --git a/common/clitkIO.cxx b/common/clitkIO.cxx
index 2126a5a..1acd352 100644
--- a/common/clitkIO.cxx
+++ b/common/clitkIO.cxx
@@ -38,9 +38,7 @@
 // Register factories
 void clitk::RegisterClitkFactories()
 {
-#ifdef unix
   clitk::GateAsciiImageIOFactory::RegisterOneFactory();
-#endif
   clitk::DicomRTDoseIOFactory::RegisterOneFactory();
 #if ITK_VERSION_MAJOR <= 3
   itk::ImageIOFactory::RegisterBuiltInFactories();

-----------------------------------------------------------------------

Summary of changes:
 common/CMakeLists.txt            |   10 +-
 common/clitkGateAsciiImageIO.cxx |  329 +++++++++++++++++++-------------------
 common/clitkGateAsciiImageIO.h   |   98 ++++++------
 common/clitkIO.cxx               |    2 -
 4 files changed, 215 insertions(+), 224 deletions(-)


hooks/post-receive
-- 
Clitk software


More information about the Clitk-commits-list mailing list