comparison 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
comparison
equal deleted inserted replaced
1674:0621e523b670 1675:6fa05252b085
813 } 813 }
814 #else 814 #else
815 LOG(INFO) << "DCMTK support is disabled, the DICOM cache is disabled"; 815 LOG(INFO) << "DCMTK support is disabled, the DICOM cache is disabled";
816 #endif 816 #endif
817 } 817 }
818
819
820 WebAssemblyOracle::CachedInstanceAccessor::CachedInstanceAccessor(WebAssemblyOracle& oracle,
821 const std::string& sopInstanceUid)
822 {
823 #if ORTHANC_ENABLE_DCMTK == 1
824 if (oracle.dicomCache_.get() != NULL)
825 {
826 reader_.reset(new ParsedDicomCache::Reader(*oracle.dicomCache_, BUCKET_SOP, sopInstanceUid));
827 }
828 #endif
829 }
830
831 bool WebAssemblyOracle::CachedInstanceAccessor::IsValid() const
832 {
833 #if ORTHANC_ENABLE_DCMTK == 1
834 return (reader_.get() != NULL &&
835 reader_->IsValid());
836 #else
837 return false;
838 #endif
839 }
840
841 const Orthanc::ParsedDicomFile& WebAssemblyOracle::CachedInstanceAccessor::GetDicom() const
842 {
843 if (IsValid())
844 {
845 #if ORTHANC_ENABLE_DCMTK == 1
846 assert(reader_.get() != NULL);
847 return reader_->GetDicom();
848 #endif
849 }
850 else
851 {
852 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
853 }
854 }
855
856 size_t WebAssemblyOracle::CachedInstanceAccessor::GetFileSize() const
857 {
858 if (IsValid())
859 {
860 #if ORTHANC_ENABLE_DCMTK == 1
861 assert(reader_.get() != NULL);
862 return reader_->GetFileSize();
863 #endif
864 }
865 else
866 {
867 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
868 }
869 }
870
871 bool WebAssemblyOracle::CachedInstanceAccessor::HasPixelData() const
872 {
873 if (IsValid())
874 {
875 #if ORTHANC_ENABLE_DCMTK == 1
876 assert(reader_.get() != NULL);
877 return reader_->HasPixelData();
878 #endif
879 }
880 else
881 {
882 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
883 }
884 }
818 } 885 }