diff --git a/src/db/db/dbEdge.h b/src/db/db/dbEdge.h index e3959c620..923125e52 100644 --- a/src/db/db/dbEdge.h +++ b/src/db/db/dbEdge.h @@ -336,7 +336,14 @@ public: template edge &transform (const Tr &t) { - *this = edge (t * m_p1, t * m_p2); + if (t.is_mirror ()) { + // NOTE: in case of mirroring transformations we swap p1 and p2. The reasoning is that + // this way we maintain the orientation semantics: "right" of the edge is "inside" of + // an area. + *this = edge (t * m_p2, t * m_p1); + } else { + *this = edge (t * m_p1, t * m_p2); + } return *this; } @@ -353,7 +360,14 @@ public: template edge transformed (const Tr &t) const { - return edge (t * m_p1, t * m_p2); + if (t.is_mirror ()) { + // NOTE: in case of mirroring transformations we swap p1 and p2. The reasoning is that + // this way we maintain the orientation semantics: "right" of the edge is "inside" of + // an area. + return edge (t * m_p2, t * m_p1); + } else { + return edge (t * m_p1, t * m_p2); + } } /** @@ -914,7 +928,7 @@ public: } /** - * @brief Swap the points of the edge + * @brief Swaps the points of the edge */ edge &swap_points () { diff --git a/src/db/unit_tests/dbEdge.cc b/src/db/unit_tests/dbEdge.cc index 940e7a474..319fd1f5f 100644 --- a/src/db/unit_tests/dbEdge.cc +++ b/src/db/unit_tests/dbEdge.cc @@ -29,6 +29,7 @@ TEST(1) { db::Edge e (0, 0, 100, 200); + db::Edge ee; db::Edge empty; EXPECT_EQ (empty.is_degenerate (), true); @@ -53,6 +54,12 @@ TEST(1) EXPECT_EQ (e.to_string (), "(0,0;100,200)"); EXPECT_EQ (e.swapped_points ().to_string (), "(100,200;0,0)"); EXPECT_EQ (e.to_string (), "(0,0;100,200)"); + EXPECT_EQ (e.transformed (db::Trans (1)).to_string (), "(0,0;-200,100)"); + EXPECT_EQ (e.transformed (db::Trans (5)).to_string (), "(200,100;0,0)"); // mirroring transformations swap points + ee = e; + ee.transform (db::Trans (5)); + EXPECT_EQ (ee.to_string (), "(200,100;0,0)"); + EXPECT_EQ (e.swapped_points ().to_string (), "(100,200;0,0)"); e.swap_points (); EXPECT_EQ (e.to_string (), "(100,200;0,0)"); @@ -66,7 +73,6 @@ TEST(1) EXPECT_EQ (e.shifted (2).to_string (), "(0,4;10,12)"); EXPECT_EQ (e.shifted (1).to_string (), "(0,3;10,11)"); - db::Edge ee; ee = e; ee.shift (2); EXPECT_EQ (ee.to_string (), "(0,4;10,12)"); diff --git a/testdata/algo/deep_edges_au1.gds b/testdata/algo/deep_edges_au1.gds new file mode 100644 index 000000000..540080332 Binary files /dev/null and b/testdata/algo/deep_edges_au1.gds differ diff --git a/testdata/algo/deep_edges_au2.gds b/testdata/algo/deep_edges_au2.gds new file mode 100644 index 000000000..022d4132e Binary files /dev/null and b/testdata/algo/deep_edges_au2.gds differ