diff Core/DicomParsing/ParsedDicomFile.cpp @ 4035:cc6ed76bba27

added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
author Alain Mazy <alain@mazy.be>
date Wed, 10 Jun 2020 10:28:01 +0200
parents 1e9f6d706237
children fa35465175b8
line wrap: on
line diff
--- a/Core/DicomParsing/ParsedDicomFile.cpp	Tue Jun 09 12:21:03 2020 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.cpp	Wed Jun 10 10:28:01 2020 +0200
@@ -1002,7 +1002,8 @@
   void ParsedDicomFile::CreateFromDicomMap(const DicomMap& source,
                                            Encoding defaultEncoding,
                                            bool permissive,
-                                           const std::string& privateCreator)
+                                           const std::string& defaultPrivateCreator,
+                                           const std::map<uint16_t, std::string>& privateCreators)
   {
     pimpl_->file_.reset(new DcmFileFormat);
     InvalidateCache();
@@ -1049,7 +1050,15 @@
         {
           // Same as "ReplacePlainString()", but with support for private creator
           const std::string& utf8Value = it->second->GetContent();
-          Replace(it->first, utf8Value, false, DicomReplaceMode_InsertIfAbsent, privateCreator);
+
+          if (it->first.IsPrivate() && privateCreators.find(it->first.GetGroup()) != privateCreators.end())
+          {
+            Replace(it->first, utf8Value, false, DicomReplaceMode_InsertIfAbsent, privateCreators.at(it->first.GetGroup()));
+          }
+          else
+          {
+            Replace(it->first, utf8Value, false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator);
+          }
         }
         catch (OrthancException&)
         {
@@ -1062,14 +1071,24 @@
     }
   }
 
+  ParsedDicomFile::ParsedDicomFile(const DicomMap& map,
+                                   Encoding defaultEncoding,
+                                   bool permissive) :
+    pimpl_(new PImpl)
+  {
+    std::map<uint16_t, std::string> noPrivateCreators;
+    CreateFromDicomMap(map, defaultEncoding, permissive, "" /* no default private creator */, noPrivateCreators);
+  }
+
 
   ParsedDicomFile::ParsedDicomFile(const DicomMap& map,
                                    Encoding defaultEncoding,
                                    bool permissive,
-                                   const std::string& privateCreator) :
+                                   const std::string& defaultPrivateCreator,
+                                   const std::map<uint16_t, std::string>& privateCreators) :
     pimpl_(new PImpl)
   {
-    CreateFromDicomMap(map, defaultEncoding, permissive, privateCreator);
+    CreateFromDicomMap(map, defaultEncoding, permissive, defaultPrivateCreator, privateCreators);
   }