diff --git a/src/db/db/dbEdgeProcessor.cc b/src/db/db/dbEdgeProcessor.cc index 60889271b..62e4443cf 100644 --- a/src/db/db/dbEdgeProcessor.cc +++ b/src/db/db/dbEdgeProcessor.cc @@ -155,7 +155,7 @@ is_point_on_fuzzy (const db::Edge &e, const db::Point &pt) if (a1 < 0) { a1 = -a1; } area_type a2 = db::vprod (offset, e.d ()); if (a2 < 0) { a2 = -a2; } - return a1 <= a2; + return a1 < a2; } } @@ -1345,32 +1345,17 @@ get_intersections_per_band_any (std::vector &cutpoints, std::vector #endif // The new cutpoint must be inserted into other edges as well. - // If the cutpoint is exactly on the edge and there is just one other edge - // 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 (n_off_edge > 1) { - (*icc)->make_cutpoints (cutpoints)->add (cp.second, &cutpoints, true); + (*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 ()); + printf ("intersection point %s gives cutpoint in %s.\n", cp.second.to_string ().c_str (), (*icc)->to_string ().c_str ()); #endif - } else { - CutPoints *cpp = (*icc)->make_cutpoints (cutpoints); - cpp->add_attractor (cp.second, (*icc)->data - 1); -#ifdef DEBUG_EDGE_PROCESSOR - printf ("intersection point %s gives weak attractor in %s.\n", cp.second.to_string ().c_str (), (*icc)->to_string ().c_str ()); -#endif - } } } @@ -1435,38 +1420,17 @@ get_intersections_per_band_any (std::vector &cutpoints, std::vector #endif // The new cutpoint must be inserted into other edges as well. - // If the cutpoint is exactly on the edge and there is just one other edge - // 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 (n_off_edge > 1) { - (*icc)->make_cutpoints (cutpoints)->add (cp.second, &cutpoints, true); + (*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 ()); + printf ("intersection point %s gives cutpoint in %s.\n", cp.second.to_string ().c_str (), (*icc)->to_string ().c_str ()); #endif - } else { - CutPoints *cpp = (*icc)->make_cutpoints (cutpoints); - cpp->add_attractor (cp.second, (*icc)->data - 1); -#ifdef DEBUG_EDGE_PROCESSOR - printf ("intersection point %s gives weak attractor in %s.\n", cp.second.to_string ().c_str (), (*icc)->to_string ().c_str ()); -#endif - } } } diff --git a/src/db/db/dbPolygonGenerators.cc b/src/db/db/dbPolygonGenerators.cc index c75b8f24d..dcb9cf274 100644 --- a/src/db/db/dbPolygonGenerators.cc +++ b/src/db/db/dbPolygonGenerators.cc @@ -296,7 +296,7 @@ PolygonGenerator::flush () { #ifdef DEBUG_POLYGON_GENERATOR for (open_map_iterator_type i = m_open.begin (); i != m_open.end (); ++i) { - printf ("%d:%s%c%c ", i->contour, i->point.to_string().c_str(), i->first ? '!' : ' ', i == m_open_pos ? '*' : ' '); + printf ("%ld:%s%c%c ", i->contour, i->point.to_string().c_str(), i->first ? '!' : ' ', i == m_open_pos ? '*' : ' '); } printf ("\n"); #endif @@ -325,12 +325,12 @@ PolygonGenerator::begin_scanline (db::Coord y) #ifdef DEBUG_POLYGON_GENERATOR printf ("m_open="); for (open_map_type::const_iterator o = m_open.begin (); o != m_open.end (); ++o) { - printf ("%d:%s ", o->contour, o->point.to_string().c_str()); + printf ("%ld:%s ", o->contour, o->point.to_string().c_str()); } printf ("\n"); printf ("contours:\n"); for (size_t j = 0; j < mp_contours->size (); ++j) { - printf ("c%d%s: ", j, (*mp_contours)[j].is_hole () ? "H" : ""); + printf ("c%ld%s: ", j, (*mp_contours)[j].is_hole () ? "H" : ""); for (size_t i = 0; i < (*mp_contours)[j].size (); ++i) { printf ("%s ", ((*mp_contours)[j].begin () + i)->to_string().c_str ()); } @@ -364,7 +364,7 @@ PolygonGenerator::skip_n (size_t n) { join_contours (std::numeric_limits::max ()); #ifdef DEBUG_POLYGON_GENERATOR - printf ("skip(%d)\n", n); + printf ("skip(%ld)\n", n); #endif while (n-- > 0) { ++m_open_pos; @@ -375,9 +375,9 @@ void PolygonGenerator::put (const db::Edge &e) { #ifdef DEBUG_POLYGON_GENERATOR - printf ("put(%s) y=%d m_open(%d)=", e.to_string().c_str(),m_y,std::distance (m_open.begin (), m_open_pos)); + printf ("put(%s) y=%d m_open(%ld)=", e.to_string().c_str(),m_y,std::distance (m_open.begin (), m_open_pos)); for (open_map_iterator_type i = m_open.begin (); i != m_open.end (); ++i) { - printf ("%d:%s%c%c ", i->contour, i->point.to_string().c_str(), i->first ? '!' : ' ', i == m_open_pos ? '*' : ' '); + printf ("%ld:%s%c%c ", i->contour, i->point.to_string().c_str(), i->first ? '!' : ' ', i == m_open_pos ? '*' : ' '); } printf ("\n"); #endif @@ -438,7 +438,7 @@ PolygonGenerator::put (const db::Edge &e) cnew.push_back (e.p2 ()); #ifdef DEBUG_POLYGON_GENERATOR - printf ("create %s %d\n", hole ? "hole" : "hull", poly_index); + printf ("create %s %ld\n", hole ? "hole" : "hull", inew); #endif m_open.insert (m_open_pos, PGPoint (hole ? e.p1 () : e.p2 (), inew, true)); m_open.insert (m_open_pos, PGPoint (hole ? e.p2 () : e.p1 (), inew, false)); @@ -449,7 +449,7 @@ PolygonGenerator::put (const db::Edge &e) #ifdef DEBUG_POLYGON_GENERATOR for (open_map_iterator_type i = m_open.begin (); i != m_open.end (); ++i) { - printf ("%d:%s%c%c ", i->contour, i->point.to_string().c_str(), i->first ? '!' : ' ', i == m_open_pos ? '*' : ' '); + printf ("%ld:%s%c%c ", i->contour, i->point.to_string().c_str(), i->first ? '!' : ' ', i == m_open_pos ? '*' : ' '); } printf ("\n"); #endif @@ -552,14 +552,14 @@ PolygonGenerator::join_contours (db::Coord x) size_t i1 = m_open_pos->contour; size_t i2 = n->contour; #ifdef DEBUG_POLYGON_GENERATOR - printf ("join %d and %d\n", i1, i2); + printf ("join %ld and %ld\n", i1, i2); for (open_map_iterator_type i = m_open.begin (); i != m_open.end (); ++i) { - printf ("%d:%s%c%c%c%c ", i->contour, i->point.to_string().c_str(), i->first ? '!' : ' ', i == m_open_pos ? '*' : ' ', i == n ? '+' : ' ', i == nn ? '#' : ' '); + printf ("%ld:%s%c%c%c%c ", i->contour, i->point.to_string().c_str(), i->first ? '!' : ' ', i == m_open_pos ? '*' : ' ', i == n ? '+' : ' ', i == nn ? '#' : ' '); } printf ("\n"); printf ("--> input contours:\n"); for (size_t j = 0; j < mp_contours->size (); ++j) { - printf ("--> c%d%s: ", j, (*mp_contours)[j].is_hole () ? "H" : ""); + printf ("--> c%ld%s: ", j, (*mp_contours)[j].is_hole () ? "H" : ""); for (size_t i = 0; i < (*mp_contours)[j].size (); ++i) { printf ("%s ", ((*mp_contours)[j].begin () + i)->to_string().c_str ()); } @@ -705,7 +705,7 @@ PolygonGenerator::join_contours (db::Coord x) if (! c1.is_hole ()) { #ifdef DEBUG_POLYGON_GENERATOR - printf ("finish %d (hull)\n", i1); + printf ("finish %ld (hull)\n", i1); #endif produce_poly (c1); @@ -775,7 +775,7 @@ PolygonGenerator::join_contours (db::Coord x) #ifdef DEBUG_POLYGON_GENERATOR printf ("--> output contours:\n"); for (size_t j = 0; j < mp_contours->size (); ++j) { - printf ("--> c%d%s: ", j, (*mp_contours)[j].is_hole () ? "H" : ""); + printf ("--> c%ld%s: ", j, (*mp_contours)[j].is_hole () ? "H" : ""); for (size_t i = 0; i < (*mp_contours)[j].size (); ++i) { printf ("%s ", ((*mp_contours)[j].begin () + i)->to_string().c_str ()); } diff --git a/src/db/unit_tests/dbEdgeProcessor.cc b/src/db/unit_tests/dbEdgeProcessor.cc index a7abc8de4..13f2110e0 100644 --- a/src/db/unit_tests/dbEdgeProcessor.cc +++ b/src/db/unit_tests/dbEdgeProcessor.cc @@ -25,6 +25,7 @@ #include "dbShapeProcessor.h" #include "dbPolygon.h" +#include "dbPolygonGenerators.h" #include "dbLayout.h" #include "dbReader.h" #include "dbCommonReader.h" @@ -1390,15 +1391,29 @@ TEST(24) in1.back ().assign_hull (p1 + 0, p1 + sizeof (p1) / sizeof (p1[0])); } - std::vector out; + { + std::vector out; - db::EdgeProcessor ep; - ep.simple_merge (in1, out, false, false); + db::EdgeProcessor ep; + ep.simple_merge (in1, out, false, false); - EXPECT_EQ (out.size (), size_t (2)); - std::sort (out.begin (), out.end ()); - EXPECT_EQ (out[0].to_string (), "(0,-9;0,0;3,0;3,-2;1,0;1,-9)"); - EXPECT_EQ (out[1].to_string (), "(-2,1;-2,3;0,1;0,10;1,10;1,1)"); + EXPECT_EQ (out.size (), size_t (1)); + std::sort (out.begin (), out.end ()); + EXPECT_EQ (out[0].to_string (), "(0,-9;0,0;-2,1;-2,3;0,1;0,10;1,10;1,1;3,0;3,-2;1,0;1,-9/1,0;1,1;0,1)"); + } + + { + std::vector out; + + db::EdgeProcessor ep; + ep.simple_merge (in1, out, false, true); + + EXPECT_EQ (out.size (), size_t (3)); + std::sort (out.begin (), out.end ()); + EXPECT_EQ (out[0].to_string (), "(0,-9;0,0;-2,1;-2,3;1,0;1,-9)"); + EXPECT_EQ (out[1].to_string (), "(3,-2;1,0;1,1;3,0)"); + EXPECT_EQ (out[2].to_string (), "(0,1;0,10;1,10;1,1)"); + } } TEST(25) @@ -2348,3 +2363,28 @@ TEST(102) 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)"); } + +// Bug 134 +TEST(134) +{ + const char *pd = "(30,-7957;0,0;56,-4102;30,-7921)"; + + db::Coord dx = 0; + db::Coord dy = -3999; + unsigned int mode = 3; + + db::Polygon p; + tl::from_string (pd, p); + + db::EdgeProcessor ep; + db::Polygon ps (p.sized (dx, dy, mode)); + ep.insert (ps); + + db::SimpleMerge op (1 /*wc>0*/); + std::vector out; + db::PolygonContainer pc (out); + db::PolygonGenerator pg (pc); + ep.process (pg, op); + + EXPECT_EQ (out.size (), size_t (0)); +} diff --git a/testdata/bool/and6.oas b/testdata/bool/and6.oas index ee22c6308..ede4333dd 100644 Binary files a/testdata/bool/and6.oas and b/testdata/bool/and6.oas differ diff --git a/testdata/bool/and6_tz.oas b/testdata/bool/and6_tz.oas index a89c61f5c..5ca2cd2a9 100644 Binary files a/testdata/bool/and6_tz.oas and b/testdata/bool/and6_tz.oas differ diff --git a/testdata/bool/anotb6.oas b/testdata/bool/anotb6.oas index c9279ee05..0573a3b89 100644 Binary files a/testdata/bool/anotb6.oas and b/testdata/bool/anotb6.oas differ diff --git a/testdata/bool/or6.oas b/testdata/bool/or6.oas index f911c0434..942045a1e 100644 Binary files a/testdata/bool/or6.oas and b/testdata/bool/or6.oas differ diff --git a/testdata/bool/size1_au.oas b/testdata/bool/size1_au.oas index c6bcdd6d2..f99203f5a 100644 Binary files a/testdata/bool/size1_au.oas and b/testdata/bool/size1_au.oas differ diff --git a/testdata/bool/size6_au1.oas b/testdata/bool/size6_au1.oas index 1f036c931..2d01fea66 100644 Binary files a/testdata/bool/size6_au1.oas and b/testdata/bool/size6_au1.oas differ diff --git a/testdata/bool/special2_au1.oas b/testdata/bool/special2_au1.oas index 4ede68bd4..79c9da9e0 100644 Binary files a/testdata/bool/special2_au1.oas and b/testdata/bool/special2_au1.oas differ diff --git a/testdata/bool/special2_au1_tz.oas b/testdata/bool/special2_au1_tz.oas index b677cc72d..a3ec6b9f4 100644 Binary files a/testdata/bool/special2_au1_tz.oas and b/testdata/bool/special2_au1_tz.oas differ diff --git a/testdata/bool/special2_au2.oas b/testdata/bool/special2_au2.oas index 64f535f29..0e731d4e8 100644 Binary files a/testdata/bool/special2_au2.oas and b/testdata/bool/special2_au2.oas differ diff --git a/testdata/bool/special2_au2_tz.oas b/testdata/bool/special2_au2_tz.oas index 76d37a8c9..e4f984d3d 100644 Binary files a/testdata/bool/special2_au2_tz.oas and b/testdata/bool/special2_au2_tz.oas differ diff --git a/testdata/bool/special2_au3.oas b/testdata/bool/special2_au3.oas index ba4797a8a..ed63e7428 100644 Binary files a/testdata/bool/special2_au3.oas and b/testdata/bool/special2_au3.oas differ diff --git a/testdata/bool/special2_au3_tz.oas b/testdata/bool/special2_au3_tz.oas index 0025f84a2..85395477c 100644 Binary files a/testdata/bool/special2_au3_tz.oas and b/testdata/bool/special2_au3_tz.oas differ diff --git a/testdata/bool/special2_au4.oas b/testdata/bool/special2_au4.oas index cb6e9e7e7..69d9e422e 100644 Binary files a/testdata/bool/special2_au4.oas and b/testdata/bool/special2_au4.oas differ diff --git a/testdata/bool/special2_au4_tz.oas b/testdata/bool/special2_au4_tz.oas index 1528b10ea..2d5747280 100644 Binary files a/testdata/bool/special2_au4_tz.oas and b/testdata/bool/special2_au4_tz.oas differ diff --git a/testdata/bool/special2_au5.oas b/testdata/bool/special2_au5.oas index e8f38fa72..a50494df8 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 e4bea08c4..a21c66fcd 100644 Binary files a/testdata/bool/special2_au5_tz.oas and b/testdata/bool/special2_au5_tz.oas differ diff --git a/testdata/bool/xor6.oas b/testdata/bool/xor6.oas index 445a0ed79..3bad17465 100644 Binary files a/testdata/bool/xor6.oas and b/testdata/bool/xor6.oas differ diff --git a/testdata/bool/xor6_max.oas b/testdata/bool/xor6_max.oas index 9dbdfc74d..07a463115 100644 Binary files a/testdata/bool/xor6_max.oas and b/testdata/bool/xor6_max.oas differ diff --git a/testdata/bool/xor6_tz.oas b/testdata/bool/xor6_tz.oas index 4dd260178..e40ded81b 100644 Binary files a/testdata/bool/xor6_tz.oas and b/testdata/bool/xor6_tz.oas differ diff --git a/testdata/bool/xor7_au1.oas b/testdata/bool/xor7_au1.oas index 6ffc97315..14ef193ed 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 6ffc97315..14ef193ed 100644 Binary files a/testdata/bool/xor7_au2.oas and b/testdata/bool/xor7_au2.oas differ diff --git a/testdata/bool/xor7_au_tz.oas b/testdata/bool/xor7_au_tz.oas index 0cb98f913..281d76107 100644 Binary files a/testdata/bool/xor7_au_tz.oas and b/testdata/bool/xor7_au_tz.oas differ diff --git a/testdata/bool/xor7_max_au1.oas b/testdata/bool/xor7_max_au1.oas index bcec6b636..00cb9e40e 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 bcec6b636..00cb9e40e 100644 Binary files a/testdata/bool/xor7_max_au2.oas and b/testdata/bool/xor7_max_au2.oas differ diff --git a/testdata/bool/xor8_au1.oas b/testdata/bool/xor8_au1.oas index b14e9cdf4..59e719d15 100644 Binary files a/testdata/bool/xor8_au1.oas and b/testdata/bool/xor8_au1.oas differ diff --git a/testdata/bool/xor8_au2.oas b/testdata/bool/xor8_au2.oas index b14e9cdf4..59e719d15 100644 Binary files a/testdata/bool/xor8_au2.oas and b/testdata/bool/xor8_au2.oas differ diff --git a/testdata/bool/xor8_au_tz.oas b/testdata/bool/xor8_au_tz.oas index c238d222f..f15321b4c 100644 Binary files a/testdata/bool/xor8_au_tz.oas and b/testdata/bool/xor8_au_tz.oas differ