/// <summary> /// Gets the point and the plane about space direction relationship. /// </summary> /// <param name="pt"></param> /// <param name="box"></param> /// <returns></returns> public static GeometryPosition GetSpacePosition(this XYZ pt, PickedBox box) { GeometryPosition result; var pt1 = pt.GetRoundPoint(); var xs = new[] { NumberUtil.GetRound(box.Min.X), NumberUtil.GetRound(box.Max.X) }; var ys = new[] { NumberUtil.GetRound(box.Min.Y), NumberUtil.GetRound(box.Max.Y) }; var zs = new[] { NumberUtil.GetRound(box.Min.Z), NumberUtil.GetRound(box.Max.Z) }; var minPt = new XYZ(xs.Min(), ys.Min(), zs.Min()); var maxPt = new XYZ(xs.Max(), ys.Max(), zs.Max()); var position = pt.GetPlanePosition(box); switch (position) { case GeometryPosition.Other when pt1.Z <minPt.Z: case GeometryPosition.Other when pt1.Z> maxPt.Z: result = GeometryPosition.Other; break; case GeometryPosition.Edge when zs.Contains(pt1.Z): result = GeometryPosition.Edge; break; default: result = GeometryPosition.Inner; break; } return(result); }
/// <summary> /// Gets the point and the plane about plane direction relationship. /// </summary> /// <param name="pt"></param> /// <param name="box"></param> /// <returns></returns> public static GeometryPosition GetPlanePosition(this XYZ pt, PickedBox box) { GeometryPosition result; var pointl = pt.GetRoundPoint(); var xs = new[] { NumberUtil.GetRound(box.Min.X), NumberUtil.GetRound(box.Max.X) }; var ys = new[] { NumberUtil.GetRound(box.Min.Y), NumberUtil.GetRound(box.Max.Y) }; var minPt = new XYZ(xs.Min(), ys.Min(), 0); var maxPt = new XYZ(xs.Max(), ys.Max(), 0); if (pointl.X < minPt.X) { result = GeometryPosition.Other; } else if (pointl.Y < minPt.Y) { result = GeometryPosition.Other; } else if (pointl.X > maxPt.X) { result = GeometryPosition.Other; } else if (pointl.Y > maxPt.Y) { result = GeometryPosition.Other; } else if (xs.Contains(pointl.X) && ys.Contains(pointl.Y)) { result = GeometryPosition.Edge; } else { result = GeometryPosition.Inner; } return(result); }