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.
This commit is contained in:
Matthias Köfferlein 2020-05-25 22:10:06 +02:00 committed by GitHub
parent 499f47577c
commit a046457cc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 2 deletions

View File

@ -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 {

View File

@ -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;
}

View File

@ -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");
}

17
testdata/cif/issue_568.cif vendored Normal file
View File

@ -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

BIN
testdata/cif/issue_568_au.gds vendored Normal file

Binary file not shown.