]> Creatis software - gdcm.git/commitdiff
Meta Elements group length (follows previous commit)
authorjpr <jpr>
Wed, 7 Sep 2005 08:55:22 +0000 (08:55 +0000)
committerjpr <jpr>
Wed, 7 Sep 2005 08:55:22 +0000 (08:55 +0000)
src/gdcmDocument.cxx
src/gdcmDocument.h
src/gdcmFile.cxx
src/gdcmFileHelper.cxx

index 557eb4e6b6a8ee1d20e998d485cc7fc0857c3823..e1abb25b65229d0d1663c31cb81e38015fef4d4f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 15:34:35 $
-  Version:   $Revision: 1.274 $
+  Date:      $Date: 2005/09/07 08:55:22 $
+  Version:   $Revision: 1.275 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -594,14 +594,14 @@ std::ifstream *Document::OpenFile()
        zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 )
    {
       std::string msg = Util::Format(
-        "ACR/DICOM starting at the begining of the file:(%04x)\n", zero);
+        "ACR/DICOM starting at the beginning of the file:(%04x)\n", zero);
       gdcmWarningMacro( msg.c_str() );
       return Fp;
    }
  
    //-- DICOM --
    Fp->seekg(126L, std::ios::cur);
-   char dicm[4] = {' ',' ',' ',' '};
+   char dicm[4]; // = {' ',' ',' ',' '};
    Fp->read(dicm,  (size_t)4);
    if ( Fp->eof() )
    {
@@ -645,11 +645,7 @@ bool Document::CloseFile()
  */
 void Document::WriteContent(std::ofstream *fp, FileType filetype)
 {
-   // \TODO move the following lines (and a lot of others, to be written)
-   // to a future function CheckAndCorrectHeader  
-
-   // (necessary if user wants to write a DICOM V3 file
-   // starting from an ACR-NEMA (V2) Header
+   // Skip if user wants to write an ACR-NEMA file
 
    if ( filetype == ImplicitVR || filetype == ExplicitVR )
    {
@@ -877,9 +873,8 @@ void Document::SkipBytes(uint32_t nBytes)
 
 /**
  * \brief   Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader
- * @param filetype Type of the File to be written 
  */
-int Document::ComputeGroup0002Length( FileType filetype ) 
+int Document::ComputeGroup0002Length( /*FileType filetype*/ ) 
 {
    uint16_t gr;
    std::string vr;
@@ -900,15 +895,19 @@ int Document::ComputeGroup0002Length( FileType filetype )
          if ( entry->GetElement() != 0x0000 )
          {
             vr = entry->GetVR();
+
+            // FIXME : group 0x0002 is *always* Explicit VR!
  
-            if ( filetype == ExplicitVR )
-            {
-               if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") || (vr == "UT") ) 
+            //if ( filetype == ExplicitVR )
+            //{
+            //   if ( (vr == "OB") || (vr == "OW") || (vr == "UT") || (vr == "SQ") )
+            // (no SQ, OW, UT in group 0x0002;)
+               if ( vr == "OB" ) 
                {
                   // explicit VR AND OB, OW, SQ, UT : 4 more bytes
                   groupLength +=  4;
                }
-            }
+            //}
             groupLength += 2 + 2 + 4 + entry->GetLength();   
          }
       }
@@ -1497,7 +1496,7 @@ void Document::LoadDocEntry(DocEntry *entry, bool forceLoad)
 }
 
 /**
- * \brief  Find the value Length of the passed Header Entry
+ * \brief  Find the value Length of the passed Doc Entry
  * @param  entry Header Entry whose length of the value shall be loaded. 
  */
 void Document::FindDocEntryLength( DocEntry *entry )
@@ -1508,7 +1507,8 @@ void Document::FindDocEntryLength( DocEntry *entry )
    
    if ( Filetype == ExplicitVR && !entry->IsImplicitVR() ) 
    {
-      if ( vr == "OB" || vr == "OW" || vr == "SQ" || vr == "UT" || vr == "UN" ) 
+      if ( vr == "OB" || vr == "OW" || vr == "SQ" || vr == "UT" 
+                                                           /*|| vr == "UN"*/ )
       {
          // The following reserved two bytes (see PS 3.5-2003, section
          // "7.1.2 Data element structure with explicit vr", p 27) must be
@@ -1530,6 +1530,9 @@ void Document::FindDocEntryLength( DocEntry *entry )
                // chance to get the pixels by deciding the element goes
                // until the end of the file. Hence we artificially fix the
                // the length and proceed.
+               gdcmWarningMacro( " Computing the length failed for " << 
+                                   entry->GetKey() <<" in " <<GetFileName());
+
                long currentPosition = Fp->tellg();
                Fp->seekg(0L,std::ios::end);
 
index 84b7224ddb51272e5b720c163715a70f00d94f84..790291e926b01a026274625b1f7cb76ce42c732d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 14:40:33 $
-  Version:   $Revision: 1.121 $
+  Date:      $Date: 2005/09/07 08:55:23 $
+  Version:   $Revision: 1.122 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -124,7 +124,7 @@ protected:
    uint16_t ReadInt16() throw ( FormatError );
    uint32_t ReadInt32() throw ( FormatError );
    void     SkipBytes(uint32_t);
-   int ComputeGroup0002Length( FileType filetype );
+   int ComputeGroup0002Length( );
 
 // Variables
    /// Refering underlying filename.
index 3fb9cb5c011e67e48846641cb6c826593e359d40..8a11ae809b4ea8faa92ef44c35938dce8db43e51 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/06 15:32:13 $
-  Version:   $Revision: 1.267 $
+  Date:      $Date: 2005/09/07 08:55:23 $
+  Version:   $Revision: 1.268 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1495,7 +1495,7 @@ bool File::Write(std::string fileName, FileType writetype)
    if ( e0000 )
    {
       std::ostringstream sLen;
-      sLen << ComputeGroup0002Length(writetype);
+      sLen << ComputeGroup0002Length( );
       e0000->SetValue(sLen.str());
    }
 
index 67274d990ce8536f1f859a740ef47d491c532edc..e91570e2833ee4a2ee654470002d92259bea5621 100644 (file)
@@ -4,8 +4,8 @@
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
 
-  Date:      $Date: 2005/09/06 15:34:29 $
-  Version:   $Revision: 1.57 $
+  Date:      $Date: 2005/09/07 08:55:23 $
+  Version:   $Revision: 1.58 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -100,7 +100,7 @@ fh1->Write(newFileName);
       (checks user given pixels length)
    FileInternal->Write(fileName,WriteType)
    fp = opens file(fileName);
-   ComputeGroup0002Length(writetype);
+   ComputeGroup0002Length( );
    BitsAllocated 12->16
       RemoveEntryNoDestroy(palettes, etc)
       Document::WriteContent(fp, writetype);