Ejemplo n.º 1
0
        /// <summary>
        /// 获取面的数据
        /// </summary>
        /// <param name="face"></param>
        /// <returns></returns>
        public static FaceData AskFaceData(Face face)
        {
            NXOpen.UF.UFSession uf = NXOpen.UF.UFSession.GetUFSession();

            int type;

            double[] point = new double[3];
            double[] dir   = new double[3];
            double[] box   = new double[6];
            double   radius;
            double   rad_data;
            int      norm_dir;

            uf.Modl.AskFaceData(face.Tag, out type, point, dir, box, out radius, out rad_data, out norm_dir);


            FaceData fd = new FaceData();

            fd.FaceType = type;

            //UVector dit = new UVector(dir[0], dir[1], dir[2]);
            //dit.Norm();

            fd.Dir = new Vector3d(dir[0], dir[1], dir[2]);

            fd.BoxMinCorner = new Point3d(box[0], box[1], box[2]);
            fd.BoxMaxCorner = new Point3d(box[3], box[4], box[5]);
            fd.Radius       = radius;
            fd.RadData      = rad_data;
            fd.IntNorm      = norm_dir;
            fd.Point        = new Point3d(point[0], point[1], point[2]);
            fd.Face         = face;
            return(fd);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取面上的点
        /// </summary>
        /// <param name="face"></param>
        /// <returns></returns>
        private static Point3d GetFacePoint(Face face)
        {
            UFSession theUFSession = UFSession.GetUFSession();
            int       statusPt;

            double[] point;
            FaceData data = FaceUtils.AskFaceData(face);

            point = new double[3] {
                data.Point.X, data.Point.Y, data.Point.Z
            };
            theUFSession.Modl.AskPointContainment(point, face.Tag, out statusPt);
            if (statusPt == 1)
            {
                return(data.Point);
            }
            else
            {
                double[] uvs = new double[4];
                theUFSession.Modl.AskFaceUvMinmax(face.Tag, uvs); //获得面u,v参数空间(u,v最小,最大值)
                double[] param = new double[2];                   //输入U,V方向值

                for (int i = 1; i < 6; i++)
                {
                    param[0] = i * (uvs[1] - uvs[0]) / 5 + uvs[0];
                    param[1] = i * (uvs[3] - uvs[2]) / 5 + uvs[2];
                    double[] point1    = new double[3];    //输出点坐标
                    double[] u1        = new double[3];    //输出 输出一阶导数在U位置
                    double[] v1        = new double[3];    //输出 输出一阶导数在V位置
                    double[] u2        = new double[3];    //输出 输出二阶导数在U位置
                    double[] v2        = new double[3];    //输出 输出二阶导数在V位置
                    double[] unit_norm = new double[3];    //输出面上该点的矢量方向
                    double[] radii     = new double[2];    //输出,双半径,输出主曲率半径
                    theUFSession.Modl.AskFaceProps(face.Tag, param, point1, u1, v1, u2, v2, unit_norm, radii);
                    theUFSession.Modl.AskPointContainment(point1, face.Tag, out statusPt);
                    if (statusPt == 1)
                    {
                        return(new Point3d(point1[0], point1[1], point1[2]));
                    }
                }
            }
            return(new Point3d());
        }