Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        private void SendRFIDEvent(string incomingUID)
        {
            EdgeResponse resp = EdgeUtils.NewSuccessResponse();
            rfidevent    e    = new rfidevent
            {
                Uid = incomingUID
            };

            resp.Payload = e.ToByteString();
            observer.SendEvent(resp);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取边
        /// </summary>
        /// <param name="xEdge"></param>
        /// <param name="yEdge"></param>
        public void GetEdge(out List <Edge> xEdge, out Point centerCom)
        {
            xEdge     = new List <Edge>();
            centerCom = null;
            string         str = "";
            ElectrodeModel ele = null;

            foreach (ElectrodeModel em in eleModels)
            {
                if (em.Info.AllInfo.SetValue.Positioning == "" || em.Info.AllInfo.SetValue.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    ele = em;
                }
            }
            if (ele == null)
            {
                return;
            }

            List <Face> faces = new List <Face>();

            faces.AddRange(ele.PartTag.Bodies.ToArray()[0].GetFaces());
            Point elePoint = ele.GetSetPoint();

            faces.Sort(delegate(Face a, Face b)
            {
                FaceData data1 = FaceUtils.AskFaceData(a);
                FaceData data2 = FaceUtils.AskFaceData(b);
                return(data1.Point.Z.CompareTo((data2.Point.Z)));
            });
            foreach (Component ct in AssmbliesUtils.GetPartComp(this.PartTag, ele.PartTag))
            {
                ElectrodeSetValueInfo value = ElectrodeSetValueInfo.GetAttribute(ct);
                if (value.Positioning == "" || value.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    centerCom = AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, elePoint.Tag) as Point;
                    foreach (Edge eg in faces[10].GetEdges())
                    {
                        NXOpen.UF.UFEval.Line lineData;
                        if (EdgeUtils.GetLineData(eg, out lineData, ref str))
                        {
                            if (UMathUtils.IsEqual(lineData.start[1], lineData.end[1]))
                            {
                                xEdge.Add(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, eg.Tag) as Edge);
                            }
                        }
                    }
                }
            }
        }
        public override void GetSlopeAndDia(Vector3d vec, out double[] slope, out double[] dia)
        {
            slope = new double[2] {
                99999, -99999
            };
            dia = new double[2] {
                99999, -99999
            };
            double anlge = UMathUtils.Angle(vec, Data.Dir);

            if (UMathUtils.IsEqual(anlge, 0) || UMathUtils.IsEqual(anlge, Math.PI))
            {
                slope[0] = slope[1] = UMathUtils.Angle(vec, FaceUtils.AskFaceNormal(this.Data.Face));
                foreach (Edge edge in this.Data.Face.GetEdges())
                {
                    if (edge.SolidEdgeType == Edge.EdgeType.Circular)
                    {
                        double radius = EdgeUtils.GetArcRadius(edge);

                        if (2 * radius > dia[1])
                        {
                            dia[1] = 2 * radius;
                        }
                        if (2 * radius < dia[0])
                        {
                            dia[0] = 2 * radius;
                        }
                    }
                }
                if (dia[0] == 99999)
                {
                    dia[0] = 0;
                }
            }
            else
            {
                double[] rid;
                FaceUtils.GetSweptSlope(this.Data.Face, vec, out slope, out rid);
                dia[0] = 2 * rid[0];
                dia[1] = 2 * rid[1];
            }
        }
Ejemplo n.º 5
0
        public void GetEdge(Face face, out List <Edge> xEdge, out List <Edge> yEdge)
        {
            xEdge = new List <Edge>();
            yEdge = new List <Edge>();
            string str = "";

            NXOpen.Assemblies.Component ct = AssmbliesUtils.GetPartComp(this.DraModel.PartTag, this.EleModel.PartTag);
            foreach (Edge eg in face.GetEdges())
            {
                NXOpen.UF.UFEval.Line lineData;
                if (EdgeUtils.GetLineData(eg, out lineData, ref str))
                {
                    if (UMathUtils.IsEqual(lineData.start[1], lineData.end[1]))
                    {
                        xEdge.Add(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, eg.Tag) as Edge);
                    }
                    if (UMathUtils.IsEqual(lineData.start[0], lineData.end[0]))
                    {
                        yEdge.Add(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, eg.Tag) as Edge);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <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]);
        }
Ejemplo n.º 7
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);
        }