Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1646:4e14735e98f8
preparing to remove FrameExtent
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 12 Nov 2020 15:16:21 +0100 |
parents | 4796fb60999e |
children | adff3cd78775 |
comparison
equal
deleted
inserted
replaced
1645:bc7bd8ee13f8 | 1646:4e14735e98f8 |
---|---|
824 }; | 824 }; |
825 | 825 |
826 | 826 |
827 | 827 |
828 | 828 |
829 // Coordinates of the clipped line for "instance1" (out) | |
830 static bool GetReferenceLineCoordinates(double& x1, | |
831 double& y1, | |
832 double& x2, | |
833 double& y2, | |
834 const OrthancStone::DicomInstanceParameters& instance1, | |
835 unsigned int frame1, | |
836 const OrthancStone::DicomInstanceParameters& instance2, | |
837 unsigned int frame2) | |
838 { | |
839 if (instance1.GetWidth() == 0 && | |
840 instance1.GetHeight() == 0) | |
841 { | |
842 return false; | |
843 } | |
844 else | |
845 { | |
846 /** | |
847 * Compute the 2D extent of the "instance1", expressed in | |
848 * centimeters, in the 2D plane defined by this DICOM instance. | |
849 * | |
850 * In a multiframe image (cf. "ExtractFrameOffsets()"), the plane of | |
851 * each frame is a translation of the plane of the first frame along | |
852 * its normal. As a consequence, the extent is the same for each | |
853 * frame, so we can ignore the frame number. | |
854 **/ | |
855 OrthancStone::Extent2D extent; | |
856 | |
857 double ox = -instance1.GetPixelSpacingX() / 2.0; | |
858 double oy = -instance1.GetPixelSpacingY() / 2.0; | |
859 extent.AddPoint(ox, oy); | |
860 extent.AddPoint(ox + instance1.GetPixelSpacingX() * static_cast<double>(instance1.GetWidth()), | |
861 oy + instance1.GetPixelSpacingY() * static_cast<double>(instance1.GetHeight())); | |
862 | |
863 const OrthancStone::CoordinateSystem3D c1 = instance1.GetFrameGeometry(frame1); | |
864 const OrthancStone::CoordinateSystem3D c2 = instance2.GetFrameGeometry(frame2); | |
865 | |
866 OrthancStone::Vector direction, origin; | |
867 | |
868 if (!extent.IsEmpty() && | |
869 instance1.GetFrameOfReferenceUid() == instance1.GetFrameOfReferenceUid() && | |
870 OrthancStone::GeometryToolbox::IntersectTwoPlanes(origin, direction, | |
871 c1.GetOrigin(), c1.GetNormal(), | |
872 c2.GetOrigin(), c2.GetNormal())) | |
873 { | |
874 double ax, ay, bx, by; | |
875 c1.ProjectPoint(ax, ay, origin); | |
876 c1.ProjectPoint(bx, by, origin + 100.0 * direction); | |
877 | |
878 return OrthancStone::GeometryToolbox::ClipLineToRectangle( | |
879 x1, y1, x2, y2, | |
880 ax, ay, bx, by, | |
881 extent.GetX1(), extent.GetY1(), extent.GetX2(), extent.GetY2()); | |
882 } | |
883 else | |
884 { | |
885 return false; | |
886 } | |
887 } | |
888 } | |
889 | |
890 | |
891 | |
829 class FrameExtent | 892 class FrameExtent |
830 { | 893 { |
831 private: | 894 private: |
832 bool isValid_; | 895 bool isValid_; |
833 std::string frameOfReferenceUid_; | 896 std::string frameOfReferenceUid_; |