using OpenTK.Mathematics; namespace Yw.WinFrmUI.Hydro { /// /// 三维点缓存辅助类 /// internal class Vector3CacheHelper { /// /// /// public Vector3CacheHelper(NetworkL3d nw) { _nw = nw; Initial(); } private NetworkL3d _nw = null; private Dictionary> _dict = new(); /// /// 是否初始化 /// public bool Initialized { get { if (_nw == null) { return false; } if (_dict.Count < 1) { return false; } return true; } } //初始化 private void Initial() { if (_nw == null) { return; } foreach (var visual in _nw.Visuals) { var pts = visual.GetPositions(); var vpts = pts.Select(x => new Vector3(x.X, x.Y, x.Z)).ToList(); _dict.Add(visual.Id, vpts); } } /// /// 获取所有 /// /// public List GetAll() { if (!Initialized) { return default; } return _dict.SelectMany(x => x.Value).Distinct().ToList(); } /// /// 通过 Id 获取 /// public List GetById(string Id) { if (string.IsNullOrEmpty(Id)) { return default; } if (_dict.ContainsKey(Id)) { return _dict[Id]; } return default; } } }