]> Creatis software - gdcm.git/commitdiff
* src/gdcmDocument.cxx : Set the file pointer TP to 0 in the constructors.
authorregrain <regrain>
Wed, 10 Nov 2004 16:13:17 +0000 (16:13 +0000)
committerregrain <regrain>
Wed, 10 Nov 2004 16:13:17 +0000 (16:13 +0000)
    Verify the file pointer value before open the file, and if it's not null,
    a verbose message is generated.
    Close correctly the file when the file isn't considered dicom-like. The
    correctly close is a call to CloseFile.
    When closing the file pointer, test if its not null to close the file.
  * src/gdcmPixelConvert.cxx : bug fix for the SIEMENS_GBS_III-16-ACR_NEMA_1.acr
    file. For an uncompressed image, the copied datas correspond in the least
    case to the image size (calculated) or the image size specified in the
    header. A verbose is generated if these two size mismatch
  -- BeNours

ChangeLog
src/gdcmDocument.cxx
src/gdcmPixelConvert.cxx

index 659f043315dd523ec0106b784d0f01564fc6eb29..3f929ffda1ec90a9cc9bbfeabef1296802575c37 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
+2004-11-10 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+  * src/gdcmDocument.cxx : Set the file pointer TP to 0 in the constructors.
+    Verify the file pointer value before open the file, and if it's not null,
+    a verbose message is generated.
+    Close correctly the file when the file isn't considered dicom-like. The
+    correctly close is a call to CloseFile.
+    When closing the file pointer, test if its not null to close the file.
+  * src/gdcmPixelConvert.cxx : bug fix for the SIEMENS_GBS_III-16-ACR_NEMA_1.acr
+    file. For an uncompressed image, the copied datas correspond in the least 
+    case to the image size (calculated) or the image size specified in the 
+    header. A verbose is generated if these two size mismatch
+
 2004-11-09 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
-  * src/TestAllReadCompareDicom.cxx : test the existence of the directory
+  * Test/TestAllReadCompareDicom.cxx : test the existence of the directory
     using an 'ifstream' other than a 'FILE *'. The previous solution ('FILE *')
     break under windows (with msvc6 compilation).
 
@@ -41,7 +53,7 @@
     little endian. This should -heopfully- fix some tests
 
 2004-11-03 Mathieu Malaterre  <Mathieu.Malaterre@creatis.insa-lyon.fr>
-  * Now the dictionary is compiled into gdcm lib. This is a default 
+  * Now the dictionary is compiled into gdcm lib. This is a default
     behavior, thus any dic file specified is picked before failback to 
     the one comiled into lib
 
index 289bf43a91cfda4485f484d61f48c769f40c5848..f2c4fb9585f8350f347c00480f1800ccf41e05c9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/09 21:55:55 $
-  Version:   $Revision: 1.119 $
+  Date:      $Date: 2004/11/10 16:13:18 $
+  Version:   $Revision: 1.120 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -90,6 +90,7 @@ Document::Document( std::string const & filename ) : ElementSet(-1)
    Filename = filename;
    Initialise();
 
+   Fp = 0;
    if ( !OpenFile() )
    {
       return;
@@ -181,6 +182,8 @@ Document::Document( std::string const & filename ) : ElementSet(-1)
  */
 Document::Document() : ElementSet(-1)
 {
+   Fp = 0;
+
    SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE);
    Initialise();
    PrintLevel = 1;  // 'Medium' print level by default
@@ -413,6 +416,13 @@ FileType Document::GetFileType()
  */
 std::ifstream* Document::OpenFile()
 {
+   if(Fp)
+   {
+      dbg.Verbose( 0,
+                   "Document::OpenFile is already opened when opening: ",
+                   Filename.c_str());
+   }
+
    Fp = new std::ifstream(Filename.c_str(), std::ios::in | std::ios::binary);
 
    if(!Fp)
@@ -441,7 +451,7 @@ std::ifstream* Document::OpenFile()
       return Fp;
    }
  
-   Fp->close();
+   CloseFile();
    dbg.Verbose( 0,
                 "Document::OpenFile not DICOM/ACR (missing preamble)",
                 Filename.c_str());
@@ -455,11 +465,14 @@ std::ifstream* Document::OpenFile()
  */
 bool Document::CloseFile()
 {
-  Fp->close();
-  delete Fp;
-  Fp = 0;
+   if( Fp )
+   {
+      Fp->close();
+      delete Fp;
+      Fp = 0;
+   }
 
-  return true; //FIXME how do we detect a non-close ifstream ?
+   return true; //FIXME how do we detect a non-close ifstream ?
 }
 
 /**
index a4277a761cf1fd1b3f3b870b448d0a1941144aba..c23cbe8ffbd2f832cf681e15c818ebf134ce9036 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/09 21:55:56 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2004/11/10 16:13:18 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -588,16 +588,16 @@ bool PixelConvert::ReadAndDecompressPixelData( std::ifstream* fp )
    //// First stage: get our hands on the Pixel Data.
    if ( !fp )
    {
-     dbg.Verbose( 0, "PixelConvert::ReadAndDecompressPixelData: "
-                     "unavailable file pointer." );
+      dbg.Verbose( 0, "PixelConvert::ReadAndDecompressPixelData: "
+                      "unavailable file pointer." );
       return false;
    }
 
    fp->seekg( PixelOffset, std::ios_base::beg );
    if( fp->fail() || fp->eof()) //Fp->gcount() == 1
    {
-     dbg.Verbose( 0, "PixelConvert::ReadAndDecompressPixelData: "
-                     "unable to find PixelOffset in file." );
+      dbg.Verbose( 0, "PixelConvert::ReadAndDecompressPixelData: "
+                      "unable to find PixelOffset in file." );
       return false;
    }
 
@@ -609,7 +609,20 @@ bool PixelConvert::ReadAndDecompressPixelData( std::ifstream* fp )
    }
    else if ( IsDecompressed )
    {
-      fp->read( (char*)Decompressed, PixelDataLength);
+      if( PixelDataLength != DecompressedSize)
+      {
+         dbg.Verbose( 0, "PixelConvert::ReadAndDecompressPixelData: "
+                      "Mismatch between PixelConvert and DecompressedSize." );
+      }
+      if( PixelDataLength > DecompressedSize)
+      {
+         fp->read( (char*)Decompressed, DecompressedSize);
+      }
+      else
+      {
+         fp->read( (char*)Decompressed, PixelDataLength);
+      }
+
       if ( fp->fail() || fp->eof())//Fp->gcount() == 1
       {
          dbg.Verbose( 0, "PixelConvert::ReadAndDecompressPixelData: "