public static ICurve CreateBsplineCurve(IReadOnlyCollection<Vector4> controlPoints, IEnumerable knotVectorU, int order, bool isPeriodic, IModeler modeler) { var controlPointsList = controlPoints .SelectMany(p => new double[] {p.X, p.Y, p.Z, p.W}.ToArray()) .ToArray(); var dimensionControlPoints = BitConverter.GetBytes(4); var orderBytes = BitConverter.GetBytes((int) order); var numControlPointsBytes = BitConverter.GetBytes((int) controlPoints.Count); var periodicity = BitConverter.GetBytes(isPeriodic ? 1 : 0); var props = new[] { BitConverter.ToDouble(dimensionControlPoints.Concat(orderBytes).ToArray(), 0), BitConverter.ToDouble(numControlPointsBytes.Concat(periodicity).ToArray(), 0) }; return (Curve) modeler.CreateBsplineCurve(props, knotVectorU, controlPointsList); }
public static ICurve CreateBsplineCurve(IReadOnlyCollection <Vector4> controlPoints, IEnumerable knotVectorU, int order, bool isPeriodic, IModeler modeler) { var controlPointsList = controlPoints .SelectMany(p => new double[] { p.X, p.Y, p.Z, p.W }.ToArray()) .ToArray(); var dimensionControlPoints = BitConverter.GetBytes(4); var orderBytes = BitConverter.GetBytes((int)order); var numControlPointsBytes = BitConverter.GetBytes((int)controlPoints.Count); var periodicity = BitConverter.GetBytes(isPeriodic ? 1 : 0); var props = new[] { BitConverter.ToDouble(dimensionControlPoints.Concat(orderBytes).ToArray(), 0), BitConverter.ToDouble(numControlPointsBytes.Concat(periodicity).ToArray(), 0) }; return((Curve)modeler.CreateBsplineCurve(props, knotVectorU, controlPointsList)); }