# Expanding curves/ Breps/ Meshes to fill the gaps in between

I have this 2D/3D floor plan coming in as surfaces (projected on a plane) or Breps. As the rooms are imported without the wall thickness, a void is left in between (varying gap widths based on wall thickness and geometry). I need to somehow expand these room volumes and have adjacent sides with no gaps in between. The challenge here is that I need these inter-spaces (gaps) to be split equally (as much as possible). the second challenge is that I need to maintain the rooms (tree structure) without adding in newer items in the tree. See the attached file. Also the end geometry needs to be clean faces rather than messy meshes. The rooms were not design in Rhino or GH so we donât have the script. the plan is always imported âas isâ. As it might occur to most âwhy not just fix it manually?â wellâŚ we have hundreds of these plans. I will take any solution as long as I can have Breps of the same rooms in the same tree order/ structure as output

Question forum fill gaps.gh (1.3 MB)

How? Scale them in X and/or Y? With all adjacent rooms (and gaps) intact and unchanged? Which rooms and in what sequence? Sounds very difficult with more info needed.

One list is 3D, the other is 2D - you donât need both, eh? Many âroomsâ are welded together.

Maybe something along this way, you will need to determine rules for when to expand and when not, right now I just made two simple thresholds. Not included yet is a way to stitch everything back into closed shapes. I remember having seen a method for that but canât recall right now:

Scaling uniformly wonât work. But with the same approach an offset would work maybe but it only needs to happen to the room edges where there is a an adjacent gap not a neighboring room edge.
Which roomsâŚ well any room that has a gap beside it. I just gave the 2D and 3D to give more editing options.

You can extract the outer edge using 2 offsets.

Then something like MEdial Axis can give you the separations

It gives that (a bit long for the calculation)

Thanks @Gijs this is getting really close! I just need to have them patched up again so I can have a surface for each room again

This is really what I was looking for but I am not sure Iâm following the entire definition @laurent_delrieu would you mind sharing the entire script photo? I followed with clipper and got the outermost boundary, I missed the next step with two curves going into the split component

Yes no problem, It is a big long and not exactly what you want but the idea is there. I also internalized the result of Medial Axis. And no problem if Color Mesh is not present it is a useful tool for vizualisation of Stripper plugin by @joncorrod .
Question forum fill gaps_LD.gh (2.4 MB)
i

@laurent_delrieu I used Clipper and that plugin is amazing at getting the clean outline of all rooms combined. I then used @Gijs suggestion with the midlines in those gaps. The part that fails is the surface split part. Any thoughts?

Question forum fill gaps_start V2.gh (191.1 KB)

I have some fails but it is because curves doesnât touch. if not closed it will not work.

Question forum fill gaps_start V2 LD.gh (223.2 KB)

1 Like

Well, what I posted was merely a start, because the algorithm has still some flaws that need to be resolved. For example, I just sample the curve once at its midpoint, and if there is more bumpy curve at the opposite side and the point will miss it, you will get a wrong offset.
If you do happen to get possible closed shapes, they can be with found with Curve.CreateBooleanRegions()
This is a tricky problem to solve. I guess you will shortly be offered an âentry level c#â by @PeterFotiadis to prove this.

1 Like

Maybe a mid level one - IF the stuff required is not internal.

But this w/e is party time: can Lewis do something with that W13 crap?.

hereâs a slightly improved version:
Question forum fill gaps_2nd_try.gh (1.4 MB)
It does miss the upper left surface though:

@Gijs This is very close, thank you! I tried it on a bunch of situations but there is no consistent results for all situations. What I found to be more helpful, having a grid and snapping the edges to that grid even if it distorts the shape a bit to the nearest rectangular pure form.
the challenge is how to extrapolate a grid from a collection of shapes (i.e. fit a line based on a collection of points) obviously step one would be edges from surfaces then reducing curves to segmentsâŚ after that kill the lines that have duplicates within a certain tolerance to align the entire plan
I canât think of a way to do thatâŚ any thoughts?

Question forum fill gaps_3rd_try.gh (678.3 KB)