Mercurial > hg > orthanc-stone
diff Applications/Platforms/WebAssembly/WebAssemblyOracle.cpp @ 1675:6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 23 Nov 2020 18:09:14 +0100 |
parents | 4fb8fdf03314 |
children | 1393e3393a0b |
line wrap: on
line diff
--- a/Applications/Platforms/WebAssembly/WebAssemblyOracle.cpp Mon Nov 23 17:05:24 2020 +0100 +++ b/Applications/Platforms/WebAssembly/WebAssemblyOracle.cpp Mon Nov 23 18:09:14 2020 +0100 @@ -815,4 +815,71 @@ LOG(INFO) << "DCMTK support is disabled, the DICOM cache is disabled"; #endif } + + + WebAssemblyOracle::CachedInstanceAccessor::CachedInstanceAccessor(WebAssemblyOracle& oracle, + const std::string& sopInstanceUid) + { +#if ORTHANC_ENABLE_DCMTK == 1 + if (oracle.dicomCache_.get() != NULL) + { + reader_.reset(new ParsedDicomCache::Reader(*oracle.dicomCache_, BUCKET_SOP, sopInstanceUid)); + } +#endif + } + + bool WebAssemblyOracle::CachedInstanceAccessor::IsValid() const + { +#if ORTHANC_ENABLE_DCMTK == 1 + return (reader_.get() != NULL && + reader_->IsValid()); +#else + return false; +#endif + } + + const Orthanc::ParsedDicomFile& WebAssemblyOracle::CachedInstanceAccessor::GetDicom() const + { + if (IsValid()) + { +#if ORTHANC_ENABLE_DCMTK == 1 + assert(reader_.get() != NULL); + return reader_->GetDicom(); +#endif + } + else + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + } + } + + size_t WebAssemblyOracle::CachedInstanceAccessor::GetFileSize() const + { + if (IsValid()) + { +#if ORTHANC_ENABLE_DCMTK == 1 + assert(reader_.get() != NULL); + return reader_->GetFileSize(); +#endif + } + else + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + } + } + + bool WebAssemblyOracle::CachedInstanceAccessor::HasPixelData() const + { + if (IsValid()) + { +#if ORTHANC_ENABLE_DCMTK == 1 + assert(reader_.get() != NULL); + return reader_->HasPixelData(); +#endif + } + else + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + } + } }