mirror of https://github.com/KLayout/klayout.git
Fixed #275 (don't write PCell context with OASIS)
The ability to disable PCell context on OASIS output with the "write_context_info" option was added.
This commit is contained in:
parent
f59e49d678
commit
c7fe1cb189
|
|
@ -1343,6 +1343,8 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.write_context_info ()) {
|
||||||
|
|
||||||
// emit property name required for the PCell context information
|
// emit property name required for the PCell context information
|
||||||
std::vector <std::string> context_prop_strings;
|
std::vector <std::string> context_prop_strings;
|
||||||
for (std::vector<db::cell_index_type>::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) {
|
for (std::vector<db::cell_index_type>::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) {
|
||||||
|
|
@ -1362,6 +1364,8 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
end_table (propnames_table_pos);
|
end_table (propnames_table_pos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1422,6 +1426,8 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.write_context_info ()) {
|
||||||
|
|
||||||
// emit property string id's required for the PCell context information
|
// emit property string id's required for the PCell context information
|
||||||
std::vector <std::string> context_prop_strings;
|
std::vector <std::string> context_prop_strings;
|
||||||
for (std::vector<db::cell_index_type>::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) {
|
for (std::vector<db::cell_index_type>::const_iterator cell = cells.begin (); cell != cells.end (); ++cell) {
|
||||||
|
|
@ -1449,6 +1455,8 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
end_table (propstrings_table_pos);
|
end_table (propstrings_table_pos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1604,7 +1612,7 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save
|
||||||
}
|
}
|
||||||
|
|
||||||
// context information as property named KLAYOUT_CONTEXT
|
// context information as property named KLAYOUT_CONTEXT
|
||||||
if (cref.is_proxy ()) {
|
if (cref.is_proxy () && options.write_context_info ()) {
|
||||||
|
|
||||||
context_prop_strings.clear ();
|
context_prop_strings.clear ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@
|
||||||
#include "dbLayoutDiff.h"
|
#include "dbLayoutDiff.h"
|
||||||
#include "dbWriter.h"
|
#include "dbWriter.h"
|
||||||
#include "dbTextWriter.h"
|
#include "dbTextWriter.h"
|
||||||
|
#include "dbLibraryProxy.h"
|
||||||
|
#include "dbTestSupport.h"
|
||||||
|
|
||||||
#include "tlUnitTest.h"
|
#include "tlUnitTest.h"
|
||||||
|
|
||||||
|
|
@ -1258,61 +1260,6 @@ TEST(115)
|
||||||
EXPECT_EQ (std::string (os.string ()), std::string (expected))
|
EXPECT_EQ (std::string (os.string ()), std::string (expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(118)
|
|
||||||
{
|
|
||||||
// 1x1 arrays (#902)
|
|
||||||
|
|
||||||
db::Manager m;
|
|
||||||
db::Layout g (&m);
|
|
||||||
|
|
||||||
db::LayerProperties lp1;
|
|
||||||
lp1.layer = 1;
|
|
||||||
lp1.datatype = 0;
|
|
||||||
|
|
||||||
g.insert_layer (0, lp1);
|
|
||||||
|
|
||||||
db::Cell &c1 (g.cell (g.add_cell ()));
|
|
||||||
c1.shapes (0).insert (db::Box (100, 0, 100, 200));
|
|
||||||
|
|
||||||
db::Cell &c2 (g.cell (g.add_cell ()));
|
|
||||||
c2.insert (db::array <db::CellInst, db::Trans> (db::CellInst (c1.cell_index ()), db::Trans (), db::Vector (0, 1), db::Vector (1, 0), 1, 1));
|
|
||||||
c2.insert (db::array <db::CellInst, db::Trans> (db::CellInst (c1.cell_index ()), db::Trans (db::Vector (17, -42)), db::Vector (0, 1), db::Vector (1, 0), 1, 1));
|
|
||||||
|
|
||||||
std::string tmp_file = tl::TestBase::tmp_file ("tmp.oas");
|
|
||||||
|
|
||||||
{
|
|
||||||
tl::OutputStream out (tmp_file);
|
|
||||||
db::SaveLayoutOptions options;
|
|
||||||
options.set_format ("OASIS");
|
|
||||||
db::Writer writer (options);
|
|
||||||
writer.write (g, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
tl::InputStream in (tmp_file);
|
|
||||||
db::Reader reader (in);
|
|
||||||
db::Layout gg;
|
|
||||||
reader.set_warnings_as_errors (true);
|
|
||||||
reader.read (gg);
|
|
||||||
|
|
||||||
const char *expected =
|
|
||||||
"begin_lib 0.001\n"
|
|
||||||
"begin_cell {$1}\n"
|
|
||||||
"box 1 0 {100 0} {100 200}\n"
|
|
||||||
"end_cell\n"
|
|
||||||
"begin_cell {$2}\n"
|
|
||||||
"sref {$1} 0 0 1 {0 0}\n"
|
|
||||||
"sref {$1} 0 0 1 {17 -42}\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))
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(116)
|
TEST(116)
|
||||||
{
|
{
|
||||||
db::Manager m;
|
db::Manager m;
|
||||||
|
|
@ -1728,3 +1675,133 @@ TEST(117)
|
||||||
EXPECT_EQ (std::string (os.string ()), std::string (expected))
|
EXPECT_EQ (std::string (os.string ()), std::string (expected))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(118)
|
||||||
|
{
|
||||||
|
// 1x1 arrays (#902)
|
||||||
|
|
||||||
|
db::Manager m;
|
||||||
|
db::Layout g (&m);
|
||||||
|
|
||||||
|
db::LayerProperties lp1;
|
||||||
|
lp1.layer = 1;
|
||||||
|
lp1.datatype = 0;
|
||||||
|
|
||||||
|
g.insert_layer (0, lp1);
|
||||||
|
|
||||||
|
db::Cell &c1 (g.cell (g.add_cell ()));
|
||||||
|
c1.shapes (0).insert (db::Box (100, 0, 100, 200));
|
||||||
|
|
||||||
|
db::Cell &c2 (g.cell (g.add_cell ()));
|
||||||
|
c2.insert (db::array <db::CellInst, db::Trans> (db::CellInst (c1.cell_index ()), db::Trans (), db::Vector (0, 1), db::Vector (1, 0), 1, 1));
|
||||||
|
c2.insert (db::array <db::CellInst, db::Trans> (db::CellInst (c1.cell_index ()), db::Trans (db::Vector (17, -42)), db::Vector (0, 1), db::Vector (1, 0), 1, 1));
|
||||||
|
|
||||||
|
std::string tmp_file = tl::TestBase::tmp_file ("tmp.oas");
|
||||||
|
|
||||||
|
{
|
||||||
|
tl::OutputStream out (tmp_file);
|
||||||
|
db::SaveLayoutOptions options;
|
||||||
|
options.set_format ("OASIS");
|
||||||
|
db::Writer writer (options);
|
||||||
|
writer.write (g, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
tl::InputStream in (tmp_file);
|
||||||
|
db::Reader reader (in);
|
||||||
|
db::Layout gg;
|
||||||
|
reader.set_warnings_as_errors (true);
|
||||||
|
reader.read (gg);
|
||||||
|
|
||||||
|
const char *expected =
|
||||||
|
"begin_lib 0.001\n"
|
||||||
|
"begin_cell {$1}\n"
|
||||||
|
"box 1 0 {100 0} {100 200}\n"
|
||||||
|
"end_cell\n"
|
||||||
|
"begin_cell {$2}\n"
|
||||||
|
"sref {$1} 0 0 1 {0 0}\n"
|
||||||
|
"sref {$1} 0 0 1 {17 -42}\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))
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(119_WithAndWithoutContext)
|
||||||
|
{
|
||||||
|
// PCells with context and without
|
||||||
|
|
||||||
|
db::Manager m;
|
||||||
|
db::Layout g (&m);
|
||||||
|
|
||||||
|
// Note: this sample requires the BASIC lib
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string fn (tl::testsrc ());
|
||||||
|
fn += "/testdata/oasis/pcell_test.gds";
|
||||||
|
tl::InputStream stream (fn);
|
||||||
|
db::Reader reader (stream);
|
||||||
|
reader.read (g);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string tmp_file = tl::TestBase::tmp_file (tl::sprintf ("tmp_dbOASISWriter119a.oas"));
|
||||||
|
|
||||||
|
{
|
||||||
|
tl::OutputStream out (tmp_file);
|
||||||
|
db::SaveLayoutOptions options;
|
||||||
|
options.set_format ("OASIS");
|
||||||
|
db::Writer writer (options);
|
||||||
|
writer.write (g, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
tl::InputStream in (tmp_file);
|
||||||
|
db::Reader reader (in);
|
||||||
|
db::Layout gg;
|
||||||
|
reader.set_warnings_as_errors (true);
|
||||||
|
reader.read (gg);
|
||||||
|
|
||||||
|
std::pair<bool, db::cell_index_type> tc = gg.cell_by_name ("TEXT");
|
||||||
|
tl_assert (tc.first);
|
||||||
|
|
||||||
|
const db::Cell &text_cell = gg.cell (tc.second);
|
||||||
|
EXPECT_EQ (text_cell.is_proxy (), true);
|
||||||
|
EXPECT_EQ (text_cell.get_display_name (), "Basic.TEXT('KLAYOUT RULES')");
|
||||||
|
|
||||||
|
CHECKPOINT ();
|
||||||
|
db::compare_layouts (_this, gg, tl::testsrc () + "/testdata/oasis/dbOASISWriter119_au.gds", db::NoNormalization);
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp_file = tl::TestBase::tmp_file (tl::sprintf ("tmp_dbOASISWriter119b.oas"));
|
||||||
|
|
||||||
|
{
|
||||||
|
tl::OutputStream out (tmp_file);
|
||||||
|
db::SaveLayoutOptions options;
|
||||||
|
options.set_write_context_info (false);
|
||||||
|
options.set_format ("OASIS");
|
||||||
|
db::Writer writer (options);
|
||||||
|
writer.write (g, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
tl::InputStream in (tmp_file);
|
||||||
|
db::Reader reader (in);
|
||||||
|
db::Layout gg;
|
||||||
|
reader.set_warnings_as_errors (true);
|
||||||
|
reader.read (gg);
|
||||||
|
|
||||||
|
std::pair<bool, db::cell_index_type> tc = gg.cell_by_name ("TEXT");
|
||||||
|
tl_assert (tc.first);
|
||||||
|
|
||||||
|
const db::Cell &text_cell = gg.cell (tc.second);
|
||||||
|
EXPECT_EQ (text_cell.is_proxy (), false);
|
||||||
|
EXPECT_EQ (text_cell.get_display_name (), "TEXT");
|
||||||
|
|
||||||
|
CHECKPOINT ();
|
||||||
|
db::compare_layouts (_this, gg, tl::testsrc () + "/testdata/oasis/dbOASISWriter119_au.gds", db::NoNormalization);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue