comparison OrthancServer/Sources/ServerIndex.cpp @ 4494:39192eb9b43d

New metadata automatically computed at the instance level: "PixelDataOffset"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Feb 2021 15:31:00 +0100
parents 50b3f4c8107e
children 6f99949b2878
comparison
equal deleted inserted replaced
4493:b57ca702a430 4494:39192eb9b43d
37 #ifndef NOMINMAX 37 #ifndef NOMINMAX
38 #define NOMINMAX 38 #define NOMINMAX
39 #endif 39 #endif
40 40
41 #include "../../OrthancFramework/Sources/DicomFormat/DicomArray.h" 41 #include "../../OrthancFramework/Sources/DicomFormat/DicomArray.h"
42 #include "../../OrthancFramework/Sources/DicomFormat/DicomStreamReader.h"
42 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" 43 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
43 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" 44 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h"
44 #include "../../OrthancFramework/Sources/Logging.h" 45 #include "../../OrthancFramework/Sources/Logging.h"
45 #include "../../OrthancFramework/Sources/Toolbox.h" 46 #include "../../OrthancFramework/Sources/Toolbox.h"
46 47
758 StoreStatus ServerIndex::Store(std::map<MetadataType, std::string>& instanceMetadata, 759 StoreStatus ServerIndex::Store(std::map<MetadataType, std::string>& instanceMetadata,
759 DicomInstanceToStore& instanceToStore, 760 DicomInstanceToStore& instanceToStore,
760 const Attachments& attachments, 761 const Attachments& attachments,
761 bool overwrite) 762 bool overwrite)
762 { 763 {
764 std::string pixelDataOffset;
765
766 {
767 // Determining the pixel data offset is costly, don't do it
768 // within the mutex (new in Orthanc 1.9.1)
769 uint64_t offset;
770 if (DicomStreamReader::LookupPixelDataOffset(offset, instanceToStore.GetBufferData(),
771 instanceToStore.GetBufferSize()))
772 {
773 pixelDataOffset = boost::lexical_cast<std::string>(offset);
774 }
775 else
776 {
777 pixelDataOffset.clear();
778 }
779 }
780
763 boost::mutex::scoped_lock lock(mutex_); 781 boost::mutex::scoped_lock lock(mutex_);
764 782
765 const DicomMap& dicomSummary = instanceToStore.GetSummary(); 783 const DicomMap& dicomSummary = instanceToStore.GetSummary();
766 const ServerIndex::MetadataMap& metadata = instanceToStore.GetMetadata(); 784 const ServerIndex::MetadataMap& metadata = instanceToStore.GetMetadata();
767 785
969 SetInstanceMetadata(content, instanceMetadata, instanceId, 987 SetInstanceMetadata(content, instanceMetadata, instanceId,
970 MetadataType_Instance_HttpUsername, s); 988 MetadataType_Instance_HttpUsername, s);
971 } 989 }
972 } 990 }
973 991
992 // New in Orthanc 1.9.1
993 SetInstanceMetadata(content, instanceMetadata, instanceId,
994 MetadataType_Instance_PixelDataOffset, pixelDataOffset);
995
974 996
975 const DicomValue* value; 997 const DicomValue* value;
976 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL && 998 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL &&
977 !value->IsNull() && 999 !value->IsNull() &&
978 !value->IsBinary()) 1000 !value->IsBinary())