# HG changeset patch # User Sebastien Jodogne # Date 1590489483 -7200 # Node ID 369c7d510a6bb60f0aed6d97f88a2b8b73269ea5 # Parent 5449610fb02f699c549e3d0d0ff00e897dedbafb support retrieving of all frames diff -r 5449610fb02f -r 369c7d510a6b Plugin/Plugin.cpp --- a/Plugin/Plugin.cpp Tue May 26 11:32:18 2020 +0200 +++ b/Plugin/Plugin.cpp Tue May 26 12:38:03 2020 +0200 @@ -509,8 +509,8 @@ OrthancPlugins::RegisterRestCallback(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/bulk/(.*)", true); OrthancPlugins::RegisterRestCallback(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/metadata", true); OrthancPlugins::RegisterRestCallback(root + "studies/([^/]*)/series/([^/]*)/metadata", true); - OrthancPlugins::RegisterRestCallback(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames", true); - OrthancPlugins::RegisterRestCallback(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames/([^/]*)", true); + OrthancPlugins::RegisterRestCallback(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames", true); + OrthancPlugins::RegisterRestCallback(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames/([^/]*)", true); OrthancPlugins::RegisterRestCallback(root + "servers", true); OrthancPlugins::RegisterRestCallback(root + "servers/([^/]*)", true); diff -r 5449610fb02f -r 369c7d510a6b Plugin/WadoRs.h --- a/Plugin/WadoRs.h Tue May 26 11:32:18 2020 +0200 +++ b/Plugin/WadoRs.h Tue May 26 12:38:03 2020 +0200 @@ -70,9 +70,13 @@ const char* url, const OrthancPluginHttpRequest* request); -void RetrieveFrames(OrthancPluginRestOutput* output, - const char* url, - const OrthancPluginHttpRequest* request); +void RetrieveAllFrames(OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request); + +void RetrieveSelectedFrames(OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request); void RetrieveInstanceRendered(OrthancPluginRestOutput* output, const char* url, diff -r 5449610fb02f -r 369c7d510a6b Plugin/WadoRsRetrieveFrames.cpp --- a/Plugin/WadoRsRetrieveFrames.cpp Tue May 26 11:32:18 2020 +0200 +++ b/Plugin/WadoRsRetrieveFrames.cpp Tue May 26 12:38:03 2020 +0200 @@ -414,18 +414,21 @@ } -void RetrieveFrames(OrthancPluginRestOutput* output, - const char* url, - const OrthancPluginHttpRequest* request) +static void RetrieveFrames(OrthancPluginRestOutput* output, + const OrthancPluginHttpRequest* request, + bool allFrames, + std::list& frames) { - std::list frames; - ParseFrameList(frames, request); - std::string orthancId, studyInstanceUid, seriesInstanceUid, sopInstanceUid; OrthancPlugins::MemoryBuffer content; if (LocateInstance(output, orthancId, studyInstanceUid, seriesInstanceUid, sopInstanceUid, request) && content.RestApiGet("/instances/" + orthancId + "/file", false)) { + if (allFrames) + { + OrthancPlugins::LogInfo("DICOMweb RetrieveFrames on " + orthancId + ", all frames"); + } + else { std::string s = "DICOMweb RetrieveFrames on " + orthancId + ", frames: "; for (std::list::const_iterator @@ -453,7 +456,40 @@ instance.reset(new OrthancPlugins::DicomInstance(content.GetData(), content.GetSize())); } + if (instance.get() == NULL) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); + } + + if (allFrames) + { + frames.clear(); + for (unsigned int i = 0; i < instance->GetFramesCount(); i++) + { + frames.push_back(i + 1); // Frames are numbered starting from 1 + } + } + AnswerFrames(output, request, *instance, studyInstanceUid, seriesInstanceUid, sopInstanceUid, frames, targetSyntax); } } + + +void RetrieveAllFrames(OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request) +{ + std::list frames; + RetrieveFrames(output, request, true, frames); +} + + +void RetrieveSelectedFrames(OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request) +{ + std::list frames; + ParseFrameList(frames, request); + RetrieveFrames(output, request, false, frames); +}