namespace Yw.WinFrmUI.Hydro
|
{
|
/// <summary>
|
/// 包围盒缓存辅助类
|
/// </summary>
|
internal class BoundingBox32dCacheHelper
|
{
|
|
/// <summary>
|
///
|
/// </summary>
|
public BoundingBox32dCacheHelper(NetworkL3d nw, Vector32dCacheHelper vc)
|
{
|
_nw = nw;
|
_vc = vc;
|
Initial();
|
}
|
|
private NetworkL3d _nw = null;
|
private Vector32dCacheHelper _vc = null;
|
private Dictionary<string, BoundingBox3> _dict = new();
|
|
//初始化
|
private void Initial()
|
{
|
if (_nw == null)
|
{
|
return;
|
}
|
if (_vc == null)
|
{
|
return;
|
}
|
_dict.Clear();
|
_nw.Nodes.ForEach(x =>
|
{
|
var pts = _vc.GetPositions(x.Id);
|
if (pts != null && pts.Count > 0)
|
{
|
var bx = BoundingBox3Helper.CalcuPointBoundingBox(pts[0], x.Style2d.Normal.Radiu);
|
_dict.Add(x.Id, bx);
|
}
|
});
|
_nw.Links.ForEach((Action<LinkL3d>)(x =>
|
{
|
var pts = _vc.GetPositions(x.Id);
|
if (pts != null && pts.Count > 0)
|
{
|
var bx = BoundingBox3Helper.CalcuLineBoundingBox(pts[0], pts[1], x.Style2d.Normal.Width);
|
_dict.Add(x.Id, bx);
|
}
|
}));
|
}
|
|
/// <summary>
|
/// 获取包围盒
|
/// </summary>
|
public BoundingBox3 GetBoundingBox(string id)
|
{
|
if (_dict.ContainsKey(id))
|
{
|
return _dict[id];
|
}
|
return default;
|
}
|
|
}
|
}
|