예제 #1
0
        /// <summary>
        /// 面上任意一点做射线
        /// </summary>
        /// <param name="face"></param>
        /// <param name="vec"></param>
        /// <returns></returns>
        public static int AskTraceARayForFaceData(Face face, Vector3d vec)
        {
            UFSession theUFSession = UFSession.GetUFSession();

            Tag[] bodyTag = { face.GetBody().Tag };
            UFModl.RayHitPointInfo[] info;
            Point3d originPt = GetFacePoint(face);

            double[] origin = { originPt.X, originPt.Y, originPt.Z };
            double[] dir    = { vec.X, vec.Y, vec.Z };
            double[] mat    = new double[16];
            theUFSession.Mtx4.Identity(mat);
            int res   = 0;
            int count = 0;

            theUFSession.Modl.TraceARay(1, bodyTag, origin, dir, mat, 0, out res, out info);
            foreach (UFModl.RayHitPointInfo ray in info)
            {
                Point3d temp = new Point3d(ray.hit_point[0], ray.hit_point[1], ray.hit_point[2]);
                double  dis  = UMathUtils.GetDis(originPt, temp);
                if (ray.hit_face != face.Tag && !UMathUtils.IsEqual(dis, 0))
                {
                    int statusPt = 0;
                    theUFSession.Modl.AskPointContainment(ray.hit_point, face.Tag, out statusPt);
                    if (statusPt != 3)
                    {
                        count++;
                    }
                }
            }
            return(count);
        }
예제 #2
0
        /// <summary>
        /// 比较两面是否是求差面
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool EqualsForSutract(FaceData other)
        {
            double anlge = UMathUtils.Angle(this.Dir, other.Dir);

            if (this.FaceType == other.FaceType && UMathUtils.IsEqual(anlge, Math.PI) && this.IntNorm == -other.IntNorm)
            {
                double[]    ptOnObj1 = new double[3];
                double[]    ptOnObj2 = new double[3];
                double      minDis   = AnalysisUtils.AskMinimumDist(this.Face.Tag, other.Face.Tag, out ptOnObj1, out ptOnObj2);
                Point3d     pt1      = new Point3d(ptOnObj1[0], ptOnObj1[1], ptOnObj1[2]);
                Point3d     pt2      = new Point3d(ptOnObj2[0], ptOnObj2[1], ptOnObj2[2]);
                List <Edge> edges1   = GetPointOnEdge(this.Face, ptOnObj1);
                List <Edge> edges2   = GetPointOnEdge(other.Face, ptOnObj2);
                bool        edgeBool = false;
                if (edges1.Count > 0 && edges2.Count > 0)
                {
                    foreach (Edge ed in edges1)
                    {
                        foreach (Edge ed1 in edges2)
                        {
                            if (ed.Tag == ed1.Tag)
                            {
                                edgeBool = true;
                            }
                        }
                    }
                }
                if (UMathUtils.IsEqual(minDis, 0) && UMathUtils.IsEqual(pt1, pt2) && !edgeBool)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
        public static ArcEdgeData GetArcData(Edge edge, ref string errorMsg)
        {
            if (edge.SolidEdgeType != Edge.EdgeType.Circular)
            {
                errorMsg = errorMsg + "该边不是圆弧";
                return(null);
            }

            NXOpen.UF.UFSession theUfSession = NXOpen.UF.UFSession.GetUFSession();
            IntPtr eval;

            theUfSession.Eval.Initialize(edge.Tag, out eval);

            NXOpen.UF.UFEval.Arc arc;
            try
            {
                theUfSession.Eval.AskArc(eval, out arc);
                ArcEdgeData arcData = new ArcEdgeData(edge);
                arcData.Center = new Point3d(arc.center[0], arc.center[1], arc.center[2]);
                arcData.Radius = arc.radius;

                arcData.IsWholeCircle = UMathUtils.IsEqual(Math.PI * 2, Math.Abs(arc.limits[1] - arc.limits[0]));
                arcData.Angle         = Math.Abs(arc.limits[1] - arc.limits[0]);
                return(arcData);
            }
            catch (Exception ex)
            {
                errorMsg += ex.Message;
                LogMgr.WriteLog("EdgeUtils:GetArcData1:" + edge.Tag.ToString() + ex.Message);
                throw ex;
            }
            finally
            {
                theUfSession.Eval.Free(eval);
            }
        }