diff --git a/src/db/db/dbPolygonGenerators.cc b/src/db/db/dbPolygonGenerators.cc index fd8b2ccda..c75b8f24d 100644 --- a/src/db/db/dbPolygonGenerators.cc +++ b/src/db/db/dbPolygonGenerators.cc @@ -731,8 +731,13 @@ PolygonGenerator::join_contours (db::Coord x) db::Coord xprev = db::coord_traits::rounded (edge_xaty (eprev, m_y)); db::Point pprev (xprev, m_y); - tl_assert (c1.size () >= 2); + // remove collinear edges along the cut line cprev.back () = pprev; + while (cprev.size () > 1 && cprev.end ()[-2].y () == m_y && cprev.end ()[-1].y () == m_y) { + cprev.pop_back (); + } + + tl_assert (c1.size () >= 2); if ((c1.begin () + 1)->y () == m_y) { cprev.insert (cprev.end (), c1.begin () + 1, c1.end ()); } else { diff --git a/src/db/unit_tests/dbEdgeProcessor.cc b/src/db/unit_tests/dbEdgeProcessor.cc index 623defb7e..f5fe79a34 100644 --- a/src/db/unit_tests/dbEdgeProcessor.cc +++ b/src/db/unit_tests/dbEdgeProcessor.cc @@ -2295,3 +2295,54 @@ TEST(101) EXPECT_EQ (out.size (), size_t (1)); EXPECT_EQ (out[0].to_string (), "(0,0;0,9;1,10;10,10;10,0)"); } + +TEST(102) +{ + db::EdgeProcessor ep; + + { + db::Point pts[] = { + db::Point (0, 0), + db::Point (0, 1000), + db::Point (1000, 1000), + db::Point (1000, 0) + }; + db::Polygon p; + p.assign_hull (&pts[0], &pts[sizeof(pts) / sizeof(pts[0])]); + ep.insert (p, 0); + } + + { + db::Point pts[] = { + db::Point (100, 100), + db::Point (100, 200), + db::Point (200, 200), + db::Point (200, 100) + }; + db::Polygon p; + p.assign_hull (&pts[0], &pts[sizeof(pts) / sizeof(pts[0])]); + ep.insert (p, 1); + } + + { + db::Point pts[] = { + db::Point (500, 100), + db::Point (500, 200), + db::Point (600, 200), + db::Point (600, 100) + }; + db::Polygon p; + p.assign_hull (&pts[0], &pts[sizeof(pts) / sizeof(pts[0])]); + ep.insert (p, 1); + } + + std::vector out; + db::PolygonContainer pc (out); + db::PolygonGenerator pg (pc, true, true); + db::BooleanOp op (db::BooleanOp::ANotB); + + ep.process (pg, op); + + EXPECT_EQ (out.size (), size_t (1)); + EXPECT_EQ (out[0].to_string (), "(0,0;0,200;100,200;100,100;200,100;200,200;500,200;500,100;600,100;600,200;0,200;0,1000;1000,1000;1000,0)"); +} diff --git a/testdata/bool/and5.oas b/testdata/bool/and5.oas index 854a5cc79..f5024e6ed 100644 Binary files a/testdata/bool/and5.oas and b/testdata/bool/and5.oas differ diff --git a/testdata/bool/anotb5.oas b/testdata/bool/anotb5.oas index c935571c9..774df860e 100644 Binary files a/testdata/bool/anotb5.oas and b/testdata/bool/anotb5.oas differ diff --git a/testdata/bool/or5.oas b/testdata/bool/or5.oas index 7195b5594..78294b9de 100644 Binary files a/testdata/bool/or5.oas and b/testdata/bool/or5.oas differ diff --git a/testdata/bool/or6.oas b/testdata/bool/or6.oas index 384483b61..f911c0434 100644 Binary files a/testdata/bool/or6.oas and b/testdata/bool/or6.oas differ diff --git a/testdata/bool/size7_au1.oas b/testdata/bool/size7_au1.oas index 9ae54de00..1fe2329e0 100644 Binary files a/testdata/bool/size7_au1.oas and b/testdata/bool/size7_au1.oas differ diff --git a/testdata/bool/special2_au1.oas b/testdata/bool/special2_au1.oas index edc8aff89..4ede68bd4 100644 Binary files a/testdata/bool/special2_au1.oas and b/testdata/bool/special2_au1.oas differ diff --git a/testdata/bool/special2_au2.oas b/testdata/bool/special2_au2.oas index 56d1c79e7..64f535f29 100644 Binary files a/testdata/bool/special2_au2.oas and b/testdata/bool/special2_au2.oas differ diff --git a/testdata/bool/special2_au3.oas b/testdata/bool/special2_au3.oas index 804d935c6..ba4797a8a 100644 Binary files a/testdata/bool/special2_au3.oas and b/testdata/bool/special2_au3.oas differ diff --git a/testdata/bool/special2_au4.oas b/testdata/bool/special2_au4.oas index 6e698ef05..cb6e9e7e7 100644 Binary files a/testdata/bool/special2_au4.oas and b/testdata/bool/special2_au4.oas differ diff --git a/testdata/bool/special2_au5.oas b/testdata/bool/special2_au5.oas index ca1be7afa..e8f38fa72 100644 Binary files a/testdata/bool/special2_au5.oas and b/testdata/bool/special2_au5.oas differ diff --git a/testdata/bool/special2_au5_tz.oas b/testdata/bool/special2_au5_tz.oas index 440a46887..e4bea08c4 100644 Binary files a/testdata/bool/special2_au5_tz.oas and b/testdata/bool/special2_au5_tz.oas differ diff --git a/testdata/bool/special3_au1.oas b/testdata/bool/special3_au1.oas index 63910c65d..3f666f44a 100644 Binary files a/testdata/bool/special3_au1.oas and b/testdata/bool/special3_au1.oas differ diff --git a/testdata/bool/special3_au2.oas b/testdata/bool/special3_au2.oas index de318603a..b0bcee8d7 100644 Binary files a/testdata/bool/special3_au2.oas and b/testdata/bool/special3_au2.oas differ diff --git a/testdata/bool/special3_au5.oas b/testdata/bool/special3_au5.oas index 30e56db14..e4f0f1e8f 100644 Binary files a/testdata/bool/special3_au5.oas and b/testdata/bool/special3_au5.oas differ diff --git a/testdata/bool/xor1_max.oas b/testdata/bool/xor1_max.oas index a148010b6..bf4956f56 100644 Binary files a/testdata/bool/xor1_max.oas and b/testdata/bool/xor1_max.oas differ diff --git a/testdata/bool/xor5.oas b/testdata/bool/xor5.oas index 6887c4249..f35773fdc 100644 Binary files a/testdata/bool/xor5.oas and b/testdata/bool/xor5.oas differ diff --git a/testdata/bool/xor5_max.oas b/testdata/bool/xor5_max.oas index f10bc226c..a8a5c9553 100644 Binary files a/testdata/bool/xor5_max.oas and b/testdata/bool/xor5_max.oas differ diff --git a/testdata/bool/xor6_max.oas b/testdata/bool/xor6_max.oas index a59d331fe..9dbdfc74d 100644 Binary files a/testdata/bool/xor6_max.oas and b/testdata/bool/xor6_max.oas differ diff --git a/testdata/bool/xor7_au1.oas b/testdata/bool/xor7_au1.oas index bb38e5b9e..6ffc97315 100644 Binary files a/testdata/bool/xor7_au1.oas and b/testdata/bool/xor7_au1.oas differ diff --git a/testdata/bool/xor7_au2.oas b/testdata/bool/xor7_au2.oas index bb38e5b9e..6ffc97315 100644 Binary files a/testdata/bool/xor7_au2.oas and b/testdata/bool/xor7_au2.oas differ diff --git a/testdata/bool/xor7_max_au1.oas b/testdata/bool/xor7_max_au1.oas index 9c3c6747b..bcec6b636 100644 Binary files a/testdata/bool/xor7_max_au1.oas and b/testdata/bool/xor7_max_au1.oas differ diff --git a/testdata/bool/xor7_max_au2.oas b/testdata/bool/xor7_max_au2.oas index 9c3c6747b..bcec6b636 100644 Binary files a/testdata/bool/xor7_max_au2.oas and b/testdata/bool/xor7_max_au2.oas differ