/// <summary> ///判断是否是导套 /// </summary> /// <returns></returns> public bool IsGuidePin() { Face face = this.Builder.CylFeater[0].CylinderFace[0].Data.Face; FaceLoopUtils.LoopList[] loopList = FaceLoopUtils.AskFaceLoops(face.Tag); string err = ""; Vector3d vec = new Vector3d(-this.Direction.X, -this.Direction.Y, -this.Direction.Z); if (loopList.Length != 2) { return(false); } foreach (FaceLoopUtils.LoopList lt in loopList) { if (lt.Type == 2 && lt.EdgeList.Length == 1) { Edge edge = NXObjectManager.Get(lt.EdgeList[0]) as Edge; if (edge.SolidEdgeType == Edge.EdgeType.Circular) { ArcEdgeData data = EdgeUtils.GetArcData(edge, ref err); if (data.Radius >= 8 && UMathUtils.IsEqual(data.Angle, Math.PI * 2)) { int count1 = TraceARay.AskTraceARay(this.Body, data.Center, vec); int count2 = TraceARay.AskTraceARay(this.Body, data.Center, this.Direction); if (count1 == 0 && count2 == 0) { return(true); } } } } } return(false); }
/// <summary> /// 获取顶边 /// </summary> /// <returns></returns> public ArcEdgeData GetTopEdge() { string err = ""; List <ArcEdgeData> arcs = new List <ArcEdgeData>(); foreach (Edge eg in this.Builder.CylFeater[0].Cylinder.Data.Face.GetEdges()) { if (eg.SolidEdgeType == Edge.EdgeType.Circular) { ArcEdgeData data = EdgeUtils.GetArcData(eg, ref err); arcs.Add(data); } } arcs.Sort(delegate(ArcEdgeData a, ArcEdgeData b) { Matrix4 mat = this.Builder.CylFeater[0].Cylinder.Matr; Point3d centerPt1 = a.Center; Point3d centerPt2 = b.Center; mat.ApplyPos(ref centerPt1); mat.ApplyPos(ref centerPt2); return(centerPt2.Z.CompareTo(centerPt1.Z)); }); return(arcs[0]); }
/// <summary> /// 判断是否是圆环面 /// </summary> /// <param name="face"></param> /// <param name="arcEdge"></param> /// <returns></returns> public static bool IsCircleAnnylus(Face face, out List <ArcEdgeData> arcEdge) { arcEdge = new List <ArcEdgeData>(); FaceLoopUtils.LoopList[] loops = FaceLoopUtils.AskFaceLoops(face.Tag); List <ArcEdgeData> arc = new List <ArcEdgeData>(); string err = ""; foreach (FaceLoopUtils.LoopList lt in loops) { if (lt.Type == 1) { foreach (Tag egTag in lt.EdgeList) { Edge ed = NXObjectManager.Get(egTag) as Edge; if (ed.SolidEdgeType == Edge.EdgeType.Circular) { ArcEdgeData arcData = EdgeUtils.GetArcData(ed, ref err); if (arcData.Angle >= Math.PI) { arc.Add(arcData); } } } } } if (arc.Count == 0) { return(false); } else if (arc.Count == 1) { arcEdge.Add(arc[0]); return(true); } else { var temp = arc.GroupBy(a => a.Center); int cout = 0; foreach (var tp in temp) { int tpCont = tp.Count(); if (cout < tpCont) { cout = tpCont; } } if (cout == 1) { double anlge = arc.Max(a => a.Angle); arcEdge.Add(arc.Find(a => a.Angle == anlge)); return(true); } else { foreach (var tp in temp) { int tpCont = tp.Count(); if (cout == tpCont) { arcEdge.AddRange(tp); return(true); } } } } return(false); }