/// <summary> /// 求两个面的夹角 /// </summary> /// <param name="face1"></param> /// <param name="face2"></param> /// <returns></returns> public static double Angle(Face face1, Face face2) { Vector3d vec1 = FaceUtils.AskFaceNormal(face1); Vector3d vec2 = FaceUtils.AskFaceNormal(face2); return(UMathUtils.Angle(vec1, vec2)); }
/// <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); }
/// <summary> /// 求曲面斜率 /// </summary> /// <param name="sweptFace"></param> /// <param name="vec"></param> /// <param name="slope"></param> /// <param name="rad"></param> public static void GetSweptSlope(Face sweptFace, Vector3d vec, out double[] slope, out double[] rad) { rad = new double[2] { 99999, -99999 }; slope = new double[2] { 99999, -99999 }; double faceArae = GetFaceArea(sweptFace); int accuracy = Convert.ToInt32(faceArae) * 100; UFSession theUFSession = UFSession.GetUFSession(); Tag faceTag = sweptFace.Tag; //输入面特征 double[] uvs = new double[4]; theUFSession.Modl.AskFaceUvMinmax(faceTag, uvs); //获得面u,v参数空间(u,v最小,最大值) double[] param = new double[2]; //输入U,V方向值 for (int i = 0; i < accuracy; i++) { param[0] = i * (uvs[1] - uvs[0]) / accuracy + uvs[0]; param[1] = i * (uvs[3] - uvs[2]) / accuracy + uvs[2]; double[] point = 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(sweptFace.Tag, param, point, u1, v1, u2, v2, unit_norm, radii); double angle = UMathUtils.Angle(vec, new Vector3d(unit_norm[0], unit_norm[1], unit_norm[2])); if (slope[0] >= angle) { slope[0] = angle; } if (slope[1] < angle) { slope[1] = angle; } if (rad[0] >= radii[0]) { rad[0] = radii[0]; } if (rad[1] < radii[1]) { rad[1] = radii[1]; } } }