-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Hello Flo_Curves Devs,
I found a bug with the marking of interior/exterior edges when subtracting complex shapes in a specific way in both v0.7.3 and v0.8.0.
It begins with a base shape created by merging four SimpleBezierPaths into a GraphPath:

And a cutout GraphPath like this:

The cutout path is then subtracted from the base shape using GraphPath::collide() and then GraphPath::set_exterior_by_subtracting(). This produces the incorrect path seen here:

Here is a recreation of what it should look like if it were correct:

The result of this error (when healed using the heal_exterior_gaps() function) looks like this:

When it should look like this:

The two black and white images were made using the original icons with which this bug was discovered, but I have written a test using the more minimal reproduction seen in the debug images.
The inner loop seen in the top right of the debug image seems to be important. When it is removed, the bug does not occur.

Also, if the top of the cutout shape, which intersects that loop, is moved higher (to around y=100) the bug does not occur.

When that point is at its normal position of y=160 it breaks.

I believe the bug is somewhere in the set_exterior_by_subtracting() function, or the function it calls, though I was unable to locate exactly where.
The subtract_multiple_partial_overlap() test I have proposed in pull request #29 creates these shapes, subtracts them, locates the edges of the inner arch, and checks their interior/exterior statuses. If they are correctly labelled as exterior, it passes. I believe that if this test passes, the bug would be fixed.
Also, I’m not sure if this is relevant, but maybe it will be useful information somehow. The edge indicated in the following image is actually two lines that partially overlap:

I would think that Flo_Curves should see the overlap and split the edge up appropriately.

I could be wrong about what this is supposed to look like, but maybe this information will be useful.