Hello, I’m new to this forum. I’m using openNURBS as C++ import library of 3DM files in my 2D CAD/CAM software. My application use segments, lines and cubic beziers to model simple geometries and polylines. While importing 3DM files I need to “convert” nurbs planar curves to beziers represenation, possibly controlling the approximation error. I tried to use ON_NurbsCurve::MakePiecewiseBezier(); and than getting bezier control points by iterating through the control vertex:
curve.MakePiecewiseBezier();
int span_count = curve.SpanCount();
int order = curve.m_order;
for(int spani = 0; spani < span_count; spani++) {
ON_3dPoint *ctrl_points = new ON_3dPoint[order];
//Load bezier control points
for(int i = 0; i < order; i++ ){
curve.GetCV(spani*(order-1) + i,ctrl_points[i]);
}
//Use control points to create bezier with our representation,
// if the order is 3 elevate degree to make cubic bezier
...
}
What I obtain with this code is a very raw approximation of the original curve. For example from a NURBS circle I obtain four quadratic bezier which is very inaccurate.
Am I using the functions in the correct way? Can you give me any suggestion about the approximation I’m trying to do?
Edit:
After further investigation I found that my approach generally works, but for some reason fail with the attached file… Circle.3dm (22.3 KB)
This is what I obtain after conversion:
Where am I missing?