Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1649:d77618883551
verification of FrameOfReferenceUID in reference lines
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 12 Nov 2020 20:56:04 +0100 |
parents | 4a43106bc122 |
children | 39137da83b0b |
comparison
equal
deleted
inserted
replaced
1648:4a43106bc122 | 1649:d77618883551 |
---|---|
824 }; | 824 }; |
825 | 825 |
826 | 826 |
827 | 827 |
828 | 828 |
829 // Coordinates of the clipped line for "instance1" (out) | 829 /** |
830 * Returns a clipped line (out: x1, y1, x2, y2), in the coordinate | |
831 * system of "instance1". Note that the frame of reference UID is not | |
832 * checked by this function. | |
833 **/ | |
830 static bool GetReferenceLineCoordinates(double& x1, | 834 static bool GetReferenceLineCoordinates(double& x1, |
831 double& y1, | 835 double& y1, |
832 double& x2, | 836 double& x2, |
833 double& y2, | 837 double& y2, |
834 const OrthancStone::DicomInstanceParameters& instance1, | 838 const OrthancStone::DicomInstanceParameters& instance1, |
862 const OrthancStone::CoordinateSystem3D c1 = instance1.GetFrameGeometry(frame1); | 866 const OrthancStone::CoordinateSystem3D c1 = instance1.GetFrameGeometry(frame1); |
863 | 867 |
864 OrthancStone::Vector direction, origin; | 868 OrthancStone::Vector direction, origin; |
865 | 869 |
866 if (!extent.IsEmpty() && | 870 if (!extent.IsEmpty() && |
867 instance1.GetFrameOfReferenceUid() == instance1.GetFrameOfReferenceUid() && | |
868 OrthancStone::GeometryToolbox::IntersectTwoPlanes(origin, direction, | 871 OrthancStone::GeometryToolbox::IntersectTwoPlanes(origin, direction, |
869 c1.GetOrigin(), c1.GetNormal(), | 872 c1.GetOrigin(), c1.GetNormal(), |
870 plane2.GetOrigin(), plane2.GetNormal())) | 873 plane2.GetOrigin(), plane2.GetNormal())) |
871 { | 874 { |
872 double ax, ay, bx, by; | 875 double ax, ay, bx, by; |
1835 DisplayCurrentFrame(); | 1838 DisplayCurrentFrame(); |
1836 } | 1839 } |
1837 } | 1840 } |
1838 } | 1841 } |
1839 | 1842 |
1843 bool GetCurrentFrameOfReferenceUid(std::string& frameOfReferenceUid) const | |
1844 { | |
1845 if (cursor_.get() != NULL && | |
1846 frames_.get() != NULL) | |
1847 { | |
1848 frameOfReferenceUid = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()).GetFrameOfReferenceUid(); | |
1849 return true; | |
1850 } | |
1851 else | |
1852 { | |
1853 return false; | |
1854 } | |
1855 } | |
1856 | |
1840 bool GetCurrentPlane(OrthancStone::CoordinateSystem3D& plane) const | 1857 bool GetCurrentPlane(OrthancStone::CoordinateSystem3D& plane) const |
1841 { | 1858 { |
1842 if (cursor_.get() != NULL && | 1859 if (cursor_.get() != NULL && |
1843 frames_.get() != NULL) | 1860 frames_.get() != NULL) |
1844 { | 1861 { |
1859 frames_.get() != NULL) | 1876 frames_.get() != NULL) |
1860 { | 1877 { |
1861 const size_t index = cursor_->GetCurrentIndex(); | 1878 const size_t index = cursor_->GetCurrentIndex(); |
1862 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(index); | 1879 const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(index); |
1863 const unsigned int frame = frames_->GetFrameNumberInInstance(index); | 1880 const unsigned int frame = frames_->GetFrameNumberInInstance(index); |
1864 | 1881 |
1865 for (std::list<const ViewerViewport*>::const_iterator | 1882 for (std::list<const ViewerViewport*>::const_iterator |
1866 it = viewports.begin(); it != viewports.end(); ++it) | 1883 it = viewports.begin(); it != viewports.end(); ++it) |
1867 { | 1884 { |
1868 assert(*it != NULL); | 1885 assert(*it != NULL); |
1869 | 1886 |
1870 OrthancStone::CoordinateSystem3D plane; | 1887 OrthancStone::CoordinateSystem3D otherPlane; |
1871 if ((*it)->GetCurrentPlane(plane)) | 1888 std::string otherFrameOfReferenceUid; |
1889 if ((*it)->GetCurrentPlane(otherPlane) && | |
1890 (*it)->GetCurrentFrameOfReferenceUid(otherFrameOfReferenceUid) && | |
1891 otherFrameOfReferenceUid == instance.GetFrameOfReferenceUid()) | |
1872 { | 1892 { |
1873 double x1, y1, x2, y2; | 1893 double x1, y1, x2, y2; |
1874 if (GetReferenceLineCoordinates(x1, y1, x2, y2, instance, frame, plane)) | 1894 if (GetReferenceLineCoordinates(x1, y1, x2, y2, instance, frame, otherPlane)) |
1875 { | 1895 { |
1876 OrthancStone::PolylineSceneLayer::Chain chain; | 1896 OrthancStone::PolylineSceneLayer::Chain chain; |
1877 chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); | 1897 chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); |
1878 chain.push_back(OrthancStone::ScenePoint2D(x2, y2)); | 1898 chain.push_back(OrthancStone::ScenePoint2D(x2, y2)); |
1879 layer->AddChain(chain, false, 0, 255, 0); | 1899 layer->AddChain(chain, false, 0, 255, 0); |
2092 } | 2112 } |
2093 } | 2113 } |
2094 | 2114 |
2095 void FocusOnPoint(const OrthancStone::Vector& p) | 2115 void FocusOnPoint(const OrthancStone::Vector& p) |
2096 { | 2116 { |
2097 static const double MAX_DISTANCE = 0.5; // 0.5 cm => TODO parameter? | 2117 //static const double MAX_DISTANCE = 0.5; // 0.5 cm => TODO parameter? |
2118 static const double MAX_DISTANCE = std::numeric_limits<double>::infinity(); | |
2098 | 2119 |
2099 OrthancStone::LinearAlgebra::Print(p); | 2120 OrthancStone::LinearAlgebra::Print(p); |
2100 size_t frameIndex; | 2121 size_t frameIndex; |
2101 if (cursor_.get() != NULL && | 2122 if (cursor_.get() != NULL && |
2102 frames_.get() != NULL && | 2123 frames_.get() != NULL && |
2103 frames_->FindClosestFrame(frameIndex, p, MAX_DISTANCE)) | 2124 frames_->FindClosestFrame(frameIndex, p, MAX_DISTANCE)) |
2104 { | 2125 { |
2105 cursor_->SetCurrentIndex(frameIndex); | 2126 cursor_->SetCurrentIndex(frameIndex); |
2106 DisplayCurrentFrame(); | 2127 DisplayCurrentFrame(); |
2107 } | |
2108 else | |
2109 { | |
2110 printf("nope\n"); | |
2111 } | 2128 } |
2112 } | 2129 } |
2113 }; | 2130 }; |
2114 | 2131 |
2115 | 2132 |