/// <summary> /// 判断是否是一个孔 /// </summary> /// <param name="other"></param> /// <returns></returns> public bool IsTheSameHole(AbstractCircleFace other) { double angle = UMathUtils.Angle(this.Data.Dir, other.Data.Dir); if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false) { return(false); } Vector3d vec1 = new Vector3d(); Vector3d vec2 = new Vector3d(); if (UMathUtils.IsEqual(this.CenterPt, other.CenterPt)) { vec1 = this.Data.Dir; vec2 = new Vector3d(-vec1.X, -vec1.Y, -vec1.Z); } else { vec1 = UMathUtils.GetVector(this.CenterPt, other.CenterPt); vec2 = UMathUtils.GetVector(other.CenterPt, this.CenterPt); } angle = UMathUtils.Angle(this.Data.Dir, vec1); if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false) { return(false); } if (TraceARay.AskTraceARay(this.Data.Face.GetBody(), this.CenterPt, vec1) > 1 && TraceARay.AskTraceARay(other.Data.Face.GetBody(), other.CenterPt, vec2) > 1) { return(false); } return(true); }
public override List <StandardPartsName> GetGuidePillar() { List <MoldBaseModel> dowFace = this.FaceEiectorPlates.FindAll(a => a.CenterPt.Z < 0); List <MoldBaseModel> dow = this.DowEiectorPlates.FindAll(a => a.CenterPt.Z < 0); List <AbstractCylinderBody> pillars = new List <AbstractCylinderBody>(); List <AbstractCylinderBody> pillar = this.cylinderBody.FindAll(a => a.Radius >= 7 && a.IsGuidePillar()); foreach (AbstractCylinderBody ab in pin) { AbstractCylinderBody pi = pillar.Find(a => UMathUtils.IsEqual(a.StratPt.X, ab.StratPt.X) && UMathUtils.IsEqual(a.StratPt.Y, ab.StratPt.Y)); //if (!pillars.Exists(a => a.Equals(pi))) //{ // pillars.Add(pi); //} if (pi != null) { pi.Name = "导柱"; pillars.Add(pi); pillar.Remove(pi); } } if (this.SupportPlate != null && dowFace.Count != 0 && dow.Count != 0) { foreach (AbstractCylinderBody ab in pillar) { Point3d start = ab.StratPt; Point3d end = ab.EndPt; this.analysis.Matr.ApplyPos(ref start); this.analysis.Matr.ApplyPos(ref end); Vector3d vec = UMathUtils.GetVector(this.DowEiectorPlates[0].CenterPt, this.SupportPlate.CenterPt); if (UMathUtils.IsEqual(UMathUtils.Angle(vec, ab.Direction), 0) && UMathUtils.IsEqual(start.Z, dow[0].CenterPt.Z + dow[0].DisPt.Z) && end.Z > this.SupportPlate.CenterPt.Z - this.SupportPlate.DisPt.Z) { ab.Name = "回针"; pillars.Add(ab); } } } else if (this.SupportPlate == null && dowFace.Count != 0 && dow.Count != 0) { foreach (AbstractCylinderBody ab in pillar) { Point3d start = ab.StratPt; Point3d end = ab.EndPt; this.analysis.Matr.ApplyPos(ref start); this.analysis.Matr.ApplyPos(ref end); Vector3d vec = UMathUtils.GetVector(this.DowEiectorPlates[0].CenterPt, this.BMoldBase.CenterPt); if (UMathUtils.IsEqual(UMathUtils.Angle(vec, ab.Direction), 0) && UMathUtils.IsEqual(start.Z, dow[0].CenterPt.Z + dow[0].DisPt.Z) && end.Z > this.BMoldBase.CenterPt.Z - this.BMoldBase.DisPt.Z) { ab.Name = "回针"; pillars.Add(ab); } } } return(GetCyliderName(pillars)); }
protected override void GetDirection() { Point3d pt1 = this.Builder.CylFeater[0].Cylinder.CenterPt; Point3d pt2 = this.Builder.CylFeater[1].Cylinder.CenterPt; Vector3d vec = UMathUtils.GetVector(pt1, pt2); this.Direction = vec; this.Builder.SetDirection(vec); }
/// <summary> /// 圆形凸台 /// </summary> /// <param name="other"></param> /// <returns></returns> public bool IsCircleStep(AbstractCircleFace other) { double angle = UMathUtils.Angle(this.Data.Dir, other.Data.Dir); if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false) { return(false); } Vector3d vec1 = UMathUtils.GetVector(this.CenterPt, other.CenterPt); angle = UMathUtils.Angle(this.Data.Dir, vec1); if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false) { return(false); } return(true); }
/// <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); }
/// <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); }
protected override void GetDirection() { this.Direction = UMathUtils.GetVector(this.Builder.CylFeater[0].Cylinder.CenterPt, this.Builder.CylFeater[1].Cylinder.CenterPt); this.Builder.SetDirection(this.Direction); }