]> Creatis software - gdcm.git/blobdiff - src/gdcmDocument.cxx
Add over verbose debug message -to be removed withing a few (hope so) days-
[gdcm.git] / src / gdcmDocument.cxx
index 665604a2996f5f997ac008d2cfdf8e8b4db89cca..ee8bf9bf1c66fa35f613027d36d61dddb486984a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:00:47 $
-  Version:   $Revision: 1.304 $
+  Date:      $Date: 2005/10/26 09:09:31 $
+  Version:   $Revision: 1.310 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -386,7 +386,8 @@ FileType Document::GetFileType()
  * \brief   Accessor to the Transfer Syntax (when present) of the
  *          current document (it internally handles reading the
  *          value from disk when only parsing occured).
- * @return  The encountered Transfer Syntax of the current document.
+ * @return  The encountered Transfer Syntax of the current document, if DICOM.
+ *          GDCM_UNKNOWN for ACR-NEMA files (or broken headers ...)
  */
 std::string Document::GetTransferSyntax()
 {
@@ -605,7 +606,7 @@ void Document::WriteContent(std::ofstream *fp, FileType filetype)
    // Skip if user wants to write an ACR-NEMA file
 
    if ( filetype == ImplicitVR || filetype == ExplicitVR ||
-     filetype == JPEG )
+        filetype == JPEG )
    {
       // writing Dicom File Preamble
       char filePreamble[128];
@@ -967,12 +968,11 @@ void Document::ParseDES(DocEntrySet *set, long offset,
       // It's too late to do the Job
       // (we should check the value, but we know it after LoadDocEntry ...)
 
-      // Uncoment this printf line to be able to 'follow' the DocEntries
+      // Uncoment this cerr line to be able to 'follow' the DocEntries
       // when something *very* strange happens
 
-      //printf( "%04x|%04x %s\n",newDocEntry->GetGroup(), 
-      //                     newDocEntry->GetElement(),
-      //                     newDocEntry->GetVR().c_str() );
+      if( Debug::GetDebugFlag() ) 
+         std::cerr<<newDocEntry->GetKey()<<" "<<newDocEntry->GetVR()<<std::endl;
 
       if ( !newDocEntry )
       {
@@ -1025,6 +1025,7 @@ void Document::ParseDES(DocEntrySet *set, long offset,
          }
          else
          {
+            newDataEntry->Delete();
             // Load only if we can add (not a duplicate key)
             LoadDocEntry( newDataEntry );
          }
@@ -1144,12 +1145,16 @@ void Document::ParseDES(DocEntrySet *set, long offset,
                                 << newSeqEntry->GetOffset() << " )" ); 
             used = false;
          }
+         else
+         {
+            newDocEntry->Delete();
+         }
  
          if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max)
          {
             if ( !used )
                newDocEntry->Delete();
-               break;
+            break;
          }
       }  // end SeqEntry : VR = "SQ"
 
@@ -1189,6 +1194,7 @@ void Document::ParseSQ( SeqEntry *seqEntry,
          if ( newDocEntry->IsSequenceDelimitor() )
          {
             seqEntry->SetDelimitationItem( newDocEntry ); 
+            newDocEntry->Delete();
             break;
          }
       }
@@ -1198,7 +1204,7 @@ void Document::ParseSQ( SeqEntry *seqEntry,
          break;
       }
       // create the current SQItem
-      SQItem *itemSQ = new SQItem( seqEntry->GetDepthLevel() );
+      SQItem *itemSQ = SQItem::New( seqEntry->GetDepthLevel() );
       unsigned int l = newDocEntry->GetReadLength();
       
       if ( l == 0xffffffff )
@@ -1212,7 +1218,6 @@ void Document::ParseSQ( SeqEntry *seqEntry,
 
       // Let's try :------------
       // remove fff0,e000, created out of the SQItem
-      newDocEntry->Delete();
       Fp->seekg(offsetStartCurrentSQItem, std::ios::beg);
       // fill up the current SQItem, starting at the beginning of fff0,e000
 
@@ -1222,6 +1227,8 @@ void Document::ParseSQ( SeqEntry *seqEntry,
       // end try -----------------
  
       seqEntry->AddSQItem( itemSQ, SQItemNumber ); 
+      itemSQ->Delete();
+      newDocEntry->Delete();
       SQItemNumber++;
       if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max )
       {
@@ -1495,7 +1502,7 @@ VRKey Document::FindDocEntryVR()
    VRKey vr;
    Fp->read(&(vr[0]),(size_t)2);
 
-   gdcmDebugMacro( "--> VR: " << vr )
+   //gdcmDebugMacro( "--> VR: " << vr )
    if ( !CheckDocEntryVR(vr) )
    {
       gdcmWarningMacro( "Unknown VR '" << vr << "'" )
@@ -1975,7 +1982,7 @@ DocEntry *Document::ReadNextDocEntry()
          }
       }
    }
-   gdcmDebugMacro( "Found VR: " << vr << " / Real VR: " << realVR );
+  // gdcmDebugMacro( "Found VR: " << vr << " / Real VR: " << realVR );
 
    DocEntry *newEntry;
    if ( Global::GetVR()->IsVROfSequence(realVR) )