public NurbsSurface SurfaceToNative(Surface surface)
        {
            var points  = new DS.Point[] [] { };
            var weights = new double[] [] { };

            var controlPoints = surface.GetControlPoints();

            points = controlPoints.Select(row => row.Select(p => DS.Point.ByCoordinates(
                                                                ScaleToNative(p.x, p.units),
                                                                ScaleToNative(p.y, p.units),
                                                                ScaleToNative(p.z, p.units))).ToArray())
                     .ToArray();

            weights = controlPoints.Select(row => row.Select(p => p.weight).ToArray()).ToArray();

            var knotsU = surface.knotsU;

            knotsU.Insert(0, knotsU[0]);
            knotsU.Add(knotsU[knotsU.Count - 1]);

            var knotsV = surface.knotsV;

            knotsV.Insert(0, knotsV[0]);
            knotsV.Add(knotsV[knotsV.Count - 1]);

            var result = DS.NurbsSurface.ByControlPointsWeightsKnots(points, weights, knotsU.ToArray(), surface.knotsV.ToArray(),
                                                                     surface.degreeU, surface.degreeV);

            return(result);
        }
        public BRepBuilderSurfaceGeometry SurfaceToNative(Surface surface)
        {
            var uvBox   = new DB.BoundingBoxUV(surface.knotsU[0], surface.knotsV[0], surface.knotsU[surface.knotsU.Count - 1], surface.knotsV[surface.knotsV.Count - 1]);
            var surfPts = surface.GetControlPoints();
            var uKnots  = SurfaceKnotsToNative(surface.knotsU);
            var vKnots  = SurfaceKnotsToNative(surface.knotsV);
            var cPts    = ControlPointsToNative(surfPts);

            BRepBuilderSurfaceGeometry result;

            if (!surface.rational)
            {
                result = DB.BRepBuilderSurfaceGeometry.CreateNURBSSurface(surface.degreeU, surface.degreeV, uKnots,
                                                                          vKnots, cPts, false, uvBox);
            }
            else
            {
                var weights = ControlPointWeightsToNative(surfPts);
                result = DB.BRepBuilderSurfaceGeometry.CreateNURBSSurface(surface.degreeU, surface.degreeV, uKnots,
                                                                          vKnots, cPts, weights, false, uvBox);
            }

            return(result);
        }