+ guint32 val_uint32 = atoi(tokens[i].c_str());
+ void *ptr = &val_uint32;
+ fwrite ( ptr,(size_t)4 ,(size_t)1 ,_fp);
+ }
+ tokens.clear();
+ return;
+ }
+ fwrite (tag->GetValue().c_str(), (size_t)lgr ,(size_t)1, _fp); // Elem value
+}
+
+/**
+ * \brief Writes in a file (according to the requested format)
+ * a single gdcmHeaderEntry passed as argument.
+ * \sa WriteEntryValue, WriteEntryTagVRLength.
+ * @param tag Pointer on the gdcmHeaderEntry to be written
+ * @param _fp Already open file pointer
+ * @param type type of the File to be written
+ */
+
+bool gdcmParser::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type)
+{
+ guint32 length = tag->GetLength();
+
+ // The value of a tag MUST (see the DICOM norm) be an odd number of
+ // bytes. When this is not the case, pad with an additional byte:
+ if(length%2==1)
+ {
+ tag->SetValue(tag->GetValue()+"\0");
+ tag->SetLength(tag->GetReadLength()+1);
+ }
+
+ WriteEntryTagVRLength(tag, _fp, type);
+ WriteEntryValue(tag, _fp, type);
+ return true;
+}
+
+/**
+ * \brief writes on disc according to the requested format
+ * (ACR-NEMA, ExplicitVR, ImplicitVR) the image
+ * using the Chained List
+ * \warning does NOT add the missing elements in the header :
+ * it's up to the user doing it !
+ * (function CheckHeaderCoherence to be written)
+ * \warning DON'T try, right now, to write a DICOM image
+ * from an ACR Header (meta elements will be missing!)
+ * \sa WriteEntriesDeprecated (Special temporary method for Theralys)
+ * @param type type of the File to be written
+ * (ACR-NEMA, ExplicitVR, ImplicitVR)
+ * @param _fp already open file pointer
+ */
+
+bool gdcmParser::WriteEntries(FILE *_fp,FileType type)
+{
+ /// \todo (?) check write failures (after *each* fwrite)
+
+ for (ListTag::iterator tag2=listEntries.begin();
+ tag2 != listEntries.end();
+ ++tag2)
+ {
+ if ( type == ACR ){
+ if ((*tag2)->GetGroup() < 0x0008)
+ // Ignore pure DICOM V3 groups
+ continue;
+ if ((*tag2)->GetElement() %2)
+ // Ignore the "shadow" groups
+ continue;
+ if ((*tag2)->GetVR() == "SQ" ) // ignore Sequences
+ continue;
+ if ((*tag2)->GetSQDepthLevel() != 0) // Not only ignore the SQ element
+ continue;
+ }
+ if (! WriteEntry(*tag2,_fp,type) )
+ return false;
+ }
+ return true;
+}
+
+/**
+ * \brief writes on disc according to the requested format
+ * (ACR-NEMA, ExplicitVR, ImplicitVR) the image,
+ * using only the last synonym of each mutimap H Table post.
+ * \warning Uses the H Table, instead of the Chained List
+ * in order to be compliant with the old way to proceed
+ * (added elements taken in to account)
+ * Only THERALYS, during a transitory phase is supposed
+ * to use this method !!!
+ * \warning DON'T try, right now, to write a DICOM image
+ * from an ACR Header (meta elements will be missing!)
+ * \sa WriteEntries
+ * @param _fp already open file pointer
+ * @param type type of the File to be written
+ * (ACR-NEMA, ExplicitVR, ImplicitVR)
+ */
+void gdcmParser::WriteEntriesDeprecated(FILE *_fp,FileType type) {