Merge pull request #167 from klayoutmatthias/issue-166

Issue 166
This commit is contained in:
Matthias Köfferlein 2018-09-17 21:21:13 +02:00 committed by GitHub
commit 1d7101bced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 4 deletions

View File

@ -112,7 +112,7 @@ struct cut_polygon_edge
{
typedef typename PointType::coord_type coord_type;
typedef typename db::edge<coord_type> edge_type;
typedef typename db::coord_traits<coord_type>::area_type projection_type;
typedef double projection_type;
cut_polygon_edge ()
: contour (-1), index (0), projected (0), point (), last_point ()
@ -179,7 +179,7 @@ public:
bool operator< (const loose_end_struct<CuttingEdgeType> &other) const
{
if (proj () != other.proj ()) {
if (! db::coord_traits<double>::equal (proj (), other.proj ())) {
return proj () < other.proj ();
} else {
return db::vprod_sign (edge (), other.edge ()) > 0;
@ -196,13 +196,13 @@ static bool _cut_polygon_internal (const PolygonType &input, const Edge &line, C
typedef db::edge<coord_type> edge_type;
typedef cut_polygon_edge<point_type> cut_polygon_edge_type;
typedef cut_polygon_segment<cut_polygon_edge_type> cutting_segment_type;
typedef typename db::coord_traits<coord_type>::area_type projection_type;
bool do_hole_assignment = (input.holes () > 0);
std::vector <PolygonType> hull_polygons;
std::vector <PolygonType> hole_polygons;
std::vector<cutting_segment_type> cutting_segments;
double line_length = line.double_length ();
for (unsigned int nc = 0; nc < input.holes () + 1; ++nc) {
@ -229,7 +229,7 @@ static bool _cut_polygon_internal (const PolygonType &input, const Edge &line, C
int s1 = line.side_of (e.p1 ());
int s2 = line.side_of (e.p2 ());
projection_type p = db::sprod (ip.second - line.p1 (), line.p2 () - line.p1 ());
double p = line_length * double (db::vprod (e.p1 () - line.p1 (), e.d ())) / double (db::vprod (line.d (), e.d ()));
if (s1 < 0 && s2 >= 0) {
// right -> left or on edge

View File

@ -1145,3 +1145,11 @@ TEST(121)
opt.max_vertex_count = 4;
run_test (_this, "t121.oas.gz", "t121_au.gds.gz", true, opt);
}
// Extreme fracturing by max. points
TEST(166)
{
db::GDS2WriterOptions opt;
opt.max_vertex_count = 4;
run_test (_this, "t166.oas.gz", "t166_au.gds.gz", false, opt);
}

View File

@ -2241,3 +2241,20 @@ TEST(403)
EXPECT_EQ (right_of.size (), size_t (0));
}
}
// issue 166
TEST(404)
{
db::Polygon poly;
std::string s ("(390,0;438,936;176,874;0,832;438,937;541,961;821,102)");
tl::Extractor ex (s.c_str ());
ex.read (poly);
std::vector<db::Polygon> sp;
db::split_polygon (poly, sp);
EXPECT_EQ (sp.size (), size_t (2));
if (sp.size () >= 2) {
EXPECT_EQ (sp[0].to_string (), "(390,0;438,936;390,925;438,937;541,961;821,102)");
EXPECT_EQ (sp[1].to_string (), "(0,832;176,874;390,925)");
}
}

BIN
testdata/gds/t166.oas.gz vendored Normal file

Binary file not shown.

BIN
testdata/gds/t166_au.gds.gz vendored Normal file

Binary file not shown.