namespace Yw.WpfUI.Hydro
{
///
/// 小管网输入参数
///
public class SmallInputL3d
{
///
///
///
public SmallInputL3d()
{
this.Scale = new PointL3d(1, 1, 1);
this.Vector = new PointL3d(0, 0, 1);
this.Angle = 0;
}
///
/// 基准节点
///
public NodeL3d BaseNode { get; set; }
///
/// 节点列表
///
public List Nodes { get; set; }
///
/// 管段列表
///
public List Links { get; set; }
///
/// 缩放
///
public PointL3d Scale { get; set; }
///
/// 方向
///
public PointL3d Vector { get; set; }
///
/// 旋转角度
///
public double Angle { get; set; }
//验证
public bool Verify()
{
if (this.BaseNode == null)
{
return false;
}
if (this.BaseNode.Position == null)
{
return false;
}
if (this.Nodes == null || this.Nodes.Count < 1)
{
return false;
}
if (this.Nodes.Exists(x => x.Position == null))
{
return false;
}
if (!this.Nodes.Contains(this.BaseNode))
{
return false;
}
if (this.Links == null || this.Links.Count < 1)
{
return false;
}
if (this.Links.Exists(x => x.StartNode == null || x.EndNode == null))
{
return false;
}
if (this.Links.Exists(x => !this.Nodes.Contains(x.StartNode) || !this.Nodes.Contains(x.EndNode)))
{
return false;
}
if (this.Scale == null)
{
this.Scale = new PointL3d(1, 1, 1);
}
if (this.Verify == null)
{
this.Vector = new PointL3d(0, 0, 1);
}
return true;
}
///
/// 克隆
///
public SmallInputL3d CloneC()
{
var input = new SmallInputL3d();
input.Angle = this.Angle;
if (this.Vector != null)
{
input.Vector = new PointL3d(this.Vector);
}
if (this.Scale != null)
{
input.Scale = new PointL3d(this.Scale);
}
var ndict = new Dictionary();
if (this.Nodes != null && this.Nodes.Count > 0)
{
input.Nodes = new List();
foreach (var node in this.Nodes)
{
var nodec = (NodeL3d)node.CloneC();
ndict.Add(node, nodec);
input.Nodes.Add(nodec);
}
}
if (ndict.ContainsKey(this.BaseNode))
{
input.BaseNode = ndict[this.BaseNode];
}
if (this.Links != null && this.Links.Count > 0)
{
input.Links = new List();
foreach (var link in this.Links)
{
var linkc = (LinkL3d)link.CloneC();
input.Links.Add(linkc);
if (link.StartNode != null)
{
if (ndict.ContainsKey(link.StartNode))
{
linkc.StartNode = ndict[link.StartNode];
}
}
if (link.EndNode != null)
{
if (ndict.ContainsKey(link.EndNode))
{
linkc.EndNode = ndict[link.EndNode];
}
}
}
}
return input;
}
}
}