Direct table access for RBA::CellMapping and RBA::LayerMapping.

This commit is contained in:
Matthias Koefferlein
2017-09-10 01:21:10 +02:00
parent b024e0ffd6
commit 501dfc25d0
4 changed files with 56 additions and 2 deletions
+21
View File
@@ -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
+18
View File
@@ -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