mirror of https://github.com/KLayout/klayout.git
Handling of ghost cells in strm2x merge
Ghost cells act as anchors for top cells of the other layout in "," merges. Unlike other cells which are renamed.
This commit is contained in:
parent
d382629e8e
commit
15120760fe
|
|
@ -892,15 +892,41 @@ void read_files (db::Layout &layout, const std::string &infile, const db::LoadLa
|
||||||
|
|
||||||
std::vector<db::cell_index_type> cells_target;
|
std::vector<db::cell_index_type> cells_target;
|
||||||
std::vector<db::cell_index_type> cells_source;
|
std::vector<db::cell_index_type> cells_source;
|
||||||
|
|
||||||
for (auto c = tmp.begin_top_down (); c != tmp.end_top_cells (); ++c) {
|
for (auto c = tmp.begin_top_down (); c != tmp.end_top_cells (); ++c) {
|
||||||
|
|
||||||
cells_source.push_back (*c);
|
cells_source.push_back (*c);
|
||||||
cells_target.push_back (layout.add_cell (tmp.cell_name (*c)));
|
|
||||||
|
// as a special rule, join ghost cells if the source top cell fits into
|
||||||
|
// a ghost cell of the target.
|
||||||
|
auto cell_target = layout.cell_by_name (tmp.cell_name (*c));
|
||||||
|
if (cell_target.first && layout.cell (cell_target.second).is_ghost_cell ()) {
|
||||||
|
cells_target.push_back (cell_target.second);
|
||||||
|
} else {
|
||||||
|
cells_target.push_back (layout.add_cell (tmp.cell_name (*c)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ghost cell joining also works the other way around: a top cell of destination
|
||||||
|
// can match a ghost cell of the source
|
||||||
|
for (auto c = tmp.end_top_cells (); c != tmp.end_top_down (); ++c) {
|
||||||
|
|
||||||
|
const db::Cell &cell_source = tmp.cell (*c);
|
||||||
|
auto cell_target = layout.cell_by_name (tmp.cell_name (*c));
|
||||||
|
|
||||||
|
if (cell_source.is_ghost_cell () && cell_target.first) {
|
||||||
|
cells_source.push_back (*c);
|
||||||
|
cells_target.push_back (cell_target.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
db::CellMapping cm;
|
||||||
|
cm.create_multi_mapping_full (layout, cells_target, tmp, cells_source);
|
||||||
|
|
||||||
db::LayerMapping lm;
|
db::LayerMapping lm;
|
||||||
lm.create_full (layout, tmp);
|
lm.create_full (layout, tmp);
|
||||||
db::CellMapping cm;
|
|
||||||
cm.create_multi_mapping_full (layout, cells_target, tmp, cells_source);
|
|
||||||
|
|
||||||
layout.move_tree_shapes (tmp, cm, lm);
|
layout.move_tree_shapes (tmp, cm, lm);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -592,3 +592,119 @@ TEST(11_3)
|
||||||
|
|
||||||
db::compare_layouts (this, layout, input_au, db::WriteOAS);
|
db::compare_layouts (this, layout, input_au, db::WriteOAS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merging with + and , under the presence of ghost cells: test+test,top->(test)
|
||||||
|
TEST(12_1)
|
||||||
|
{
|
||||||
|
std::string input_dir = tl::testdata ();
|
||||||
|
input_dir += "/bd";
|
||||||
|
|
||||||
|
std::string input_au = input_dir + "/strm2oas_au_12_1.oas";
|
||||||
|
std::string input = input_dir + "/strm2oas_a.oas+" + input_dir + "/strm2oas_b.oas," + input_dir + "/strm2oas_c.oas";
|
||||||
|
|
||||||
|
std::string output = this->tmp_file ("strm2oas_12_1.oas");
|
||||||
|
const char *argv[] = { "x",
|
||||||
|
"--blend-mode=0",
|
||||||
|
input.c_str (),
|
||||||
|
output.c_str ()
|
||||||
|
};
|
||||||
|
|
||||||
|
EXPECT_EQ (bd::converter_main (sizeof (argv) / sizeof (argv[0]), (char **) argv, bd::GenericWriterOptions::oasis_format_name), 0);
|
||||||
|
|
||||||
|
db::Layout layout;
|
||||||
|
{
|
||||||
|
tl::InputStream stream (output);
|
||||||
|
db::LoadLayoutOptions options;
|
||||||
|
db::Reader reader (stream);
|
||||||
|
reader.read (layout, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
db::compare_layouts (this, layout, input_au, db::WriteOAS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merging with + and , under the presence of ghost cells: top->(test),test+test
|
||||||
|
TEST(12_2)
|
||||||
|
{
|
||||||
|
std::string input_dir = tl::testdata ();
|
||||||
|
input_dir += "/bd";
|
||||||
|
|
||||||
|
std::string input_au = input_dir + "/strm2oas_au_12_2.oas";
|
||||||
|
std::string input = input_dir + "/strm2oas_c.oas," + input_dir + "/strm2oas_a.oas+" + input_dir + "/strm2oas_b.oas";
|
||||||
|
|
||||||
|
std::string output = this->tmp_file ("strm2oas_12_2.oas");
|
||||||
|
const char *argv[] = { "x",
|
||||||
|
"--blend-mode=0",
|
||||||
|
input.c_str (),
|
||||||
|
output.c_str ()
|
||||||
|
};
|
||||||
|
|
||||||
|
EXPECT_EQ (bd::converter_main (sizeof (argv) / sizeof (argv[0]), (char **) argv, bd::GenericWriterOptions::oasis_format_name), 0);
|
||||||
|
|
||||||
|
db::Layout layout;
|
||||||
|
{
|
||||||
|
tl::InputStream stream (output);
|
||||||
|
db::LoadLayoutOptions options;
|
||||||
|
db::Reader reader (stream);
|
||||||
|
reader.read (layout, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
db::compare_layouts (this, layout, input_au, db::WriteOAS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merging with + and , under the presence of ghost cells: test+test,toptop->top->(test)
|
||||||
|
TEST(12_3)
|
||||||
|
{
|
||||||
|
std::string input_dir = tl::testdata ();
|
||||||
|
input_dir += "/bd";
|
||||||
|
|
||||||
|
std::string input_au = input_dir + "/strm2oas_au_12_3.oas";
|
||||||
|
std::string input = input_dir + "/strm2oas_a.oas+" + input_dir + "/strm2oas_b.oas," + input_dir + "/strm2oas_cc.oas";
|
||||||
|
|
||||||
|
std::string output = this->tmp_file ("strm2oas_12_3.oas");
|
||||||
|
const char *argv[] = { "x",
|
||||||
|
"--blend-mode=0",
|
||||||
|
input.c_str (),
|
||||||
|
output.c_str ()
|
||||||
|
};
|
||||||
|
|
||||||
|
EXPECT_EQ (bd::converter_main (sizeof (argv) / sizeof (argv[0]), (char **) argv, bd::GenericWriterOptions::oasis_format_name), 0);
|
||||||
|
|
||||||
|
db::Layout layout;
|
||||||
|
{
|
||||||
|
tl::InputStream stream (output);
|
||||||
|
db::LoadLayoutOptions options;
|
||||||
|
db::Reader reader (stream);
|
||||||
|
reader.read (layout, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
db::compare_layouts (this, layout, input_au, db::WriteOAS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merging with + and , under the presence of ghost cells: toptop->top->(test),test+test
|
||||||
|
TEST(12_4)
|
||||||
|
{
|
||||||
|
std::string input_dir = tl::testdata ();
|
||||||
|
input_dir += "/bd";
|
||||||
|
|
||||||
|
std::string input_au = input_dir + "/strm2oas_au_12_4.oas";
|
||||||
|
std::string input = input_dir + "/strm2oas_cc.oas," + input_dir + "/strm2oas_a.oas+" + input_dir + "/strm2oas_b.oas";
|
||||||
|
|
||||||
|
std::string output = this->tmp_file ("strm2oas_12_4.oas");
|
||||||
|
const char *argv[] = { "x",
|
||||||
|
"--blend-mode=0",
|
||||||
|
input.c_str (),
|
||||||
|
output.c_str ()
|
||||||
|
};
|
||||||
|
|
||||||
|
EXPECT_EQ (bd::converter_main (sizeof (argv) / sizeof (argv[0]), (char **) argv, bd::GenericWriterOptions::oasis_format_name), 0);
|
||||||
|
|
||||||
|
db::Layout layout;
|
||||||
|
{
|
||||||
|
tl::InputStream stream (output);
|
||||||
|
db::LoadLayoutOptions options;
|
||||||
|
db::Reader reader (stream);
|
||||||
|
reader.read (layout, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
db::compare_layouts (this, layout, input_au, db::WriteOAS);
|
||||||
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue