# HG changeset patch # User Sebastien Jodogne # Date 1596790010 -7200 # Node ID 0ddc5297a8ab8874aa913af0cb87e4eb01de7068 # Parent a4f28efdfccfe8b3e3b387f9994de09cd0e0f37e centralization of default parameters for JSON/DicomMap conversions from DCMTK diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp --- a/OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -161,9 +161,11 @@ try { std::set ignoreTagLength; - + + // TODO => Parameters in class "DicomServer" FromDcmtkBridge::ExtractDicomSummary(summary, **imageDataSet, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); - FromDcmtkBridge::ExtractDicomAsJson(dicomJson, **imageDataSet, ignoreTagLength); + FromDcmtkBridge::ExtractDicomAsJson(dicomJson, **imageDataSet, DicomToJsonFormat_Full, + DicomToJsonFlags_Default, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet)) { diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp --- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -980,9 +980,10 @@ DicomToJsonFormat format, DicomToJsonFlags flags, unsigned int maxStringLength, - Encoding defaultEncoding, const std::set& ignoreTagLength) { + const Encoding defaultEncoding = GetDefaultDicomEncoding(); + bool hasCodeExtensions; Encoding encoding = DetectEncoding(hasCodeExtensions, dataset, defaultEncoding); @@ -2037,19 +2038,6 @@ } - void FromDcmtkBridge::ExtractDicomAsJson(Json::Value& target, - DcmDataset& dataset, - const std::set& ignoreTagLength) - { - ExtractDicomAsJson(target, dataset, - DicomToJsonFormat_Full, - DicomToJsonFlags_Default, - ORTHANC_MAXIMUM_TAG_LENGTH, - GetDefaultDicomEncoding(), - ignoreTagLength); - } - - void FromDcmtkBridge::InitializeCodecs() { #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h --- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h Fri Aug 07 10:46:50 2020 +0200 @@ -80,14 +80,6 @@ bool hasCodeExtensions, const std::set& ignoreTagLength); - static void ExtractDicomAsJson(Json::Value& target, - DcmDataset& dataset, - DicomToJsonFormat format, - DicomToJsonFlags flags, - unsigned int maxStringLength, - Encoding defaultEncoding, - const std::set& ignoreTagLength); - static void ChangeStringEncoding(DcmItem& dataset, Encoding source, bool hasSourceCodeExtensions, @@ -226,6 +218,9 @@ static void ExtractDicomAsJson(Json::Value& target, DcmDataset& dataset, + DicomToJsonFormat format, + DicomToJsonFlags flags, + unsigned int maxStringLength, const std::set& ignoreTagLength); static void InitializeCodecs(); diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp --- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -1428,8 +1428,7 @@ { std::set ignoreTagLength; FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), - format, flags, maxStringLength, - GetDefaultDicomEncoding(), ignoreTagLength); + format, flags, maxStringLength, ignoreTagLength); } @@ -1440,22 +1439,7 @@ const std::set& ignoreTagLength) { FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), - format, flags, maxStringLength, - GetDefaultDicomEncoding(), ignoreTagLength); - } - - - void ParsedDicomFile::DatasetToJson(Json::Value& target, - const std::set& ignoreTagLength) - { - FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), ignoreTagLength); - } - - - void ParsedDicomFile::DatasetToJson(Json::Value& target) - { - const std::set ignoreTagLength; - FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), ignoreTagLength); + format, flags, maxStringLength, ignoreTagLength); } diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h --- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h Fri Aug 07 10:46:50 2020 +0200 @@ -216,13 +216,6 @@ unsigned int maxStringLength, const std::set& ignoreTagLength); - // This version uses the default parameters for - // FileContentType_DicomAsJson - void DatasetToJson(Json::Value& target, - const std::set& ignoreTagLength); - - void DatasetToJson(Json::Value& target); - void HeaderToJson(Json::Value& target, DicomToJsonFormat format); diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancServer/Sources/DicomInstanceToStore.cpp --- a/OrthancServer/Sources/DicomInstanceToStore.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancServer/Sources/DicomInstanceToStore.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -34,6 +34,8 @@ #include "PrecompiledHeadersServer.h" #include "DicomInstanceToStore.h" +#include "OrthancConfiguration.h" + #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" #include "../../OrthancFramework/Sources/Logging.h" @@ -241,22 +243,17 @@ assert(parsed_.HasContent()); // At this point, we have parsed the DICOM file - std::set ignoreTagLength; if (!summary_.HasContent()) { summary_.Allocate(); - FromDcmtkBridge::ExtractDicomSummary(summary_.GetContent(), - *parsed_.GetContent().GetDcmtkObject().getDataset(), - ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); + OrthancConfiguration::DefaultExtractDicomSummary(summary_.GetContent(), parsed_.GetContent()); } if (!json_.HasContent()) { json_.Allocate(); - FromDcmtkBridge::ExtractDicomAsJson(json_.GetContent(), - *parsed_.GetContent().GetDcmtkObject().getDataset(), - ignoreTagLength); + OrthancConfiguration::DefaultDicomDatasetToJson(json_.GetContent(), parsed_.GetContent()); } } diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancServer/Sources/OrthancConfiguration.cpp --- a/OrthancServer/Sources/OrthancConfiguration.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancServer/Sources/OrthancConfiguration.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -34,6 +34,7 @@ #include "PrecompiledHeadersServer.h" #include "OrthancConfiguration.h" +#include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" #include "../../OrthancFramework/Sources/HttpServer/HttpServer.h" #include "../../OrthancFramework/Sources/Logging.h" #include "../../OrthancFramework/Sources/OrthancException.h" @@ -896,4 +897,37 @@ // New configuration option in Orthanc 1.6.0 return GetStringParameter("DefaultPrivateCreator", ""); } + + + void OrthancConfiguration::DefaultExtractDicomSummary(DicomMap& target, + ParsedDicomFile& dicom) + { + std::set ignoreTagLength; + dicom.ExtractDicomSummary(target, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); + } + + + void OrthancConfiguration::DefaultDicomDatasetToJson(Json::Value& target, + ParsedDicomFile& dicom) + { + std::set ignoreTagLength; + DefaultDicomDatasetToJson(target, dicom, ignoreTagLength); + } + + + void OrthancConfiguration::DefaultDicomDatasetToJson(Json::Value& target, + ParsedDicomFile& dicom, + const std::set& ignoreTagLength) + { + dicom.DatasetToJson(target, DicomToJsonFormat_Full, DicomToJsonFlags_Default, + ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); + } + + + void OrthancConfiguration::DefaultDicomHeaderToJson(Json::Value& target, + ParsedDicomFile& dicom) + { + std::set ignoreTagLength; + dicom.HeaderToJson(target, DicomToJsonFormat_Full); + } } diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancServer/Sources/OrthancConfiguration.h --- a/OrthancServer/Sources/OrthancConfiguration.h Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancServer/Sources/OrthancConfiguration.h Fri Aug 07 10:46:50 2020 +0200 @@ -45,7 +45,10 @@ namespace Orthanc { + class DicomMap; + class DicomTag; class HttpServer; + class ParsedDicomFile; class ServerIndex; class TemporaryFile; @@ -233,5 +236,18 @@ TemporaryFile* CreateTemporaryFile() const; std::string GetDefaultPrivateCreator() const; + + static void DefaultExtractDicomSummary(DicomMap& target, + ParsedDicomFile& dicom); + + static void DefaultDicomDatasetToJson(Json::Value& target, + ParsedDicomFile& dicom); + + static void DefaultDicomDatasetToJson(Json::Value& target, + ParsedDicomFile& dicom, + const std::set& ignoreTagLength); + + static void DefaultDicomHeaderToJson(Json::Value& target, + ParsedDicomFile& dicom); }; } diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -572,7 +572,7 @@ * interpretation, and with windowing parameters. **/ ServerContext::DicomCacheLocker locker(context, publicId); - locker.GetDicom().ExtractDicomSummary(dicom, ORTHANC_MAXIMUM_TAG_LENGTH); + OrthancConfiguration::DefaultExtractDicomSummary(dicom, locker.GetDicom()); } } catch (OrthancException& e) @@ -1996,7 +1996,7 @@ ParsedDicomFile dicom(dicomContent); Json::Value header; - dicom.HeaderToJson(header, DicomToJsonFormat_Full); + OrthancConfiguration::DefaultDicomHeaderToJson(header, dicom); AnswerDicomAsJson(call, header); } diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancServer/Sources/ServerContext.cpp --- a/OrthancServer/Sources/ServerContext.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -694,7 +694,7 @@ ParsedDicomFile parsed(dicom); Json::Value summary; - parsed.DatasetToJson(summary); + OrthancConfiguration::DefaultDicomDatasetToJson(summary, parsed); result = summary.toStyledString(); @@ -748,7 +748,7 @@ ReadDicom(dicom, instancePublicId); ParsedDicomFile parsed(dicom); - parsed.DatasetToJson(result, ignoreTagLength); + OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength); } } diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancServer/Sources/ServerIndex.cpp --- a/OrthancServer/Sources/ServerIndex.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancServer/Sources/ServerIndex.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -2468,7 +2468,7 @@ void ServerIndex::ReconstructInstance(ParsedDicomFile& dicom) { DicomMap summary; - dicom.ExtractDicomSummary(summary, ORTHANC_MAXIMUM_TAG_LENGTH); + OrthancConfiguration::DefaultExtractDicomSummary(summary, dicom); DicomInstanceHasher hasher(summary); diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancServer/Sources/ServerJobs/MergeStudyJob.cpp --- a/OrthancServer/Sources/ServerJobs/MergeStudyJob.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancServer/Sources/ServerJobs/MergeStudyJob.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -36,6 +36,7 @@ #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" #include "../../../OrthancFramework/Sources/Logging.h" #include "../../../OrthancFramework/Sources/SerializationToolbox.h" +#include "../OrthancConfiguration.h" #include "../ServerContext.h" @@ -201,7 +202,7 @@ { ServerContext::DicomCacheLocker locker(GetContext(), instances.front()); - locker.GetDicom().ExtractDicomSummary(dicom, ORTHANC_MAXIMUM_TAG_LENGTH); + OrthancConfiguration::DefaultExtractDicomSummary(dicom, locker.GetDicom()); } const std::set moduleTags = removals_; diff -r a4f28efdfccf -r 0ddc5297a8ab OrthancServer/Sources/ServerToolbox.cpp --- a/OrthancServer/Sources/ServerToolbox.cpp Thu Aug 06 18:25:47 2020 +0200 +++ b/OrthancServer/Sources/ServerToolbox.cpp Fri Aug 07 10:46:50 2020 +0200 @@ -41,6 +41,7 @@ #include "../../OrthancFramework/Sources/OrthancException.h" #include "Database/IDatabaseWrapper.h" #include "Database/ResourcesContent.h" +#include "OrthancConfiguration.h" #include "ServerContext.h" #include @@ -269,7 +270,7 @@ // Update the tags of this resource DicomMap dicomSummary; - dicom.ExtractDicomSummary(dicomSummary, ORTHANC_MAXIMUM_TAG_LENGTH); + OrthancConfiguration::DefaultExtractDicomSummary(dicomSummary, dicom); database.ClearMainDicomTags(resource); @@ -379,7 +380,7 @@ ServerContext::DicomCacheLocker locker(context, *it); Json::Value dicomAsJson; - locker.GetDicom().DatasetToJson(dicomAsJson); + OrthancConfiguration::DefaultDicomDatasetToJson(dicomAsJson, locker.GetDicom()); std::string s = dicomAsJson.toStyledString(); context.AddAttachment(*it, FileContentType_DicomAsJson, s.c_str(), s.size());