C#: Reconstructing a NURBS Curve from another NURBS Curve's Properties?


hey guys,

i’d like to reconstruct a NURBS curve from another NURBS curve’s properties.

Since NurbsCurve.Create() only asks for rationality, degree and a list of control point locations, this cannot be easily done for e.g. a circle, because (at least) weight information is missing.

How would you completely and safely reconstruct a NURBS curve from its properties like control point locations, rationality, knot vectors, etc?

cheers, Heinz

(Lukasz Domagala) #2

Iv’e asked a similar question not so long ago…it is possible

(Dale Fugier) #3

HI @lungenstrudel,

I am thinking something like this should do it.

public static NurbsCurve CopyNurbsCurve(NurbsCurve src)
  if (null == src || !src.IsValid)
    return null;

  var dimension = src.Dimension;
  var order = src.Order;
  var rational = src.IsRational;
  var point_count = src.Points.Count;

  var nc = new NurbsCurve(dimension, rational, order, point_count);
  for (var i = 0; i < src.Points.Count; i++)
    nc.Points[i] = src.Points[i];

  for (var i = 0; i < src.Knots.Count; i++)
    nc.Knots[i] = src.Knots[i];

  return nc.IsValid ? nc : null;

Does this help?

– Dale