From e45037a76a022cad16637c32e49ed792063ccd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=B6fferlein?= Date: Mon, 25 May 2020 22:10:06 +0200 Subject: [PATCH] Fixed bug #568 (CIF writer issue with small rotation angles) (#569) * Fixed bug #568 (CIF writer issue with small rotation angles) * Fixed the reader bug too which created the rounding issue. --- .../streamers/cif/db_plugin/dbCIFReader.cc | 2 +- .../streamers/cif/db_plugin/dbCIFWriter.cc | 2 +- .../streamers/cif/unit_tests/dbCIFReader.cc | 6 ++++++ testdata/cif/issue_568.cif | 17 +++++++++++++++++ testdata/cif/issue_568_au.gds | Bin 0 -> 374 bytes 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 testdata/cif/issue_568.cif create mode 100644 testdata/cif/issue_568_au.gds diff --git a/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc b/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc index f63d9ffb5..8ad8894f7 100644 --- a/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc +++ b/src/plugins/streamers/cif/db_plugin/dbCIFReader.cc @@ -581,7 +581,7 @@ CIFReader::read_cell (db::Layout &layout, db::Cell &cell, double sf, int level) if (rx >= 0 && ry == 0) { - cell.shapes ((unsigned int) layer).insert (db::Box (sf * (x - 0.5 * w), sf * (y - 0.5 * h), sf * (x + 0.5 * w), sf * (y + 0.5 * h))); + cell.shapes ((unsigned int) layer).insert (db::Box (db::Point (sf * (x - 0.5 * w), sf * (y - 0.5 * h)), db::Point (sf * (x + 0.5 * w), sf * (y + 0.5 * h)))); } else { diff --git a/src/plugins/streamers/cif/db_plugin/dbCIFWriter.cc b/src/plugins/streamers/cif/db_plugin/dbCIFWriter.cc index 67d339867..955eb8569 100644 --- a/src/plugins/streamers/cif/db_plugin/dbCIFWriter.cc +++ b/src/plugins/streamers/cif/db_plugin/dbCIFWriter.cc @@ -184,7 +184,7 @@ CIFWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::SaveLa } // TODO: that can be done smarter ... - while (fabs (xa - floor (0.5 + xa)) > 1e-3 || fabs (ya - floor (0.5 + ya)) > 1e-3) { + for (int n = 0; n < 20 && (fabs (xa - floor (0.5 + xa)) > 1e-3 || fabs (ya - floor (0.5 + ya)) > 1e-3); ++n) { xa *= 2.0; ya *= 2.0; } diff --git a/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc b/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc index c347525a1..e572e9e11 100644 --- a/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc +++ b/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc @@ -194,3 +194,9 @@ TEST(rot_boxes) { run_test (_this, tl::testsrc (), "issue_305.cif", "issue_305_au.gds"); } + +// Issue #568 +TEST(rot_instances) +{ + run_test (_this, tl::testsrc (), "issue_568.cif", "issue_568_au.gds"); +} diff --git a/testdata/cif/issue_568.cif b/testdata/cif/issue_568.cif new file mode 100644 index 000000000..6625b0586 --- /dev/null +++ b/testdata/cif/issue_568.cif @@ -0,0 +1,17 @@ +(CIF generated by the cifwrite library); +DS2 1 10; +9 test_cell2; +L L1D0; +B 1000 1000 500,500; +DF; +DS3 1 10; +9 test_encore; +L L1D0; +DF; +DS1 1 10; +9 test_top_cell; +L L1D0; +C3 R100000,0 T0,0; +C2 R1048576,105207 T0,0; +DF; +E diff --git a/testdata/cif/issue_568_au.gds b/testdata/cif/issue_568_au.gds new file mode 100644 index 0000000000000000000000000000000000000000..fbca7d584237f8762413d0f7468a67d7937d3e24 GIT binary patch literal 374 zcmZQzV_;&6V31*CVt>NG${@iY#$d$2g3M;%U}E#}bYfr-VP>^+>@@d2w)}&o%MSeo zv!g;7WLR