changeset 438:369c7d510a6b

support retrieving of all frames
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 26 May 2020 12:38:03 +0200
parents 5449610fb02f
children 76233f8f867f 8a51b90a72b7
files Plugin/Plugin.cpp Plugin/WadoRs.h Plugin/WadoRsRetrieveFrames.cpp
diffstat 3 files changed, 51 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/Plugin.cpp	Tue May 26 11:32:18 2020 +0200
+++ b/Plugin/Plugin.cpp	Tue May 26 12:38:03 2020 +0200
@@ -509,8 +509,8 @@
         OrthancPlugins::RegisterRestCallback<RetrieveBulkData>(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/bulk/(.*)", true);
         OrthancPlugins::RegisterRestCallback<RetrieveInstanceMetadata>(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/metadata", true);
         OrthancPlugins::RegisterRestCallback<RetrieveSeriesMetadata>(root + "studies/([^/]*)/series/([^/]*)/metadata", true);
-        OrthancPlugins::RegisterRestCallback<RetrieveFrames>(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames", true);
-        OrthancPlugins::RegisterRestCallback<RetrieveFrames>(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames/([^/]*)", true);
+        OrthancPlugins::RegisterRestCallback<RetrieveAllFrames>(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames", true);
+        OrthancPlugins::RegisterRestCallback<RetrieveSelectedFrames>(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames/([^/]*)", true);
 
         OrthancPlugins::RegisterRestCallback<ListServers>(root + "servers", true);
         OrthancPlugins::RegisterRestCallback<ListServerOperations>(root + "servers/([^/]*)", true);
--- a/Plugin/WadoRs.h	Tue May 26 11:32:18 2020 +0200
+++ b/Plugin/WadoRs.h	Tue May 26 12:38:03 2020 +0200
@@ -70,9 +70,13 @@
                       const char* url,
                       const OrthancPluginHttpRequest* request);
 
-void RetrieveFrames(OrthancPluginRestOutput* output,
-                    const char* url,
-                    const OrthancPluginHttpRequest* request);
+void RetrieveAllFrames(OrthancPluginRestOutput* output,
+                       const char* url,
+                       const OrthancPluginHttpRequest* request);
+
+void RetrieveSelectedFrames(OrthancPluginRestOutput* output,
+                            const char* url,
+                            const OrthancPluginHttpRequest* request);
 
 void RetrieveInstanceRendered(OrthancPluginRestOutput* output,
                               const char* url,
--- a/Plugin/WadoRsRetrieveFrames.cpp	Tue May 26 11:32:18 2020 +0200
+++ b/Plugin/WadoRsRetrieveFrames.cpp	Tue May 26 12:38:03 2020 +0200
@@ -414,18 +414,21 @@
 }
 
 
-void RetrieveFrames(OrthancPluginRestOutput* output,
-                    const char* url,
-                    const OrthancPluginHttpRequest* request)
+static void RetrieveFrames(OrthancPluginRestOutput* output,
+                           const OrthancPluginHttpRequest* request,
+                           bool allFrames,
+                           std::list<unsigned int>& frames)
 {
-  std::list<unsigned int> frames;
-  ParseFrameList(frames, request);
-
   std::string orthancId, studyInstanceUid, seriesInstanceUid, sopInstanceUid;
   OrthancPlugins::MemoryBuffer content;
   if (LocateInstance(output, orthancId, studyInstanceUid, seriesInstanceUid, sopInstanceUid, request) &&
       content.RestApiGet("/instances/" + orthancId + "/file", false))
   {
+    if (allFrames)
+    {
+      OrthancPlugins::LogInfo("DICOMweb RetrieveFrames on " + orthancId + ", all frames");
+    }
+    else
     {
       std::string s = "DICOMweb RetrieveFrames on " + orthancId + ", frames: ";
       for (std::list<unsigned int>::const_iterator 
@@ -453,7 +456,40 @@
       instance.reset(new OrthancPlugins::DicomInstance(content.GetData(), content.GetSize()));
     }
 
+    if (instance.get() == NULL)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
+    }
+
+    if (allFrames)
+    {
+      frames.clear();
+      for (unsigned int i = 0; i < instance->GetFramesCount(); i++)
+      {
+        frames.push_back(i + 1);  // Frames are numbered starting from 1
+      }
+    }
+
     AnswerFrames(output, request, *instance, studyInstanceUid, seriesInstanceUid,
                  sopInstanceUid, frames, targetSyntax);
   }    
 }
+
+
+void RetrieveAllFrames(OrthancPluginRestOutput* output,
+                       const char* url,
+                       const OrthancPluginHttpRequest* request)
+{
+  std::list<unsigned int> frames;
+  RetrieveFrames(output, request, true, frames);
+}
+
+
+void RetrieveSelectedFrames(OrthancPluginRestOutput* output,
+                            const char* url,
+                            const OrthancPluginHttpRequest* request)
+{
+  std::list<unsigned int> frames;
+  ParseFrameList(frames, request);
+  RetrieveFrames(output, request, false, frames);
+}