Partitioning Rectilinear Polygon

Hello everybody!

I am trying to work on a grasshopper developer of styrofoam cuts for architectural models. So I am now facing quite a problem when it comes to partitioning flat polygons in smaller and optimized rectangles.

i) At this point in the script, I have all these (all the time) different polygons subdivided into smaller rectangles (see image 1). The idea would be to merge some rectangles in order to obtain bigger, optimal rectangles, always by avoiding flat long pieces (which would be really problematic to realize in foam) (see image 2). Has someone by any chance a hint on how to achieve this?

ii) By the way, I do not know if the strategy of dividing in smaller rectangles and then merging them into bigger ones is a good one. I found some references on the subject of “covering an orthogonal polygon”, which presents some computational algorithms on the matter; and “partitioning rectilinear polygon” with python+mathplotlib: it seems that it is definitely possible to solve the question through an iterative process, but I was wondering if it there was a way to achieve the same result with Grasshopper.

Thank you so much in advance!

Andrea (14.0 KB)

You choose the rectangles based on what? there are many possibilities
for example why not this?

You are right! There are many possibilities, I just picked one layout among others. What I would be great to avoid is something like this (see image) where there are rectangles that have huge Base/Height ratio, like the small horizontal one. Simply because they would be really difficult to execute as foam pieces.

You could look at that


Thank you! It is indeed similar to what I am trying to do. I will immediately dive into.