diff OrthancServer/ParsedDicomFile.cpp @ 2310:b7fba68747f6 issue-46-anonymization

DicomModification::Clear()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Jul 2017 14:00:00 +0200
parents e002430baa41
children 96b3ec054b69
line wrap: on
line diff
--- a/OrthancServer/ParsedDicomFile.cpp	Wed Jul 12 13:40:02 2017 +0200
+++ b/OrthancServer/ParsedDicomFile.cpp	Wed Jul 12 14:00:00 2017 +0200
@@ -508,6 +508,28 @@
   }
 
 
+  void ParsedDicomFile::Clear(const DicomTag& tag,
+                              bool onlyIfExists)
+  {
+    InvalidateCache();
+
+    DcmItem* dicom = pimpl_->file_->getDataset();
+    DcmTagKey key(tag.GetGroup(), tag.GetElement());
+
+    if (onlyIfExists &&
+        !dicom->tagExists(key))
+    {
+      // The tag is non-existing, do not clear it
+    }
+    else
+    {
+      if (!dicom->insertEmptyElement(key, OFTrue /* replace old value */).good())
+      {
+        throw OrthancException(ErrorCode_InternalError);
+      }
+    }
+  }
+
 
   void ParsedDicomFile::RemovePrivateTagsInternal(const std::set<DicomTag>* toKeep)
   {