haplokuon / netDxf

.net dxf Reader-Writer
MIT License
1.01k stars 411 forks source link

How can I add new point to Spline.ControlPoints? #470

Open jim-jiang-github opened 1 year ago

jim-jiang-github commented 1 year ago

Spline.ControlPoints is a Array, and only Support getter no setter. How can I add new point to Spline.ControlPoints? Can only re-instantiate an object? If you re-instantiate an object, what parameters do you need to pass to Spline besides ControlPoints?

haplokuon commented 1 year ago

You can use the Spline constructor public Spline(IEnumerable<Vector3> controlPoints, IEnumerable<double> weights, short degree, bool closedPeriodic)

As the "controlPoints" parameter pass your new array of Vector3 that represents your new control points list. As the "weights" parameter you can just pass null if you use the default value of one for the weights vector or you just do not know what is the purpose of it. If you do, you already know what to do with it. As the "degree" parameter pass the value of the property Degree of your previous spline. As the "closedPeriodic" parameter pass the value of the property IsClosedPeriodic of your previous spline.

jim-jiang-github commented 1 year ago

You can use the Spline constructor public Spline(IEnumerable<Vector3> controlPoints, IEnumerable<double> weights, short degree, bool closedPeriodic)

As the "controlPoints" parameter pass your new array of Vector3 that represents your new control points list. As the "weights" parameter you can just pass null if you use the default value of one for the weights vector or you just do not know what is the purpose of it. If you do, you already know what to do with it. As the "degree" parameter pass the value of the property Degree of your previous spline. As the "closedPeriodic" parameter pass the value of the property IsClosedPeriodic of your previous spline.

Thank you very much.