changeset 93:5fdcb04afb0d

extension: retrieve all frames if none is specified
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 10 Dec 2015 09:53:46 +0100
parents 85609146eb16
children 499df60ad0e2
files Plugin/Plugin.cpp Plugin/WadoRs.cpp
diffstat 2 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/Plugin.cpp	Wed Dec 09 17:13:09 2015 +0100
+++ b/Plugin/Plugin.cpp	Thu Dec 10 09:53:46 2015 +0100
@@ -196,6 +196,7 @@
       Register(root, "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/bulk/(.*)", Protect<RetrieveBulkData>);
       Register(root, "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/metadata", Protect<RetrieveInstanceMetadata>);
       Register(root, "studies/([^/]*)/series/([^/]*)/metadata", Protect<RetrieveSeriesMetadata>);
+      Register(root, "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames", Protect<RetrieveFrames>);
       Register(root, "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames/([^/]*)", Protect<RetrieveFrames>);
     }
     else
--- a/Plugin/WadoRs.cpp	Wed Dec 09 17:13:09 2015 +0100
+++ b/Plugin/WadoRs.cpp	Thu Dec 10 09:53:46 2015 +0100
@@ -783,9 +783,9 @@
 {
   frames.clear();
 
-  if (request->groupsCount < 3)
+  if (request->groupsCount <= 3 ||
+      request->groups[3] == NULL)
   {
-    frames.push_back(0);
     return;
   }
 
@@ -889,7 +889,7 @@
                          const OrthancPluginHttpRequest* request,
                          const OrthancPlugins::ParsedDicomFile& dicom,
                          const gdcm::TransferSyntax& syntax,
-                         const std::list<unsigned int>& frames)
+                         std::list<unsigned int>& frames)
 {
   if (!dicom.GetDataSet().FindDataElement(OrthancPlugins::DICOM_TAG_PIXEL_DATA))
   {
@@ -931,6 +931,16 @@
     }
 
     size_t framesCount = pixelData.GetByteValue()->GetLength() / frameSize;
+
+    if (frames.empty())
+    {
+      // If no frame is provided, return all the frames (this is an extension)
+      for (size_t i = 0; i < framesCount; i++)
+      {
+        frames.push_back(i);
+      }
+    }
+
     const char* buffer = pixelData.GetByteValue()->GetPointer();
     assert(sizeof(char) == 1);
 
@@ -955,6 +965,15 @@
   {
     // Multi-fragment image, we assume that each fragment corresponds to one frame
 
+    if (frames.empty())
+    {
+      // If no frame is provided, return all the frames (this is an extension)
+      for (size_t i = 0; i < fragments->GetNumberOfFragments(); i++)
+      {
+        frames.push_back(i);
+      }
+    }
+
     for (std::list<unsigned int>::const_iterator 
            frame = frames.begin(); frame != frames.end(); ++frame)
     {