Ejemplo n.º 1
0
        public bool IsInSameFrameOfReference(DicomImagePlane other)
        {
            Frame otherFrame = other._sourceFrame;

            if (_sourceFrame.ParentImageSop.StudyInstanceUid != otherFrame.ParentImageSop.StudyInstanceUid)
            {
                return(false);
            }

            return(this._sourceFrame.FrameOfReferenceUid == otherFrame.FrameOfReferenceUid);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
		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;
		}
Ejemplo n.º 4
0
		public float GetAngleBetween(DicomImagePlane other)
		{
			return Normal.GetAngleBetween(other.Normal);
		}
Ejemplo n.º 5
0
		public bool IsOrthogonalTo(DicomImagePlane other, float angleTolerance)
		{
			return Normal.IsOrthogonalTo(other.Normal, angleTolerance);
		}
Ejemplo n.º 6
0
		public bool IsParallelTo(DicomImagePlane other, float angleTolerance)
		{
			return Normal.IsParallelTo(other.Normal, angleTolerance);
		}
Ejemplo n.º 7
0
		public bool IsInSameFrameOfReference(DicomImagePlane other)
		{
			Frame otherFrame = other._sourceFrame;

			if (_sourceFrame.ParentImageSop.StudyInstanceUid != otherFrame.ParentImageSop.StudyInstanceUid)
				return false;

			return this._sourceFrame.FrameOfReferenceUid == otherFrame.FrameOfReferenceUid;
		}
Ejemplo n.º 8
0
		private void InitializeWithCachedData(DicomImagePlane cachedData)
		{
			Normal = cachedData.Normal;
			PositionPatientTopLeft = cachedData.PositionPatientTopLeft;
			PositionPatientTopRight = cachedData.PositionPatientTopRight;
			PositionPatientBottomLeft = cachedData.PositionPatientBottomLeft;
			PositionPatientBottomRight = cachedData.PositionPatientBottomRight;
			PositionPatientCenterOfImage = cachedData.PositionPatientCenterOfImage;
			PositionImagePlaneTopLeft = cachedData.PositionImagePlaneTopLeft;
		}
Ejemplo n.º 9
0
		private static DicomImagePlane CreateFromFrame(Frame frame)
		{
			int height = frame.Rows - 1;
			int width = frame.Columns - 1;

			DicomImagePlane plane = new DicomImagePlane();
			plane.PositionPatientTopLeft = frame.ImagePlaneHelper.ConvertToPatient(new PointF(0, 0));
			plane.PositionPatientTopRight = frame.ImagePlaneHelper.ConvertToPatient(new PointF(width, 0));
			plane.PositionPatientBottomLeft = frame.ImagePlaneHelper.ConvertToPatient(new PointF(0, height));
			plane.PositionPatientBottomRight = frame.ImagePlaneHelper.ConvertToPatient(new PointF(width, height));
			plane.PositionPatientCenterOfImage = frame.ImagePlaneHelper.ConvertToPatient(new PointF(width / 2F, height / 2F));

			plane.Normal = frame.ImagePlaneHelper.GetNormalVector();

			if (plane.Normal == null || plane.PositionPatientCenterOfImage == null)
				return null;

			// here, we want the position in the coordinate system of the image plane, 
			// without moving the origin (e.g. leave it at the patient origin).
			plane.PositionImagePlaneTopLeft = frame.ImagePlaneHelper.ConvertToImagePlane(plane.PositionPatientTopLeft, Vector3D.Null);

			return plane;
		}
Ejemplo n.º 10
0
		private static DicomImagePlane CreateFromCache(Frame frame)
		{
			string key = String.Format("{0}:{1}", frame.ParentImageSop.SopInstanceUid, frame.FrameNumber);

			DicomImagePlane cachedData;
			if (ImagePlaneDataCache.ContainsKey(key))
			{
				cachedData = ImagePlaneDataCache[key];
			}
			else
			{
				cachedData = CreateFromFrame(frame);
				if (cachedData != null)
					ImagePlaneDataCache[key] = cachedData;
			}

			if (cachedData != null)
			{
				DicomImagePlane plane = new DicomImagePlane();
				plane.InitializeWithCachedData(cachedData);
				return plane;
			}

			return null;
		}
Ejemplo n.º 11
0
 public float GetAngleBetween(DicomImagePlane other)
 {
     return(Normal.GetAngleBetween(other.Normal));
 }
Ejemplo n.º 12
0
 public bool IsOrthogonalTo(DicomImagePlane other, float angleTolerance)
 {
     return(Normal.IsOrthogonalTo(other.Normal, angleTolerance));
 }