Mercurial > hg > orthanc-stone
diff Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1704:902d13889ae4
LoadMultipartInstanceInViewport() in C++
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 27 Nov 2020 17:15:09 +0100 |
parents | 76c590a62755 |
children | aec45e0b2528 |
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Fri Nov 27 16:36:43 2020 +0100 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Fri Nov 27 17:15:09 2020 +0100 @@ -575,6 +575,35 @@ } } + bool SortMultipartInstanceFrames(OrthancStone::SortedFrames& target, + const std::string& seriesInstanceUid, + const std::string& sopInstanceUid) const + { + OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid); + + if (accessor.IsComplete()) + { + for (size_t i = 0; i < accessor.GetInstancesCount(); i++) + { + std::string s; + if (accessor.GetInstance(i).LookupStringValue(s, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false) && + s == sopInstanceUid) + { + target.Clear(); + target.AddInstance(accessor.GetInstance(i)); + target.Sort(); + return true; + } + } + + return true; + } + else + { + return false; + } + } + size_t GetSeriesNumberOfFrames(const std::string& seriesInstanceUid) const { OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid); @@ -3078,6 +3107,30 @@ EMSCRIPTEN_KEEPALIVE + int LoadMultipartInstanceInViewport(const char* canvas, + const char* seriesInstanceUid, + const char* sopInstanceUid) + { + try + { + std::unique_ptr<OrthancStone::SortedFrames> frames(new OrthancStone::SortedFrames); + + if (GetResourcesLoader().SortMultipartInstanceFrames(*frames, seriesInstanceUid, sopInstanceUid)) + { + GetViewport(canvas)->SetFrames(frames.release()); + return 1; + } + else + { + return 0; + } + } + EXTERN_CATCH_EXCEPTIONS; + return 0; + } + + + EMSCRIPTEN_KEEPALIVE void AllViewportsUpdateSize(int fitContent) { try