Detect shapes split by intersecting lines

I want to detect separate shapes as lines split the canvas. I saved line intersection points in the list of PVectors, but don’t know how to connect points that complete split shapes separately.

Here’s a sample image that has 4 lines splitting the canvas with their intersection points marked in red and saved in the list (the left one). I also saved in the same list the corners and default line points marked in black. Is there any way to detect all split shapes separately, for example, to apply different colors to each? (The image on the right is what I want to.)


This seems to be a similar question and answers: Detecting all the shapes formed by intersecting lines - #5 by jeremydouglass (Still, I am not sure how to connect intersection points to separate shapes.)

1 Like

I was working on this just last night :smiley: .

The feature will be included in the next release of Processing Geometry Suite (for now the code is in the dev branch – you don’t even need to compute points of intersection, simply provide a list of line segment vertices).


Awesome, other examples look great too! Thank you!

This functionality has now been released. The method in question is PGS_Processing.polygonizeLines().

1 Like