]> Creatis software - gdcm.git/blobdiff - src/gdcmDocument.cxx
The bad hack I made to bypass illegal images where undefined length UN data
[gdcm.git] / src / gdcmDocument.cxx
index efe6d1c92f85856307ad1b4667a63b8a34699a3b..62f286563ac8bc275fb601c84a192973ab035df7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/01/02 10:48:52 $
-  Version:   $Revision: 1.377 $
+  Date:      $Date: 2008/01/07 18:12:02 $
+  Version:   $Revision: 1.379 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1228,7 +1228,7 @@ void Document::ParseDES(DocEntrySet *set, long offset,
       {
          /////////////////////// SeqEntry :  VR = "SQ"
 
-         unsigned long l = newDocEntry->GetReadLength();          
+         unsigned long l = newDocEntry->GetReadLength();
          if ( l != 0 ) // don't mess the delim_mode for 'zero-length sequence'
          {
             if ( l == 0xffffffff )
@@ -1327,7 +1327,9 @@ void Document::ParseDES(DocEntrySet *set, long offset,
       first = false;
       
       if (UnexpectedEOF) // some terminator was missing
+      {
          break;
+      }
    }                               // end While
    gdcmDebugMacro( "Exit from ParseDES, delim-mode " << delim_mode );
 }
@@ -1389,8 +1391,8 @@ bool Document::ParseSQ( SeqEntry *seqEntry,
     
       if (offsetStartCurrentSQItem <= OffsetOfPreviousParseDES)
       {
-         gdcmWarningMacro("Bad assumption was made on illegal 'unknown length' UN!");
-         gdcmWarningMacro("OffsetOfPreviousParseDES " << std::hex << OffsetOfPreviousParseDES
+         gdcmWarningMacro("Bad assumption was made on illegal 'unknown length' UN!" << std::endl <<
+                          "OffsetOfPreviousParseDES " << std::hex << OffsetOfPreviousParseDES
                            << " offsetStartCurrentSQItem " << offsetStartCurrentSQItem);
          /// \todo when  "Bad assumption (SQ) on illegal 'unknown length' UN", Backtrack again + try OB      
          return false; 
@@ -1399,9 +1401,8 @@ bool Document::ParseSQ( SeqEntry *seqEntry,
       {
          OffsetOfPreviousParseDES = offsetStartCurrentSQItem;
       }
-     
+
       // fill up the current SQItem, starting at the beginning of fff0,e000
-            
       Fp->seekg(offsetStartCurrentSQItem, std::ios::beg);        // Once per SQItem
       ParseDES(itemSQ, offsetStartCurrentSQItem, l+8, dlm_mod);
       offsetStartCurrentSQItem = Fp->tellg();                    // Once per SQItem
@@ -1423,7 +1424,8 @@ bool Document::ParseSQ( SeqEntry *seqEntry,
  * \brief   When a private Sequence + Implicit VR is encountered
  *           we cannot guess it's a Sequence till we find the first
  *           Item Starter. We then backtrack to do the job.
- * @param   docEntry Item Starter that warned us 
+ * @param   docEntry Item Starter that warned us
+ * @param   set DocEntrySet (ElementSet/SQItem) the DocEntry will belong
  */
 DocEntry *Document::Backtrack(DocEntry *docEntry, DocEntrySet *set)
 {
@@ -1660,8 +1662,8 @@ uint32_t Document::FindDocEntryLengthOBOrOW()
       {
          gdcmWarningMacro( 
               "Neither an Item tag nor a Sequence delimiter tag on :" 
-           << std::hex << group << " , " << elem 
-           << ")" );
+           << std::hex << group << "|" << elem << ") Pos. on entry was 0x(" <<positionOnEntry<< ") "
+            );
   
          Fp->seekg(positionOnEntry, std::ios::beg); // Once per fragment (if any) of OB,OW DataElements
          throw FormatUnexpected( 
@@ -1724,7 +1726,7 @@ VRKey Document::FindDocEntryVR()
    if ( !Global::GetVR()->IsValidVR(vr) )
    {  
 
-      gdcmWarningMacro( "Unknown VR " << vr.GetHexaRepresentation() 
+      gdcmWarningMacro( "Unknown VR " << vr.GetHexaRepresentation() << std::hex
                         << " at offset : 0x(" << CurrentOffsetPosition-4
                         << ") for group " << std::hex << CurrentGroup );