Skip to content

Commit

Permalink
Merge pull request #1501 from KLayout/issue-1482
Browse files Browse the repository at this point in the history
Fixed issue #1482 (strict mode oasis should write the S_CELL_OFFSET i…
  • Loading branch information
klayoutmatthias authored Nov 7, 2023
2 parents 8d51124 + 53d1491 commit 6a58745
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1338,30 +1338,34 @@ 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

// 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));
}
std::vector<tl::Variant> values;

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 ()));
// 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);
write_property_def (s_bounding_box_name, values, true);

}

// PROPERTY record with S_CELL_OFFSET
if (cell_positions) {
Expand Down
59 changes: 59 additions & 0 deletions src/plugins/streamers/oasis/unit_tests/dbOASISWriterTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()));

{
Expand Down

0 comments on commit 6a58745

Please sign in to comment.