# HG changeset patch # User Sebastien Jodogne # Date 1605210964 -3600 # Node ID d776188835510c0c54851513625038723208f5ed # Parent 4a43106bc122a53c764f7a5796b50b79cdf23bc6 verification of FrameOfReferenceUID in reference lines diff -r 4a43106bc122 -r d77618883551 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Nov 12 19:27:08 2020 +0100 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Nov 12 20:56:04 2020 +0100 @@ -826,7 +826,11 @@ -// Coordinates of the clipped line for "instance1" (out) +/** + * Returns a clipped line (out: x1, y1, x2, y2), in the coordinate + * system of "instance1". Note that the frame of reference UID is not + * checked by this function. + **/ static bool GetReferenceLineCoordinates(double& x1, double& y1, double& x2, @@ -864,7 +868,6 @@ OrthancStone::Vector direction, origin; if (!extent.IsEmpty() && - instance1.GetFrameOfReferenceUid() == instance1.GetFrameOfReferenceUid() && OrthancStone::GeometryToolbox::IntersectTwoPlanes(origin, direction, c1.GetOrigin(), c1.GetNormal(), plane2.GetOrigin(), plane2.GetNormal())) @@ -1837,6 +1840,20 @@ } } + bool GetCurrentFrameOfReferenceUid(std::string& frameOfReferenceUid) const + { + if (cursor_.get() != NULL && + frames_.get() != NULL) + { + frameOfReferenceUid = frames_->GetInstanceOfFrame(cursor_->GetCurrentIndex()).GetFrameOfReferenceUid(); + return true; + } + else + { + return false; + } + } + bool GetCurrentPlane(OrthancStone::CoordinateSystem3D& plane) const { if (cursor_.get() != NULL && @@ -1861,17 +1878,20 @@ const size_t index = cursor_->GetCurrentIndex(); const OrthancStone::DicomInstanceParameters& instance = frames_->GetInstanceOfFrame(index); const unsigned int frame = frames_->GetFrameNumberInInstance(index); - + for (std::list::const_iterator it = viewports.begin(); it != viewports.end(); ++it) { assert(*it != NULL); - OrthancStone::CoordinateSystem3D plane; - if ((*it)->GetCurrentPlane(plane)) + OrthancStone::CoordinateSystem3D otherPlane; + std::string otherFrameOfReferenceUid; + if ((*it)->GetCurrentPlane(otherPlane) && + (*it)->GetCurrentFrameOfReferenceUid(otherFrameOfReferenceUid) && + otherFrameOfReferenceUid == instance.GetFrameOfReferenceUid()) { double x1, y1, x2, y2; - if (GetReferenceLineCoordinates(x1, y1, x2, y2, instance, frame, plane)) + if (GetReferenceLineCoordinates(x1, y1, x2, y2, instance, frame, otherPlane)) { OrthancStone::PolylineSceneLayer::Chain chain; chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); @@ -2094,7 +2114,8 @@ void FocusOnPoint(const OrthancStone::Vector& p) { - static const double MAX_DISTANCE = 0.5; // 0.5 cm => TODO parameter? + //static const double MAX_DISTANCE = 0.5; // 0.5 cm => TODO parameter? + static const double MAX_DISTANCE = std::numeric_limits::infinity(); OrthancStone::LinearAlgebra::Print(p); size_t frameIndex; @@ -2105,10 +2126,6 @@ cursor_->SetCurrentIndex(frameIndex); DisplayCurrentFrame(); } - else - { - printf("nope\n"); - } } }; diff -r 4a43106bc122 -r d77618883551 OrthancStone/Sources/Toolbox/SortedFrames.cpp --- a/OrthancStone/Sources/Toolbox/SortedFrames.cpp Thu Nov 12 19:27:08 2020 +0100 +++ b/OrthancStone/Sources/Toolbox/SortedFrames.cpp Thu Nov 12 20:56:04 2020 +0100 @@ -426,7 +426,6 @@ for (size_t i = 1; i < frames_.size(); i++) { double d = frames_[i].ComputeDistance(point); - printf("%f ", d); if (d < closestDistance) { frameIndex = i; @@ -434,7 +433,6 @@ } } - printf("\n>> %f\n", closestDistance); return (closestDistance <= maximumDistance); } }