]> Creatis software - gdcm.git/commitdiff
Port Mathieu's patch from gdcm 1.2 (in gdcmValEntry.cxx)
authorjpr <jpr>
Tue, 4 Jul 2006 09:36:18 +0000 (09:36 +0000)
committerjpr <jpr>
Tue, 4 Jul 2006 09:36:18 +0000 (09:36 +0000)
ENH: Better patch. Always pad with space except if VR is UI
(Shouldn't we think in unifying gdcm1.3 an cvs version -post gdcm1.3-
a lot of work is done twice; interesting enhencements are now in gdcm1.3
The only pb is New vs new, right?

src/gdcmDataEntry.cxx

index 570c3c50d31633761a595b7cb8687a665e60b0bf..36aa38e2af16e073d6adbf3d38d34f9a11dd053c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/06/29 13:26:08 $
-  Version:   $Revision: 1.39 $
+  Date:      $Date: 2006/07/04 09:36:18 $
+  Version:   $Revision: 1.40 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -366,7 +366,6 @@ uint32_t DataEntry::GetValueCount( ) const
 void DataEntry::SetString(std::string const &value)
 {
    DeleteBinArea();
-
    const VRKey &vr = GetVR();
    if ( vr == "US" || vr == "SS" )
    {
@@ -417,16 +416,16 @@ void DataEntry::SetString(std::string const &value)
       tokens.clear();
    }
    else
-   {
-      //if( value.size() > 0 )  // when user sets a string to 0, *do* the job.
-      {
-         size_t l =  value.size();    
-         SetLength(l + l%2);
-         NewBinArea();
-         memcpy(BinArea, value.c_str(), l);
-         if (l%2)
+   {      
+      size_t l =  value.size();    
+      SetLength(l + l%2);
+      NewBinArea();
+      memcpy(BinArea, value.c_str(), l);
+      if (l%2) // padded with blank except for UI
+         if ( vr == "UI" ) 
             BinArea[l] = '\0';
-      }      
+         else
+            BinArea[l] = ' ';                
    }
    State = STATE_LOADED;
 }