]> Creatis software - gdcm.git/blobdiff - src/gdcmDocument.cxx
Comments
[gdcm.git] / src / gdcmDocument.cxx
index 732a972384f2780941d95ae9f524c255a8b4f26d..2bf79ead5b000e767932fba248527d599996b0ea 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/27 09:55:00 $
-  Version:   $Revision: 1.313 $
+  Date:      $Date: 2005/10/28 15:52:46 $
+  Version:   $Revision: 1.320 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -187,7 +187,7 @@ bool Document::DoTheLoadingDocumentJob(  )
       /// In order to fix things "Quick and Dirty" the dictionary was
       /// altered on PURPOSE but now contains a WRONG value.
       /// In order to fix things and restore the dictionary to its
-      /// correct value, one needs to decided of the semantics by deciding
+      /// correct value, one needs to decide of the semantics by deciding
       /// whether the following tags are either :
       /// - multivaluated US, and hence loaded as ValEntry, but afterwards
       ///   also used as BinEntry, which requires the proper conversion,
@@ -552,7 +552,6 @@ double Document::SwapDouble(double a)
    return a;
 } 
 
-
 //
 // -----------------File I/O ---------------
 /**
@@ -609,7 +608,7 @@ std::ifstream *Document::OpenFile()
        zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 )
    {
       std::string msg = Util::Format(
-             "ACR/DICOM starting at the beginning of the file:(%04x)\n", zero);
+        "ACR/DICOM starting by 0x(%04x) at the beginning of the file\n", zero);
       // FIXME : is it a Warning message, or a Debug message?
       gdcmWarningMacro( msg.c_str() );
       return Fp;
@@ -761,11 +760,17 @@ void Document::LoadEntryBinArea(DataEntry *entry)
    uint32_t i;
    unsigned short vrLgth = 
                         Global::GetVR()->GetAtomicElementLength(entry->GetVR());
-   if( entry->GetVR() == "OW" )
-      vrLgth = 1;
+
+// FIXME : trouble expected if we read an ... OW Entry (LUT, etc ..)
+//   if( entry->GetVR() == "OW" )
+//      vrLgth = 1;
 
    switch(vrLgth)
    {
+      case 1:
+      {
+         break;
+      }     
       case 2:
       {
          uint16_t *data16 = (uint16_t *)data;
@@ -1534,7 +1539,7 @@ VRKey Document::FindDocEntryVR()
    // we used a heuristic that found "UL" in the first tag and/or
    // 'Transfer Syntax' told us it is.
    // Alas this doesn't guarantee that all the tags will be in explicit VR. 
-   // In some cases one finds implicit VR tags mixed within an explicit VR file
+   // In some cases one finds implicit VR tags mixed within an explicit VR file.
    // Hence we make sure the present tag is in explicit VR and try to fix things
    // if it happens not to be the case.
 
@@ -1544,8 +1549,8 @@ VRKey Document::FindDocEntryVR()
    if ( !CheckDocEntryVR(vr) )
    {
       gdcmWarningMacro( "Unknown VR " << std::hex << "0x(" 
-                        << vr[0] << vr[1] << ") at offset :" 
-                        << positionOnEntry );
+                        << (unsigned int)vr[0] << "|" << (unsigned int)vr[1] 
+                        << ") at offset :" << positionOnEntry );
       Fp->seekg(positionOnEntry, std::ios::beg);
       return GDCM_VRUNKNOWN;
    }
@@ -1785,12 +1790,12 @@ bool Document::CheckSwap()
       if ( net2host )
       {
          SwapCode = 4321;
-         gdcmDebugMacro( "HostByteOrder != NetworkByteOrder");
+         gdcmDebugMacro( "HostByteOrder != NetworkByteOrder, SwapCode = 4321");
       }
       else 
       {
          SwapCode = 1234;
-         gdcmDebugMacro( "HostByteOrder = NetworkByteOrder");
+         gdcmDebugMacro( "HostByteOrder = NetworkByteOrder, SwapCode = 1234");
       }
       
       // Position the file position indicator at first tag 
@@ -2126,12 +2131,18 @@ void Document::HandleOutOfGroup0002(uint16_t &group, uint16_t &elem)
    {
       Group0002Parsed = true;
       // we just came out of group 0002
-      // if Transfer syntax is Big Endian we have to change CheckSwap
+      // 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) )
       {
-         gdcmDebugMacro("True DICOM File, with NO Tansfer Syntax: " << ts );
+         gdcmWarningMacro("True DICOM File, with illegal Transfer Syntax: [" 
+                          << ts << "]");
          return;
       }
 
@@ -2140,9 +2151,9 @@ void Document::HandleOutOfGroup0002(uint16_t &group, uint16_t &elem)
 
       if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == 
                                                     TS::ImplicitVRLittleEndian )
-         {
-            Filetype = ImplicitVR;
-         }
+      {
+         Filetype = ImplicitVR;
+      }
        
       // FIXME Strangely, this works with 
       //'Implicit VR BigEndian Transfer Syntax (GE Private)