comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1822:0489fe25ce48

support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 26 May 2021 18:13:35 +0200
parents dccdc7e59929
children a56bf4c534ef
comparison
equal deleted inserted replaced
1821:36430d73e36c 1822:0489fe25ce48
1397 1397
1398 const Orthanc::DicomMap& dicom = message.GetResources()->GetResource(0); 1398 const Orthanc::DicomMap& dicom = message.GetResources()->GetResource(0);
1399 1399
1400 { 1400 {
1401 OrthancStone::DicomInstanceParameters params(dicom); 1401 OrthancStone::DicomInstanceParameters params(dicom);
1402
1403 params.EnrichUsingDicomWeb(message.GetResources()->GetSourceJson(0));
1404 GetViewport().centralPixelSpacingX_ = params.GetPixelSpacingX();
1405 GetViewport().centralPixelSpacingY_ = params.GetPixelSpacingY();
1406
1407 if (params.HasPixelSpacing())
1408 {
1409 GetViewport().stoneAnnotations_->SetUnits(OrthancStone::Units_Millimeters);
1410 }
1411 else
1412 {
1413 GetViewport().stoneAnnotations_->SetUnits(OrthancStone::Units_Pixels);
1414 }
1415
1416 if (params.GetPixelSpacingX() != 0 &&
1417 params.GetPixelSpacingY() != 0 &&
1418 params.GetWidth() != 0 &&
1419 params.GetHeight())
1420 {
1421 GetViewport().centralPhysicalWidth_ = (params.GetPixelSpacingX() *
1422 static_cast<double>(params.GetWidth()));
1423 GetViewport().centralPhysicalHeight_ = (params.GetPixelSpacingY() *
1424 static_cast<double>(params.GetHeight()));
1425 }
1402 1426
1403 GetViewport().windowingPresetCenters_.resize(params.GetWindowingPresetsCount()); 1427 GetViewport().windowingPresetCenters_.resize(params.GetWindowingPresetsCount());
1404 GetViewport().windowingPresetWidths_.resize(params.GetWindowingPresetsCount()); 1428 GetViewport().windowingPresetWidths_.resize(params.GetWindowingPresetsCount());
1405 1429
1406 for (size_t i = 0; i < params.GetWindowingPresetsCount(); i++) 1430 for (size_t i = 0; i < params.GetWindowingPresetsCount(); i++)
1701 bool serverSideTranscoding_; 1725 bool serverSideTranscoding_;
1702 OrthancStone::Vector synchronizationOffset_; 1726 OrthancStone::Vector synchronizationOffset_;
1703 bool synchronizationEnabled_; 1727 bool synchronizationEnabled_;
1704 double centralPhysicalWidth_; // LSD-479 1728 double centralPhysicalWidth_; // LSD-479
1705 double centralPhysicalHeight_; 1729 double centralPhysicalHeight_;
1730 double centralPixelSpacingX_;
1731 double centralPixelSpacingY_;
1706 1732
1707 bool hasFocusOnInstance_; 1733 bool hasFocusOnInstance_;
1708 std::string focusSopInstanceUid_; 1734 std::string focusSopInstanceUid_;
1709 size_t focusFrameNumber_; 1735 size_t focusFrameNumber_;
1710 1736
1854 layer->SetLinearInterpolation(true); 1880 layer->SetLinearInterpolation(true);
1855 layer->SetFlipX(flipX_); 1881 layer->SetFlipX(flipX_);
1856 layer->SetFlipY(flipY_); 1882 layer->SetFlipY(flipY_);
1857 1883
1858 double pixelSpacingX, pixelSpacingY; 1884 double pixelSpacingX, pixelSpacingY;
1859 OrthancStone::GeometryToolbox::GetPixelSpacing(pixelSpacingX, pixelSpacingY, instance.GetTags()); 1885
1886 if (instance.HasPixelSpacing())
1887 {
1888 pixelSpacingX = instance.GetPixelSpacingX();
1889 pixelSpacingY = instance.GetPixelSpacingY();
1890 }
1891 else
1892 {
1893 pixelSpacingX = centralPixelSpacingX_;
1894 pixelSpacingY = centralPixelSpacingY_;
1895 }
1860 1896
1861 if (FIX_LSD_479) 1897 if (FIX_LSD_479)
1862 { 1898 {
1863 /** 1899 /**
1864 * Some series contain a first instance (secondary capture) that 1900 * Some series contain a first instance (secondary capture) that
2142 hasFocusOnInstance_(false), 2178 hasFocusOnInstance_(false),
2143 focusFrameNumber_(0), 2179 focusFrameNumber_(0),
2144 synchronizationOffset_(OrthancStone::LinearAlgebra::CreateVector(0, 0, 0)), 2180 synchronizationOffset_(OrthancStone::LinearAlgebra::CreateVector(0, 0, 0)),
2145 synchronizationEnabled_(false), 2181 synchronizationEnabled_(false),
2146 centralPhysicalWidth_(1), 2182 centralPhysicalWidth_(1),
2147 centralPhysicalHeight_(1) 2183 centralPhysicalHeight_(1),
2184 centralPixelSpacingX_(1),
2185 centralPixelSpacingY_(1)
2148 { 2186 {
2149 if (!framesCache_) 2187 if (!framesCache_)
2150 { 2188 {
2151 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); 2189 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
2152 } 2190 }
2417 "/instances/" + centralInstance.GetSopInstanceUid() + "/metadata"); 2455 "/instances/" + centralInstance.GetSopInstanceUid() + "/metadata");
2418 2456
2419 loader_->ScheduleGetDicomWeb( 2457 loader_->ScheduleGetDicomWeb(
2420 boost::make_shared<OrthancStone::LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), 2458 boost::make_shared<OrthancStone::LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID),
2421 0, source_, uri, new LoadSeriesDetailsFromInstance(GetSharedObserver())); 2459 0, source_, uri, new LoadSeriesDetailsFromInstance(GetSharedObserver()));
2422 }
2423
2424 if (centralInstance.GetPixelSpacingX() != 0 &&
2425 centralInstance.GetPixelSpacingY() != 0 &&
2426 centralInstance.GetWidth() != 0 &&
2427 centralInstance.GetHeight())
2428 {
2429 centralPhysicalWidth_ = (centralInstance.GetPixelSpacingX() *
2430 static_cast<double>(centralInstance.GetWidth()));
2431 centralPhysicalHeight_ = (centralInstance.GetPixelSpacingY() *
2432 static_cast<double>(centralInstance.GetHeight()));
2433 } 2460 }
2434 } 2461 }
2435 2462
2436 ApplyScheduledFocus(); 2463 ApplyScheduledFocus();
2437 } 2464 }