Curve.Simplify Regression in Rhino 8

Hi,

We came across this bug while testing for our upgrade to Rhino 8. If you run the following code on Rhino 7 it works just fine. On Rhino 8 it returns null.

var tolerance = 1e-3;
var radialTolerance = RhinoMath.ToRadians(1);

var polyLineCurve = new Polyline(new Point3d[] {
	new(0, 0, 0),
	new(500, 0, 0),
	new(500, 1000, 0),
	new(0, 1000, 0),
	new(0, 0, 0),
}).ToNurbsCurve();

var segments = polyLineCurve.DuplicateSegments();
var curves = Curve.JoinCurves(segments, tolerance);
var curve = curves[0].Simplify(CurveSimplifyOptions.All, tolerance, radialTolerance);

In case it matters, this was tested on Rhino 8.19.25132.1001 and Rhino 7.27.23032.13001 on Windows.

Originally this was add to our code as a workaround for the Simplify code not accounting for co-linearity properly in order to simplify those curves. See this thread for more context.

For now we are skipping the simplification, and might use our own simplification code instead if needed. Still, it is a simple scenario, so a fix would be appreciated.

Hi @SK-Structurecraft,

I can see the results are different. When the curve cannot be simplified, you expect the function to return the input curve (instead of null)?

– Dale

I would expect the function to return null, however I’m guessing that the details here matter a bit. With this case I’m assuming it cannot be simplified because it is as simple as it can be. In that particular case I would assume it would just return the input curve. If it fails to simplify the curve for other reasons (the segments intersects weirdly, it isn’t closed etc.) it should return null.

The simplest solution would be to have a TryGetSimplefied method with an out parameter for the curve instead. And then have the method documentation clearly state when it returns false. Otherwise you end up guessing or having to do curve checking afterwards.