I am trying to clean up Stress Lines that are produced by Karamba so that I can 3d print them. Curves should be culled that overlap or that become denser than the width of the 3d printed filament.

I’ve written a C# script that iterates through the list of curves, and measures the distance to other curves in the same list, and removes a curve from the list if the distance to other curves is too small. I used the Curve.GetDistanceBetweenCurves method to find curves that were within a certain distance. This works okay, but it is definitely not an optimized result and is computationally heavy. (admittedly I don’t know entirely what this component is doing, maybe I can decrease tolerance significantly).

This is first attempt was so heavy in part because the list of curves is unsorted. I think what I want to do is just measure the distance to the neighboring curves in the list. However, the adjacent curves in the list are not the adjacent curves in Cartesian space. So I had to measure the distance to all other curves in the list. Shhheesshhh, definitely not ideal.

So I am attempting to sort the list of curves. I want to sort the curves based on the x-coordinate of some point on the curve. Because of the boundary condition, I don’t use end points, but instead I sort based on mid points. This works fairly well (see image below), but it is still error prone. It tends to have its highest accuracy towards the middle of the surface where the lines converge. But the outliers still introduce errors.

So then, I did a similar Curve.GetDistanceBetweenCurves method, but this time, only between a curve and its neighbor in the list. This made the computation much lighter and more rapid.

I am still far from having stress lines evenly spaced at 2mm from each other. Hopefully, you all have some advice to help guide me down a better path.

Curves output from Karamba:

Culling curves that become too close together:

Curves get sorted fairly well in the middle, but the edge conditions are still a mess.

culling lines based on density.gh (2.0 MB)