diff 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
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerIndex.cpp	Thu Feb 04 11:42:25 2021 +0100
+++ b/OrthancServer/Sources/ServerIndex.cpp	Thu Feb 04 15:31:00 2021 +0100
@@ -39,6 +39,7 @@
 #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"
@@ -760,6 +761,23 @@
                                  const Attachments& attachments,
                                  bool overwrite)
   {
+    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<std::string>(offset);
+      }
+      else
+      {
+        pixelDataOffset.clear();
+      }
+    }
+    
     boost::mutex::scoped_lock lock(mutex_);
 
     const DicomMap& dicomSummary = instanceToStore.GetSummary();
@@ -971,6 +989,10 @@
           }
         }
 
+        // New in Orthanc 1.9.1
+        SetInstanceMetadata(content, instanceMetadata, instanceId,
+                            MetadataType_Instance_PixelDataOffset, pixelDataOffset);
+
         
         const DicomValue* value;
         if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL &&