namespace Yw.WinFrmUI.Hydro { /// /// /// public partial class NetworkL3d { /// /// 判断是否存在 /// public bool IsExist(string id) { return _parters.Exists(x => x.Id == id); } /// /// 获取包围盒 /// public BoundingBoxL3d GetBoundingBox() { var minX = float.MaxValue; var minY = float.MaxValue; var minZ = float.MaxValue; var maxX = float.MinValue; var maxY = float.MinValue; var maxZ = float.MinValue; foreach (var node in this.Nodes) { minX = Math.Min(minX, node.Position.X); minY = Math.Min(minY, node.Position.Y); minZ = Math.Min(minZ, node.Position.Z); maxX = Math.Max(maxX, node.Position.X); maxY = Math.Max(maxY, node.Position.Y); maxZ = Math.Max(maxZ, node.Position.Z); } return new BoundingBoxL3d() { Min = new PointL3d(minX, minY, minZ), Max = new PointL3d(maxX, maxY, maxZ) }; } /// /// 获取中心点 /// public PointL3d GetCenter(BoundingBoxL3d boundingBox) { if (boundingBox == null) { boundingBox = GetBoundingBox(); } return boundingBox.GetCenter(); } } }