Sorting boxes based on region containment

Hello all

I feel like this is a problem that has a known solution but I just don’t know enough terminology. I am trying to panelize a region with a grid of a specified size tile based around a given plane. Currently, I generate a bounding box around my region, generate all tiles, then sort them by inside(Red), edge condition (green), and outside (blue) relative to my region (pink). Sorting is done using the Curve.PlanarClosedCurveRelationship() method. Here is a picture of my results.

Inside panels are identified correctly. However, the edge conditions don’t have the desired results. I want edge panels to be those that cross the edge of my region, meaning it has area both inside and outside the region. Instead it seems to function at having any intersections with the region. This results in the circled area being labeled as edge panels when the upper row should all be labeled as inside and the bottom row should all be labeled as outside.

Does anyone know of a good method that solves this edge case? I have included my grasshopper script. Many thanks in advance for the help.

Panelization Location Sort.gh (24.1 KB)

You can check for the relation to the region with a slightly internal offset version of your panels (offset amount equal to the tolerance you want), so intersecting panels will still be caught but you avoid the curve overlap problem.

2 Likes

That did it perfect, thank you!