# HG changeset patch # User Sebastien Jodogne # Date 1591784482 -7200 # Node ID e072b4e336002df51358c6a8c115bc4d780261b7 # Parent 5e26d004838c431f506addc07d5ea85327eb2b43# Parent c6e82885f570f98e4864bfe530babba1a614206c merge diff -r 5e26d004838c -r e072b4e33600 Core/DicomNetworking/DicomControlUserConnection.cpp --- a/Core/DicomNetworking/DicomControlUserConnection.cpp Wed Jun 10 12:18:21 2020 +0200 +++ b/Core/DicomNetworking/DicomControlUserConnection.cpp Wed Jun 10 12:21:22 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(); diff -r 5e26d004838c -r e072b4e33600 Core/DicomNetworking/DicomFindAnswers.cpp --- a/Core/DicomNetworking/DicomFindAnswers.cpp Wed Jun 10 12:18:21 2020 +0200 +++ b/Core/DicomNetworking/DicomFindAnswers.cpp Wed Jun 10 12:21:22 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 */)); } diff -r 5e26d004838c -r e072b4e33600 Core/DicomParsing/ParsedDicomFile.cpp --- a/Core/DicomParsing/ParsedDicomFile.cpp Wed Jun 10 12:18:21 2020 +0200 +++ b/Core/DicomParsing/ParsedDicomFile.cpp Wed Jun 10 12:21:22 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& 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 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& privateCreators) : pimpl_(new PImpl) { - CreateFromDicomMap(map, defaultEncoding, permissive, privateCreator); + CreateFromDicomMap(map, defaultEncoding, permissive, defaultPrivateCreator, privateCreators); } diff -r 5e26d004838c -r e072b4e33600 Core/DicomParsing/ParsedDicomFile.h --- a/Core/DicomParsing/ParsedDicomFile.h Wed Jun 10 12:18:21 2020 +0200 +++ b/Core/DicomParsing/ParsedDicomFile.h Wed Jun 10 12:21:22 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& privateCreators); void RemovePrivateTagsInternal(const std::set* 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& privateCreators + ); ParsedDicomFile(const void* content, size_t size); diff -r 5e26d004838c -r e072b4e33600 OrthancServer/DicomInstanceToStore.cpp --- a/OrthancServer/DicomInstanceToStore.cpp Wed Jun 10 12:18:21 2020 +0200 +++ b/OrthancServer/DicomInstanceToStore.cpp Wed Jun 10 12:21:22 2020 +0200 @@ -211,8 +211,7 @@ { parsed_.TakeOwnership(new ParsedDicomFile(summary_.GetConstContent(), GetDefaultDicomEncoding(), - false /* be strict */, - "" /* no private creator */)); + false /* be strict */)); } } diff -r 5e26d004838c -r e072b4e33600 OrthancServer/OrthancFindRequestHandler.cpp --- a/OrthancServer/OrthancFindRequestHandler.cpp Wed Jun 10 12:18:21 2020 +0200 +++ b/OrthancServer/OrthancFindRequestHandler.cpp Wed Jun 10 12:21:22 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::const_iterator tag = sequencesToReturn.begin(); tag != sequencesToReturn.end(); ++tag) diff -r 5e26d004838c -r e072b4e33600 UnitTestsSources/FromDcmtkTests.cpp --- a/UnitTestsSources/FromDcmtkTests.cpp Wed Jun 10 12:18:21 2020 +0200 +++ b/UnitTestsSources/FromDcmtkTests.cpp Wed Jun 10 12:21:22 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));