Beispiel #1
0
        static RevSurface ToRhinoConicalSurface(NXOpen.Face face, FaceEx.FaceData faceData)
        {
            double totalHeight;           // 圆锥总高度

            NXOpen.Point3d top;           // 圆锥顶点

            double radius;                // 锥底半径
            var    faceBoundingBox = face.GetAlignedBoundingBox(faceData.Direction);

            if (face.GetEdges().Length == 1 && face.GetEdges()[0].SolidEdgeType == NXOpen.Edge.EdgeType.Circular)
            {
                // 无修剪的锥形
                TheUfSession.Eval.Initialize2(face.GetEdges()[0].Tag, out var edgeEvaluator);
                TheUfSession.Eval.AskArc(edgeEvaluator, out var arc);
                TheUfSession.Eval.Free(edgeEvaluator);

                NXOpen.Point3d bottom = arc.center.ToPoint3d();        // 锥底中心点

                totalHeight = faceBoundingBox.Height;

                top = bottom.Move(faceBoundingBox.HeightDirection, totalHeight);

                radius = arc.radius;
            }
            else
            {
                var tangentOfHalfAngle = Math.Tan(faceData.RadiusData);

                top = faceData.Point.Move(faceBoundingBox.HeightDirection, faceData.Radius / tangentOfHalfAngle);

                totalHeight = faceBoundingBox.Height + faceData.Radius / Math.Tan(faceData.RadiusData);

                radius = faceData.Radius + faceBoundingBox.Height * tangentOfHalfAngle;
            }

            var cone = new Cone(new Plane(top.ToRhino(), faceBoundingBox.HeightDirection.Reverse().ToRhino()), totalHeight, radius);

            return(cone.ToRevSurface());

            // var curve = new LineCurve(outerPointOnCircle.ToRhino(), top.ToRhino());
            // return RevSurface.Create(curve, new Line(bottom.ToRhino(), top.ToRhino()), 0.0, Math.PI * 2.0);
        }