ChristianLutz / gpcj

General Poly Clipper Algorithm in Java
Other
7 stars 1 forks source link

Intersection of complex polygons fails #2

Open mipastgt opened 1 week ago

mipastgt commented 1 week ago

I don't know whether this project is still supported but I just give it a try.

The attached test tries to compute the intersection of a complex polygon (just two rectangles) with another polygon (a simple rectangle). The test fails with an illegal state exception so computing the intersection of complex polygons does not seem to be supported, although I haven't found any hint in the documentation about this.

Only applies to polys of size 1 java.lang.IllegalStateException: Only applies to polys of size 1 at com.seisw.util.geom.PolyDefault.setContributing(PolyDefault.kt:257) at com.seisw.util.geom.Clip.minimax_test(Clip.kt:841) at com.seisw.util.geom.Clip.clip(Clip.kt:223) at com.seisw.util.geom.Clip.intersection(Clip.kt:104) at com.seisw.util.geom.PolyDefault.intersection(PolyDefault.kt:268) at com.seisw.util.geom.IntersectionTest.test(IntersectionTest.kt:33) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

IntersectionTest.kt.zip

ChristianLutz commented 6 days ago

Hello,

thank you for reporting it. And documenting this error.

It is quite some time since I used the library. Never developed any of it by myself.

But I'll give it a try.