mirror of https://github.com/KLayout/klayout.git
Merge pull request #2341 from KLayout/bugfix/issue-2339
Fixing issue #2339
This commit is contained in:
commit
41ef531d37
|
|
@ -1920,13 +1920,15 @@ static void map_databases (rdb::Database &self, const rdb::Database &other,
|
|||
std::map<id_type, id_type> &rev_tag2tag,
|
||||
bool create_missing)
|
||||
{
|
||||
std::list<std::pair<rdb::Cell *, const rdb::Cell *> > new_cells;
|
||||
|
||||
for (auto c = other.cells ().begin (); c != other.cells ().end (); ++c) {
|
||||
// TODO: do we have a consistent scheme of naming variants? What requirements
|
||||
// exist towards detecting variant specific waivers
|
||||
rdb::Cell *this_cell = self.cell_by_qname_non_const (c->qname ());
|
||||
if (! this_cell && create_missing) {
|
||||
this_cell = self.create_cell (c->name (), c->variant (), c->layout_name ());
|
||||
this_cell->import_references (c->references ());
|
||||
new_cells.push_back (std::make_pair (this_cell, c.operator-> ()));
|
||||
}
|
||||
if (this_cell) {
|
||||
cell2cell.insert (std::make_pair (this_cell->id (), c->id ()));
|
||||
|
|
@ -1934,6 +1936,19 @@ static void map_databases (rdb::Database &self, const rdb::Database &other,
|
|||
}
|
||||
}
|
||||
|
||||
// import and map references for new cells
|
||||
for (auto cp = new_cells.begin (); cp != new_cells.end (); ++cp) {
|
||||
auto &new_refs = cp->first->references ();
|
||||
for (auto r = cp->second->references ().begin (); r != cp->second->references ().end (); ++r) {
|
||||
rdb::Reference rnew = *r;
|
||||
auto cid = rev_cell2cell.find (rnew.parent_cell_id ());
|
||||
if (cid != rev_cell2cell.end ()) {
|
||||
rnew.set_parent_cell_id (cid->second);
|
||||
new_refs.insert (rnew);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto c = other.categories ().begin (); c != other.categories ().end (); ++c) {
|
||||
map_category (*c, self, cat2cat, rev_cat2cat, create_missing, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -979,16 +979,18 @@ TEST(22_MergeCells)
|
|||
}
|
||||
|
||||
{
|
||||
rdb::Cell *cell1, *cell2, *cell3;
|
||||
cell1 = db2.create_cell ("B");
|
||||
cell2 = db2.create_cell ("A");
|
||||
cell3 = db2.create_cell ("A", "VAR2", "ALAY");
|
||||
|
||||
// NOTE: db2 parent is at a different position (issue #2339)
|
||||
rdb::Cell *parent;
|
||||
parent = db2.create_cell ("TOP");
|
||||
|
||||
rdb::Cell *cell;
|
||||
cell = db2.create_cell ("B");
|
||||
cell->references ().insert (rdb::Reference (db::DCplxTrans (db::DVector (1.0, 0.0)), parent->id ()));
|
||||
cell = db2.create_cell ("A");
|
||||
cell->references ().insert (rdb::Reference (db::DCplxTrans (db::DVector (1.0, 2.5)), parent->id ())); // reference not taken!
|
||||
cell = db2.create_cell ("A", "VAR2", "ALAY");
|
||||
cell->references ().insert (rdb::Reference (db::DCplxTrans (db::DVector (1.0, -1.0)), parent->id ()));
|
||||
cell1->references ().insert (rdb::Reference (db::DCplxTrans (db::DVector (1.0, 0.0)), parent->id ()));
|
||||
cell2->references ().insert (rdb::Reference (db::DCplxTrans (db::DVector (1.0, 2.5)), parent->id ())); // reference not taken as cell will be taken from db1
|
||||
cell3->references ().insert (rdb::Reference (db::DCplxTrans (db::DVector (1.0, -1.0)), parent->id ()));
|
||||
}
|
||||
|
||||
db1.merge (db2);
|
||||
|
|
@ -996,13 +998,13 @@ TEST(22_MergeCells)
|
|||
std::set<std::string> cells;
|
||||
for (auto c = db1.cells ().begin (); c != db1.cells ().end (); ++c) {
|
||||
if (c->references ().begin () != c->references ().end ()) {
|
||||
cells.insert (c->qname () + "[" + c->references ().begin ()->trans_str () + "]");
|
||||
cells.insert (c->qname () + "[" + c->references ().begin ()->trans_str () + ":" + db1.cell_by_id (c->references ().begin ()->parent_cell_id ())->qname () + "]");
|
||||
} else {
|
||||
cells.insert (c->qname ());
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_EQ (tl::join (cells.begin (), cells.end (), ";"), "A:1[r0 *1 1,2];A:VAR1[r0 *1 1,-2];A:VAR2[r0 *1 1,-1];B[r0 *1 1,0];TOP");
|
||||
EXPECT_EQ (tl::join (cells.begin (), cells.end (), ";"), "A:1[r0 *1 1,2:TOP];A:VAR1[r0 *1 1,-2:TOP];A:VAR2[r0 *1 1,-1:TOP];B[r0 *1 1,0:TOP];TOP");
|
||||
}
|
||||
|
||||
TEST(23_MergeTags)
|
||||
|
|
|
|||
Loading…
Reference in New Issue