Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1644:4796fb60999e
removing methods from SortedFrames to simplify api
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 10 Nov 2020 18:08:16 +0100 |
parents | 53d378ef7277 |
children | 4e14735e98f8 |
comparison
equal
deleted
inserted
replaced
1643:882e2253a90e | 1644:4796fb60999e |
---|---|
1328 { | 1328 { |
1329 size_t index = prefetchQueue_.front().GetFrameIndex(); | 1329 size_t index = prefetchQueue_.front().GetFrameIndex(); |
1330 bool isFull = prefetchQueue_.front().IsFull(); | 1330 bool isFull = prefetchQueue_.front().IsFull(); |
1331 prefetchQueue_.pop_front(); | 1331 prefetchQueue_.pop_front(); |
1332 | 1332 |
1333 const std::string sopInstanceUid = frames_->GetFrameSopInstanceUid(index); | 1333 const std::string sopInstanceUid = frames_->GetInstanceOfFrame(index).GetSopInstanceUid(); |
1334 unsigned int frameNumber = frames_->GetFrameNumberInInstance(index); | 1334 unsigned int frameNumber = frames_->GetFrameNumberInInstance(index); |
1335 | 1335 |
1336 { | 1336 { |
1337 FramesCache::Accessor accessor(*cache_, sopInstanceUid, frameNumber); | 1337 FramesCache::Accessor accessor(*cache_, sopInstanceUid, frameNumber); |
1338 if (!accessor.IsValid() || | 1338 if (!accessor.IsValid() || |
1370 if (cursor_.get() != NULL && | 1370 if (cursor_.get() != NULL && |
1371 frames_.get() != NULL) | 1371 frames_.get() != NULL) |
1372 { | 1372 { |
1373 size_t index = cursor_->GetCurrentIndex(); | 1373 size_t index = cursor_->GetCurrentIndex(); |
1374 | 1374 |
1375 if (frames_->GetFrameSopInstanceUid(index) == sopInstanceUid && | 1375 if (frames_->GetInstanceOfFrame(index).GetSopInstanceUid() == sopInstanceUid && |
1376 frames_->GetFrameNumberInInstance(index) == frameNumber) | 1376 frames_->GetFrameNumberInInstance(index) == frameNumber) |
1377 { | 1377 { |
1378 DisplayCurrentFrame(); | 1378 DisplayCurrentFrame(); |
1379 } | 1379 } |
1380 } | 1380 } |
1412 else | 1412 else |
1413 { | 1413 { |
1414 quality = DisplayedFrameQuality_High; | 1414 quality = DisplayedFrameQuality_High; |
1415 } | 1415 } |
1416 | 1416 |
1417 currentFrameExtent_ = FrameExtent(frames_->GetFrameTags(index)); | 1417 currentFrameExtent_ = FrameExtent(frames_->GetInstanceOfFrame(index).GetTags()); |
1418 | 1418 |
1419 { | 1419 { |
1420 // Prepare prefetching | 1420 // Prepare prefetching |
1421 prefetchQueue_.clear(); | 1421 prefetchQueue_.clear(); |
1422 for (size_t i = 0; i < cursor_->GetPrefetchSize() && i < 16; i++) | 1422 for (size_t i = 0; i < cursor_->GetPrefetchSize() && i < 16; i++) |
1471 OrthancStone::FloatTextureSceneLayer& layer = | 1471 OrthancStone::FloatTextureSceneLayer& layer = |
1472 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(scene.GetLayer(LAYER_TEXTURE)); | 1472 dynamic_cast<OrthancStone::FloatTextureSceneLayer&>(scene.GetLayer(LAYER_TEXTURE)); |
1473 layer.GetWindowing(windowingCenter_, windowingWidth_); | 1473 layer.GetWindowing(windowingCenter_, windowingWidth_); |
1474 } | 1474 } |
1475 } | 1475 } |
1476 | 1476 |
1477 | 1477 |
1478 static bool IsFrameMonochrome1(const OrthancStone::SortedFrames& frames, | |
1479 size_t frameIndex) | |
1480 { | |
1481 const OrthancStone::DicomInstanceParameters& instance = frames.GetInstanceOfFrame(frameIndex); | |
1482 return (instance.GetImageInformation().GetPhotometricInterpretation() == | |
1483 Orthanc::PhotometricInterpretation_Monochrome1); | |
1484 } | |
1485 | |
1486 | |
1478 bool DisplayFrame(unsigned int& quality, | 1487 bool DisplayFrame(unsigned int& quality, |
1479 size_t index) | 1488 size_t index) |
1480 { | 1489 { |
1481 if (frames_.get() == NULL) | 1490 if (frames_.get() == NULL) |
1482 { | 1491 { |
1483 return false; | 1492 return false; |
1484 } | 1493 } |
1485 | 1494 |
1486 const std::string sopInstanceUid = frames_->GetFrameSopInstanceUid(index); | 1495 const std::string sopInstanceUid = frames_->GetInstanceOfFrame(index).GetSopInstanceUid(); |
1487 size_t frameNumber = frames_->GetFrameNumberInInstance(index); | 1496 size_t frameNumber = frames_->GetFrameNumberInInstance(index); |
1488 | 1497 |
1489 FramesCache::Accessor accessor(*cache_, sopInstanceUid, frameNumber); | 1498 FramesCache::Accessor accessor(*cache_, sopInstanceUid, frameNumber); |
1490 if (accessor.IsValid()) | 1499 if (accessor.IsValid()) |
1491 { | 1500 { |
1504 case Orthanc::PixelFormat_Float32: | 1513 case Orthanc::PixelFormat_Float32: |
1505 { | 1514 { |
1506 std::unique_ptr<OrthancStone::FloatTextureSceneLayer> tmp( | 1515 std::unique_ptr<OrthancStone::FloatTextureSceneLayer> tmp( |
1507 new OrthancStone::FloatTextureSceneLayer(accessor.GetImage())); | 1516 new OrthancStone::FloatTextureSceneLayer(accessor.GetImage())); |
1508 tmp->SetCustomWindowing(windowingCenter_, windowingWidth_); | 1517 tmp->SetCustomWindowing(windowingCenter_, windowingWidth_); |
1509 tmp->SetInverted(inverted_ ^ frames_->IsFrameMonochrome1(index)); | 1518 tmp->SetInverted(inverted_ ^ IsFrameMonochrome1(*frames_, index)); |
1510 layer.reset(tmp.release()); | 1519 layer.reset(tmp.release()); |
1511 break; | 1520 break; |
1512 } | 1521 } |
1513 | 1522 |
1514 default: | 1523 default: |
1519 layer->SetFlipX(flipX_); | 1528 layer->SetFlipX(flipX_); |
1520 layer->SetFlipY(flipY_); | 1529 layer->SetFlipY(flipY_); |
1521 | 1530 |
1522 double pixelSpacingX, pixelSpacingY; | 1531 double pixelSpacingX, pixelSpacingY; |
1523 OrthancStone::GeometryToolbox::GetPixelSpacing( | 1532 OrthancStone::GeometryToolbox::GetPixelSpacing( |
1524 pixelSpacingX, pixelSpacingY, frames_->GetFrameTags(index)); | 1533 pixelSpacingX, pixelSpacingY, frames_->GetInstanceOfFrame(index).GetTags()); |
1525 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY); | 1534 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY); |
1526 | 1535 |
1527 | 1536 |
1528 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsLayer; | 1537 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsLayer; |
1529 | 1538 |
1594 int priority, | 1603 int priority, |
1595 bool isPrefetch) | 1604 bool isPrefetch) |
1596 { | 1605 { |
1597 if (frames_.get() != NULL) | 1606 if (frames_.get() != NULL) |
1598 { | 1607 { |
1599 std::string sopInstanceUid = frames_->GetFrameSopInstanceUid(index); | 1608 std::string sopInstanceUid = frames_->GetInstanceOfFrame(index).GetSopInstanceUid(); |
1600 unsigned int frameNumber = frames_->GetFrameNumberInInstance(index); | 1609 unsigned int frameNumber = frames_->GetFrameNumberInInstance(index); |
1601 | 1610 |
1602 { | 1611 { |
1603 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock()); | 1612 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context_.Lock()); |
1604 lock->Schedule( | 1613 lock->Schedule( |
1619 { | 1628 { |
1620 ScheduleLoadFullDicomFrame(index, priority, isPrefetch); | 1629 ScheduleLoadFullDicomFrame(index, priority, isPrefetch); |
1621 } | 1630 } |
1622 else if (frames_.get() != NULL) | 1631 else if (frames_.get() != NULL) |
1623 { | 1632 { |
1624 std::string sopInstanceUid = frames_->GetFrameSopInstanceUid(index); | 1633 std::string sopInstanceUid = frames_->GetInstanceOfFrame(index).GetSopInstanceUid(); |
1625 unsigned int frameNumber = frames_->GetFrameNumberInInstance(index); | 1634 unsigned int frameNumber = frames_->GetFrameNumberInInstance(index); |
1626 bool isMonochrome1 = frames_->IsFrameMonochrome1(index); | 1635 bool isMonochrome1 = IsFrameMonochrome1(*frames_, index); |
1627 | 1636 |
1628 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() + | 1637 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() + |
1629 "/series/" + frames_->GetSeriesInstanceUid() + | 1638 "/series/" + frames_->GetSeriesInstanceUid() + |
1630 "/instances/" + sopInstanceUid + | 1639 "/instances/" + sopInstanceUid + |
1631 "/frames/" + boost::lexical_cast<std::string>(frameNumber + 1) + "/rendered"); | 1640 "/frames/" + boost::lexical_cast<std::string>(frameNumber + 1) + "/rendered"); |
1855 frames_->GetFramesCount(), DisplayedFrameQuality_None); | 1864 frames_->GetFramesCount(), DisplayedFrameQuality_None); |
1856 } | 1865 } |
1857 | 1866 |
1858 if (frames_->GetFramesCount() != 0) | 1867 if (frames_->GetFramesCount() != 0) |
1859 { | 1868 { |
1860 const std::string& sopInstanceUid = frames_->GetFrameSopInstanceUid(cursor_->GetCurrentIndex()); | 1869 const std::string& sopInstanceUid = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()).GetSopInstanceUid(); |
1861 | 1870 |
1862 { | 1871 { |
1863 // Fetch the default windowing for the central instance | 1872 // Fetch the default windowing for the central instance |
1864 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() + | 1873 const std::string uri = ("studies/" + frames_->GetStudyInstanceUid() + |
1865 "/series/" + frames_->GetSeriesInstanceUid() + | 1874 "/series/" + frames_->GetSeriesInstanceUid() + |