LDraw.org Discussion Forums
Flood fill utility - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: Models and Parts (https://forums.ldraw.org/forum-18.html)
+--- Forum: Parts Authoring (https://forums.ldraw.org/forum-19.html)
+--- Thread: Flood fill utility (/thread-24567.html)



Flood fill utility - Orion Pobursky - 2021-04-20

Is there some sort of "flood fill" utility to triangle-ize the blank space in a pattern (up to a defined bounding rectangle). Filling in the negative space with color 16 triangles is super time consuming. 

Maybe this exists and just to dense to find it.


RE: Flood fill utility - Philippe Hurbain - 2021-04-20

(2021-04-20, 14:38)Orion Pobursky Wrote: Is there some sort of "flood fill" utility to triangle-ize the blank space in a pattern (up to a defined bounding rectangle). Filling in the negative space with color 16 triangles is super time consuming. 

Maybe this exists and just to dense to find it.
That's an old wish... No solution I know of Sad https://forums.ldraw.org/thread-22210-post-25645.html#pid25645


RE: Flood fill utility - Magnus Forsberg - 2021-04-20

(2021-04-20, 15:47)Philippe Hurbain Wrote: That's an old wish... No solution I know of Sad https://forums.ldraw.org/thread-22210-post-25645.html#pid25645

Isn't that how Img4Dat works?
First create some sort of line between colours, and then flood fill each area with triangles.


RE: Flood fill utility - Orion Pobursky - 2021-04-20

(2021-04-20, 15:47)Philippe Hurbain Wrote: That's an old wish... No solution I know of Sad https://forums.ldraw.org/thread-22210-post-25645.html#pid25645

Bummer. Well back to the grind.


RE: Flood fill utility - Gerald Lasser - 2021-04-20

You could try the "Line2Pattern" function of LDPE.

It does pretty much what you want, the only disadvantage is that the area needs to have boundaries with lines of colour 24.

e.g. you have this code:
Code:
4 16 -1.7 0 4.6 -2.8 0 2.6 -3.3 0 -4.1 -2.1 0 -4.3
4 16 -2.1 0 -4.3 -3.3 0 -4.1 -.5 0 -6.7 1.8 0 -6.3
4 16 1.8 0 -6.3 -.5 0 -6.7 4.8 0 -7.3 6.1 0 -6
4 16 6.1 0 -6 4.8 0 -7.3 11.4 0 -6.6 9.5 0 -2.8
4 16 7.5 0 .8 6.1 0 -6 9.5 0 -2.8 11.1 0 2.1
3 16 7.5 0 4 7.5 0 .8 11.1 0 2.1
4 16 7.5 0 .8 7.5 0 4 5.8 0 5.7 3.9 0 4.5
4 16 3.9 0 4.5 5.8 0 5.7 1.3 0 5.8 -.5 0 3.9
3 16 1.3 0 5.8 -1.7 0 4.6 -.5 0 3.9
3 16 1.7 0 .6 2.1 0 -2.8 5.8 0 -.7
3 16 .2 0 1.8 2.1 0 -2.8 1.7 0 .6
3 16 3 0 3.4 2.8 0 1.9 4.4 0 1.7
2 24 -1.7 0 4.6 -.5 0 3.9
2 24 -.5 0 3.9 3.9 0 4.5
2 24 3.9 0 4.5 7.5 0 .8
2 24 7.5 0 .8 6.1 0 -6
2 24 6.1 0 -6 1.8 0 -6.3
2 24 1.8 0 -6.3 -2.1 0 -4.3
2 24 -2.1 0 -4.3 -1.7 0 4.6
2 24 2.8 0 1.9 3 0 3.4
2 24 3 0 3.4 4.4 0 1.7
2 24 4.4 0 1.7 2.8 0 1.9
2 24 1.7 0 .6 5.8 0 -.7
2 24 5.8 0 -.7 2.1 0 -2.8
2 24 2.1 0 -2.8 .2 0 1.8
2 24 .2 0 1.8 1.7 0 .6

2 11 .9 0 -4.75 5.05 0 -3.35

The quads and triangles basically don't mean anything.

Important are the lines, the colour24 lines mark you boundaries.

now tihin these boundaries, there is a line of colour 11.

Select ALL lines (boundaries plus the line whihc dictates the fill-colour)

Invoke "Line2Pattern" under tools

and you will get these additional tiangles

Code:
3 16 2.1 0 -2.8 5.8 0 -.7 1.7 0 .6
3 11 .2 0 1.8 -.5 0 3.9 -2.1 0 -4.3
3 11 2.1 0 -2.8 6.1 0 -6 5.8 0 -.7
3 11 5.8 0 -.7 6.1 0 -6 7.5 0 .8
3 11 -.5 0 3.9 3 0 3.4 3.9 0 4.5
3 11 2.1 0 -2.8 .2 0 1.8 -2.1 0 -4.3
3 16 2.1 0 -2.8 1.7 0 .6 .2 0 1.8
3 16 -.5 0 3.9 3.9 0 4.5 -1.7 0 4.6
3 16 2.8 0 1.9 4.4 0 1.7 3 0 3.4
3 11 -.5 0 3.9 -1.7 0 4.6 -2.1 0 -4.3
3 11 1.8 0 -6.3 2.1 0 -2.8 -2.1 0 -4.3
3 11 1.8 0 -6.3 6.1 0 -6 2.1 0 -2.8
3 11 4.4 0 1.7 5.8 0 -.7 7.5 0 .8
3 11 4.4 0 1.7 3.9 0 4.5 3 0 3.4
3 11 4.4 0 1.7 7.5 0 .8 3.9 0 4.5
3 11 .2 0 1.8 1.7 0 .6 2.8 0 1.9
3 11 4.4 0 1.7 1.7 0 .6 5.8 0 -.7
3 11 4.4 0 1.7 2.8 0 1.9 1.7 0 .6
3 11 3 0 3.4 .2 0 1.8 2.8 0 1.9
3 11 3 0 3.4 -.5 0 3.9 .2 0 1.8

It duplicates some of the existing col 16 triangles, but the result of the mockup is good.


To move this function to LDPC would be a massive relief :-)

IMHO a few algorithms needed to be considered
- "Space Seeker": Look for triangles without any colour next to them -> Make a line
- "Check integrity": Look if the boundariy has no gap

Then apply this algorithm... and we are happy

EDIT: the "SPace Seeker" is in theory the Edger "Unmatched edges", right?