mirror of https://github.com/KLayout/klayout.git
Direct table access for RBA::CellMapping and RBA::LayerMapping.
This commit is contained in:
parent
b024e0ffd6
commit
501dfc25d0
|
|
@ -159,7 +159,15 @@ Class<db::CellMapping> decl_CellMapping ("CellMapping",
|
|||
"\n"
|
||||
"This method has been introduced in version 0.23."
|
||||
) +
|
||||
gsi::method ("map", &db::CellMapping::map,
|
||||
gsi::method ("table", &db::CellMapping::table,
|
||||
"@brief Returns the mapping table.\n"
|
||||
"\n"
|
||||
"The mapping table is a dictionary where the keys are source layout cell indexes and the values are the target layout cell indexes.\n"
|
||||
"Note that the target cell index can be \\DropCell to indicate that a cell is supposed to be dropped.\n"
|
||||
"\n"
|
||||
"This method has been introduced in version 0.25."
|
||||
) +
|
||||
gsi::method ("map", &db::CellMapping::map,
|
||||
"@brief Explicitly specifies a mapping.\n"
|
||||
"\n"
|
||||
"@args cell_index_b, cell_index_a\n"
|
||||
|
|
|
|||
|
|
@ -70,7 +70,14 @@ Class<db::LayerMapping> decl_LayerMapping ("LayerMapping",
|
|||
"Beside using the mapping generator algorithms provided through \\create and \\create_full, "
|
||||
"it is possible to explicitly specify layer mappings using this method.\n"
|
||||
) +
|
||||
gsi::method ("has_mapping?", &db::LayerMapping::has_mapping,
|
||||
gsi::method ("table", &db::LayerMapping::table,
|
||||
"@brief Returns the mapping table.\n"
|
||||
"\n"
|
||||
"The mapping table is a dictionary where the keys are source layout layer indexes and the values are the target layout layer indexes.\n"
|
||||
"\n"
|
||||
"This method has been introduced in version 0.25."
|
||||
) +
|
||||
gsi::method ("has_mapping?", &db::LayerMapping::has_mapping,
|
||||
"@brief Determine if a layer in layout_b has a mapping to a layout_a layer.\n"
|
||||
"\n"
|
||||
"@args layer_index_b\n"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,25 @@ def mapping_to_s(ly1, ly2, cm)
|
|||
r
|
||||
end
|
||||
|
||||
def mapping_to_s_from_table(ly1, ly2, cm)
|
||||
table = cm.table
|
||||
r = ""
|
||||
ly1.each_cell_top_down do |c|
|
||||
s = ly1.cell(c).name
|
||||
if table[c]
|
||||
t = table[c]
|
||||
if t == RBA::CellMapping::DropCell
|
||||
s += "=>(0)"
|
||||
else
|
||||
s += "=>" + ly2.cell(t).name
|
||||
end
|
||||
end
|
||||
r == "" || (r += ";")
|
||||
r += s
|
||||
end
|
||||
r
|
||||
end
|
||||
|
||||
class DBCellMapping_TestClass < TestBase
|
||||
|
||||
def test_1
|
||||
|
|
@ -102,6 +121,7 @@ class DBCellMapping_TestClass < TestBase
|
|||
mp = RBA::CellMapping::new
|
||||
mp.from_names(ly1, top1, ly2, top2)
|
||||
assert_equal(mapping_to_s(ly2, ly1, mp), "c0;c2=>c2;c1=>c1;c3=>c3")
|
||||
assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "c0;c2=>c2;c1=>c1;c3=>c3")
|
||||
|
||||
mp = RBA::CellMapping::new
|
||||
mp.from_geometry(ly1, top1, ly2, top2)
|
||||
|
|
@ -181,6 +201,7 @@ class DBCellMapping_TestClass < TestBase
|
|||
mp.from_geometry(ly1, top1, ly2, top2)
|
||||
mp.map(ci2, RBA::CellMapping::DropCell)
|
||||
assert_equal(mapping_to_s(ly2, ly1, mp), "c0;c2=>(0);c1=>c1;c3")
|
||||
assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "c0;c2=>(0);c1=>c1;c3")
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,20 @@ def mapping_to_s(ly1, ly2, lm)
|
|||
r
|
||||
end
|
||||
|
||||
def mapping_to_s_from_table(ly1, ly2, lm)
|
||||
r = ""
|
||||
table = lm.table
|
||||
ly1.layer_indices.each do |li|
|
||||
s = ly1.get_info(li).to_s
|
||||
if table[li]
|
||||
s += "=>" + ly2.get_info(table[li]).to_s
|
||||
end
|
||||
r == "" || (r += ";")
|
||||
r += s
|
||||
end
|
||||
r
|
||||
end
|
||||
|
||||
class DBLayerMapping_TestClass < TestBase
|
||||
|
||||
def test_1
|
||||
|
|
@ -60,6 +74,8 @@ class DBLayerMapping_TestClass < TestBase
|
|||
a3 = ly1.insert_layer(RBA::LayerInfo::new("A"))
|
||||
|
||||
ly2 = RBA::Layout::new
|
||||
assert_equal(mapping_to_s(ly2, ly1, mp), "")
|
||||
assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "")
|
||||
|
||||
b1 = ly2.insert_layer(RBA::LayerInfo::new("A"))
|
||||
b2 = ly2.insert_layer(RBA::LayerInfo::new(3, 0))
|
||||
|
|
@ -68,10 +84,12 @@ class DBLayerMapping_TestClass < TestBase
|
|||
mp = RBA::LayerMapping::new
|
||||
mp.create(ly1, ly2)
|
||||
assert_equal(mapping_to_s(ly2, ly1, mp), "A=>A;3/0;2/0=>2/0")
|
||||
assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "A=>A;3/0;2/0=>2/0")
|
||||
|
||||
mp = RBA::LayerMapping::new
|
||||
nl = mp.create_full(ly1, ly2)
|
||||
assert_equal(mapping_to_s(ly2, ly1, mp), "A=>A;3/0=>3/0;2/0=>2/0")
|
||||
assert_equal(mapping_to_s_from_table(ly2, ly1, mp), "A=>A;3/0=>3/0;2/0=>2/0")
|
||||
assert_equal(nl.inspect, "[3]")
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue