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 000000000..02c2372e9 Binary files /dev/null and b/testdata/cif/issue_305_au.gds differ