FIT Options

Im finishing up this littel guy

but I have an issue in trying to reduce pointcount, after I get my polylines back I .Tonurbscurve, then rebuild. Id prefer to fitcrv with a tolerance, but my program shows nothing… no matter what tolerance I use.

CUrrent Code: (using iterations of dekink and rebuild)

if (get_rc == GetResult.Option)
{
List Smoothed = new List();
var Lines = Outlines(FileName,InvertImage.CurrentValue);
foreach(Polyline line in Lines)
{
for (int i = 0; i < KinkRemoval.CurrentValue; i++)
{
line.Smooth(1);
}
var Dekinked = line.ToNurbsCurve().Rebuild(line.Count/RebuildMultiple.CurrentValue, 3, false);
Dekinked.Scale(0.1);
Smoothed.Add(Dekinked);
}
PointsConduit.ConduitEdges = Smoothed;
doc.Views.Redraw();
continue;
}

and the code that does not work… any ideas where I am going wrong?

(FitTolerance being a double value in my command line.)

if (get_rc == GetResult.Option)
                {
                    List<Curve> Smoothed = new List<Curve>();
                    var Lines = Outlines(FileName, InvertImage.CurrentValue);
                    foreach (Polyline line in Lines)
                    {
                        var Dekinked = line.ToNurbsCurve().Fit(3, fitTolerance.CurrentValue, 0);
                        Dekinked.Scale(0.1);
                        Smoothed.Add(Dekinked);
                    }
                    PointsConduit.ConduitEdges = Smoothed;
                    doc.Views.Redraw();
                    continue;
                }

Hi @ChristopherBotha,

Can you provide source code to a test command, that we can run here, that doesn’t work how you want? Please include some test geometry too.

Thanks,

– Dale

Hi Dale. Turns out that my edge detection was delivering a VERY heavy curve, anything over a few thousand points and the fit command just exits. Im going back to the drawing board on the openCV end of this. I will feedback when I get back to this in the new year.

Hi @ChristopherBotha,

Can you post a curve that the FitCrv command does not work with?

– Dale

Hi Dale.

solved it by examining the output curve more closely, it was zillions of 90 degree lines, I changed fitcrv to angle tolerance 91 degrees and works perfectly now.