]> Creatis software - gdcm.git/commitdiff
BUG: Newer version of the software on Siemens MR write proper lenght.
authorjpr <jpr>
Tue, 14 Mar 2006 12:09:18 +0000 (12:09 +0000)
committerjpr <jpr>
Tue, 14 Mar 2006 12:09:18 +0000 (12:09 +0000)
GDCM was overriding without checking for wrong length first.
Can now read old (broken) and new Siemens DICOM files.
Thx to Mathieu.

src/gdcmDocument.cxx

index 29caf97645d5e8592866c7b37e5abea761d5f7f5..06a91f83695301b25ba07cf7a7f7a1301888b2f7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/10 10:52:10 $
-  Version:   $Revision: 1.344 $
+  Date:      $Date: 2006/03/14 12:09:18 $
+  Version:   $Revision: 1.345 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1730,9 +1730,20 @@ void Document::FixDocEntryFoundLength(DocEntry *entry,
    // 'Leonardo' source. Hence, one might consider commenting out the
    // following fix on efficiency reasons.
    else if ( gr == 0x0009 && ( elem == 0x1113 || elem == 0x1114 ) )
-   {
-      foundLength = 4;
-      entry->SetReadLength(4); // a bug is to be fixed !
+   { 
+   // Ideally we should check we are in Explicit and double check
+   // that VR=UL... this is done properly in gdcm2
+      if( foundLength == 6 )
+      {
+         gdcmWarningMacro( "Replacing Length from 6 into 4" );
+         foundLength = 4;
+         entry->SetReadLength(4); // a bug is to be fixed !
+      } 
+      else if ( foundLength%4 )
+      {
+        gdcmErrorMacro( "This looks like to a buggy Siemens DICOM file."
+        "The length of this tag seems to be wrong" );
+      }
    } 
  
    else if ( entry->GetVR() == "SQ" )