]> Creatis software - gdcm.git/commitdiff
dealing with 'zero length' integers
authorjpr <jpr>
Mon, 13 Sep 2004 07:49:35 +0000 (07:49 +0000)
committerjpr <jpr>
Mon, 13 Sep 2004 07:49:35 +0000 (07:49 +0000)
src/gdcmDictSet.cxx
src/gdcmDictSet.h
src/gdcmDocument.cxx
src/gdcmFile.cxx
src/gdcmFile.h

index ee8b8cf9f4542810698cec03828d35fd133ee7e1..7b7e8da4f5b150f8dd1563ceec5ec20cfa91264d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/08/31 14:24:47 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2004/09/13 07:49:35 $
+  Version:   $Revision: 1.36 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -165,15 +165,6 @@ gdcmDict *gdcmDictSet::GetDict(DictKey const & dictName)
    return NULL;
 }
 
-/**
- * \brief   Retrieve the default reference DICOM V3 public dictionary.
- * \result  The retrieved default dictionary.
- */
-gdcmDict *gdcmDictSet::GetDefaultPubDict() 
-{
-   return GetDict(PUB_DICT_NAME);
-}
-
 /**
  * \brief   Create a gdcmDictEntry which will be reference 
  *          in no dictionnary
index 1cd5b0d91433ccfb2508b4bf3e00486e0a05aa56..4eb4189a5673ce6d696b6e2ee234b18e2f3850d1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictSet.h,v $
   Language:  C++
-  Date:      $Date: 2004/08/03 17:28:59 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2004/09/13 07:49:35 $
+  Version:   $Revision: 1.25 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -51,7 +51,13 @@ public:
                                DictKey const & name );
 
    gdcmDict* GetDict( DictKey const & DictName );
-   gdcmDict* GetDefaultPubDict();
+
+   /// \brief   Retrieve the default reference DICOM V3 public dictionary.
+   gdcmDict* GetDefaultPubDict() { return GetDict(PUB_DICT_NAME); };
+
+   // \brief   Retrieve the virtual reference DICOM dictionary.
+   // \warning : not end user intended
+   // gdcmDict* GetVirtualDict() { return &VirtualEntry; };
 
    gdcmDictEntry* NewVirtualDictEntry(uint16_t group, uint16_t element,
                                       std::string vr     = "Unknown",
@@ -69,7 +75,7 @@ private:
    /// Directory path to dictionaries
    std::string DictPath;
    /// H table for the on the fly created gdcmDictEntries  
-   std::map<std::string,gdcmDictEntry *> VirtualEntry;
+   TagKeyHT VirtualEntry; 
 };
 
 //-----------------------------------------------------------------------------
index 9b5b2ac4e7f03d731f94e20a56c93b2a3b378f87..cdcdd9cb1b69e1b335a8fd568573075c8f76e8d2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/10 18:54:38 $
-  Version:   $Revision: 1.74 $
+  Date:      $Date: 2004/09/13 07:49:36 $
+  Version:   $Revision: 1.75 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -664,7 +664,8 @@ gdcmBinEntry * gdcmDocument::ReplaceOrCreateByNumber(
       b = new gdcmBinEntry(a);
       AddEntry(b);
       b->SetVoidArea(voidArea);
-   }   
+   } 
+
    SetEntryByNumber(voidArea, lgth, group, elem);
    //b->SetVoidArea(voidArea);  //what if b == 0 !!
 
@@ -870,6 +871,9 @@ bool gdcmDocument::SetEntryByNumber(std::string const & content,
                                     uint16_t group,
                                     uint16_t element) 
 {
+   int c;
+   int l;
+
    gdcmValEntry* valEntry = GetValEntryByNumber(group, element);
    if (!valEntry )
    {
@@ -878,30 +882,31 @@ bool gdcmDocument::SetEntryByNumber(std::string const & content,
       return false;
    }
    // Non even content must be padded with a space (020H)...
-   std::string evenContent = content;
-   if( evenContent.length() % 2 )
+   std::string finalContent = content;
+   if( finalContent.length() % 2 )
    {
-      evenContent += '\0';  // ... therefore we padd with (000H) .!?!
+      finalContent += '\0';  // ... therefore we padd with (000H) .!?!
    }      
-   valEntry->SetValue(evenContent);
+   valEntry->SetValue(finalContent);
    
    // Integers have a special treatement for their length:
-   gdcmVRKey vr = valEntry->GetVR();
-   if( vr == "US" || vr == "SS" )
-   {
-      int c = CountSubstring(content, "\\"); // for multivaluated items
-      valEntry->SetLength((c+1)*2);
-   }
-   else if( vr == "UL" || vr == "SL" )
-   {
-      int c = CountSubstring(content, "\\"); // for multivaluated items
-      valEntry->SetLength((c+1)*4);
-   }
-   else
-   {
-      valEntry->SetLength(evenContent.length());
-   }
 
+   l = finalContent.length();
+   if ( l != 0) // To avoid to be cheated by 'zero length' integers
+   {   
+      gdcmVRKey vr = valEntry->GetVR();
+      if( vr == "US" || vr == "SS" )
+      {
+         c = CountSubstring(content, "\\") + 1; // for multivaluated items
+         l = c*2;
+      }
+      else if( vr == "UL" || vr == "SL" )
+      {
+         c = CountSubstring(content, "\\") + 1; // for multivaluated items
+         l = c*4;;
+      }
+   }
+   valEntry->SetLength(l);
    return true;
 } 
 
@@ -935,7 +940,7 @@ bool gdcmDocument::SetEntryByNumber(void *content,
 */      
    gdcmBinEntry* a = (gdcmBinEntry *)TagHT[key];           
    a->SetVoidArea(content);  
