]> Creatis software - gdcm.git/blobdiff - src/gdcmDataEntry.cxx
ENH: do not run dash
[gdcm.git] / src / gdcmDataEntry.cxx
index 7263a80e9ce97768cc639eb9b958a14bb49186a3..833be232f3c7efc3d1f29f4f3fad5c568ca0987c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/30 09:14:41 $
-  Version:   $Revision: 1.51 $
+  Date:      $Date: 2008/04/10 12:15:35 $
+  Version:   $Revision: 1.54 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,6 +30,8 @@
  #include <stdlib.h> // for atof
  #include <ctype.h>  // for isdigit
 #endif
+#include <string.h> // memcpy
+#include <stdlib.h> // atof
 
 // Could be defined like MAX_SIZE_LOAD_ELEMENT_VALUE
 #define GDCM_MAX_LENGTH_TO_CONVERT_TO_HEXA 8
@@ -427,10 +429,12 @@ void DataEntry::SetString(std::string const &value)
       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] = ' ';                
+        {
+        if ( vr == "UI" )
+          BinArea[l] = '\0';
+        else
+          BinArea[l] = ' ';
+        }
    }
    State = STATE_LOADED;
 }
@@ -598,25 +602,39 @@ std::string const &DataEntry::GetHexaRepresentation() const
   }
   else if( vr == "FL" )
   {
-     float *data=(float *)BinArea;
+     unsigned char *toto=(unsigned char *)BinArea;
      for (unsigned int i=0; i < GetValueCount(); i++)
      {
-        s2  << std::setw( 4 ) << std::setfill( '0' );
+         s2.str("");
          if( i!=0 )
            s2 << '\\';
-        s2 << data[i];
+         unsigned int a4;
+         for(int iif=0; iif<4; iif++)
+         {
+            a4=toto[iif];
+            s2 << a4; 
+         }
      }
      *StrHexaArea=s2.str();
   }
   else if( vr == "FD" )
   {
-     double *data=(double *)BinArea;
+     //double *data=(double *)BinArea;
+     unsigned char *toto=(unsigned char *)BinArea;
      for (unsigned int i=0; i < GetValueCount(); i++)
      {
-        s2  << std::setw( 8 ) << std::setfill( '0' );
-         if( i!=0 )
+        s2.str("");
+        if( i!=0 )
            s2 << '\\';
-        s2 << data[i];
+        //s2 << data[i];
+
+         unsigned int a4;
+         for(int iid=0; iid<8; iid++)
+         {
+            a4=toto[iid];
+            s2 << a4; 
+         }
+
      }
      *StrHexaArea=s2.str();
   }
@@ -789,7 +807,7 @@ void DataEntry::DeleteBinArea(void)
       delete StrArea;
       StrArea = 0;
    }
-   if (StrArea)
+   if (StrHexaArea)
    {
       delete StrHexaArea;
       StrHexaArea = 0;