/// <summary> /// 通过属性获取 /// </summary> /// <param name="bodys">一种齿(阵列)</param> /// <returns></returns> public ElectrodeToolhInfo[,] GetToolhInfosForAttribute(List <Body> bodys, Matrix4 matr, CartesianCoordinateSystem csys) { ElectrodeToolhInfo[,] info = new ElectrodeToolhInfo[this.PitchXNum, this.PitchYNum]; var toolhNumList = bodys.GroupBy(a => AttributeUtils.GetAttrForInt(a, "ToolhNumber")); List <BodyPitchClassify> bps = new List <BodyPitchClassify>(); foreach (var toolhNum in toolhNumList) { BodyPitchClassify bp = new BodyPitchClassify(toolhNum.ToList(), matr, csys, this.PitchXNum, this.PitchYNum); bp.SetAttribute(); bps.Add(bp); } for (int i = 0; i < this.PitchXNum; i++) { for (int k = 0; k < this.PitchYNum; k++) { List <Body> temp = new List <Body>(); foreach (BodyPitchClassify by in bps) { temp.Add(by.ClassifyBodys[i, k]); } info[i, k] = ElectrodeToolhInfo.GetToolhInfoForAttribute(temp.ToArray()); } } return(info); }
/// <summary> /// 通过属性获得 /// </summary> /// <param name="bodys">一种齿(没阵列)</param> /// <returns></returns> public static ElectrodeToolhInfo GetToolhInfoForAttribute(params Body[] bodys) { ElectrodeToolhInfo info = new ElectrodeToolhInfo(bodys); info.ToolhName = AttributeUtils.GetAttrForString(bodys[0], "ToolhName"); for (int i = 0; i < 2; i++) { info.Offset[i] = AttributeUtils.GetAttrForDouble(bodys[0], "Offset", i); } int k = 1; foreach (Body by in bodys) { BodyInfo byInfo = BodyInfo.GetAttribute(by); byInfo.Number = k; info.infos.Add(byInfo); k++; } return(info); }