private void GetDowBaseModel() { List <MoldBaseModel> down = analysis.GetDownModel(this.moldbase); if (down.Count > 0) { if (down[down.Count - 1].DisPt.Z * 2 <= 10 && down.Count != 1) { down.RemoveAt(down.Count - 1); } if (UMathUtils.IsEqual(down[0].CenterPt.Z + down[0].DisPt.Z, this.BMoldBase.CenterPt.Z - this.BMoldBase.DisPt.Z) && UMathUtils.IsEqual(down[0].CenterPt.X, 0) && UMathUtils.IsEqual(down[0].CenterPt.Y, 0)) { this.SupportPlate = down[0]; this.SupportPlate.Name = "托板"; } if (down.Count > 1) { this.Baseplate = down[down.Count - 1]; this.Baseplate.Name = "底板"; } MoldBaseModel kon = this.analysis.GetKnockoutPlate(this.moldbase); if (kon != null) { this.PushPlate = kon; this.PushPlate.Name = "推板"; } List <MoldBaseModel> spa = this.analysis.GetSpacer(down); //方铁 if (spa.Count > 0) { this.Spacer.AddRange(spa); List <MoldBaseModel> eiec = this.analysis.GetEiectorPlates(this.moldbase, spa); if (eiec.Count != 0) { double max = eiec.Max(a => a.CenterPt.Z); foreach (MoldBaseModel mm in eiec) { if (UMathUtils.IsEqual(mm.CenterPt.Z, max)) { mm.Name = "面针板"; FaceEiectorPlates.Add(mm); } else { mm.Name = "底针板"; DowEiectorPlates.Add(mm); } } } } } foreach (MoldBaseModel mm in down) //无名板 { if (mm.Name == null || mm.Name.Equals("")) { this.OtherBaseModel.Add(mm); } } }
protected bool IsPassThrough(AbstractCylinderBody ab, MoldBaseModel start, MoldBaseModel end) { double anlge = UMathUtils.Angle(analysis.Matr.GetZAxis(), ab.Direction); Point3d startPt = ab.StratPt; Point3d endPt = ab.EndPt; this.analysis.Matr.ApplyPos(ref startPt); this.analysis.Matr.ApplyPos(ref endPt); if (UMathUtils.IsEqual(anlge, 0)) { if (startPt.Z > start.CenterPt.Z - start.DisPt.Z && endPt.Z < end.CenterPt.Z + end.DisPt.Z && startPt.Z < end.CenterPt.Z - end.DisPt.Z) { return(true); } } if (UMathUtils.IsEqual(anlge, Math.PI)) { if (startPt.Z < start.CenterPt.Z + start.DisPt.Z && endPt.Z > end.CenterPt.Z - end.DisPt.Z && startPt.Z > end.CenterPt.Z + end.DisPt.Z) { return(true); } } return(false); }
/// <summary> /// 获取上模板 /// </summary> protected override void GetUpBaseModel() { List <MoldBaseModel> up = analysis.GetUpModel(this.moldbase); if (up.Count > 0) { if (up[up.Count - 1].DisPt.Z <= 5 && up.Count != 1) { up.RemoveAt(up.Count - 1); } if (up.Count == 1) { this.UpBaseplate = up[0]; this.UpBaseplate.Name = "水口板"; } else { if (UMathUtils.IsEqual(up[0].CenterPt.Z - up[0].DisPt.Z, this.AMoldBase.CenterPt.Z + this.AMoldBase.DisPt.Z)) { this.ShuiSupportPlate = up[0]; this.ShuiSupportPlate.Name = "水口推板"; } this.UpBaseplate = up[up.Count - 1]; this.UpBaseplate.Name = "水口板"; } List <MoldBaseModel> spa = this.analysis.GetSpacer(up); //方铁 if (spa.Count > 0) { this.Spacer.AddRange(spa); List <MoldBaseModel> eiec = this.analysis.GetEiectorPlates(this.moldbase, spa); if (eiec.Count > 0) { double max = eiec.Max(a => a.CenterPt.Z); foreach (MoldBaseModel mm in eiec) { if (UMathUtils.IsEqual(mm.CenterPt.Z, max)) { mm.Name = "底针板"; DowEiectorPlates.Add(mm); } else { mm.Name = "面针板"; this.FaceEiectorPlates.Add(mm); } } } } } foreach (MoldBaseModel mm in up) //无名板 { if (mm.Name == null || mm.Name.Equals("")) { this.OtherBaseModel.Add(mm); } } }
/// <summary> /// 根据AB板得到矩阵 /// </summary> /// <returns></returns> private Matrix4 GetMatr() { CoordinateSystem wcs = workPart.WCS.CoordinateSystem; Matrix4 mat = new Matrix4(); mat.Identity(); mat.TransformToCsys(wcs, ref mat); Matrix4 inv = mat.GetInversMatrix(); CartesianCoordinateSystem cs = BoundingBoxUtils.CreateCoordinateSystem(mat, inv); MoldBaseModel aMold = new MoldBaseModel(aBody, mat, cs); MoldBaseModel bMold = new MoldBaseModel(bBody, mat, cs); Vector3d vec = UMathUtils.GetVector(bMold.CenterPt, aMold.CenterPt); Point3d center = UMathUtils.GetMiddle(bMold.CenterPt, aMold.CenterPt); inv.ApplyPos(ref center); mat.TransformToZAxis(center, vec); return(mat); }
public AnalysisMold(Body aBody, Body bBody) { this.aBody = aBody; this.bBody = bBody; workPart = Session.GetSession().Parts.Work; this.Matr = GetMatr(); Matrix4 inv = this.Matr.GetInversMatrix(); csys = BoundingBoxUtils.CreateCoordinateSystem(this.Matr, inv); MoldBaseModel aMold = new MoldBaseModel(aBody, Matr, csys); aMold.Name = "A板"; this.AMoldBase = aMold; MoldBaseModel bMold = new MoldBaseModel(bBody, Matr, csys); bMold.Name = "B板"; this.BMoldBase = bMold; }
/// <summary> /// 添加板件 /// </summary> /// <param name="body"></param> /// <returns></returns> public bool AddMoldBody(Body body, string name) { StepBuilder builder; BodyCircleFeater bf = new BodyCircleFeater(body); Matrix4 inv = this.analysis.Matr.GetInversMatrix(); CartesianCoordinateSystem csys = BoundingBoxUtils.CreateCoordinateSystem(this.analysis.Matr, inv); if (bf.IsCylinderBody(out builder)) { return(false); } else { MoldBaseModel mold = new MoldBaseModel(body, this.analysis.Matr, csys); mold.Name = name; this.OtherBaseModel.Add(mold); return(true); } }
/// <summary> /// 获取模板和圆柱形 /// </summary> /// <returns></returns> public void GetBase(out List <MoldBaseModel> moldBase, out List <AbstractCylinderBody> cylinder) { moldBase = new List <MoldBaseModel>(); cylinder = new List <AbstractCylinderBody>(); foreach (Body by in workPart.Bodies) { MoldBaseModel mm = new MoldBaseModel(by, this.Matr, csys); if ((UMathUtils.IsEqual(mm.CenterPt.X, 0) && UMathUtils.IsEqual(mm.CenterPt.Y, 0)) && ((Math.Round(mm.DisPt.X, 4) >= Math.Round(AMoldBase.DisPt.X, 4) && Math.Round(mm.DisPt.Y, 4) >= Math.Round(AMoldBase.DisPt.Y, 4)))) { moldBase.Add(mm); } else { StepBuilder builder; if (mm.DisPt.Z > mm.DisPt.X && mm.DisPt.Z > mm.DisPt.Y) { BodyCircleFeater bf = new BodyCircleFeater(by); if (bf.IsCylinderBody(out builder)) { AbstractCylinderBody ab = CylinderBodyFactory.Create(builder); if (ab != null) { double angle = UMathUtils.Angle(ab.Direction, this.Matr.GetZAxis()); if (UMathUtils.IsEqual(angle, 0) || UMathUtils.IsEqual(angle, Math.PI)) { cylinder.Add(ab); } } } } else if ((UMathUtils.IsEqual(mm.CenterPt.X, 0) || UMathUtils.IsEqual(mm.CenterPt.Y, 0)) && ((Math.Round(mm.DisPt.X, 4) >= Math.Round(AMoldBase.DisPt.X, 4) || Math.Round(mm.DisPt.Y, 4) >= Math.Round(AMoldBase.DisPt.Y, 4)))) { moldBase.Add(mm); } } } }
/// <summary> /// 获取螺栓 /// </summary> /// <returns></returns> public List <AbstractCylinderBody> GetBolt(List <AbstractCylinderBody> cylinder, MoldBaseModel other) { Vector3d vec = UMathUtils.GetVector(new Point3d(0, 0, this.CenterPt.Z), new Point3d(0, 0, other.CenterPt.Z)); List <AbstractCylinderBody> temp = cylinder.FindAll(a => UMathUtils.IsEqual(UMathUtils.Angle(vec, a.Direction), 0)); List <AbstractCylinderBody> bolt = new List <AbstractCylinderBody>(); foreach (AbstractCylinderBody ab in temp) { Point3d start = ab.StratPt; Point3d end = ab.EndPt; this.matr.ApplyPos(ref start); this.matr.ApplyPos(ref end); if ((start.Z > this.CenterPt.Z - this.DisPt.Z && start.Z < this.CenterPt.Z + this.DisPt.Z) && (end.Z > other.CenterPt.Z - other.DisPt.Z && end.Z <= other.CenterPt.Z + other.DisPt.Z)) { // ab.Name = "M" + Math.Ceiling(ab.Radius * 2).ToString(); ab.Name = "螺丝"; bolt.Add(ab); continue; } } return(bolt); }