]> Creatis software - gdcm.git/blobdiff - src/gdcmDocument.cxx
Try to warn user when 'DeflatedExplicitVR' Transfer Syntax found.
[gdcm.git] / src / gdcmDocument.cxx
index de43533a2a901ba7de041bb099dcd45d139aac2a..e3796900612094aa0d2d225b21bb42e2e6af3a93 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 16:04:43 $
-  Version:   $Revision: 1.330 $
+  Date:      $Date: 2006/01/26 09:22:23 $
+  Version:   $Revision: 1.335 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -91,14 +91,6 @@ bool Document::Load(  )
    return DoTheLoadingDocumentJob( );
 }
 
-//#ifndef GDCM_LEGACY_REMOVE 
-bool Document::Load( std::string const &fileName ) 
-{
-   Filename = fileName;
-   return DoTheLoadingDocumentJob( );
-}
-//#endif
-
 /**
  * \brief   Performs the Loading Job (internal use only)  
  * @return false if file cannot be open or no swap info was found,
@@ -991,6 +983,33 @@ int Document::ComputeGroup0002Length( )
    return groupLength; 
 }
 
+/**
+ * \brief   CallStartMethod
+ */
+void Document::CallStartMethod()
+{
+   Progress = 0.0f;
+   Abort    = false;
+   CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS);
+}
+
+/**
+ * \brief   CallProgressMethod
+ */
+void Document::CallProgressMethod()
+{
+   CommandManager::ExecuteCommand(this,CMD_PROGRESS);
+}
+
+/**
+ * \brief   CallEndMethod
+ */
+void Document::CallEndMethod()
+{
+   Progress = 1.0f;
+   CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS);
+}
+
 //-----------------------------------------------------------------------------
 // Private
 /**
@@ -1022,7 +1041,7 @@ void Document::ParseDES(DocEntrySet *set, long offset,
    bool delim_mode_intern = delim_mode;
    bool first = true;
    gdcmDebugMacro( "Enter in ParseDES, delim-mode " <<  delim_mode
-                     << " at offset " << std::hex << offset ); 
+                     << " at offset " << std::hex << "0x(" << offset << ")" ); 
    while (true)
    {
       if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max)
@@ -1069,8 +1088,8 @@ void Document::ParseDES(DocEntrySet *set, long offset,
          {
             gdcmDebugMacro( "in ParseDES : cannot add a DataEntry "
                                  << newDataEntry->GetKey()  
-                                 << " (at offset : " 
-                                 << newDataEntry->GetOffset() << " )" );
+                                 << " (at offset : 0x(
+                                 << newDataEntry->GetOffset() << ") )" );
             used=false;
          }
          else
@@ -1079,7 +1098,6 @@ void Document::ParseDES(DocEntrySet *set, long offset,
             // Load only if we can add (not a duplicate key)
             LoadDocEntry( newDataEntry );
          }
-
          if ( newDataEntry->GetElement() == 0x0000 ) // if on group length
          {
             if ( newDataEntry->GetGroup()%2 != 0 )   // if Shadow Group
@@ -1087,8 +1105,9 @@ void Document::ParseDES(DocEntrySet *set, long offset,
                if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr
                {
                   std::string strLgrGroup = newDataEntry->GetString();
+
                   int lgrGroup;
-                  if ( newDataEntry->IsUnfound() )
+                  //if ( newDataEntry->IsUnfound() ) /?!? JPR
                   {
                      lgrGroup = atoi(strLgrGroup.c_str());
                      Fp->seekg(lgrGroup, std::ios::cur);
@@ -1177,8 +1196,8 @@ void Document::ParseDES(DocEntrySet *set, long offset,
          {  // Don't try to parse zero-length sequences
 
             gdcmDebugMacro( "Entry in ParseSQ, delim " << delim_mode_intern
-                               << " at offset " << std::hex
-                               << newDocEntry->GetOffset() );
+                               << " at offset 0x(" << std::hex
+                               << newDocEntry->GetOffset() << ")");
 
             ParseSQ( newSeqEntry, 
                      newDocEntry->GetOffset(),
@@ -1191,8 +1210,8 @@ void Document::ParseDES(DocEntrySet *set, long offset,
          {
             gdcmWarningMacro( "in ParseDES : cannot add a SeqEntry "
                                 << newSeqEntry->GetKey()
-                                << " (at offset : " 
-                                << newSeqEntry->GetOffset() << " )" ); 
+                                << " (at offset : 0x(
+                                << newSeqEntry->GetOffset() << ") )" ); 
             used = false;
          }
          else
@@ -1303,8 +1322,8 @@ DocEntry *Document::Backtrack(DocEntry *docEntry)
    long offset    = PreviousDocEntry->GetOffset();
 
    gdcmDebugMacro( "Backtrack :" << std::hex << group 
-                                   << "|" << elem
-                                   << " at offset " << offset );
+                                 << "|" << elem
+                                 << " at offset 0x(" <<offset << ")" );
    RemoveEntry( PreviousDocEntry );
 
    // forge the Seq Entry
@@ -1555,7 +1574,7 @@ VRKey Document::FindDocEntryVR()
       if ( CurrentGroup != 0xfffe )
          gdcmWarningMacro( "Unknown VR " << std::hex << "0x(" 
                         << (unsigned int)vr[0] << "|" << (unsigned int)vr[1] 
-                        << ") at offset :" << positionOnEntry );
+                        << ") at offset : 0x(" << positionOnEntry<< ")" );
       Fp->seekg(positionOnEntry, std::ios::beg);
       return GDCM_VRUNKNOWN;
    }
@@ -2137,17 +2156,6 @@ void Document::HandleOutOfGroup0002(uint16_t &group, uint16_t &elem)
       // if Transfer Syntax is Big Endian we have to change CheckSwap
 
       std::string ts = GetTransferSyntax();
-      if ( ts == GDCM_UNKNOWN )
-      {
-         gdcmDebugMacro("True DICOM File, with NO Transfer Syntax (?!) " );
-         return;      
-      }
-      if ( !Global::GetTS()->IsTransferSyntax(ts) )
-      {
-         gdcmWarningMacro("True DICOM File, with illegal Transfer Syntax: [" 
-                          << ts << "]");
-         return;
-      }
 
       // Group 0002 is always 'Explicit ...' 
       // even when Transfer Syntax says 'Implicit ..." 
@@ -2159,7 +2167,7 @@ void Document::HandleOutOfGroup0002(uint16_t &group, uint16_t &elem)
       }
        
       // FIXME Strangely, this works with 
-      //'Implicit VR BigEndian Transfer Syntax (GE Private)
+      //'Implicit VR BigEndian Transfer Syntax' (GE Private)
       //
       // --> Probabely normal, since we considered we never have 
       // to trust manufacturers.
@@ -2174,6 +2182,33 @@ void Document::HandleOutOfGroup0002(uint16_t &group, uint16_t &elem)
          group = SwapShort(group);
          elem  = SwapShort(elem);
       }
+      
+      /// \todo  find a trick to warn user and stop processing
+            
+      if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == 
+                                             TS::DeflatedExplicitVRLittleEndian)
+      {
+           gdcmWarningMacro("Transfer Syntax [" 
+                        << GetTransferSyntaxName() << "] :"
+                        << " not yet dealt with ");
+           return;       
+      }
+      
+      // The following shouldn't occur very often
+      // Let's check at the very end.
+
+      if ( ts == GDCM_UNKNOWN )
+      {
+         gdcmDebugMacro("True DICOM File, with NO Transfer Syntax (?!) " );
+         return;      
+      }
+      
+      if ( !Global::GetTS()->IsTransferSyntax(ts) )
+      {
+         gdcmWarningMacro("True DICOM File, with illegal Transfer Syntax: [" 
+                          << ts << "]");
+         return;
+      }      
    }
 }