Mercurial > hg > orthanc-stone
comparison Samples/Sdl/Loader.cpp @ 710:3046a603eebf
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 20 May 2019 13:13:04 +0200 |
parents | 7457b4ee1f29 |
children | 70d1c28560b3 |
comparison
equal
deleted
inserted
replaced
709:7457b4ee1f29 | 710:3046a603eebf |
---|---|
1475 } | 1475 } |
1476 | 1476 |
1477 virtual void Handle(const Orthanc::ImageAccessor& image, | 1477 virtual void Handle(const Orthanc::ImageAccessor& image, |
1478 unsigned int quality) const | 1478 unsigned int quality) const |
1479 { | 1479 { |
1480 assert(quality <= 2); | 1480 that_.SetSliceContent(slice_, image, quality); |
1481 that_.volume_.SetSliceContent(slice_, image, quality); | |
1482 that_.ScheduleNextSliceDownload(); | |
1483 } | 1481 } |
1484 }; | 1482 }; |
1485 | 1483 |
1486 | 1484 |
1487 class LoadSeriesGeometryHandler : public MessageHandler | 1485 class LoadSeriesGeometryHandler : public MessageHandler |
1495 { | 1493 { |
1496 } | 1494 } |
1497 | 1495 |
1498 virtual void Handle(const Json::Value& body) const | 1496 virtual void Handle(const Json::Value& body) const |
1499 { | 1497 { |
1500 { | 1498 that_.SetGeometry(body); |
1501 Json::Value::Members instances = body.getMemberNames(); | 1499 } |
1502 | 1500 }; |
1503 OrthancStone::SlicesSorter slices; | 1501 |
1502 | |
1503 void SetGeometry(const Json::Value& body) | |
1504 { | |
1505 { | |
1506 Json::Value::Members instances = body.getMemberNames(); | |
1507 | |
1508 OrthancStone::SlicesSorter slices; | |
1504 | 1509 |
1505 for (size_t i = 0; i < instances.size(); i++) | 1510 for (size_t i = 0; i < instances.size(); i++) |
1506 { | 1511 { |
1507 Orthanc::DicomMap dicom; | 1512 Orthanc::DicomMap dicom; |
1508 dicom.FromDicomAsJson(body[instances[i]]); | 1513 dicom.FromDicomAsJson(body[instances[i]]); |
1509 | 1514 |
1510 std::auto_ptr<DicomInstanceParameters> instance(new DicomInstanceParameters(dicom)); | 1515 std::auto_ptr<DicomInstanceParameters> instance(new DicomInstanceParameters(dicom)); |
1511 instance->SetOrthancInstanceIdentifier(instances[i]); | 1516 instance->SetOrthancInstanceIdentifier(instances[i]); |
1512 | 1517 |
1513 OrthancStone::CoordinateSystem3D geometry = instance->GetGeometry(); | 1518 OrthancStone::CoordinateSystem3D geometry = instance->GetGeometry(); |
1514 slices.AddSlice(geometry, instance.release()); | 1519 slices.AddSlice(geometry, instance.release()); |
1515 } | 1520 } |
1516 | 1521 |
1517 that_.volume_.SetGeometry(slices); | 1522 volume_.SetGeometry(slices); |
1518 } | 1523 } |
1519 | 1524 |
1520 if (that_.volume_.GetSlicesCount() != 0) | 1525 if (volume_.GetSlicesCount() != 0) |
1521 { | 1526 { |
1522 that_.strategy_.reset(new OrthancStone::BasicFetchingStrategy( | 1527 strategy_.reset(new OrthancStone::BasicFetchingStrategy( |
1523 new OrthancStone::BasicFetchingItemsSorter(that_.volume_.GetSlicesCount()), 2)); | 1528 new OrthancStone::BasicFetchingItemsSorter(volume_.GetSlicesCount()), 2)); |
1524 | 1529 |
1525 for (unsigned int i = 0; i < 4; i++) // Schedule up to 4 simultaneous downloads (TODO - parameter) | 1530 for (unsigned int i = 0; i < 4; i++) // Schedule up to 4 simultaneous downloads (TODO - parameter) |
1526 { | 1531 { |
1527 that_.ScheduleNextSliceDownload(); | 1532 ScheduleNextSliceDownload(); |
1528 } | 1533 } |
1529 } | 1534 } |
1530 } | 1535 } |
1531 }; | |
1532 | |
1533 | |
1534 class LoadInstanceGeometryHandler : public MessageHandler | |
1535 { | |
1536 private: | |
1537 VolumeSeriesOrthancLoader& that_; | |
1538 | |
1539 public: | |
1540 LoadInstanceGeometryHandler(VolumeSeriesOrthancLoader& that) : | |
1541 that_(that) | |
1542 { | |
1543 } | |
1544 | |
1545 virtual void Handle(const Json::Value& body) const | |
1546 { | |
1547 Orthanc::DicomMap dicom; | |
1548 dicom.FromDicomAsJson(body); | |
1549 | |
1550 DicomInstanceParameters instance(dicom); | |
1551 } | |
1552 }; | |
1553 | 1536 |
1554 | 1537 |
1555 void ScheduleNextSliceDownload() | 1538 void ScheduleNextSliceDownload() |
1556 { | 1539 { |
1557 assert(strategy_.get() != NULL); | 1540 assert(strategy_.get() != NULL); |
1598 oracle_.Schedule(*this, command.release()); | 1581 oracle_.Schedule(*this, command.release()); |
1599 } | 1582 } |
1600 } | 1583 } |
1601 | 1584 |
1602 | 1585 |
1586 void SetSliceContent(unsigned int sliceIndex, | |
1587 const Orthanc::ImageAccessor& image, | |
1588 unsigned int quality) | |
1589 { | |
1590 assert(quality <= 2); | |
1591 | |
1592 volume_.SetSliceContent(sliceIndex, image, quality); | |
1593 ScheduleNextSliceDownload(); | |
1594 } | |
1595 | |
1596 | |
1603 IOracle& oracle_; | 1597 IOracle& oracle_; |
1604 bool active_; | 1598 bool active_; |
1605 DicomVolumeImage volume_; | 1599 DicomVolumeImage volume_; |
1606 | 1600 |
1607 std::auto_ptr<OrthancStone::IFetchingStrategy> strategy_; | 1601 std::auto_ptr<OrthancStone::IFetchingStrategy> strategy_; |
1639 command->SetUri("/series/" + seriesId + "/instances-tags"); | 1633 command->SetUri("/series/" + seriesId + "/instances-tags"); |
1640 command->SetPayload(new LoadSeriesGeometryHandler(*this)); | 1634 command->SetPayload(new LoadSeriesGeometryHandler(*this)); |
1641 | 1635 |
1642 oracle_.Schedule(*this, command.release()); | 1636 oracle_.Schedule(*this, command.release()); |
1643 } | 1637 } |
1644 | |
1645 void LoadInstance(const std::string& instanceId) | |
1646 { | |
1647 if (active_) | |
1648 { | |
1649 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
1650 } | |
1651 | |
1652 active_ = true; | |
1653 | |
1654 // Tag "3004-000c" is "Grid Frame Offset Vector", which is | |
1655 // mandatory to read RT DOSE, but is too long to be returned by default | |
1656 | |
1657 // TODO => Should be part of a second call if needed | |
1658 | |
1659 std::auto_ptr<Refactoring::OrthancRestApiCommand> command(new Refactoring::OrthancRestApiCommand); | |
1660 command->SetUri("/instances/" + instanceId + "/tags?ignore-length=3004-000c"); | |
1661 command->SetPayload(new LoadInstanceGeometryHandler(*this)); | |
1662 | |
1663 oracle_.Schedule(*this, command.release()); | |
1664 } | |
1665 }; | 1638 }; |
1666 | 1639 |
1667 | 1640 |
1641 | |
1642 #if 0 | |
1643 void LoadInstance(const std::string& instanceId) | |
1644 { | |
1645 if (active_) | |
1646 { | |
1647 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
1648 } | |
1649 | |
1650 active_ = true; | |
1651 | |
1652 // Tag "3004-000c" is "Grid Frame Offset Vector", which is | |
1653 // mandatory to read RT DOSE, but is too long to be returned by default | |
1654 | |
1655 // TODO => Should be part of a second call if needed | |
1656 | |
1657 std::auto_ptr<Refactoring::OrthancRestApiCommand> command(new Refactoring::OrthancRestApiCommand); | |
1658 command->SetUri("/instances/" + instanceId + "/tags?ignore-length=3004-000c"); | |
1659 command->SetPayload(new LoadInstanceGeometryHandler(*this)); | |
1660 | |
1661 oracle_.Schedule(*this, command.release()); | |
1662 } | |
1663 #endif | |
1668 | 1664 |
1669 | 1665 |
1670 /* class VolumeSlicerBase : public IVolumeSlicer | 1666 /* class VolumeSlicerBase : public IVolumeSlicer |
1671 { | 1667 { |
1672 private: | 1668 private: |
2344 } | 2340 } |
2345 | 2341 |
2346 | 2342 |
2347 // 2017-11-17-Anonymized | 2343 // 2017-11-17-Anonymized |
2348 //loader1->LoadSeries("cb3ea4d1-d08f3856-ad7b6314-74d88d77-60b05618"); // CT | 2344 //loader1->LoadSeries("cb3ea4d1-d08f3856-ad7b6314-74d88d77-60b05618"); // CT |
2349 loader2->LoadInstance("41029085-71718346-811efac4-420e2c15-d39f99b6"); // RT-DOSE | 2345 //loader2->LoadInstance("41029085-71718346-811efac4-420e2c15-d39f99b6"); // RT-DOSE |
2350 | 2346 |
2351 // Delphine | 2347 // Delphine |
2352 loader1->LoadSeries("5990e39c-51e5f201-fe87a54c-31a55943-e59ef80e"); // CT | 2348 loader1->LoadSeries("5990e39c-51e5f201-fe87a54c-31a55943-e59ef80e"); // CT |
2353 | 2349 |
2354 LOG(WARNING) << "...Waiting for Ctrl-C..."; | 2350 LOG(WARNING) << "...Waiting for Ctrl-C..."; |