diff --git a/src/db/db/dbEdgeProcessor.cc b/src/db/db/dbEdgeProcessor.cc index 60c449a13..60889271b 100644 --- a/src/db/db/dbEdgeProcessor.cc +++ b/src/db/db/dbEdgeProcessor.cc @@ -1349,13 +1349,17 @@ get_intersections_per_band_any (std::vector &cutpoints, std::vector // the cutpoint will be a weak attractor - that is an optional cutpoint. // In that case we can skip the cutpoint because no related edge will move. ip_weak.clear (); + size_t n_off_edge = on_edge1 ? 0 : 1; for (std::vector ::iterator cc = c; cc != f; ++cc) { if ((with_h || cc->dy () != 0) && cc != c1 && cc != c2 && is_point_on_fuzzy (*cc, cp.second)) { ip_weak.push_back (&*cc); + if (!is_point_on_exact (*cc, cp.second)) { + ++n_off_edge; + } } } for (std::vector ::iterator icc = ip_weak.begin (); icc != ip_weak.end (); ++icc) { - if (ip_weak.size () > 1 || !on_edge1) { + if (n_off_edge > 1) { (*icc)->make_cutpoints (cutpoints)->add (cp.second, &cutpoints, true); #ifdef DEBUG_EDGE_PROCESSOR printf ("intersection point %s gives cutpoint in %s.\n", cp.second.to_string ().c_str (), (*icc)->to_string ().c_str ()); @@ -1435,13 +1439,23 @@ get_intersections_per_band_any (std::vector &cutpoints, std::vector // the cutpoint will be a weak attractor - that is an optional cutpoint. // In that case we can skip the cutpoint because no related edge will move. ip_weak.clear (); + size_t n_off_edge = 0; + if (!on_edge1) { + n_off_edge += 1; + } + if (!on_edge2) { + n_off_edge += 1; + } for (std::vector ::iterator cc = c; cc != f; ++cc) { if ((with_h || cc->dy () != 0) && cc != c1 && cc != c2 && is_point_on_fuzzy (*cc, cp.second)) { ip_weak.push_back (&*cc); + if (!is_point_on_exact (*cc, cp.second)) { + ++n_off_edge; + } } } for (std::vector ::iterator icc = ip_weak.begin (); icc != ip_weak.end (); ++icc) { - if (ip_weak.size () > 1 || !on_edge1 || !on_edge2) { + if (n_off_edge > 1) { (*icc)->make_cutpoints (cutpoints)->add (cp.second, &cutpoints, true); #ifdef DEBUG_EDGE_PROCESSOR printf ("intersection point %s gives cutpoint in %s.\n", cp.second.to_string ().c_str (), (*icc)->to_string ().c_str ()); diff --git a/src/db/unit_tests/dbEdgeProcessor.cc b/src/db/unit_tests/dbEdgeProcessor.cc index 72e29671a..623defb7e 100644 --- a/src/db/unit_tests/dbEdgeProcessor.cc +++ b/src/db/unit_tests/dbEdgeProcessor.cc @@ -2244,3 +2244,54 @@ TEST(100) db::compare_layouts (_this, lr, au_fn); } +// #74 (GitHub) +TEST(101) +{ + db::EdgeProcessor ep; + + { + db::Point pts[] = { + db::Point (0, 0), + db::Point (0, 10), + db::Point (10, 10), + db::Point (10, 0) + }; + db::Polygon p; + p.assign_hull (&pts[0], &pts[sizeof(pts) / sizeof(pts[0])]); + ep.insert (p, 0); + } + + { + db::Point pts[] = { + db::Point (-1, -1), + db::Point (-1, 8), + db::Point (2, 11), + db::Point (2, -1) + }; + db::Polygon p; + p.assign_hull (&pts[0], &pts[sizeof(pts) / sizeof(pts[0])]); + ep.insert (p, 1); + } + + { + db::Point pts[] = { + db::Point (2, -1), + db::Point (2, 11), + db::Point (11, 11), + db::Point (11, -1) + }; + 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, false, true); + db::BooleanOp op (db::BooleanOp::And); + + ep.process (pg, op); + + EXPECT_EQ (out.size (), size_t (1)); + EXPECT_EQ (out[0].to_string (), "(0,0;0,9;1,10;10,10;10,0)"); +}