Mercurial > hg > orthanc
changeset 4140:0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Aug 2020 10:46:50 +0200 |
parents | a4f28efdfccf |
children | 99927401587c |
files | OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h OrthancServer/Sources/DicomInstanceToStore.cpp OrthancServer/Sources/OrthancConfiguration.cpp OrthancServer/Sources/OrthancConfiguration.h OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/ServerContext.cpp OrthancServer/Sources/ServerIndex.cpp OrthancServer/Sources/ServerJobs/MergeStudyJob.cpp OrthancServer/Sources/ServerToolbox.cpp |
diffstat | 13 files changed, 75 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- 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<DicomTag> 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)) {
--- 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<DicomTag>& 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<DicomTag>& ignoreTagLength) - { - ExtractDicomAsJson(target, dataset, - DicomToJsonFormat_Full, - DicomToJsonFlags_Default, - ORTHANC_MAXIMUM_TAG_LENGTH, - GetDefaultDicomEncoding(), - ignoreTagLength); - } - - void FromDcmtkBridge::InitializeCodecs() { #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1
--- 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<DicomTag>& ignoreTagLength); - static void ExtractDicomAsJson(Json::Value& target, - DcmDataset& dataset, - DicomToJsonFormat format, - DicomToJsonFlags flags, - unsigned int maxStringLength, - Encoding defaultEncoding, - const std::set<DicomTag>& 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<DicomTag>& ignoreTagLength); static void InitializeCodecs();
--- 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<DicomTag> ignoreTagLength; FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), - format, flags, maxStringLength, - GetDefaultDicomEncoding(), ignoreTagLength); + format, flags, maxStringLength, ignoreTagLength); } @@ -1440,22 +1439,7 @@ const std::set<DicomTag>& ignoreTagLength) { FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), - format, flags, maxStringLength, - GetDefaultDicomEncoding(), ignoreTagLength); - } - - - void ParsedDicomFile::DatasetToJson(Json::Value& target, - const std::set<DicomTag>& ignoreTagLength) - { - FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), ignoreTagLength); - } - - - void ParsedDicomFile::DatasetToJson(Json::Value& target) - { - const std::set<DicomTag> ignoreTagLength; - FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), ignoreTagLength); + format, flags, maxStringLength, ignoreTagLength); }
--- 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<DicomTag>& ignoreTagLength); - // This version uses the default parameters for - // FileContentType_DicomAsJson - void DatasetToJson(Json::Value& target, - const std::set<DicomTag>& ignoreTagLength); - - void DatasetToJson(Json::Value& target); - void HeaderToJson(Json::Value& target, DicomToJsonFormat format);
--- 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<DicomTag> 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()); } }
--- 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<DicomTag> ignoreTagLength; + dicom.ExtractDicomSummary(target, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); + } + + + void OrthancConfiguration::DefaultDicomDatasetToJson(Json::Value& target, + ParsedDicomFile& dicom) + { + std::set<DicomTag> ignoreTagLength; + DefaultDicomDatasetToJson(target, dicom, ignoreTagLength); + } + + + void OrthancConfiguration::DefaultDicomDatasetToJson(Json::Value& target, + ParsedDicomFile& dicom, + const std::set<DicomTag>& ignoreTagLength) + { + dicom.DatasetToJson(target, DicomToJsonFormat_Full, DicomToJsonFlags_Default, + ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); + } + + + void OrthancConfiguration::DefaultDicomHeaderToJson(Json::Value& target, + ParsedDicomFile& dicom) + { + std::set<DicomTag> ignoreTagLength; + dicom.HeaderToJson(target, DicomToJsonFormat_Full); + } }
--- 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<DicomTag>& ignoreTagLength); + + static void DefaultDicomHeaderToJson(Json::Value& target, + ParsedDicomFile& dicom); }; }
--- 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); }
--- 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); } }
--- 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);
--- 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<DicomTag> moduleTags = removals_;
--- 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 <cassert> @@ -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());