Merge pull request #1501 from KLayout/issue-1482

Fixed issue #1482 (strict mode oasis should write the S_CELL_OFFSET i…
This commit is contained in:
Matthias Köfferlein 2023-11-07 21:35:21 +01:00 committed by GitHub
commit 6a587456e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 81 additions and 18 deletions

View File

@ -1338,31 +1338,35 @@ OASISWriter::write_cellname_table (size_t &cellnames_table_pos, const std::vecto
write ((unsigned long) *cell);
}
if (m_options.write_std_properties > 1) {
if (m_options.write_std_properties >= 1) {
reset_modal_variables ();
// write S_BOUNDING_BOX entries
if (m_options.write_std_properties > 1) {
std::vector<tl::Variant> values;
// write S_BOUNDING_BOX entries
std::vector<tl::Variant> values;
// TODO: how to set the "depends on external cells" flag?
db::Box bbox = layout.cell (*cell).bbox ();
if (bbox.empty ()) {
// empty box
values.push_back (tl::Variant ((unsigned int) 0x2));
bbox = db::Box (0, 0, 0, 0);
} else {
values.push_back (tl::Variant ((unsigned int) 0x0));
}
values.push_back (tl::Variant (bbox.left ()));
values.push_back (tl::Variant (bbox.bottom ()));
values.push_back (tl::Variant (bbox.width ()));
values.push_back (tl::Variant (bbox.height ()));
write_property_def (s_bounding_box_name, values, true);
// TODO: how to set the "depends on external cells" flag?
db::Box bbox = layout.cell (*cell).bbox ();
if (bbox.empty ()) {
// empty box
values.push_back (tl::Variant ((unsigned int) 0x2));
bbox = db::Box (0, 0, 0, 0);
} else {
values.push_back (tl::Variant ((unsigned int) 0x0));
}
values.push_back (tl::Variant (bbox.left ()));
values.push_back (tl::Variant (bbox.bottom ()));
values.push_back (tl::Variant (bbox.width ()));
values.push_back (tl::Variant (bbox.height ()));
write_property_def (s_bounding_box_name, values, true);
// PROPERTY record with S_CELL_OFFSET
if (cell_positions) {
std::map<db::cell_index_type, size_t>::const_iterator pp = cell_positions->find (*cell);

View File

@ -1532,6 +1532,65 @@ TEST(116)
EXPECT_EQ (std::string (os.string ()), std::string (expected))
}
{
std::string tmp_file = tl::TestBase::tmp_file ("tmp_dbOASISWriter116d2.gds");
{
tl::OutputStream out (tmp_file);
db::SaveLayoutOptions write_options;
write_options.set_format ("OASIS");
db::OASISWriterOptions oas_write_options;
oas_write_options.write_std_properties = 1;
oas_write_options.strict_mode = true;
oas_write_options.write_cblocks = false;
write_options.set_options (oas_write_options);
db::Writer writer (write_options);
writer.write (g, out);
}
tl::InputStream in (tmp_file);
db::OASISReaderOptions oas_options;
oas_options.read_all_properties = true;
oas_options.expect_strict_mode = 1;
db::LoadLayoutOptions options;
options.set_options (oas_options);
db::Reader reader (in);
db::Layout gg;
reader.set_warnings_as_errors (true);
reader.read (gg, options);
const char *expected =
"set props {\n"
" {{S_MAX_SIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_MAX_UNSIGNED_INTEGER_WIDTH} {4}}\n"
" {{S_TOP_CELL} {$2}}\n"
" {{S_TOP_CELL} {$1}}\n"
" {{name} {117}}\n"
" {17 {17value}}\n"
"}\n"
"begin_libp $props 0.001\n"
"set props {\n"
" {42 {42}}\n"
" {{S_CELL_OFFSET} {182}}\n"
"}\n"
"begin_cellp $props {$1}\n"
"path 1 0 0 0 0 {0 100} {1000 1200}\n"
"end_cell\n"
"set props {\n"
" {{S_CELL_OFFSET} {180}}\n"
"}\n"
"begin_cellp $props {$2}\n"
"end_cell\n"
"end_lib\n"
;
tl::OutputStringStream os;
tl::OutputStream stream (os);
db::TextWriter textwriter (stream);
textwriter.write (gg);
EXPECT_EQ (std::string (os.string ()), std::string (expected))
}
c1.insert (db::CellInstArray (c2.cell_index (), db::Trans ()));
{