# HG changeset patch # User Sebastien Jodogne # Date 1354183913 -3600 # Node ID 03817919169bfa5ab61c6e1933fa0d45d4d6bcf4 # Parent 4ce7fdcc8879827565eaf394a84f2a2d8f489515 list of frames diff -r 4ce7fdcc8879 -r 03817919169b OrthancServer/OrthancRestApi.cpp --- a/OrthancServer/OrthancRestApi.cpp Thu Nov 29 10:59:40 2012 +0100 +++ b/OrthancServer/OrthancRestApi.cpp Thu Nov 29 11:11:53 2012 +0100 @@ -375,76 +375,6 @@ // Get the DICOM or the JSON file of one instance --------------------------- - else if (uri.size() == 3 && - uri[0] == "instances" && - (uri[2] == "file" || - uri[2] == "tags" || - uri[2] == "simplified-tags")) - { - CompressionType compressionType; - std::string fileUuid, contentType, filename; - if (uri[2] == "file") - { - existingResource = index_.GetFile(fileUuid, compressionType, uri[1], AttachedFileType_Dicom); - contentType = "application/dicom"; - filename = fileUuid + ".dcm"; - } - else if (uri[2] == "tags" || - uri[2] == "simplified-tags") - { - existingResource = index_.GetFile(fileUuid, compressionType, uri[1], AttachedFileType_Json); - contentType = "application/json"; - filename = fileUuid + ".json"; - } - - if (existingResource) - { - if (uri[2] == "simplified-tags") - { - Json::Value simplified, full; - ReadJson(full, storage_, fileUuid); - SimplifyTags(simplified, full); - SendJson(output, simplified); - return; - } - else - { - output.AnswerFile(storage_, fileUuid, contentType, filename.c_str()); - return; - } - } - } - - - else if (uri.size() == 3 && - uri[0] == "instances" && - uri[2] == "frames") - { - Json::Value instance(Json::objectValue); - existingResource = index_.LookupResource(instance, uri[1], ResourceType_Instance); - - if (existingResource) - { - result = Json::arrayValue; - - unsigned int numberOfFrames = 1; - try - { - Json::Value tmp = instance["MainDicomTags"]["NumberOfFrames"]; - numberOfFrames = boost::lexical_cast(tmp.asString()); - } - catch (boost::bad_lexical_cast) - { - } - - for (unsigned int i = 0; i < numberOfFrames; i++) - { - result.append(i); - } - } - } - - else if (uri[0] == "instances" && ((uri.size() == 3 && (uri[2] == "preview" || diff -r 4ce7fdcc8879 -r 03817919169b OrthancServer/OrthancRestApi2.cpp --- 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(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); Register("/instances/{id}/simplified-tags", GetInstanceTags); + Register("/instances/{id}/frames", ListFrames); // TODO : "content", "frames" }