]> Creatis software - gdcm.git/blobdiff - src/gdcmDocument.cxx
Let's take into account (again) LoadMode !
[gdcm.git] / src / gdcmDocument.cxx
index 08c874a7a0a4fd4f7c51832d03ad787aedf71e1d..34b18e5f2d2dd451484efdeb672e8b431275d18e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/14 14:23:44 $
-  Version:   $Revision: 1.327 $
+  Date:      $Date: 2005/12/14 10:00:28 $
+  Version:   $Revision: 1.334 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -89,17 +89,6 @@ bool Document::Load(  )
       return false;
    }
    return DoTheLoadingDocumentJob( );
-} 
-/**
- * \brief   Loader. (DEPRECATED : not to break the API)   
- * @param   fileName 'Document' (File or DicomDir) to be open for parsing
- * @return false if file cannot be open or no swap info was found,
- *         or no tag was found.
- */
-bool Document::Load( std::string const &fileName ) 
-{
-   Filename = fileName;
-   return DoTheLoadingDocumentJob( );
 }
 
 /**
@@ -337,22 +326,33 @@ bool Document::SetShaDict(DictKey const &dictName)
  * @return false when we're 150 % sure it's NOT a Dicom/Acr file,
  *         true otherwise. 
  */
-bool Document::IsReadable()
+bool Document::IsParsable()
 {
    if ( Filetype == Unknown )
    {
-      gdcmErrorMacro( "Wrong filetype for " << GetFileName());
+      gdcmWarningMacro( "Wrong filetype for " << GetFileName());
       return false;
    }
 
    if ( IsEmpty() )
    { 
-      gdcmErrorMacro( "No tag in internal hash table.");
+      gdcmWarningMacro( "No tag in internal hash table.");
       return false;
    }
 
    return true;
 }
+/**
+ * \brief  This predicate tells us whether or not the current Document 
+ *         was properly parsed and contains at least *one* Dicom Element
+ *         (and nothing more, sorry).
+ * @return false when we're 150 % sure it's NOT a Dicom/Acr file,
+ *         true otherwise. 
+ */
+bool Document::IsReadable()
+{
+   return IsParsable();
+}
 
 /**
  * \brief   Predicate for dicom version 3 file.
@@ -983,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
 /**
@@ -1014,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)
@@ -1061,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
@@ -1071,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
@@ -1079,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);
@@ -1169,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(),
@@ -1183,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
@@ -1295,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
@@ -1547,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;
    }