From a81a8cdbc8c204bc8d7e271536b1612169a8cebc Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 10 Feb 2019 16:03:46 +0100 Subject: [PATCH] Modified edge transformation to maintain the orientation paradigm When the transformation is mirroring, edges now swap their points to maintain the right-is-inside paradigm. --- src/db/db/dbEdge.h | 20 +++++++++++++++++--- src/db/unit_tests/dbEdge.cc | 8 +++++++- testdata/algo/deep_edges_au1.gds | Bin 0 -> 7406 bytes testdata/algo/deep_edges_au2.gds | Bin 0 -> 1898 bytes 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 testdata/algo/deep_edges_au1.gds create mode 100644 testdata/algo/deep_edges_au2.gds 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 0000000000000000000000000000000000000000..5400803328cc8e406195caf88e9674d89c83e63c GIT binary patch literal 7406 zcmb7|&5ImW6vb~>byt66l4#Pa5JZE5f<`e>kzkle#0(>&j6=|7Ao&9n1SN>51Y#f> zgn+K1iy#;maU}?W%u2+?tg>(+C=zfj3}iKf)8)DM)~$3^=2hJ{&~qE!`PDh^qu#4( z$|y| zlw~W+CzjqM>JEvr-3hLr?MVpVAL0Lly(#|Vx(}pzzI`swr;l+Z>ikLF2c49tDfz-r zk*QJH)91yMCA^R7hWj;5pkBuZHNRf*YN7J$p#F}cM6J|x-R%X+5=KxwgAe*FN%3*cSE)wA zC`#2rMT|TsOIV|_@cp&DhWYvo`^Fj)eq31_jTEafSC7U}s%DBky8H6Qm!MH^{PurPI$+cSJPWXQ$pApKH_ia79w@om)p6JG5p8I_HUS1z!hp5 zyH0V|23LPEl4Gsjd!|%V`eV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