Mercurial > hg > orthanc-dicomweb
changeset 336:9257352fbcf9
Retrieve Rendered Transaction for frames, fixes issue #6
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 22 Jun 2019 12:01:38 +0200 |
parents | 487fca2fa5e2 |
children | 496573be1794 |
files | NEWS Plugin/Plugin.cpp Status.txt |
diffstat | 3 files changed, 72 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Sat Jun 22 11:17:30 2019 +0200 +++ b/NEWS Sat Jun 22 12:01:38 2019 +0200 @@ -12,7 +12,7 @@ * Handling of the HTTP header "Forwarded" for WADO-RS * New URI: /dicom-web/servers/.../qido * New URI: /dicom-web/servers/.../delete -* Basic implementation of WADO-RS "Retrieve rendered instance" +* First implementation of WADO-RS "Retrieve Rendered Transaction" Version 0.6 (2019-02-27)
--- a/Plugin/Plugin.cpp Sat Jun 22 11:17:30 2019 +0200 +++ b/Plugin/Plugin.cpp Sat Jun 22 12:01:38 2019 +0200 @@ -32,6 +32,8 @@ #include <EmbeddedResources.h> +#include <boost/algorithm/string/predicate.hpp> + bool RequestHasKey(const OrthancPluginHttpRequest* request, const char* key) { @@ -386,9 +388,10 @@ -void RetrieveInstanceRendered(OrthancPluginRestOutput* output, - const char* url, - const OrthancPluginHttpRequest* request) + +static void AnswerFrameRendered(OrthancPluginRestOutput* output, + int frame, + const OrthancPluginHttpRequest* request) { OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); @@ -398,16 +401,41 @@ } else { - Orthanc::MimeType mime = Orthanc::MimeType_Jpeg; - - std::string publicId; - if (LocateInstance(output, publicId, request)) + std::string instanceId; + if (LocateInstance(output, instanceId, request)) { + Orthanc::MimeType mime = Orthanc::MimeType_Jpeg; // This is the default in DICOMweb + + for (uint32_t i = 0; i < request->headersCount; i++) + { + if (boost::iequals(request->headersKeys[i], "Accept") && + !boost::iequals(request->headersValues[i], "*/*")) + { + try + { + // TODO - Support conversion to GIF + + mime = Orthanc::StringToMimeType(request->headersValues[i]); + if (mime != Orthanc::MimeType_Png && + mime != Orthanc::MimeType_Jpeg) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + } + catch (Orthanc::OrthancException&) + { + LOG(ERROR) << "Unsupported MIME type in WADO-RS rendered frame: " << request->headersValues[i]; + throw; + } + } + } + std::map<std::string, std::string> headers; headers["Accept"] = Orthanc::EnumerationToString(mime); - + OrthancPlugins::MemoryBuffer buffer; - if (buffer.RestApiGet("/instances/" + publicId + "/preview", headers, false)) + if (buffer.RestApiGet("/instances/" + instanceId + "/frames/" + + boost::lexical_cast<std::string>(frame) + "/preview", headers, false)) { OrthancPluginAnswerBuffer(context, output, buffer.GetData(), buffer.GetSize(), Orthanc::EnumerationToString(mime)); @@ -417,6 +445,25 @@ } +void RetrieveInstanceRendered(OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request) +{ + AnswerFrameRendered(output, 0, request); +} + + +void RetrieveFrameRendered(OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request) +{ + assert(request->groupsCount == 4); + const char* frame = request->groups[3]; + + AnswerFrameRendered(output, boost::lexical_cast<int>(frame), request); +} + + @@ -562,6 +609,7 @@ OrthancPlugins::RegisterRestCallback<GetClientInformation>(root + "info", true); OrthancPlugins::RegisterRestCallback<RetrieveInstanceRendered>(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/rendered", true); + OrthancPlugins::RegisterRestCallback<RetrieveFrameRendered>(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames/([^/]*)/rendered", true); // Extend the default Orthanc Explorer with custom JavaScript for STOW client
--- a/Status.txt Sat Jun 22 11:17:30 2019 +0200 +++ b/Status.txt Sat Jun 22 12:01:38 2019 +0200 @@ -1,4 +1,4 @@ -Reference: http://medical.nema.org/medical/dicom/current/output/html/part18.html +Reference: http://dicom.nema.org/MEDICAL/dicom/2019a/output/html/part18.html @@ -86,7 +86,19 @@ 6.5.8 WADO-RS / RetrieveRenderedTransaction =========================================== -Not supported yet. +http://dicom.nema.org/MEDICAL/dicom/2019a/output/chtml/part18/sect_6.5.8.html + +Supported +--------- + +* Single-frame and multi-frame retrieval +* JPEG and PNG output + +Not supported +------------- + +* GIF output +* None of the "Retrieve Rendered Query Parameters" (table 6.5.8-2)