mirror of https://github.com/KLayout/klayout.git
Another refinement for DSS bug fix.
This commit is contained in:
parent
70af6bd7c9
commit
605fa44ca6
|
|
@ -1244,7 +1244,7 @@ DeepShapeStore::cell_mapping_to_original (unsigned int layout_index, db::Layout
|
|||
std::map<db::cell_index_type, db::HierarchyBuilder::CellMapKey>::const_iterator icm = cm_skipped_variants.find (var_org);
|
||||
if (icm != cm_skipped_variants.end ()) {
|
||||
|
||||
// create the variant clone in the original layout too and delete this cell
|
||||
// create the variant clone in the original layout too
|
||||
VariantsCollectorBase::copy_shapes (*into_layout, np->second, icm->second.original_cell);
|
||||
new_variants.push_back (std::make_pair (np->second, icm->second.original_cell));
|
||||
|
||||
|
|
@ -1269,22 +1269,32 @@ DeepShapeStore::cell_mapping_to_original (unsigned int layout_index, db::Layout
|
|||
|
||||
// copy cell instances for the new variants
|
||||
|
||||
// collect the cells that are handled during cell mapping -
|
||||
// we do not need to take care of them when creating variants,
|
||||
// but there may be others inside "into_layout" which are
|
||||
// not present in the DSS and for which we need to copy the
|
||||
// instances.
|
||||
std::vector<db::cell_index_type> mapped = cm->second.target_cells ();
|
||||
std::sort (mapped.begin (), mapped.end ());
|
||||
std::map<db::cell_index_type, db::cell_index_type> variant_to_org;
|
||||
for (auto vv = new_variants.begin (); vv != new_variants.end (); ++vv) {
|
||||
variant_to_org.insert (std::make_pair (vv->first, vv->second));
|
||||
}
|
||||
|
||||
// Copy the variant instances - but only those for cells which are not handled by the cell mapping object.
|
||||
for (auto vv = new_variants.begin (); vv != new_variants.end (); ++vv) {
|
||||
|
||||
const db::Cell &from = into_layout->cell (vv->second);
|
||||
db::Cell &to = into_layout->cell (vv->first);
|
||||
const db::Cell &from = into_layout->cell (vv->second); // original
|
||||
db::Cell &to = into_layout->cell (vv->first); // variant
|
||||
|
||||
// Collect and copy the cells which are not mapped already.
|
||||
// Skip variant original cells if their variants are included.
|
||||
std::set<db::cell_index_type> dont_copy;
|
||||
|
||||
for (auto c = to.begin_child_cells (); ! c.at_end (); ++c) {
|
||||
auto v2o = variant_to_org.find (*c);
|
||||
if (v2o != variant_to_org.end ()) {
|
||||
dont_copy.insert (v2o->second);
|
||||
} else {
|
||||
dont_copy.insert (*c);
|
||||
}
|
||||
}
|
||||
|
||||
for (db::Cell::const_iterator i = from.begin (); ! i.at_end (); ++i) {
|
||||
auto m = std::lower_bound (mapped.begin (), mapped.end (), i->cell_index ());
|
||||
if (m == mapped.end () || *m != i->cell_index ()) {
|
||||
if (dont_copy.find (i->cell_index ()) == dont_copy.end ()) {
|
||||
to.insert (*i);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,3 +341,44 @@ TEST(7_RestoreWithCellSelection2)
|
|||
db::compare_layouts (_this, ly, tl::testdata () + "/algo/dss_bug2_au.gds");
|
||||
}
|
||||
|
||||
TEST(8_RestoreWithCellSelection3)
|
||||
{
|
||||
db::Layout ly;
|
||||
|
||||
{
|
||||
std::string fn (tl::testdata ());
|
||||
fn += "/algo/dss_bug3.gds";
|
||||
tl::InputStream stream (fn);
|
||||
db::Reader reader (stream);
|
||||
reader.read (ly);
|
||||
}
|
||||
|
||||
unsigned int l2 = ly.get_layer (db::LayerProperties (2, 0));
|
||||
|
||||
db::Cell &top_cell = ly.cell (*ly.begin_top_down ());
|
||||
|
||||
db::RecursiveShapeIterator in_it (ly, top_cell, l2);
|
||||
db::RecursiveShapeIterator other_it (ly, top_cell, l2);
|
||||
|
||||
std::set<db::cell_index_type> us;
|
||||
us.insert (ly.cell_by_name ("X").second);
|
||||
us.insert (ly.cell_by_name ("C3").second);
|
||||
in_it.unselect_cells (us);
|
||||
|
||||
std::set<db::cell_index_type> us2;
|
||||
us2.insert (top_cell.cell_index ());
|
||||
other_it.unselect_cells (us2);
|
||||
other_it.select_cells (us);
|
||||
|
||||
db::DeepShapeStore dss;
|
||||
|
||||
db::Region in_region (in_it, dss);
|
||||
db::Region other_region (other_it, dss);
|
||||
in_region += other_region;
|
||||
|
||||
ly.clear_layer (l2);
|
||||
in_region.insert_into (&ly, top_cell.cell_index (), l2);
|
||||
|
||||
db::compare_layouts (_this, ly, tl::testdata () + "/algo/dss_bug3_au.gds");
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue