+ // 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;
+}
+
+/**
+ * \ingroup gdcmParser
+ * \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) {
+
+ // restent a tester les echecs en ecriture (apres chaque fwrite)
+
+ for (TagHeaderEntryHT::iterator tag2=tagHT.begin();
+ tag2 != tagHT.end();
+ ++tag2){
+ if ( type == ACR ){
+ if ((*tag2->second).GetGroup() < 0x0008) continue; // ignore pure DICOM V3 groups
+ if ((*tag2->second).GetElement() %2) continue; // ignore shadow groups
+ if ((*tag2->second).GetVR() == "SQ" ) continue; // ignore Sequences
+ if ((*tag2->second).GetSQDepthLevel() != 0) continue; // Not only ignore the SQ element
+ }
+ if ( ! WriteEntry(tag2->second,_fp,type))
+ break;