Mercurial > hg > orthanc
changeset 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 |
files | OrthancServer/OrthancRestApi.cpp OrthancServer/OrthancRestApi2.cpp |
diffstat | 2 files changed, 30 insertions(+), 70 deletions(-) [+] |
line wrap: on
line diff
--- 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<unsigned int>(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" ||
--- 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" }