public bool IsInSameFrameOfReference(DicomImagePlane other) { Frame otherFrame = other._sourceFrame; if (_sourceFrame.ParentImageSop.StudyInstanceUid != otherFrame.ParentImageSop.StudyInstanceUid) { return(false); } return(this._sourceFrame.FrameOfReferenceUid == otherFrame.FrameOfReferenceUid); }
private static ReferenceLine GetReferenceLine(DicomImagePlane referenceImagePlane, DicomImagePlane targetImagePlane) { Vector3D intersectionPatient1, intersectionPatient2; if (!referenceImagePlane.GetIntersectionPoints(targetImagePlane, out intersectionPatient1, out intersectionPatient2)) { return(null); } Vector3D intersectionImagePlane1 = targetImagePlane.ConvertToImagePlane(intersectionPatient1); Vector3D intersectionImagePlane2 = targetImagePlane.ConvertToImagePlane(intersectionPatient2); //The coordinates need to be converted to pixel coordinates because right now they are in mm. PointF intersectionImage1 = targetImagePlane.ConvertToImage(new PointF(intersectionImagePlane1.X, intersectionImagePlane1.Y)); PointF intersectionImage2 = targetImagePlane.ConvertToImage(new PointF(intersectionImagePlane2.X, intersectionImagePlane2.Y)); string label = referenceImagePlane.InstanceNumber.ToString(); return(new ReferenceLine(intersectionImage1, intersectionImage2, label)); }
public bool GetIntersectionPoints(DicomImagePlane other, out Vector3D intersectionPointPatient1, out Vector3D intersectionPointPatient2) { intersectionPointPatient1 = intersectionPointPatient2 = null; Vector3D[,] lineSegmentsImagePlaneBounds = new Vector3D[, ] { // Bounding line segments of this (reference) image plane. { PositionPatientTopLeft, PositionPatientTopRight }, { PositionPatientTopLeft, PositionPatientBottomLeft }, { PositionPatientBottomRight, PositionPatientTopRight }, { PositionPatientBottomRight, PositionPatientBottomLeft } }; List <Vector3D> planeIntersectionPoints = new List <Vector3D>(); for (int i = 0; i < 4; ++i) { // Intersect the bounding line segments of the reference image with the plane of the target image. Vector3D intersectionPoint = Vector3D.GetLinePlaneIntersection(other.Normal, other.PositionPatientCenterOfImage, lineSegmentsImagePlaneBounds[i, 0], lineSegmentsImagePlaneBounds[i, 1], true); if (intersectionPoint != null) { planeIntersectionPoints.Add(intersectionPoint); } } if (planeIntersectionPoints.Count < 2) { return(false); } intersectionPointPatient1 = planeIntersectionPoints[0]; intersectionPointPatient2 = CollectionUtils.SelectFirst(planeIntersectionPoints, delegate(Vector3D point) { return(!planeIntersectionPoints[0].Equals(point)); }); return(intersectionPointPatient1 != null && intersectionPointPatient2 != null); }
public float GetAngleBetween(DicomImagePlane other) { return(Normal.GetAngleBetween(other.Normal)); }
public bool IsOrthogonalTo(DicomImagePlane other, float angleTolerance) { return(Normal.IsOrthogonalTo(other.Normal, angleTolerance)); }
public void Toggle() { if (this.SelectedOverlayGraphicsProvider == null) { return; } if (this.SelectedPresentationImage == null) { return; } try { var selectPresentationImage = this.SelectedPresentationImage; IPrintViewImageViewer printViewImageViewer = this.ImageViewer as IPrintViewImageViewer; if (printViewImageViewer.ReferenceLines.ContainsKey(selectPresentationImage)) { foreach (var referenceLine in printViewImageViewer.ReferenceLines[selectPresentationImage]) { this.SelectedOverlayGraphicsProvider.OverlayGraphics.Remove(referenceLine); } } else { printViewImageViewer.ReferenceLines.Add(selectPresentationImage, new List <IGraphic>()); } DicomImagePlane targetImagePlane = DicomImagePlane.FromImage(selectPresentationImage); if (targetImagePlane == null) { return; } IDisplaySet displaySet = this.Context.Viewer.SelectedImageBox.DisplaySet; List <ReferenceLine> lines = new List <ReferenceLine>(); int index = 0; foreach (var referenceImage in displaySet.PresentationImages) { index++; if (referenceImage == selectPresentationImage) { continue; } if (jgCount != 0 && index % jgCount != 0) { continue; } DicomImagePlane referenceImagePlane = DicomImagePlane.FromImage(referenceImage); if (referenceImagePlane == null) { continue; } if (referenceImagePlane.StudyInstanceUid == targetImagePlane.StudyInstanceUid) { ReferenceLine line = GetReferenceLine(referenceImagePlane, targetImagePlane); // CompositeGraphic lineGraphic = new CompositeGraphic(); LinePrimitive linePrimitive = new LinePrimitive(); linePrimitive.LineStyle = LineStyle.Dash; linePrimitive.Point1 = line.StartPoint; linePrimitive.Point2 = line.EndPoint; InvariantTextPrimitive text = new InvariantTextPrimitive(line.Label); text.Location = new PointF(line.EndPoint.X + 10, line.EndPoint.Y); //lineGraphic.Graphics.Add(linePrimitive); //lineGraphic.Graphics.Add(text); bool isHaveSameLine = false; foreach (var referenceLine in lines) { if (line.StartPoint == referenceLine.StartPoint && line.EndPoint == referenceLine.EndPoint) { isHaveSameLine = true; break; } } if (!isHaveSameLine) { lines.Add(line); this.SelectedOverlayGraphicsProvider.OverlayGraphics.Add(linePrimitive); this.SelectedOverlayGraphicsProvider.OverlayGraphics.Add(text); printViewImageViewer.ReferenceLines[selectPresentationImage].Add(linePrimitive); printViewImageViewer.ReferenceLines[selectPresentationImage].Add(text); } } } selectPresentationImage.Tile.Draw(); } catch (Exception) { IPrintViewImageViewer printViewImageViewer = this.ImageViewer as IPrintViewImageViewer; if (printViewImageViewer.ReferenceLines.ContainsKey(this.SelectedPresentationImage)) { printViewImageViewer.ReferenceLines.Remove(this.SelectedPresentationImage); } } }