|
using OpenTK.Mathematics;
|
|
namespace Yw.WinFrmUI.Hydro
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class NetworkL3d
|
{
|
|
/// <summary>
|
/// 判断是否存在
|
/// </summary>
|
public bool IsExist(string id)
|
{
|
return _parters.Exists(x => x.Id == id);
|
}
|
|
/// <summary>
|
/// 获取包围盒
|
/// </summary>
|
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)
|
};
|
}
|
|
/// <summary>
|
/// 获取中心点
|
/// </summary>
|
public PointL3d GetCenter(BoundingBoxL3d boundingBox)
|
{
|
if (boundingBox == null)
|
{
|
boundingBox = GetBoundingBox();
|
}
|
return boundingBox.GetCenter();
|
}
|
|
/// <summary>
|
/// 绘制2d
|
/// </summary>
|
public void Draw2d()
|
{
|
this.Links?.ForEach(x => x.Draw2d());
|
this.Nodes?.ForEach(x => x.Draw2d());
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
}
|