Complicated Nonplanar 3D Infill Pattern Creation Help

So this is a complicated problem but I will describe it the best I can.

This is a file containing geometry being sliced in a nonplanar method and creating infill on the interior. However, the infill pattern I have going for it is poorly optimized and not accomplishing what I need it to. Basically, I am offsetting the outer perimeter to generate infill inside of it. But due to how the offset works, the geometry becomes confused and starts to leave the interior of the curve being offset (Offset curve in green)

I am currently shattering the offset curve then keeping the longest two segments, combining them, and then generating the infill for the resulting polyline. This works fine for the larger slices but eventually the geometry gets too thin to actually require infill and the portions of the offset curve outside the curve it was offset from get longer than the interior portions of the offset curve itsself, creating infill outside the perimeter curve. At this point I would like to switch the infill generation to just the interior offset curve if possible.

My problem is the detection of that.
I tried using the midpoints of longest, shattered interior offset curve, but midpoint distances eventually get close to zero and then “bounce”, increasing as the wrong geometry becomes more pronounced (2->1->0.5->1->3->5->etc.). and I am having a hard time detecting that with some kind of an “if” statement.


However, it isn’t a permanent solution to the problem. If the slices above the one previously sliced eventually require infill, the generation wouldn’t happen once the instance is switched to one without infill. So if anyone has a better idea on how to detect when the infill is being generated outside of the perimeter curve, or even a better way to generate infill generally, I am open to hearing about it.

Hopefully all of that makes sense. I have included the files for reference. Any help would be much appreciated.
downloaded_Propeller_sliced2.gh (38.1 KB)
propeller_fixed.3dm (4.8 MB)

Which one is the curve you are trying to offset? Only showing the curve and the desired result is a good idea.

Here is the guidance.


Help Us Help You - Grasshopper - McNeel Forum

Thanks for the reply! I’ve grouped the GH commands in question in the file. See attached.

This is correct, with the nonplanar infill being generated inside a perimeter of a slice:
image

However, when the geometry near the top of the part becomes thinner there are problems.
image
With how I have the infill generation setup, the infill pattern looks for the longest lines drawn from shattering the offset curve. When the part is thinnest, the lines found from that method end up being outside the geometry, creating irregularities.

The desired result in these cases, if possible, would be to keep what is reasonably inside the perimeter curve (between the two blue dots) and being able to switch back to the infill pattern already setup if the part becomes larger in the “above” slices if that makes sense…
image

propeller_fixed.3dm (4.8 MB)
downloaded_Propeller_sliced2.gh (35.2 KB)