-   //a->SetLength(lgth);  // ???  
+   a->SetLength(lgth);
 
    return true;
 } 
index b3eb62e680299e2f8d0ba6a44de98e652057a7ed..e94cb485419c56c470a8b5e397dbba115783d86a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/10 18:54:38 $
-  Version:   $Revision: 1.124 $
+  Date:      $Date: 2004/09/13 07:49:36 $
+  Version:   $Revision: 1.125 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -102,28 +102,15 @@ void gdcmFile::SetInitialValues()
       InitialPlanConfig    = Header->GetEntryByNumber(0x0028,0x0006);
       InitialBitsAllocated = Header->GetEntryByNumber(0x0028,0x0100);
                
-      // the following entries *may* be removed
-      // by gdcmFile::GetImageDataIntoVectorRaw  
-      // we save them.
-
-     // we SHALL save them !
-     // (some troubles, now)
-     /*
+      // the following entries *may* be removed from the H table
+      // (NOT deleted ...) by gdcmFile::GetImageDataIntoVectorRaw  
+      // we keep a pointer on them.
       InitialRedLUTDescr   = Header->GetDocEntryByNumber(0x0028,0x1101);
       InitialGreenLUTDescr = Header->GetDocEntryByNumber(0x0028,0x1102);
       InitialBlueLUTDescr  = Header->GetDocEntryByNumber(0x0028,0x1103);
       InitialRedLUTData    = Header->GetDocEntryByNumber(0x0028,0x1201);
       InitialGreenLUTData  = Header->GetDocEntryByNumber(0x0028,0x1202);
       InitialBlueLUTData   = Header->GetDocEntryByNumber(0x0028,0x1203); 
-      
-      if (InitialRedLUTData == NULL)
-         std::cout << "echec InitialRedLUTData " << std::endl;
-      else  
-      { 
-         printf("%p\n",InitialRedLUTData);
-         InitialRedLUTData->Print(); std::cout <<std::endl;
-      }
-     */        
    }
 }
 
@@ -141,26 +128,9 @@ gdcmFile::~gdcmFile()
    }
    Header = 0;
 
-   if ( InitialRedLUTDescr )           
-      delete InitialRedLUTDescr;
-     
-   if ( InitialGreenLUTDescr )
-      delete InitialGreenLUTDescr;
-      
-   if ( InitialBlueLUTDescr )      
-      delete InitialBlueLUTDescr; 
-          
-/* LATER ...
-       
-   if ( InitialRedLUTData )      
-      delete InitialRedLUTData;
-   
-   if ( InitialGreenLUTData != NULL)
-      delete InitialGreenLUTData;
-      
-   if ( InitialBlueLUTData != NULL)      
-      delete InitialBlueLUTData;      
-*/  
+// InitialLutDescriptors and InitialLutData
+// will have to be deleted if the don't belong any longer
+// to the Header H table ...
 }
 
 //-----------------------------------------------------------------------------
index 0f3ed6bf19f7a1a3a9ef95c019b2590fa2f0a6de..90ea66afd248678bfd8c2d678af2cbe0bdb38765 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.h,v $
   Language:  C++
-  Date:      $Date: 2004/09/12 01:40:09 $
-  Version:   $Revision: 1.46 $
+  Date:      $Date: 2004/09/13 07:49:36 $
+  Version:   $Revision: 1.47 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -155,9 +155,10 @@ private:
   /// \brief Bits Allocated              (0x0028,0x0100), as found on disk
    std::string InitialBitsAllocated;
    
-  // some DocEntry that can be moved ou of the H table during reading process
+  // some DocEntry that can be moved out of the H table during reading process
   // if user asked to transform gray level + LUT image into RGB image
-   
+  // We keep a pointer on them for a future use.
+     
   /// \brief Red Palette Color Lookup Table Descriptor   0028 1101 as read
   gdcmDocEntry* InitialRedLUTDescr;  
   /// \brief Green Palette Color Lookup Table Descriptor 0028 1102 as read