# HG changeset patch # User Sebastien Jodogne # Date 1612877121 -3600 # Node ID 6f99949b2878b1d187a995aad94415d3607c52ce # Parent 7b99e8bb82468a5f7d12fe3c1fc1bbe31555d626 reorganization diff -r 7b99e8bb8246 -r 6f99949b2878 OrthancServer/Sources/ServerContext.cpp --- a/OrthancServer/Sources/ServerContext.cpp Tue Feb 09 11:37:13 2021 +0100 +++ b/OrthancServer/Sources/ServerContext.cpp Tue Feb 09 14:25:21 2021 +0100 @@ -36,6 +36,7 @@ #include "../../OrthancFramework/Sources/Cache/SharedArchive.h" #include "../../OrthancFramework/Sources/DicomFormat/DicomElement.h" +#include "../../OrthancFramework/Sources/DicomFormat/DicomStreamReader.h" #include "../../OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.h" #include "../../OrthancFramework/Sources/DicomParsing/DicomModification.h" #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" @@ -509,7 +510,14 @@ default: throw OrthancException(ErrorCode_ParameterOutOfRange); - } + } + + + bool hasPixelDataOffset; + uint64_t pixelDataOffset; + hasPixelDataOffset = DicomStreamReader::LookupPixelDataOffset( + pixelDataOffset, dicom.GetBufferData(), dicom.GetBufferSize()); + try { @@ -573,7 +581,7 @@ typedef std::map InstanceMetadata; InstanceMetadata instanceMetadata; StoreStatus status = index_.Store( - instanceMetadata, dicom, attachments, overwrite); + instanceMetadata, dicom, attachments, overwrite, hasPixelDataOffset, pixelDataOffset); // Only keep the metadata for the "instance" level dicom.GetMetadata().clear(); diff -r 7b99e8bb8246 -r 6f99949b2878 OrthancServer/Sources/ServerIndex.cpp --- a/OrthancServer/Sources/ServerIndex.cpp Tue Feb 09 11:37:13 2021 +0100 +++ b/OrthancServer/Sources/ServerIndex.cpp Tue Feb 09 14:25:21 2021 +0100 @@ -39,7 +39,6 @@ #endif #include "../../OrthancFramework/Sources/DicomFormat/DicomArray.h" -#include "../../OrthancFramework/Sources/DicomFormat/DicomStreamReader.h" #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" #include "../../OrthancFramework/Sources/Logging.h" @@ -759,25 +758,10 @@ StoreStatus ServerIndex::Store(std::map& instanceMetadata, DicomInstanceToStore& instanceToStore, const Attachments& attachments, - bool overwrite) + bool overwrite, + bool hasPixelDataOffset, + uint64_t pixelDataOffset) { - std::string pixelDataOffset; - - { - // Determining the pixel data offset is costly, don't do it - // within the mutex (new in Orthanc 1.9.1) - uint64_t offset; - if (DicomStreamReader::LookupPixelDataOffset(offset, instanceToStore.GetBufferData(), - instanceToStore.GetBufferSize())) - { - pixelDataOffset = boost::lexical_cast(offset); - } - else - { - pixelDataOffset.clear(); - } - } - boost::mutex::scoped_lock lock(mutex_); const DicomMap& dicomSummary = instanceToStore.GetSummary(); @@ -991,8 +975,9 @@ // New in Orthanc 1.9.1 SetInstanceMetadata(content, instanceMetadata, instanceId, - MetadataType_Instance_PixelDataOffset, pixelDataOffset); - + MetadataType_Instance_PixelDataOffset, + (hasPixelDataOffset ? + boost::lexical_cast(pixelDataOffset) : "")); const DicomValue* value; if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL && diff -r 7b99e8bb8246 -r 6f99949b2878 OrthancServer/Sources/ServerIndex.h --- a/OrthancServer/Sources/ServerIndex.h Tue Feb 09 11:37:13 2021 +0100 +++ b/OrthancServer/Sources/ServerIndex.h Tue Feb 09 14:25:21 2021 +0100 @@ -141,7 +141,9 @@ StoreStatus Store(std::map& instanceMetadata, DicomInstanceToStore& instance, const Attachments& attachments, - bool overwrite); + bool overwrite, + bool hasPixelDataOffset, + uint64_t pixelDataOffset); void GetGlobalStatistics(/* out */ uint64_t& diskSize, /* out */ uint64_t& uncompressedSize, diff -r 7b99e8bb8246 -r 6f99949b2878 OrthancServer/UnitTestsSources/ServerIndexTests.cpp --- a/OrthancServer/UnitTestsSources/ServerIndexTests.cpp Tue Feb 09 11:37:13 2021 +0100 +++ b/OrthancServer/UnitTestsSources/ServerIndexTests.cpp Tue Feb 09 14:25:21 2021 +0100 @@ -728,7 +728,7 @@ DicomInstanceToStore toStore; toStore.SetSummary(instance); ASSERT_EQ(StoreStatus_Success, index.Store(instanceMetadata, toStore, attachments, - false /* don't overwrite */)); + false /* don't overwrite */, true /* pixel data offset */, 42)); ASSERT_EQ(6u, instanceMetadata.size()); ASSERT_TRUE(instanceMetadata.find(MetadataType_RemoteAet) != instanceMetadata.end()); ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_ReceptionDate) != instanceMetadata.end()); @@ -736,6 +736,8 @@ ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_SopClassUid) != instanceMetadata.end()); ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_PixelDataOffset) != instanceMetadata.end()); + ASSERT_EQ("42", instanceMetadata[MetadataType_Instance_PixelDataOffset]); + // The default transfer syntax depends on the OS endianness std::string s = instanceMetadata[MetadataType_Instance_TransferSyntax]; ASSERT_TRUE(s == "1.2.840.10008.1.2.1" ||