]> Creatis software - gdcm.git/commitdiff
handling 'non string elements' unsecure area (LUT, overlays, etc)
authorjpr <jpr>
Tue, 3 Feb 2004 16:57:25 +0000 (16:57 +0000)
committerjpr <jpr>
Tue, 3 Feb 2004 16:57:25 +0000 (16:57 +0000)
src/gdcmHeader.cxx
src/gdcmHeaderEntry.cxx
src/gdcmHeaderEntry.h
src/gdcmParser.cxx

index 60eb0fc065f7ccf78379973285f64a33e957979c..7b28ed4294e152e08fec80a0967471bd5b6116dc 100644 (file)
@@ -96,9 +96,9 @@ gdcmHeader::~gdcmHeader (void) {
  *         false otherwise. 
  */
 bool gdcmHeader::IsReadable(void) {
-   if(!gdcmParser::IsReadable())
+   if(!gdcmParser::IsReadable()) {
       return(false);
-
+   }
    std::string res = GetEntryByNumber(0x0028, 0x0005);
    if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) 
       return false; // Image Dimensions
index 514a591eace2439f0b913a6b01cc2771bc08f765..0185b9157ce0844e180d81b6b669043a9b9d075b 100644 (file)
@@ -25,6 +25,7 @@
  */
 gdcmHeaderEntry::gdcmHeaderEntry(gdcmDictEntry* in) {
        ImplicitVR = false;
+       voidArea = NULL; // unsecure memory area to hold 'non string' values
        entry = in;
 }
 
@@ -83,15 +84,20 @@ void gdcmHeaderEntry::Print(std::ostream & os) {
     
    s << "[" << GetName()<< "]";
 
-     
-           
-   if( (GetLength()<MAX_SIZE_PRINT_ELEMENT_VALUE) || 
-       (printLevel>=3)  || 
-       (d2.find("gdcm::NotLoaded.") < d2.length()) )
-      s << " [" << d2 << "]";
-   else 
-      s << " [ gdcm::too long for print (" << GetLength() << ") ]";
-
+   if (voidArea != NULL) {
+       s << " [gdcm::Non String Data Loaded in Unsecure Area (" 
+         << GetLength() << ") ]";
+   } 
+   
+   else {             
+      if( (GetLength()<MAX_SIZE_PRINT_ELEMENT_VALUE) || 
+          (printLevel>=3)  || 
+          (d2.find("gdcm::NotLoaded.") < d2.length()) )
+         s << " [" << d2 << "]";
+      else 
+         s << " [gdcm::too long for print (" << GetLength() << ") ]";
+   }
+   
    // Display the UID value (instead of displaying the rough code)  
    if (g == 0x0002) {  // Any more to be displayed ?
       if ( (e == 0x0010) || (e == 0x0002) )
index 20e23cebfe424a3b0c4de7e036b38624590caaa2..577ff569ab3cf295770a659551fc31d4397e8b1a 100644 (file)
@@ -118,7 +118,7 @@ private:
                          
 
    std::string  value;
-   void *voidArea;  // unsecure memory area to hold 'non string' values 
+   void *voidArea;   // unsecure memory area to hold 'non string' values 
                      // (ie : Lookup Tables, overlays)
    size_t Offset;    // Offset from the begining of file for direct user access
    int printLevel;
index 22a77c21648c8c535dd19eeca3107fb3dd088d26..df9f48f2f370c2c4cc25ff589e58a2576521e200 100644 (file)
@@ -755,6 +755,9 @@ void *gdcmParser::LoadEntryVoidArea(guint16 Group, guint16 Elem)
        free(a);
        return NULL;
    }
+   cout << hex << Group << " " << Elem << "loaded" <<endl;
+   Element->SetPrintLevel(2);
+   Element->Print();
    return a;  
 }
 
@@ -1012,6 +1015,7 @@ void gdcmParser::WriteEntries(FileType type, FILE * _fp)
    guint32 val_uint32;
    guint16 val_uint16;
    guint16 valZero =0;
+   void *voidArea;
    std::vector<std::string> tokens;
    
    // TODO : function CheckHeaderCoherence to be written
@@ -1035,6 +1039,8 @@ void gdcmParser::WriteEntries(FileType type, FILE * _fp)
       lgr = (*tag2)->GetReadLength();
       val = (*tag2)->GetValue().c_str();
       vr =  (*tag2)->GetVR();
+      voidArea = (*tag2)->GetVoidArea();
+      
       if ( type == ACR ) 
       { 
          if (gr < 0x0008)   continue; // ignore pure DICOM V3 groups
@@ -1091,6 +1097,11 @@ void gdcmParser::WriteEntries(FileType type, FILE * _fp)
       if (vr == "SQ")  continue; // no "value" to write for the SEQuences
       if (gr == 0xfffe)continue;
       
+      if (voidArea != NULL) { // there is a 'non string' LUT, overlay, etc
+         fwrite ( voidArea,(size_t)lgr ,(size_t)1 ,_fp); // Elem value
+        continue;            
+      }
+      
       if (vr == "US" || vr == "SS") 
       {
          tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
@@ -1240,7 +1251,9 @@ void gdcmParser::LoadHeaderEntries(void) {
       LoadEntryVoidArea(0x0028,0x1221);  // Segmented Red   Palette Color LUT Data
       LoadEntryVoidArea(0x0028,0x1222);  // Segmented Green Palette Color LUT Data
       LoadEntryVoidArea(0x0028,0x1223);  // Segmented Blue  Palette Color LUT Data
-   }   
+   } 
+   //FIXME : how to use it?
+   LoadEntryVoidArea(0x0028,0x3006);  //LUT Data (CTX dependent)     
    
    // --------------------------------------------------------------
    // Special Patch to allow gdcm to read ACR-LibIDO formated images
@@ -2022,24 +2035,21 @@ bool gdcmParser::CheckSwap() {
       // * the 4 bytes of the first tag (0002, 0000),or (0002, 0001)
       // i.e. a total of  136 bytes.
       entCur = deb + 136;
-      // FIXME
-      // Use gdcmParser::dicom_vr to test all the possibilities
-      // instead of just checking for UL, OB and UI !?
-      
+     
       // FIXME : FIXME:
       // Sometimes (see : gdcmData/icone.dcm) group 0x0002 *is* Explicit VR,
       // but elem 0002,0010 (Transfert Syntax) tells us the file is *Implicit* VR.
       // -and it is !- 
       
-      // The following test is *absolutely useless*, since everything *goes right*
-      // with a *100 % wrong* assumption !!!
-      
       if( (memcmp(entCur, "UL", (size_t)2) == 0) ||
          (memcmp(entCur, "OB", (size_t)2) == 0) ||
          (memcmp(entCur, "UI", (size_t)2) == 0) ||       
          (memcmp(entCur, "CS", (size_t)2) == 0) )  // CS, to remove later
                                                    // when Write DCM *adds*
-                                                   // group 0000  
+      // FIXME
+      // Use gdcmParser::dicom_vr to test all the possibilities
+      // instead of just checking for UL, OB and UI !?                                             // group 0000 
+                                                    
       {
          filetype = ExplicitVR;
          dbg.Verbose(1, "gdcmParser::CheckSwap:",