changeset 4036:c6e82885f570

merge
author Alain Mazy <alain@mazy.be>
date Wed, 10 Jun 2020 10:28:15 +0200
parents cc6ed76bba27 (diff) 78ee0155ec67 (current diff)
children e072b4e33600
files Core/HttpServer/EmbeddedResourceHttpHandler.cpp Core/HttpServer/EmbeddedResourceHttpHandler.h OrthancServer/OrthancFindRequestHandler.cpp
diffstat 7 files changed, 52 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomNetworking/DicomControlUserConnection.cpp	Wed Jun 10 10:14:15 2020 +0200
+++ b/Core/DicomNetworking/DicomControlUserConnection.cpp	Wed Jun 10 10:28:15 2020 +0200
@@ -216,12 +216,12 @@
         }
 
         return new ParsedDicomFile(*fix, GetDefaultDicomEncoding(),
-                                   false /* be strict */, "" /* no private creator */);
+                                   false /* be strict */);
       }
 
       default:
         return new ParsedDicomFile(fields, GetDefaultDicomEncoding(),
-                                   false /* be strict */, "" /* no private creator */);
+                                   false /* be strict */);
     }
   }
 
@@ -478,7 +478,7 @@
     else
     {
       query.reset(new ParsedDicomFile(originalFields, GetDefaultDicomEncoding(),
-                                      false /* be strict */, "" /* no private creator */));
+                                      false /* be strict */));
     }
     
     DcmDataset* dataset = query->GetDcmtkObject().getDataset();
--- a/Core/DicomNetworking/DicomFindAnswers.cpp	Wed Jun 10 10:14:15 2020 +0200
+++ b/Core/DicomNetworking/DicomFindAnswers.cpp	Wed Jun 10 10:28:15 2020 +0200
@@ -122,8 +122,8 @@
     // We use the permissive mode to be tolerant wrt. invalid DICOM
     // files that contain some tags with out-of-range values (such
     // tags are removed from the answers)
-    AddAnswerInternal(new ParsedDicomFile(map, encoding_, true /* permissive */,
-                                          "" /* no private creator */));
+    AddAnswerInternal(new ParsedDicomFile(map, encoding_, true /* permissive */));
+                                          //"" /* no private creator */));
   }
 
 
--- a/Core/DicomParsing/ParsedDicomFile.cpp	Wed Jun 10 10:14:15 2020 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.cpp	Wed Jun 10 10:28:15 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);
   }
 
 
--- a/Core/DicomParsing/ParsedDicomFile.h	Wed Jun 10 10:14:15 2020 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.h	Wed Jun 10 10:28:15 2020 +0200
@@ -93,7 +93,8 @@
     void CreateFromDicomMap(const DicomMap& source,
                             Encoding defaultEncoding,
                             bool permissive,
-                            const std::string& privateCreator);
+                            const std::string& defaultPrivateCreator,
+                            const std::map<uint16_t, std::string>& privateCreators);
 
     void RemovePrivateTagsInternal(const std::set<DicomTag>* toKeep);
 
@@ -112,8 +113,15 @@
 
     ParsedDicomFile(const DicomMap& map,
                     Encoding defaultEncoding,
+                    bool permissive
+                    );
+
+    ParsedDicomFile(const DicomMap& map,
+                    Encoding defaultEncoding,
                     bool permissive,
-                    const std::string& privateCreator);
+                    const std::string& defaultPrivateCreator,
+                    const std::map<uint16_t, std::string>& privateCreators
+                    );
 
     ParsedDicomFile(const void* content,
                     size_t size);
--- a/OrthancServer/DicomInstanceToStore.cpp	Wed Jun 10 10:14:15 2020 +0200
+++ b/OrthancServer/DicomInstanceToStore.cpp	Wed Jun 10 10:28:15 2020 +0200
@@ -211,8 +211,7 @@
           {
             parsed_.TakeOwnership(new ParsedDicomFile(summary_.GetConstContent(),
                                                       GetDefaultDicomEncoding(),
-                                                      false /* be strict */,
-                                                      "" /* no private creator */));
+                                                      false /* be strict */));
           }                                
         }
 
--- a/OrthancServer/OrthancFindRequestHandler.cpp	Wed Jun 10 10:14:15 2020 +0200
+++ b/OrthancServer/OrthancFindRequestHandler.cpp	Wed Jun 10 10:28:15 2020 +0200
@@ -374,7 +374,7 @@
     else
     {
       ParsedDicomFile dicom(result, GetDefaultDicomEncoding(),
-                            true /* be permissive, cf. issue #136 */, defaultPrivateCreator);
+                            true /* be permissive, cf. issue #136 */, defaultPrivateCreator, privateCreators);
 
       for (std::list<DicomTag>::const_iterator tag = sequencesToReturn.begin();
            tag != sequencesToReturn.end(); ++tag)
