diff OrthancServer/OrthancRestApi2.cpp @ 214:03817919169b

list of frames
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2012 11:11:53 +0100
parents 4ce7fdcc8879
children c07170f3f4f7
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi2.cpp	Thu Nov 29 10:59:40 2012 +0100
+++ b/OrthancServer/OrthancRestApi2.cpp	Thu Nov 29 11:11:53 2012 +0100
@@ -193,6 +193,35 @@
     }
   }
 
+  
+  static void ListFrames(RestApi::GetCall& call)
+  {
+    RETRIEVE_CONTEXT(call);
+
+    Json::Value instance;
+    if (context.GetIndex().LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance))
+    {
+      unsigned int numberOfFrames = 1;
+
+      try
+      {
+        Json::Value tmp = instance["MainDicomTags"]["NumberOfFrames"];
+        numberOfFrames = boost::lexical_cast<unsigned int>(tmp.asString());
+      }
+      catch (...)
+      {
+      }
+
+      Json::Value result = Json::arrayValue;
+      for (unsigned int i = 0; i < numberOfFrames; i++)
+      {
+        result.append(i);
+      }
+
+      call.GetOutput().AnswerJson(result);
+    }
+  }
+
 
 
   // DICOM bridge -------------------------------------------------------------
@@ -246,6 +275,7 @@
     Register("/instances/{id}/file", GetInstanceFile);
     Register("/instances/{id}/tags", GetInstanceTags<false>);
     Register("/instances/{id}/simplified-tags", GetInstanceTags<true>);
+    Register("/instances/{id}/frames", ListFrames);
 
     // TODO : "content", "frames"
   }