]> Creatis software - gdcm.git/blobdiff - src/gdcmDataEntry.cxx
Add #include for BCC
[gdcm.git] / src / gdcmDataEntry.cxx
index 97afe0cb24cb22876179ae42ed5039eda4c8336c..1d8706f9596dce302f114a80b08d54af89ce1631 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/29 12:48:45 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2006/01/27 10:01:33 $
+  Version:   $Revision: 1.29 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 #include <fstream>
 
+#if defined(__BORLANDC__)
+ #include <mem.h> // for memcpy
+ #include <stdlib.h> // for atof
+ #include <ctype.h> // for isdigit
+#endif
+
 namespace gdcm 
 {
 //-----------------------------------------------------------------------------
@@ -75,7 +81,9 @@ DataEntry::~DataEntry ()
 //-----------------------------------------------------------------------------
 // Public
 /**
- * \brief Sets the value (non string) of the current Dicom Header Entry
+ * \brief Sets the value (non string) of the current DataEntry
+ * @param area area
+ * @param self self
  */
 void DataEntry::SetBinArea( uint8_t *area, bool self )  
 { 
@@ -87,7 +95,9 @@ void DataEntry::SetBinArea( uint8_t *area, bool self )
    State = STATE_LOADED;
 }
 /**
- * \brief Inserts the value (non string) into the current Dicom Header Entry
+ * \brief Inserts the value (non string) into the current DataEntry
+ * @param area area
+ * @param length length 
  */
 void DataEntry::CopyBinArea( uint8_t *area, uint32_t length )
 {
@@ -107,6 +117,11 @@ void DataEntry::CopyBinArea( uint8_t *area, uint32_t length )
    }
 }
 
+/**
+ * \brief Inserts the elementary (non string) value into the current DataEntry
+ * @param id index of the elementary value to be set
+ * @param val value, passed as a double 
+ */
 void DataEntry::SetValue(const uint32_t &id, const double &val)
 {
    if( !BinArea )
@@ -151,9 +166,10 @@ void DataEntry::SetValue(const uint32_t &id, const double &val)
 }
 /**
  * \brief returns, as a double (?!?) one of the values 
- //      (when entry is multivaluated), identified by its index.
- //      Returns 0.0 if index is wrong
- //     FIXME : warn the user there was a problem ! 
+ *      (when entry is multivaluated), identified by its index.
+ *      Returns 0.0 if index is wrong
+ *     FIXME : warn the user there was a problem ! 
+ * @param id id
  */
 double DataEntry::GetValue(const uint32_t &id) const
 {
@@ -307,7 +323,7 @@ uint32_t DataEntry::GetValueCount( ) const
    return GetLength();
 }
 /**
- * \brief Sets the 'value' of aEntry, passed as a std::string
+ * \brief Sets the 'value' of a DataEntry, passed as a std::string
  * @param value string representation of the value to be set
  */ 
 void DataEntry::SetString(std::string const &value)
@@ -485,7 +501,7 @@ void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
       return; //delimitors have NO value
    }
    
-   // --> We only deal with Little Endian writting
+   // --> We only deal with Little Endian writting.
    // --> forget Big Endian Transfer Syntax writting!
    //     Next DICOM version will give it up ...
  
@@ -506,8 +522,8 @@ void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
         
    uint8_t *data = BinArea; //safe notation
    size_t l = GetLength(); 
-   gdcmDebugMacro ("in DataEntry::WriteContent " << GetKey() 
-             << " : " << Global::GetVR()->GetAtomicElementLength(this->GetVR())
+   gdcmDebugMacro("in DataEntry::WriteContent " << GetKey() << " AtomicLength: "
+              << Global::GetVR()->GetAtomicElementLength(this->GetVR() ) // << " BinArea in :" << &BinArea
              );
    if (BinArea) // the binArea was *actually* loaded
    {
@@ -524,7 +540,6 @@ void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
          }     
          case 2:
          {
-gdcmDebugMacro ("AtomicLength = 2 found; lgt =" << l); 
             uint16_t *data16 = (uint16_t *)data;
             for(i=0;i<l/vrLgth;i++)
                binary_write( *fp, data16[i]);
@@ -552,13 +567,16 @@ gdcmDebugMacro ("AtomicLength = 2 found; lgt =" << l);
    }
    else
    {
-      // nothing was loaded, but we need to skip space on disc
-      
+      // nothing was loaded, but we need to skip space on disc     
+      if (l != 0)
+      {
       //  --> WARNING : nothing is written; 
       //  --> the initial data (on the the source image) is lost
-      //  --> user is *not* informed !
-      
-      fp->seekp(l, std::ios::cur);
+      //  --> user is *not* informed !      
+         gdcmDebugMacro ("Nothing was loaded, but we need to skip space on disc. "
+                      << "Length =" << l << " for " << GetKey() );   
+         fp->seekp(l, std::ios::cur);
+      }
    }
    // to avoid gdcm to propagate oddities
    // (length was already modified)  
@@ -578,7 +596,7 @@ uint32_t DataEntry::ComputeFullLength()
 //-----------------------------------------------------------------------------
 // Protected
 /// \brief Creates a DataEntry owned BinArea (remove previous one if any)
-void DataEntry::NewBinArea(void)
+void DataEntry::NewBinArea( )
 {
    DeleteBinArea();
    if( GetLength() > 0 )