micycle1 / PGS

Processing Geometry Suite
https://micycle1.github.io/PGS/
170 stars 13 forks source link

`PGS_ShapeBoolean.union(PShape, PShape)` returns shape identical to input argument #62

Closed puebloDeLaMuerte closed 1 year ago

puebloDeLaMuerte commented 2 years ago

Hi,

i have an array of many PShapes created from tiling an initial square repeatedly using PGS_Processing.slice(). Within that array i pick two neigbouring shapes for unision via the PGS_ShapeBoolean.union(PShape,PShape) function. This works like a charm most of the time and returns a PShape that combines the areas of the two input shapes. Sometimes it doesen't want to do so and instead just returns a PShape that is identical to the second input argument of union(PShape,PShape).

What's confusing is that i cannot tell the difference between cases where it works and where it doesnt. The input shapes look valid to me in both cases...

Not shure if this is a bug or if you can point me towards common issues with unision that i should look into...

Thx for a reply and thanks for sharing this awesome library!

micycle1 commented 2 years ago

Can you certify that the coordinates of the two slice shapes overlap perfectly? I'm guessing this isn't the case somehow. If so, you could put the tiles through PGS_Conversion.roundVertexCoords() first, and see whether that leads to the expected output.

Perhaps after having been sliced, the adjacent slices sometimes have very slight differences in their coordinates -- a small gap which means they cannot be unioned.

puebloDeLaMuerte commented 2 years ago

Thx for your reply! Not shure how i would check if the shapes overlap perfectly. I did check for Vertices being very close but not exacly in the same spot, but that doesn't produce meaningful results in cases where the touching corners of one shape don't lie on the corners of the other but instead lie on the connecting lines between two points of the other shape. (Not touching corners, but corners touching the side of another shape).

I did try using PGS_Conversion.roundVertexCoords() which seems to help in some cases, making the non-unision more rare, but not completely go away.

Just thought i'd share my findings - not shure what to try next... thx anyways!

micycle1 commented 2 years ago

Can you share code?

micycle1 commented 1 year ago

Closed -- stale. Further, union() should always reproduce both shapes even if they do not intersect (in this case they become a single group shape having 2 disjoint child shapes).