polybooljs icon indicating copy to clipboard operation
polybooljs copied to clipboard

Zero length segments created

Open lgpmichael2 opened this issue 2 years ago • 1 comments

Hi,

OK so I've been having issues where I was getting zero length segments. They were created by either difference or intersect, not sure which, the path of creating them was a bit obscure (several hundred polygons some with thousands of vertices being operated on).

None of the initial polygons had a zero length segment, I checked that, but they ended up with some

So, I added the following. It SEEMS to be working and by the looks of it should be safe, but I'd like someone who knows more of the inner workings to verify there are no side effects before I create a PR.

--- js/polybool.js.crash        2021-09-21 08:31:22.649552763 +0100
+++ js/polybool.js      2021-09-21 07:18:43.756997472 +0100
@@ -882,6 +882,15 @@
 
                        if (ev.isStart){
 
+                           if (ev.pt[0]==ev.other.pt[0] &&
+                               ev.pt[1]==ev.other.pt[1])
+                           {
+                               //Identical, drop it
+                               ev.other.remove();
+                               ev.remove();
+                               continue;
+                           }
+
                                if (buildLog)
                                        buildLog.segmentNew(ev.seg, ev.primary);

lgpmichael2 avatar Sep 21 '21 07:09 lgpmichael2

Thanks!

Unfortunately, I really haven't looked at this code in a long time, so I don't have the context in my head anymore. If it's okay, I'll just leave this ticket open so if someone else wants to try out the patch, they have the information.

velipso avatar Sep 21 '21 13:09 velipso