Mercurial > hg > orthanc-stone
comparison Samples/Sdl/Loader.cpp @ 713:e63c8b9b7b02
setting texture geometry
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 20 May 2019 15:44:01 +0200 |
parents | f334b098b243 |
children | c3bbb130abc4 |
comparison
equal
deleted
inserted
replaced
712:f334b098b243 | 713:e63c8b9b7b02 |
---|---|
1560 { | 1560 { |
1561 std::auto_ptr<Refactoring::GetOrthancWebViewerJpegCommand> tmp( | 1561 std::auto_ptr<Refactoring::GetOrthancWebViewerJpegCommand> tmp( |
1562 new Refactoring::GetOrthancWebViewerJpegCommand); | 1562 new Refactoring::GetOrthancWebViewerJpegCommand); |
1563 tmp->SetHttpHeader("Accept-Encoding", "gzip"); | 1563 tmp->SetHttpHeader("Accept-Encoding", "gzip"); |
1564 tmp->SetInstance(instance); | 1564 tmp->SetInstance(instance); |
1565 tmp->SetQuality((quality == 0 ? 50 : 95)); | 1565 tmp->SetQuality((quality == 0 ? 50 : 90)); |
1566 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); | 1566 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); |
1567 command.reset(tmp.release()); | 1567 command.reset(tmp.release()); |
1568 } | 1568 } |
1569 | 1569 |
1570 command->SetPayload(new Orthanc::SingleValueObject<unsigned int>(sliceIndex)); | 1570 command->SetPayload(new Orthanc::SingleValueObject<unsigned int>(sliceIndex)); |
1792 | 1792 |
1793 | 1793 |
1794 class DicomVolumeMPRSlicer : public IVolumeSlicer | 1794 class DicomVolumeMPRSlicer : public IVolumeSlicer |
1795 { | 1795 { |
1796 private: | 1796 private: |
1797 bool linearInterpolation_; | |
1797 OrthancStone::Scene2D& scene_; | 1798 OrthancStone::Scene2D& scene_; |
1798 int layerDepth_; | 1799 int layerDepth_; |
1799 IDicomVolumeSource& source_; | 1800 IDicomVolumeSource& source_; |
1800 bool first_; | 1801 bool first_; |
1801 OrthancStone::VolumeProjection lastProjection_; | 1802 OrthancStone::VolumeProjection lastProjection_; |
1804 | 1805 |
1805 public: | 1806 public: |
1806 DicomVolumeMPRSlicer(OrthancStone::Scene2D& scene, | 1807 DicomVolumeMPRSlicer(OrthancStone::Scene2D& scene, |
1807 int layerDepth, | 1808 int layerDepth, |
1808 IDicomVolumeSource& source) : | 1809 IDicomVolumeSource& source) : |
1810 linearInterpolation_(false), | |
1809 scene_(scene), | 1811 scene_(scene), |
1810 layerDepth_(layerDepth), | 1812 layerDepth_(layerDepth), |
1811 source_(source), | 1813 source_(source), |
1812 first_(true) | 1814 first_(true) |
1813 { | 1815 { |
1814 } | 1816 } |
1817 | |
1818 void SetLinearInterpolation(bool enabled) | |
1819 { | |
1820 linearInterpolation_ = enabled; | |
1821 } | |
1822 | |
1823 bool IsLinearInterpolation() const | |
1824 { | |
1825 return linearInterpolation_; | |
1826 } | |
1815 | 1827 |
1816 virtual void SetViewportPlane(const OrthancStone::CoordinateSystem3D& plane) | 1828 virtual void SetViewportPlane(const OrthancStone::CoordinateSystem3D& plane) |
1817 { | 1829 { |
1818 if (!source_.GetVolume().HasGeometry() || | 1830 if (!source_.GetVolume().HasGeometry() || |
1819 source_.GetVolume().GetSlicesCount() == 0) | 1831 source_.GetVolume().GetSlicesCount() == 0) |
1820 { | 1832 { |
1821 scene_.DeleteLayer(layerDepth_); | 1833 scene_.DeleteLayer(layerDepth_); |
1822 return; | 1834 return; |
1823 } | 1835 } |
1824 | 1836 |
1837 const OrthancStone::VolumeImageGeometry& geometry = source_.GetVolume().GetImage().GetGeometry(); | |
1838 | |
1825 OrthancStone::VolumeProjection projection; | 1839 OrthancStone::VolumeProjection projection; |
1826 unsigned int sliceIndex; | 1840 unsigned int sliceIndex; |
1827 if (!source_.GetVolume().GetImage().GetGeometry().DetectSlice(projection, sliceIndex, plane)) | 1841 if (!geometry.DetectSlice(projection, sliceIndex, plane)) |
1828 { | 1842 { |
1829 // The cutting plane is neither axial, nor coronal, nor | 1843 // The cutting plane is neither axial, nor coronal, nor |
1830 // sagittal. Could use "VolumeReslicer" here. | 1844 // sagittal. Could use "VolumeReslicer" here. |
1831 scene_.DeleteLayer(layerDepth_); | 1845 scene_.DeleteLayer(layerDepth_); |
1832 return; | 1846 return; |
1872 | 1886 |
1873 OrthancStone::ImageBuffer3D::SliceReader reader(source_.GetVolume().GetImage(), projection, sliceIndex); | 1887 OrthancStone::ImageBuffer3D::SliceReader reader(source_.GetVolume().GetImage(), projection, sliceIndex); |
1874 texture.reset(parameters.CreateTexture(reader.GetAccessor())); | 1888 texture.reset(parameters.CreateTexture(reader.GetAccessor())); |
1875 } | 1889 } |
1876 | 1890 |
1877 // TODO - | 1891 const OrthancStone::CoordinateSystem3D& system = geometry.GetProjectionGeometry(projection); |
1878 // void SetOrigin(double x, double y); | 1892 |
1879 // void SetPixelSpacing(double sx, double sy); | 1893 double x0, y0, x1, y1; |
1880 // void SetAngle(double angle); | 1894 system.ProjectPoint(x0, y0, system.GetOrigin()); |
1881 // void SetLinearInterpolation(bool isLinearInterpolation); | 1895 system.ProjectPoint(x0, y0, system.GetOrigin() + system.GetAxisX()); |
1882 | 1896 texture->SetOrigin(x0, y0); |
1897 | |
1898 double dx = x1 - x0; | |
1899 double dy = y1 - y0; | |
1900 if (!OrthancStone::LinearAlgebra::IsCloseToZero(dx) || | |
1901 !OrthancStone::LinearAlgebra::IsCloseToZero(dy)) | |
1902 { | |
1903 texture->SetAngle(atan2(dy, dx)); | |
1904 } | |
1905 | |
1906 OrthancStone::Vector tmp; | |
1907 geometry.GetVoxelDimensions(projection); | |
1908 texture->SetPixelSpacing(tmp[0], tmp[1]); | |
1909 | |
1910 texture->SetLinearInterpolation(linearInterpolation_); | |
1883 | 1911 |
1884 scene_.SetLayer(layerDepth_, texture.release()); | 1912 scene_.SetLayer(layerDepth_, texture.release()); |
1885 } | 1913 } |
1886 } | 1914 } |
1887 }; | 1915 }; |