public override Snap.NX.Face GetChamferFace() { if (ChamferFace != null) { return(ChamferFace); } Snap.NX.Face result = null; var results = new List <Snap.NX.Face>(); if (BaseFace != null) { var baseFOriention = new Snap.Orientation(BaseFace.GetFaceDirection()); var v1 = Snap.Vector.Unit(baseFOriention.AxisX); var v2 = Snap.Vector.Unit(baseFOriention.AxisY); var v3 = Snap.Vector.Unit(v1 + v2); var v4 = v3.Copy(Snap.Geom.Transform.CreateRotation(new Snap.Position(), BaseFace.GetFaceDirection(), 90)).Unitize(); var chamferFaces = ElecBody.Faces.Where(u => u.ObjectSubType == Snap.NX.ObjectTypes.SubType.FacePlane && Snap.Compute.Distance(u, BaseFace) < SnapEx.Helper.Tolerance).ToList(); chamferFaces.ForEach(u => { var faceDir = u.GetFaceDirection(); if (SnapEx.Helper.Equals(v3, faceDir, SnapEx.Helper.Tolerance) || SnapEx.Helper.Equals(-v3, faceDir, SnapEx.Helper.Tolerance) || SnapEx.Helper.Equals(-v4, faceDir, SnapEx.Helper.Tolerance) || SnapEx.Helper.Equals(v4, faceDir, SnapEx.Helper.Tolerance) ) { results.Add(u); } }); } result = results.FirstOrDefault(); if (results.Count > 1) { var baseFaceBoxUV = BaseFace.BoxUV; var elecBasePos = BaseFace.Position((baseFaceBoxUV.MinU + baseFaceBoxUV.MaxU) / 2, (baseFaceBoxUV.MinV + baseFaceBoxUV.MaxV) / 2); var faceDirection = BaseFace.GetFaceDirection(); var plane = new Snap.Geom.Surface.Plane(elecBasePos, faceDirection); foreach (var u in results) { var uv = u.BoxUV; var cneterPoint = u.Position((uv.MaxU + uv.MinU) / 2, (uv.MaxV + uv.MaxV) / 2); var resullt = Snap.Compute.ClosestPoints(cneterPoint, plane); var dir = Snap.Vector.Unit(resullt.Point1 - resullt.Point2); if (SnapEx.Helper.Equals(dir, -faceDirection) && Snap.Compute.Distance(BaseFace, u) < SnapEx.Helper.Tolerance) { result = u; break; } } } ChamferFace = result; return(result); }
/// <summary> /// 获取所有的电极头部面 /// </summary> protected static List <Snap.NX.Face> GetElecHeadFaces(List <Snap.NX.Face> faces, Snap.NX.Face baseFace, out List <Snap.NX.Face> sideFaces) { var headFaces = new List <Snap.NX.Face>(); var tempSideFaces = new List <Snap.NX.Face>(); if (baseFace != null) { //头部面 var allFace = faces.ToList(); var baseFaceBoxUV = baseFace.BoxUV; var elecBasePos = baseFace.Position((baseFaceBoxUV.MinU + baseFaceBoxUV.MaxU) / 2, (baseFaceBoxUV.MinV + baseFaceBoxUV.MaxV) / 2); allFace.RemoveAll(u => u.NXOpenTag == baseFace.NXOpenTag); var faceDirection = baseFace.GetFaceDirection(); var plane = new Snap.Geom.Surface.Plane(elecBasePos, faceDirection); allFace.ToList().ForEach(u => { try { var uv = u.BoxEx(); var cneterPoint = new Snap.Position((uv.MaxX + uv.MinX) / 2, (uv.MaxY + uv.MinY) / 2, (uv.MaxZ + uv.MinZ) / 2); var resullt = Snap.Compute.ClosestPoints(cneterPoint, plane); var dir = Snap.Vector.Unit(resullt.Point1 - resullt.Point2); if (SnapEx.Helper.Equals(dir, faceDirection)) { headFaces.Add(u); } else if (u.ObjectSubType == Snap.NX.ObjectTypes.SubType.FacePlane && SnapEx.Helper.Equals(dir, -faceDirection)) { tempSideFaces.Add(u); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }); } sideFaces = tempSideFaces; return(headFaces); }
internal PlaneResult(Snap.UI.Response response, Snap.Geom.Surface.Plane plane) { this.Response = response; this.Plane = plane; }
public virtual Snap.NX.Curve[] Divide(Snap.Geom.Surface.Plane geomPlane, Snap.Position helpPoint) { Compute.IntersectionResult result = Compute.IntersectInfo(this, geomPlane, helpPoint); return(this.Divide(new double[] { result.CurveParameter })); }
public override Snap.NX.Face GetChamferFace() { Snap.NX.Face result = null; var results = new List <Snap.NX.Face>(); if (BaseFace != null && DiagonalLine != null) { var boxUV = BaseFace.BoxUV; var points = new List <Snap.Position>(); points.Add(BaseFace.Position(boxUV.MinU, boxUV.MinV)); points.Add(BaseFace.Position(boxUV.MinU, boxUV.MaxV)); points.Add(BaseFace.Position(boxUV.MaxU, boxUV.MinV)); points.Add(BaseFace.Position(boxUV.MaxU, boxUV.MaxV)); points.RemoveAll(u => SnapEx.Helper.Equals(u, DiagonalLine.StartPoint, SnapEx.Helper.Tolerance)); points.RemoveAll(u => SnapEx.Helper.Equals(u, DiagonalLine.EndPoint, SnapEx.Helper.Tolerance)); var v1 = Snap.Vector.Unit(points.First() - DiagonalLine.StartPoint); var v2 = Snap.Vector.Unit(points.First() - DiagonalLine.EndPoint); var v3 = Snap.Vector.Unit(v1 + v2); var v4 = v3.Copy(Snap.Geom.Transform.CreateRotation(new Snap.Position(), BaseFace.GetFaceDirection(), 90)).Unitize(); if (points.Count > 0) { ElecBody.Faces.Where(u => u.ObjectSubType == Snap.NX.ObjectTypes.SubType.FacePlane).ToList().ForEach(u => { var faceDir = u.GetFaceDirection(); if (SnapEx.Helper.Equals(v3, faceDir, SnapEx.Helper.Tolerance) || SnapEx.Helper.Equals(-v3, faceDir, SnapEx.Helper.Tolerance) || SnapEx.Helper.Equals(-v4, faceDir, SnapEx.Helper.Tolerance) || SnapEx.Helper.Equals(v4, faceDir, SnapEx.Helper.Tolerance) ) { results.Add(u); } }); } } result = results.FirstOrDefault(); if (results.Count > 1) { var baseFaceBoxUV = BaseFace.BoxUV; var elecBasePos = BaseFace.Position((baseFaceBoxUV.MinU + baseFaceBoxUV.MaxU) / 2, (baseFaceBoxUV.MinV + baseFaceBoxUV.MaxV) / 2); var faceDirection = BaseFace.GetFaceDirection(); var plane = new Snap.Geom.Surface.Plane(elecBasePos, faceDirection); results.ForEach(u => { var uv = u.BoxUV; var cneterPoint = u.Position((uv.MaxU + uv.MinU) / 2, (uv.MaxV + uv.MaxV) / 2); var resullt = Snap.Compute.ClosestPoints(cneterPoint, plane); var dir = Snap.Vector.Unit(resullt.Point1 - resullt.Point2); if (SnapEx.Helper.Equals(dir, -faceDirection)) { result = u; return; } }); } ChamferFace = result; return(result); }