Exemple #1
0
        public static Edge ToTopologic(this global::Rhino.Geometry.NurbsCurve nurbsCurve)
        {
            if (nurbsCurve == null)
            {
                return(null);
            }

            int           degree     = nurbsCurve.Degree;
            bool          isPeriodic = nurbsCurve.IsPeriodic;
            bool          isRational = nurbsCurve.IsRational;
            List <double> knots      = nurbsCurve.Knots.ToList();

            knots.Insert(0, knots[0]);
            knots.Add(knots.Last());

            NurbsCurvePointList ghControlPoints = nurbsCurve.Points;
            List <Vertex>       controlPoints   = new List <Vertex>();
            List <double>       weights         = new List <double>();

            for (int i = 0; i < ghControlPoints.Count; ++i)
            {
                controlPoints.Add(ghControlPoints[i].Location.ToTopologic());
                weights.Add(ghControlPoints[i].Weight);
            }

            return(Edge.ByNurbsParameters(controlPoints, weights, knots, isRational, isPeriodic, degree));
        }
Exemple #2
0
        private Topologic.Edge ByNurbsCurve(Rhino.Geometry.NurbsCurve ghNurbsCurve)
        {
            int  degree                = ghNurbsCurve.Degree;
            bool isClosed              = ghNurbsCurve.IsClosed;
            bool isPeriodic            = ghNurbsCurve.IsPeriodic;
            bool isRational            = ghNurbsCurve.IsRational;
            NurbsCurveKnotList ghKnots = ghNurbsCurve.Knots;
            List <double>      knots   = ghKnots.ToList();

            // OCCT-compatible
            knots.Insert(0, knots[0]);
            knots.Add(knots.Last());

            NurbsCurvePointList     ghControlPoints = ghNurbsCurve.Points;
            List <Topologic.Vertex> controlPoints   = new List <Topologic.Vertex>();
            List <double>           weights         = new List <double>();

            for (int i = 0; i < ghControlPoints.Count; ++i)
            {
                controlPoints.Add(ByPoint(ghControlPoints[i].Location));
                weights.Add(ghControlPoints[i].Weight);
            }

            return(Topologic.Edge.ByNurbsParameters(controlPoints, weights, knots, isRational, isPeriodic, degree));
        }
        static DB.XYZ[] ToXYZArray(NurbsCurvePointList list, double factor)
        {
            var count  = list.Count;
            var points = new DB.XYZ[count];

            int p = 0;

            if (factor == 1.0)
            {
                while (p < count)
                {
                    var location = list[p].Location;
                    points[p++] = new DB::XYZ(location.X, location.Y, location.Z);
                }
            }
            else
            {
                while (p < count)
                {
                    var location = list[p].Location;
                    points[p++] = new DB::XYZ(location.X * factor, location.Y * factor, location.Z * factor);
                }
            }

            return(points);
        }
Exemple #4
0
        static global::NXOpen.Point3d[] ToNXPoint3dArray(NurbsCurvePointList list, double factor)
        {
            var count  = list.Count;
            var points = new global::NXOpen.Point3d[count];

            int p = 0;

            if (factor == 1.0)
            {
                while (p < count)
                {
                    var location = list[p].Location;
                    points[p++] = new NXOpen.Point3d(location.X, location.Y, location.Z);
                }
            }
            else
            {
                while (p < count)
                {
                    var location = list[p].Location;
                    points[p++] = new NXOpen.Point3d(location.X * factor, location.Y * factor, location.Z * factor);
                }
            }

            return(points);
        }
Exemple #5
0
        public static List <SurfacePoint> _SurfacePoints(this NurbsCurvePointList points)
        {
            var count = points.Count;
            var res   = new List <SurfacePoint>(count);

            for (int i = 0; i < count; i++)
            {
                res.Add(new SurfacePoint(points[i].Location));
            }
            return(res);
        }
Exemple #6
0
        public static Point3d[] _Locations(this NurbsCurvePointList points)
        {
            //return points.Select(o => o.Location).ToArray();
            var count = points.Count;
            var res   = new Point3d[count];

            for (int i = 0; i < count; i++)
            {
                res[i] = points[i].Location;
            }
            return(res);
        }
        public static NXOpen.Point3d[] ToHost(NurbsCurvePointList list)
        {
            var count  = list.Count;
            var points = new NXOpen.Point3d[count];

            for (int p = 0; p < count; ++p)
            {
                var location = list[p].Location;
                points[p] = new NXOpen.Point3d(location.X, location.Y, location.Z);
            }

            return(points);
        }
Exemple #8
0
        public static DB.XYZ[] ToHost(NurbsCurvePointList list)
        {
            var count  = list.Count;
            var points = new DB.XYZ[count];

            for (int p = 0; p < count; ++p)
            {
                var location = list[p].Location;
                points[p] = new DB::XYZ(location.X, location.Y, location.Z);
            }

            return(points);
        }
        public static List <XYZ> ConvertRhinoControlPoints(NurbsCurvePointList ctrlPoints, out List <double> weights)
        {
            List <XYZ> points = new List <XYZ>();

            weights = new List <double>();
            try
            {
                foreach (Rhino.Geometry.ControlPoint ctrlPoint in ctrlPoints)
                {
                    points.Add(new XYZ(ctrlPoint.Location.X, ctrlPoint.Location.Y, ctrlPoint.Location.Z));
                    weights.Add(ctrlPoint.Weight);
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            return(points);
        }