diff --git a/src/db/db/dbPolygonTools.cc b/src/db/db/dbPolygonTools.cc index db18b69d3..ca1f077ea 100644 --- a/src/db/db/dbPolygonTools.cc +++ b/src/db/db/dbPolygonTools.cc @@ -2300,9 +2300,11 @@ static void decompose_convex_helper (int depth, PreferredOrientation po, const d db::Box bbox = sp.box (); db::coord_traits::area_type atot = 0; + db::coord_traits::distance_type min_edge = std::numeric_limits::distance_type>::max (); for (size_t i = 0; i < n; ++i) { db::Edge ep (sp.hull ()[(i + n - 1) % n], sp.hull ()[i]); atot += db::vprod (ep.p2 () - db::Point (), ep.p1 () - db::Point ()); + min_edge = std::min (min_edge, ep.length ()); } std::set skipped; @@ -2449,9 +2451,14 @@ static void decompose_convex_helper (int depth, PreferredOrientation po, const d int cr = 0; if (x.second == efc.p1 ()) { if (db::vprod (efc, efp) < 0) { - cr = 2; // cut terminates at another concave corner + cr = 3; // cut terminates at another concave corner } else { - cr = 1; // cut terminates at a convex corner + cr = 2; // cut terminates at a convex corner + } + } else { + db::coord_traits::distance_type el = std::min (x.second.distance (efc.p1 ()), x.second.distance (efc.p2 ())); + if (el >= min_edge) { + cr = 1; // does not induce shorter edge than we have so far } }