diff Core/DicomFormat/DicomMap.cpp @ 3006:0e1755e5efd0

DicomMap::ExtractMainDicomTags()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Dec 2018 12:37:10 +0100
parents 8265a6b56100
children abe49ca61cd5
line wrap: on
line diff
--- a/Core/DicomFormat/DicomMap.cpp	Wed Dec 12 15:42:33 2018 +0100
+++ b/Core/DicomFormat/DicomMap.cpp	Thu Dec 13 12:37:10 2018 +0100
@@ -1021,6 +1021,54 @@
   }
 
 
+  void DicomMap::Merge(const DicomMap& other)
+  {
+    for (Map::const_iterator it = other.map_.begin();
+         it != other.map_.end(); ++it)
+    {
+      assert(it->second != NULL);
+
+      if (map_.find(it->first) == map_.end())
+      {
+        map_[it->first] = it->second->Clone();
+      }
+    }
+  }
+
+
+  void DicomMap::ExtractMainDicomTagsInternal(const DicomMap& other,
+                                              ResourceType level)
+  {
+    const DicomTag* tags = NULL;
+    size_t size = 0;
+
+    LoadMainDicomTags(tags, size, level);
+    assert(tags != NULL && size > 0);
+
+    for (size_t i = 0; i < size; i++)
+    {
+      Map::const_iterator found = other.map_.find(tags[i]);
+
+      if (found != other.map_.end() &&
+          map_.find(tags[i]) == map_.end())
+      {
+        assert(found->second != NULL);
+        map_[tags[i]] = found->second->Clone();
+      }
+    }
+  }
+    
+
+  void DicomMap::ExtractMainDicomTags(const DicomMap& other)
+  {
+    Clear();
+    ExtractMainDicomTagsInternal(other, ResourceType_Patient);
+    ExtractMainDicomTagsInternal(other, ResourceType_Study);
+    ExtractMainDicomTagsInternal(other, ResourceType_Series);
+    ExtractMainDicomTagsInternal(other, ResourceType_Instance);
+  }    
+
+
   void DicomMap::Serialize(Json::Value& target) const
   {
     target = Json::objectValue;