]> Creatis software - gdcm.git/commitdiff
Some fixes to help dealing with UnLoaded values
authorjpr <jpr>
Thu, 9 Sep 2004 17:49:24 +0000 (17:49 +0000)
committerjpr <jpr>
Thu, 9 Sep 2004 17:49:24 +0000 (17:49 +0000)
(ForceLoad no yet commited)

src/gdcmBinEntry.cxx
src/gdcmBinEntry.h
src/gdcmCommon.h
src/gdcmDocEntry.cxx
src/gdcmDocument.cxx
src/gdcmFile.cxx
src/gdcmHeader.cxx
src/gdcmValEntry.cxx

index 651ed623062dadb91f4126bb1734ae9f463fbd7d..720bbd7714f807c360d0b3fd7b7cbafeae1eb023 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/08/31 14:24:47 $
-  Version:   $Revision: 1.23 $
+  Date:      $Date: 2004/09/09 17:49:24 $
+  Version:   $Revision: 1.24 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -44,7 +44,7 @@ gdcmBinEntry::gdcmBinEntry(gdcmDocEntry* e) : gdcmValEntry(e->GetDictEntry())
    PrintLevel   = e->GetPrintLevel();
    SQDepthLevel = e->GetDepthLevel();
 
-   VoidArea = NULL; // let's be carefull !
+   VoidArea = 0; // let's be carefull !
 }
 
 /**
@@ -55,7 +55,7 @@ gdcmBinEntry::~gdcmBinEntry()
    if (VoidArea)
    {
       free (VoidArea);
-      VoidArea = NULL; // let's be carefull !
+      VoidArea = 0; // let's be carefull !
    }
 }
 
@@ -73,8 +73,9 @@ void gdcmBinEntry::Print(std::ostream &os)
    void *voidArea = GetVoidArea();
    if (voidArea)
    {
-      s << " [gdcm::Binary data loaded with length is "
-        << GetLength() << "]";
+      //s << " [" << GDCM_BINLOADED 
+      s << " [" << GetValue()
+        << "; length = " << GetLength() << "]";
    }
    else
    {
@@ -84,7 +85,8 @@ void gdcmBinEntry::Print(std::ostream &os)
       }
       else 
       {
-         s << " [gdcm::Binary data NOT loaded]";
+         //s << " [gdcm::Binary data NOT loaded]";
+         s << " [" <<GetValue() << "]";
       }
          
    }
@@ -106,6 +108,11 @@ void gdcmBinEntry::Write(FILE *fp, FileType filetype)
       // there is a 'non string' LUT, overlay, etc
       fwrite ( voidArea,(size_t)lgr ,(size_t)1 ,fp); // Elem value
    }
+   else
+   {
+    // nothing was loaded, but we need to skip space on disc
+      fseek(fp,(size_t)lgr,SEEK_CUR); 
+   }
 }
 //-----------------------------------------------------------------------------
 // Public
index ca1beedbd0ba987b6c77967a20ffea14ec7bd7ae..6f4b561d90ea5f556f1bad656711de06a241a0b6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/09/03 20:27:44 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2004/09/09 17:49:24 $
+  Version:   $Revision: 1.15 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -41,7 +41,7 @@ public:
    ~gdcmBinEntry();
    
    void Print(std::ostream &os = std::cout);
-   virtual void Write(FILE*, FileType);
+   void Write(FILE*, FileType);
 
    /// \brief Returns the area value of the current Dicom Header Entry
    ///  when it's not string-translatable (e.g : a LUT table)         
index 89e76f67d5c7f9b869784e966bc9326bf1accbda..e36b21e30046509d25b1d6cbaf7cb2f15dd04b92 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmCommon.h,v $
   Language:  C++
-  Date:      $Date: 2004/07/19 11:51:26 $
-  Version:   $Revision: 1.29 $
+  Date:      $Date: 2004/09/09 17:49:24 $
+  Version:   $Revision: 1.30 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -91,7 +91,10 @@ typedef  unsigned int   uint32_t;
 
 #include <string>
 
-const std::string GDCM_UNFOUND = "gdcm::Unfound";   /// MEMORY LEAK
+const std::string GDCM_UNFOUND   = "gdcm::Unfound";   /// MEMORY LEAK
+const std::string GDCM_BINLOADED = "gdcm::Binary data loaded";
+const std::string GDCM_NOTLOADED = "gdcm::NotLoaded";
+const std::string GDCM_UNREAD    = "gdcm::UnRead";
 
 typedef std::string gdcmTagKey;
 typedef std::string TagName;
index 208bd1e6e1e15251d4ae66387c97ee452a2cc92c..54c7ed04a629726e3e8d8c184bfe8ea2822586ea 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/03 15:09:30 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2004/09/09 17:49:24 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -164,7 +164,7 @@ void gdcmDocEntry::Write(FILE *fp, FileType filetype)
          // Unknown was 'written'
          // deal with Little Endian            
          fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,fp);
-         fwrite ( &z,  (size_t)2 ,(size_t)1 ,fp);
+         fwrite ( &z,       (size_t)2 ,(size_t)1 ,fp);
       }
       else
       {
index 71312ce5ce2b6bab3c66efceca65e65559e5e349..6a25788fc9d58933284147914af5d1fa507503a9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/07 13:57:04 $
-  Version:   $Revision: 1.71 $
+  Date:      $Date: 2004/09/09 17:49:24 $
+  Version:   $Revision: 1.72 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1504,34 +1504,33 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry)
    if (length > MaxSizeLoadEntry)
    {
       if (gdcmBinEntry* binEntryPtr = dynamic_cast< gdcmBinEntry* >(entry) )
-      {         
-         s << "gdcm::NotLoaded (BinEntry)";
+      {  
+         //s << "gdcm::NotLoaded (BinEntry)";
+         s << GDCM_NOTLOADED;
          s << " Address:" << (long)entry->GetOffset();
          s << " Length:"  << entry->GetLength();
          s << " x(" << std::hex << entry->GetLength() << ")";
          binEntryPtr->SetValue(s.str());
       }
-      // to be sure we are at the end of the value ...
-      fseek(Fp, (long)entry->GetOffset()+(long)entry->GetLength(), SEEK_SET);      
-      // Following return introduced by JPR on version 1.25. Since the 
-      // treatement of a ValEntry is never executed (doh!) this means
-      // we were lucky up to now because we NEVER encountered a ValEntry
-      // whose length was bigger thant MaxSizeLoadEntry !? I can't believe
-      // this could ever work...
-      return;  //FIXME FIXME FIXME FIXME JPR ????
-
        // Be carefull : a BinEntry IS_A ValEntry ... 
-      if (gdcmValEntry* valEntryPtr = dynamic_cast< gdcmValEntry* >(entry) )
+      else if (gdcmValEntry* valEntryPtr = dynamic_cast< gdcmValEntry* >(entry) )
       {
-         s << "gdcm::NotLoaded. (ValEntry)";
+        // s << "gdcm::NotLoaded. (ValEntry)";
+         s << GDCM_NOTLOADED;  
          s << " Address:" << (long)entry->GetOffset();
          s << " Length:"  << entry->GetLength();
          s << " x(" << std::hex << entry->GetLength() << ")";
          valEntryPtr->SetValue(s.str());
       }
+      else
+      {
+         // fusible
+         std::cout<< "MaxSizeLoadEntry exceeded, neither a BinEntry "
+                  << "nor a ValEntry ?! Should never print that !" << std::endl;
+      }
+
       // to be sure we are at the end of the value ...
       fseek(Fp,(long)entry->GetOffset()+(long)entry->GetLength(),SEEK_SET);      
-
       return;
    }
 
@@ -1610,7 +1609,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry)
       {
          dbg.Verbose(1, "gdcmDocument::LoadDocEntry",
                         "unread element value");
-         valEntry->SetValue("gdcm::UnRead");
+         valEntry->SetValue(GDCM_UNREAD);
          return;
       }
 
index a2ddfc70a88fad33cfa402db1f869fb346c057ff..000b5baeec758361b04d00ac8114851ff7472fd6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/01 16:23:59 $
-  Version:   $Revision: 1.122 $
+  Date:      $Date: 2004/09/09 17:49:25 $
+  Version:   $Revision: 1.123 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -223,7 +223,10 @@ void *gdcmFile::GetImageData()
       GetImageDataIntoVector(PixelData, ImageDataSize);
       // Will be 7fe0, 0010 in standard case
       GetHeader()->SetEntryVoidAreaByNumber( PixelData, 
-         GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel()); 
+         GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel());
+      // Now, the value is loaded.
+      GetHeader()->SetEntryByNumber( GDCM_BINLOADED,
+         GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel());
    }      
    PixelRead = 0; // no PixelRaw
 
@@ -348,6 +351,9 @@ void * gdcmFile::GetImageDataRaw ()
       // will be 7fe0, 0010 in standard cases
       GetHeader()->SetEntryVoidAreaByNumber(PixelData, 
          GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel()); 
+      // Now, the value is loaded.
+      GetHeader()->SetEntryByNumber( GDCM_BINLOADED,
+         GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel());
    } 
    PixelRead = 1; // PixelRaw
 
index 4419fb9131a13f7191ac94d2844a387b2c08a674..654a1b08e831d8ffb4ad4a503c74cf51c525878b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/01 16:23:59 $
-  Version:   $Revision: 1.183 $
+  Date:      $Date: 2004/09/09 17:49:25 $
+  Version:   $Revision: 1.184 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1194,7 +1194,6 @@ uint8_t* gdcmHeader::GetLUTRGBA()
       *a = 1; // Alpha component
       a += 4;
    }
-
    return LUTRGBA;
 } 
 
@@ -1208,6 +1207,12 @@ std::string gdcmHeader::GetTransfertSyntaxName()
    // use the gdcmTS (TS : Transfert Syntax)
    std::string transfertSyntax = GetEntryByNumber(0x0002,0x0010);
 
+   if ( transfertSyntax == GDCM_NOTLOADED ) { // fusible
+      std::cout << "Transfert Syntax not loaded. " << std::endl
+               << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
+               << std::endl;
+      return "Uncompressed ACR-NEMA";
+   }
    if ( transfertSyntax == GDCM_UNFOUND )
    {
       dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName:"
index 8b14f72f1e7d34f4e0f1ae0eada41234b434a826..ebf6947fc12477124ee21ebfc2bb47f359815d9f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmValEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/08/27 15:48:44 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2004/09/09 17:49:25 $
+  Version:   $Revision: 1.23 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -92,7 +92,8 @@ void gdcmValEntry::Print(std::ostream & os)
    v  = GetValue();  // not applicable for SQ ...     
    d2 = CreateCleanString(v);  // replace non printable characters by '.'            
    if( (GetLength()<=MAX_SIZE_PRINT_ELEMENT_VALUE) || 
-       (PrintLevel>=3)  || (d2.find("gdcm::NotLoaded.") < d2.length()) )
+       //(PrintLevel>=3)  || (d2.find("gdcm::NotLoaded.") < d2.length()) )
+       (PrintLevel>=3)  || (d2.find(GDCM_NOTLOADED) < d2.length()) )
    {
       s << " [" << d2 << "]";
    }