From 8f21cdf449a8f5ffa2fdb2d4592b235b86b319c2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 21 Jul 2019 22:57:02 +0200 Subject: [PATCH] Fixed issue #305 (CIF reader issue with rotated boxes) --- .../streamers/cif/db_plugin/dbCIFReader.cc | 10 ++++++---- .../streamers/cif/unit_tests/dbCIFReader.cc | 5 +++++ testdata/cif/issue_305.cif | 18 ++++++++++++++++++ testdata/cif/issue_305_au.gds | Bin 0 -> 426 bytes 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 testdata/cif/issue_305.cif create mode 100644 testdata/cif/issue_305_au.gds diff --git a/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc b/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc index a7ef013bb..c24a97933 100644 --- a/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc +++ b/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc @@ -592,11 +592,13 @@ CIFReader::read_cell (db::Layout &layout, db::Cell &cell, double sf, int level) double xw = sf * w * 0.5 * rx * n, yw = sf * w * 0.5 * ry * n; double xh = -sf * h * 0.5 * ry * n, yh = sf * h * 0.5 * rx * n; + db::Point c (sf * x, sf * y); + db::Point points [4]; - points [0] = db::Point (x - xw - xh, y - yw - yh); - points [1] = db::Point (x - xw + xh, y - yw + yh); - points [2] = db::Point (x + xw + xh, y + yw + yh); - points [3] = db::Point (x + xw - xh, y + yw - yh); + points [0] = c + db::Vector (-xw - xh, -yw - yh); + points [1] = c + db::Vector (-xw + xh, -yw + yh); + points [2] = c + db::Vector (xw + xh, yw + yh); + points [3] = c + db::Vector (xw - xh, yw - yh); db::Polygon p; p.assign_hull (points, points + 4); diff --git a/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc b/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc index b032e14e6..b81f9f5ae 100644 --- a/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc +++ b/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc @@ -189,3 +189,8 @@ TEST(lasi) run_test (_this, tl::testsrc (), "lasi.cif.gz", "lasi_au.gds.gz"); } +// Issue #305 +TEST(rot_boxes) +{ + run_test (_this, tl::testsrc (), "issue_305.cif", "issue_305_au.gds"); +} diff --git a/testdata/cif/issue_305.cif b/testdata/cif/issue_305.cif new file mode 100644 index 000000000..083bf6e70 --- /dev/null +++ b/testdata/cif/issue_305.cif @@ -0,0 +1,18 @@ +DS 1 10 1; +9 test; +L TEST; + +(Origin marker) +B 1 1 0,0; + +(Draw two offset boxes without rotation) +B 10 1 20,-10; +B 10 1 20,10; + +(Try drawing the same boxes with rotation) +(They appear nearly centered on the origin in Klayout, the offset is wrong?) +B 10 1 20,-10 5,-2; +B 10 1 20,10 5,2; + +DF; +E diff --git a/testdata/cif/issue_305_au.gds b/testdata/cif/issue_305_au.gds new file mode 100644 index 0000000000000000000000000000000000000000..02c2372e920576bd6f5181694a6f9d17b19d3b35 GIT binary patch literal 426 zcmZQzV_;&6V31*CVt>rQ&LGMl#$e81h|Ff-U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLWX&V`D2xEiPeT;b353<7HxCWMJcCVqjp<5nyIu;OzVV|F;1H1MA!W|Nkro zDiHer|1VIIb2Cu97cS2t$belxn-Bv7&={b8ARP-*4^(&oq#sBZgUkcV{@ K{p>&~76t%^c3-Ig literal 0 HcmV?d00001