comparison 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
comparison
equal deleted inserted replaced
1703:76c590a62755 1704:902d13889ae4
573 { 573 {
574 return false; 574 return false;
575 } 575 }
576 } 576 }
577 577
578 bool SortMultipartInstanceFrames(OrthancStone::SortedFrames& target,
579 const std::string& seriesInstanceUid,
580 const std::string& sopInstanceUid) const
581 {
582 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
583
584 if (accessor.IsComplete())
585 {
586 for (size_t i = 0; i < accessor.GetInstancesCount(); i++)
587 {
588 std::string s;
589 if (accessor.GetInstance(i).LookupStringValue(s, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false) &&
590 s == sopInstanceUid)
591 {
592 target.Clear();
593 target.AddInstance(accessor.GetInstance(i));
594 target.Sort();
595 return true;
596 }
597 }
598
599 return true;
600 }
601 else
602 {
603 return false;
604 }
605 }
606
578 size_t GetSeriesNumberOfFrames(const std::string& seriesInstanceUid) const 607 size_t GetSeriesNumberOfFrames(const std::string& seriesInstanceUid) const
579 { 608 {
580 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid); 609 OrthancStone::SeriesMetadataLoader::Accessor accessor(*metadataLoader_, seriesInstanceUid);
581 610
582 if (accessor.IsComplete()) 611 if (accessor.IsComplete())
3076 return 0; 3105 return 0;
3077 } 3106 }
3078 3107
3079 3108
3080 EMSCRIPTEN_KEEPALIVE 3109 EMSCRIPTEN_KEEPALIVE
3110 int LoadMultipartInstanceInViewport(const char* canvas,
3111 const char* seriesInstanceUid,
3112 const char* sopInstanceUid)
3113 {
3114 try
3115 {
3116 std::unique_ptr<OrthancStone::SortedFrames> frames(new OrthancStone::SortedFrames);
3117
3118 if (GetResourcesLoader().SortMultipartInstanceFrames(*frames, seriesInstanceUid, sopInstanceUid))
3119 {
3120 GetViewport(canvas)->SetFrames(frames.release());
3121 return 1;
3122 }
3123 else
3124 {
3125 return 0;
3126 }
3127 }
3128 EXTERN_CATCH_EXCEPTIONS;
3129 return 0;
3130 }
3131
3132
3133 EMSCRIPTEN_KEEPALIVE
3081 void AllViewportsUpdateSize(int fitContent) 3134 void AllViewportsUpdateSize(int fitContent)
3082 { 3135 {
3083 try 3136 try
3084 { 3137 {
3085 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it) 3138 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)