WIP: edge and edge pairs with properties, tests, conversion constructors, edge neighborhood tests with properties.

This commit is contained in:
Matthias Koefferlein
2024-12-30 23:47:34 +01:00
parent d406488bbb
commit c112f78b1c
9 changed files with 180 additions and 35 deletions
+16 -13
View File
@@ -93,10 +93,13 @@ class DBEdgeNeighborhood_TestClass < TestBase
l1 = ly.layer(1, 0)
cell = ly.create_cell("TOP")
cell.shapes(l1).insert(RBA::Box::new(0, 0, 1000, 1000))
pid1 = RBA::Layout::properties_id({ 1 => "one" })
cell.shapes(l1).insert(RBA::Box::new(0, 0, 1000, 1000), pid1)
cell.shapes(l1).insert(RBA::Box::new(-1100, 0, -100, 1000))
prim = RBA::Region::new(cell.begin_shapes_rec(l1))
prim.enable_properties
visitor = MyVisitor::new
@@ -116,19 +119,19 @@ class DBEdgeNeighborhood_TestClass < TestBase
res = prim.complex_op(node)
assert_equal(visitor.log,
"Polygon: (-1100,0;-1100,1000;-100,1000;-100,0)\n" +
"edge = (-1100,0;-1100,1000)\n" +
"edge = (-1100,1000;-100,1000)\n" +
"edge = (-100,1000;-100,0)\n" +
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100)\n" +
"edge = (-100,0;-1100,0)\n" +
"Polygon: (-1100,0;-1100,1000;-100,1000;-100,0) props={}\n" +
"edge = (-1100,0;-1100,1000) props={}\n" +
"edge = (-1100,1000;-100,1000) props={}\n" +
"edge = (-100,1000;-100,0) props={}\n" +
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100) props={1=>one}\n" +
"edge = (-100,0;-1100,0) props={}\n" +
"/Polygon\n" +
"Polygon: (0,0;0,1000;1000,1000;1000,0)\n" +
"edge = (0,0;0,1000)\n" +
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100)\n" +
"edge = (0,1000;1000,1000)\n" +
"edge = (1000,1000;1000,0)\n" +
"edge = (1000,0;0,0)\n" +
"Polygon: (0,0;0,1000;1000,1000;1000,0) props={1=>one}\n" +
"edge = (0,0;0,1000) props={1=>one}\n" +
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100) props={}\n" +
"edge = (0,1000;1000,1000) props={1=>one}\n" +
"edge = (1000,1000;1000,0) props={1=>one}\n" +
"edge = (1000,0;0,0) props={1=>one}\n" +
"/Polygon\n"
)
+32
View File
@@ -246,6 +246,38 @@ class DBEdgePair_TestClass < TestBase
end
def test_edgePairWithProperties
s = RBA::EdgePairWithProperties::new
assert_equal(s.to_s, "(0,0;0,0)/(0,0;0,0) props={}")
pid = RBA::Layout::properties_id({ 1 => "one" })
s = RBA::EdgePairWithProperties::new(RBA::EdgePair::new(RBA::Edge::new(0, 0, 100, 200), RBA::Edge::new(10, 10, 110, 210)), pid)
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}")
assert_equal(s.property(1), "one")
assert_equal(s.properties, { 1 => "one" })
s.set_property(1, "xxx")
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>xxx}")
s.delete_property(1)
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={}")
assert_equal(s.property(1), nil)
s = RBA::DEdgePairWithProperties::new
assert_equal(s.to_s, "(0,0;0,0)/(0,0;0,0) props={}")
pid = RBA::Layout::properties_id({ 1 => "one" })
s = RBA::DEdgePairWithProperties::new(RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 100, 200), RBA::DEdge::new(10, 10, 110, 210)), pid)
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>one}")
assert_equal(s.property(1), "one")
assert_equal(s.properties, { 1 => "one" })
s.set_property(1, "xxx")
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={1=>xxx}")
s.delete_property(1)
assert_equal(s.to_s, "(0,0;100,200)/(10,10;110,210) props={}")
assert_equal(s.property(1), nil)
end
end
load("test_epilogue.rb")
+32
View File
@@ -333,6 +333,38 @@ class DBEdge_TestClass < TestBase
end
def test_edgeWithProperties
s = RBA::EdgeWithProperties::new
assert_equal(s.to_s, "(0,0;0,0) props={}")
pid = RBA::Layout::properties_id({ 1 => "one" })
s = RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 200), pid)
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
assert_equal(s.property(1), "one")
assert_equal(s.properties, { 1 => "one" })
s.set_property(1, "xxx")
assert_equal(s.to_s, "(0,0;100,200) props={1=>xxx}")
s.delete_property(1)
assert_equal(s.to_s, "(0,0;100,200) props={}")
assert_equal(s.property(1), nil)
s = RBA::DEdgeWithProperties::new
assert_equal(s.to_s, "(0,0;0,0) props={}")
pid = RBA::Layout::properties_id({ 1 => "one" })
s = RBA::DEdgeWithProperties::new(RBA::DEdge::new(0, 0, 100, 200), pid)
assert_equal(s.to_s, "(0,0;100,200) props={1=>one}")
assert_equal(s.property(1), "one")
assert_equal(s.properties, { 1 => "one" })
s.set_property(1, "xxx")
assert_equal(s.to_s, "(0,0;100,200) props={1=>xxx}")
s.delete_property(1)
assert_equal(s.to_s, "(0,0;100,200) props={}")
assert_equal(s.property(1), nil)
end
end
load("test_epilogue.rb")