--- a/UnitTestsSources/FromDcmtkTests.cpp	Wed Jun 10 10:14:15 2020 +0200
+++ b/UnitTestsSources/FromDcmtkTests.cpp	Wed Jun 10 10:28:15 2020 +0200
@@ -1137,14 +1137,14 @@
 
   {
     DicomMap m;
-    ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false, "" /* no private creator */);
+    ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false);
     ASSERT_EQ(1u, dicom.GetDcmtkObject().getDataset()->card());
     CheckEncoding(dicom, Encoding_Ascii);
   }
 
   {
     DicomMap m;
-    ParsedDicomFile dicom(m, Encoding_Latin4, false, "" /* no private creator */);
+    ParsedDicomFile dicom(m, Encoding_Latin4, false);
     ASSERT_EQ(1u, dicom.GetDcmtkObject().getDataset()->card());
     CheckEncoding(dicom, Encoding_Latin4);
   }
@@ -1152,7 +1152,7 @@
   {
     DicomMap m;
     m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 148", false);
-    ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false, "" /* no private creator */);
+    ParsedDicomFile dicom(m, GetDefaultDicomEncoding(), false);
     ASSERT_EQ(1u, dicom.GetDcmtkObject().getDataset()->card());
     CheckEncoding(dicom, Encoding_Latin5);
   }
@@ -1160,7 +1160,7 @@
   {
     DicomMap m;
     m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 148", false);
-    ParsedDicomFile dicom(m, Encoding_Latin1, false, "" /* no private creator */);
+    ParsedDicomFile dicom(m, Encoding_Latin1, false);
     ASSERT_EQ(1u, dicom.GetDcmtkObject().getDataset()->card());
     CheckEncoding(dicom, Encoding_Latin5);
   }
@@ -1210,7 +1210,7 @@
         DicomMap m;
         m.SetValue(DICOM_TAG_PATIENT_NAME, testEncodingsExpected[i], false);
 
-        ParsedDicomFile dicom(m, testEncodings[i], false, "" /* no private creator */);
+        ParsedDicomFile dicom(m, testEncodings[i], false);
     
         const char* encoded = NULL;
         ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->findAndGetString(DCM_PatientName, encoded).good());
@@ -1230,7 +1230,7 @@
         m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, GetDicomSpecificCharacterSet(testEncodings[i]), false);
         m.SetValue(DICOM_TAG_PATIENT_NAME, testEncodingsExpected[i], false);
 
-        ParsedDicomFile dicom(m, testEncodings[i], false, "" /* no private creator */);
+        ParsedDicomFile dicom(m, testEncodings[i], false);
 
         Json::Value v2;
         dicom.DatasetToJson(v2, DicomToJsonFormat_Human, DicomToJsonFlags_Default, 0);
@@ -1255,7 +1255,7 @@
 
       std::string tag;
 
-      ParsedDicomFile dicom(m, Encoding_Utf8, false, "" /* no private creator */);
+      ParsedDicomFile dicom(m, Encoding_Utf8, false);
       bool hasCodeExtensions;
       ASSERT_EQ(Encoding_Utf8, dicom.DetectEncoding(hasCodeExtensions));
       ASSERT_FALSE(hasCodeExtensions);
@@ -1306,7 +1306,7 @@
     DicomMap m;
     m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
 
-    ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false, "" /* no private creator */);
+    ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false);
 
     bool hasCodeExtensions;
     ASSERT_EQ(Encoding_Latin3, d.DetectEncoding(hasCodeExtensions));
@@ -1319,7 +1319,7 @@
     m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 13", false);
     m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
 
-    ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false, "" /* no private creator */);
+    ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false);
 
     bool hasCodeExtensions;
     ASSERT_EQ(Encoding_Japanese, d.DetectEncoding(hasCodeExtensions));
@@ -1332,7 +1332,7 @@
     m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "nope", false);
     m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
 
-    ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3, false, "" /* no private creator */),
+    ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3, false),
                  OrthancException);
   }
   
@@ -1342,7 +1342,7 @@
     m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "ISO_IR 13", true);
     m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
 
-    ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3, false, "" /* no private creator */),
+    ASSERT_THROW(ParsedDicomFile d(m, Encoding_Latin3, false),
                  OrthancException);
   }
   
@@ -1353,7 +1353,7 @@
     m.SetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET, "", false);
     m.SetValue(DICOM_TAG_PATIENT_NAME, "HELLO", false);
 
-    ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false, "" /* no private creator */);
+    ParsedDicomFile d(m, Encoding_Latin3 /* default encoding */, false);
 
     bool hasCodeExtensions;
     ASSERT_EQ(Encoding_Latin3, d.DetectEncoding(hasCodeExtensions));