Mercurial > hg > orthanc-stone
comparison Samples/Sdl/Loader.cpp @ 692:10910827f235
simplification in DicomVolumeSlicer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 16 May 2019 20:39:30 +0200 |
parents | 032a94cca5c4 |
children | 7457b4ee1f29 |
comparison
equal
deleted
inserted
replaced
691:032a94cca5c4 | 692:10910827f235 |
---|---|
1601 }; | 1601 }; |
1602 | 1602 |
1603 | 1603 |
1604 | 1604 |
1605 | 1605 |
1606 class VolumeSlicerBase : public IVolumeSlicer | 1606 /* class VolumeSlicerBase : public IVolumeSlicer |
1607 { | 1607 { |
1608 private: | 1608 private: |
1609 OrthancStone::Scene2D& scene_; | 1609 OrthancStone::Scene2D& scene_; |
1610 int layerDepth_; | 1610 int layerDepth_; |
1611 bool first_; | 1611 bool first_; |
1651 scene_(scene), | 1651 scene_(scene), |
1652 layerDepth_(layerDepth), | 1652 layerDepth_(layerDepth), |
1653 first_(true) | 1653 first_(true) |
1654 { | 1654 { |
1655 } | 1655 } |
1656 }; | 1656 };*/ |
1657 | 1657 |
1658 | 1658 |
1659 | 1659 |
1660 class DicomVolumeSlicer : public VolumeSlicerBase | 1660 class DicomVolumeSlicer : public IVolumeSlicer |
1661 { | 1661 { |
1662 private: | 1662 private: |
1663 const DicomVolumeImage& volume_; | 1663 OrthancStone::Scene2D& scene_; |
1664 bool hasLastSlice_; | 1664 int layerDepth_; |
1665 uint64_t lastSliceRevision_; | 1665 const DicomVolumeImage& volume_; |
1666 bool first_; | |
1667 OrthancStone::VolumeProjection lastProjection_; | |
1668 unsigned int lastSliceIndex_; | |
1669 uint64_t lastSliceRevision_; | |
1666 | 1670 |
1667 public: | 1671 public: |
1668 DicomVolumeSlicer(OrthancStone::Scene2D& scene, | 1672 DicomVolumeSlicer(OrthancStone::Scene2D& scene, |
1669 int layerDepth, | 1673 int layerDepth, |
1670 const DicomVolumeImage& volume) : | 1674 const DicomVolumeImage& volume) : |
1671 VolumeSlicerBase(scene, layerDepth), | 1675 scene_(scene), |
1676 layerDepth_(layerDepth), | |
1672 volume_(volume), | 1677 volume_(volume), |
1673 hasLastSlice_(false) | 1678 first_(true) |
1674 { | 1679 { |
1675 } | 1680 } |
1676 | 1681 |
1677 virtual void SetViewportPlane(const OrthancStone::CoordinateSystem3D& plane) | 1682 virtual void SetViewportPlane(const OrthancStone::CoordinateSystem3D& plane) |
1678 { | 1683 { |
1679 if (!volume_.HasGeometry()) | 1684 if (!volume_.HasGeometry()) |
1680 { | 1685 { |
1681 DeleteLayer(); | 1686 scene_.DeleteLayer(layerDepth_); |
1682 return; | 1687 return; |
1683 } | 1688 } |
1684 | 1689 |
1685 OrthancStone::VolumeProjection projection; | 1690 OrthancStone::VolumeProjection projection; |
1686 unsigned int sliceIndex; | 1691 unsigned int sliceIndex; |
1687 if (!volume_.GetImage().GetGeometry().DetectSlice(projection, sliceIndex, plane)) | 1692 if (!volume_.GetImage().GetGeometry().DetectSlice(projection, sliceIndex, plane)) |
1688 { | 1693 { |
1689 // The cutting plane is neither axial, nor coronal, nor | 1694 // The cutting plane is neither axial, nor coronal, nor |
1690 // sagittal. Could use "VolumeReslicer" here. | 1695 // sagittal. Could use "VolumeReslicer" here. |
1691 DeleteLayer(); | 1696 scene_.DeleteLayer(layerDepth_); |
1692 return; | 1697 return; |
1693 } | 1698 } |
1694 | 1699 |
1695 uint64_t sliceRevision; | 1700 uint64_t sliceRevision; |
1696 if (projection == OrthancStone::VolumeProjection_Axial) | 1701 if (projection == OrthancStone::VolumeProjection_Axial) |
1701 { | 1706 { |
1702 // For coronal and sagittal projections, we take the global | 1707 // For coronal and sagittal projections, we take the global |
1703 // revision of the volume | 1708 // revision of the volume |
1704 sliceRevision = volume_.GetRevision(); | 1709 sliceRevision = volume_.GetRevision(); |
1705 } | 1710 } |
1706 | 1711 |
1707 if (!HasViewportPlaneChanged(plane) && | 1712 if (first_ || |
1708 hasLastSlice_ && | 1713 lastProjection_ == projection || |
1714 lastSliceIndex_ == sliceIndex || | |
1709 lastSliceRevision_ == sliceRevision) | 1715 lastSliceRevision_ == sliceRevision) |
1710 { | 1716 { |
1711 // The viewport plane and the content of the slice have not | 1717 // Eiter the viewport plane, or the content of the slice have not |
1712 // changed since the last time the layer was set: No update needed | 1718 // changed since the last time the layer was set: Update is needed |
1713 return; | 1719 |
1714 } | 1720 first_ = false; |
1715 else | 1721 lastProjection_ = projection; |
1716 { | 1722 lastSliceIndex_ = sliceIndex; |
1717 // The layer must be updated | |
1718 SetLastViewportPlane(plane); | |
1719 hasLastSlice_ = true; | |
1720 lastSliceRevision_ = sliceRevision; | 1723 lastSliceRevision_ = sliceRevision; |
1721 | 1724 |
1722 { | 1725 { |
1723 OrthancStone::ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, sliceIndex); | 1726 OrthancStone::ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, sliceIndex); |
1724 | 1727 |
1725 // TODO: Convert the image to Float32 or RGB24 | 1728 // TODO: Convert the image to Float32 or RGB24 |
1726 | 1729 |