Пример #1
0
        public static Rhino.Geometry.Transform ToRhino(this NXOpen.Matrix4x4 value)
        {
            var rhino = RawDecoder.ToRhinoTransform(value);

            UnitConverter.Scale(ref rhino, UnitConverter.NXToRhinoUnitsRatio);
            return(rhino);
        }
Пример #2
0
        public static Point3d ToRhinoPoint3d(this double[] value)
        {
            var rhino = RawDecoder.ToRhinoPoint3d(value);

            UnitConverter.Scale(ref rhino, UnitConverter.NXToRhinoUnitsRatio);
            return(rhino);
        }
Пример #3
0
        public static Vector3d ToRhino(this NXOpen.Vector3d value)
        {
            Vector3d rhino = RawDecoder.ToRhino(value);

            UnitConverter.Scale(ref rhino, UnitConverter.NXToRhinoUnitsRatio);
            return(rhino);
        }
Пример #4
0
        public static Point ToRhino(this NXOpen.Point point)
        {
            var rhino = RawDecoder.ToRhino(point);

            UnitConverter.Scale(rhino, UnitConverter.NXToRhinoUnitsRatio);
            return(rhino);
        }
Пример #5
0
        public static PolylineCurve ToPolylineCurve(this NXOpen.Polyline value)
        {
            var rhino = RawDecoder.ToRhinoCurve(value);

            UnitConverter.Scale(rhino, UnitConverter.NXToRhinoUnitsRatio);
            return(rhino);
        }
Пример #6
0
        public static Plane ToRhino(this NXOpen.Plane value)
        {
            var rhino = RawDecoder.ToRhino(value);

            UnitConverter.Scale(ref rhino, UnitConverter.NXToRhinoUnitsRatio);
            return(rhino);
        }
Пример #7
0
        public static Brep ToBrep(this NXOpen.Face value)
        {
            var rhino = RawDecoder.ToRhinoBrep(value);

            UnitConverter.Scale(rhino, UnitConverter.NXToRhinoUnitsRatio);
            return(rhino);
        }
Пример #8
0
        public static Curve ToRhino(this NXOpen.Curve value)
        {
            Curve rhino = RawDecoder.ToRhinoCurve(value);

            UnitConverter.Scale(rhino, UnitConverter.NXToRhinoUnitsRatio);

            return(rhino);
        }
Пример #9
0
        public static Surface ToRhinoSurface(this NXOpen.Face face)
        {
            var rhino = RawDecoder.ToRhinoSurface(face, out _);

            if (rhino == null)
            {
                return(null);
            }

            UnitConverter.Scale(rhino, UnitConverter.NXToRhinoUnitsRatio);
            return(rhino);
        }
Пример #10
0
        public static Curve ToRhinoCurve(this NXOpen.IBaseCurve value)
        {
            Curve rhino = null;

            switch (value)
            {
            case NXOpen.Edge edge:
                rhino = RawDecoder.ToRhinoCurve(edge);
                break;

            case NXOpen.Curve c:
                rhino = RawDecoder.ToRhinoCurve(c);
                break;

            default:
                throw new NotImplementedException("未实现的曲线转换类型:" + value.GetType().FullName);
            }

            UnitConverter.Scale(rhino, UnitConverter.NXToRhinoUnitsRatio);

            return(rhino);
        }
Пример #11
0
        public static Curve ToRhinoCurve(NXOpen.Edge edge)
        {
            var edgeType = edge.SolidEdgeType;

            switch (edgeType)
            {
            case NXOpen.Edge.EdgeType.Rubber:
                break;

            case NXOpen.Edge.EdgeType.Linear:
                edge.GetVertices(out var sp, out var ep);
                return(new LineCurve(new Line(sp.ToRhino(), ep.ToRhino())));

            case NXOpen.Edge.EdgeType.Circular:
                TheUfSession.Eval.Initialize2(edge.Tag, out var edgeEvaluator);
                TheUfSession.Eval.AskArc(edgeEvaluator, out var arc);
                TheUfSession.Eval.Free(edgeEvaluator);

                return(RawDecoder.CreateArc(arc.center.ToRhinoPoint3d(), arc.x_axis.ToRhinoVector3d(), arc.y_axis.ToRhinoVector3d(), arc.limits[0], arc.limits[1], arc.radius));

            case NXOpen.Edge.EdgeType.Elliptical:
                TheUfSession.Eval.Initialize2(edge.Tag, out var evaluator);
                TheUfSession.Eval.AskEllipse(evaluator, out var ellipse);
                TheUfSession.Eval.Free(evaluator);

                NurbsCurve nurbsCurve = RawDecoder.CreateNurbsCurve(ellipse.center.ToRhinoPoint3d(), ellipse.x_axis.ToRhinoVector3d(), ellipse.y_axis.ToRhinoVector3d(), ellipse.limits[0], ellipse.limits[1], ellipse.major, ellipse.minor, edge.GetPoint(0.0).ToRhino(), edge.GetPoint(1.0).ToRhino());

                return(nurbsCurve);

            case NXOpen.Edge.EdgeType.Intersection:
                break;

            case NXOpen.Edge.EdgeType.Spline:
                TheUfSession.Eval.Initialize2(edge.Tag, out var splineEvaluator);
                TheUfSession.Eval.AskSplineControlPts(splineEvaluator, out var controlPointCount, out var controlPoints);
                TheUfSession.Eval.AskSplineKnots(splineEvaluator, out var knotsCount, out var knots);
                TheUfSession.Eval.AskSpline(splineEvaluator, out var splineData);
                TheUfSession.Eval.Free(splineEvaluator);

                NXOpen.Point4d[] controlPoint4ds = new NXOpen.Point4d[controlPointCount];
                for (int i = 0; i < controlPointCount; i++)
                {
                    controlPoint4ds[i] = new NXOpen.Point4d
                    {
                        X = controlPoints[i * 4],
                        Y = controlPoints[i * 4 + 1],
                        Z = controlPoints[i * 4 + 2],
                        W = controlPoints[i * 4 + 3],
                    };
                }

                return(RawDecoder.CreateNurbsCurve(controlPoint4ds, knots, splineData.is_rational, splineData.order));

            case NXOpen.Edge.EdgeType.SpCurve:
                break;

            case NXOpen.Edge.EdgeType.Foreign:
                break;

            case NXOpen.Edge.EdgeType.ConstantParameter:
                break;

            case NXOpen.Edge.EdgeType.TrimmedCurve:
                break;

            case NXOpen.Edge.EdgeType.Convergent:
                break;

            case NXOpen.Edge.EdgeType.Undefined:
                break;

            default:
                break;
            }

            var nxCurve = edge.CreateCurveFromEdge();

            var rhinoCurve = nxCurve.ToRhino();

            nxCurve.Delete();

            return(rhinoCurve);
        }