Merge pull request #2209 from KLayout/bugfix/issue-2208

Fixing issue #2208
This commit is contained in:
Matthias Köfferlein
2025-11-09 18:22:47 +01:00
committed by GitHub
15 changed files with 27 additions and 6 deletions
+4 -4
View File
@@ -858,7 +858,7 @@ public:
coord_type distance (const db::point<C> &p) const
{
// the distance is computed from
// d = (a x b) / sqrt (a * a)
// d = (a x b) / |a|
// where b = p - p1, a = p2 - p1
if (is_degenerate ()) {
// for safety handle this case - without a reasonable result
@@ -866,7 +866,7 @@ public:
} else {
// compute the distance as described above
area_type axb = coord_traits::vprod (m_p2.x (), m_p2.y (), p.x (), p.y (), m_p1.x (), m_p1.y ());
double d = double (axb) / double (length ());
double d = double (axb) / double_length ();
// and round
return coord_traits::rounded (d);
}
@@ -929,7 +929,7 @@ public:
distance_type distance_abs (const db::point<C> &p) const
{
// the distance is computed from
// d = (a x b) / sqrt (a * a)
// d = (a x b) / |a|
// where b = p - p1, a = p2 - p1
if (is_degenerate ()) {
// for safety handle this case - without a reasonable result
@@ -937,7 +937,7 @@ public:
} else {
// compute the distance as described above
area_type axb = coord_traits::vprod (m_p2.x (), m_p2.y (), p.x (), p.y (), m_p1.x (), m_p1.y ());
double d = fabs (double (axb)) / double (length ());
double d = fabs (double (axb)) / double_length ();
// and round
return coord_traits::rounded_distance (d);
}
+1 -1
View File
@@ -1327,7 +1327,7 @@ TEST(105)
EXPECT_EQ (smooth (p, 0, false).to_string (), "(0,0;0,1000;100,1000;100,1100;800,1100;800,1000;2000,1000;2000,0)");
EXPECT_EQ (smooth (p, 50, false).to_string (), "(0,0;0,1000;100,1000;100,1100;800,1100;800,1000;2000,1000;2000,0)");
EXPECT_EQ (smooth (p, 80, false).to_string (), "(0,0;0,1000;100,1100;800,1100;800,1000;2000,1000;2000,0)");
EXPECT_EQ (smooth (p, 90, false).to_string (), "(0,0;100,1100;800,1100;800,1000;2000,1000;2000,0)");
EXPECT_EQ (smooth (p, 90, false).to_string (), "(0,0;0,1000;800,1100;800,1000;2000,1000;2000,0)");
EXPECT_EQ (smooth (p, 100, false).to_string (), "(0,0;0,1000;2000,1000;2000,0)");
EXPECT_EQ (smooth (p, 100, true).to_string (), "(0,0;0,1000;100,1000;100,1100;800,1100;800,1000;2000,1000;2000,0)");
}
+21
View File
@@ -2998,3 +2998,24 @@ TEST(issue_909)
EXPECT_EQ (r.to_string (), "(0,0;0,100;100,100;100,0);(0,0;0,300;200,300;200,0)");
}
TEST(issue_2208)
{
db::Point points[] = {
db::Point (-36, -2698),
db::Point (-3226, 492),
db::Point (-2871, 847),
db::Point (-746, -1278),
db::Point (-751, -1283),
db::Point (-746, -1288),
db::Point (-741, -1283),
db::Point (319, -2343)
};
db::Region r;
db::Polygon p;
p.assign_hull (points + 0, points + sizeof (points) / sizeof (points [0]));
r.insert (p);
db::EdgePairs ep = r.width_check (500);
EXPECT_EQ (ep.to_string (), "(-1046,-1688;-1151,-1583)|(-751,-1283;-746,-1288)");
}
@@ -104,7 +104,7 @@ TEST(1b)
TEST(2)
{
run_test (_this, "t2.dxf.gz", "t2_au.gds.gz");
run_test (_this, "t2.dxf.gz", "t2_au2.gds.gz");
}
TEST(3)
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.