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

View File

@ -591,14 +591,14 @@ Class<db::Box> decl_Box ("db", "Box",
"database objects."
);
static db::BoxWithProperties *new_box_with_properties (const db::Box &poly, db::properties_id_type pid)
static db::BoxWithProperties *new_box_with_properties (const db::Box &box, db::properties_id_type pid)
{
return new db::BoxWithProperties (poly, pid);
return new db::BoxWithProperties (box, pid);
}
Class<db::BoxWithProperties> decl_BoxWithProperties (decl_Box, "db", "BoxWithProperties",
gsi::properties_support_methods<db::BoxWithProperties> () +
constructor ("new", &new_box_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_box_with_properties, gsi::arg ("box"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
@ -665,14 +665,14 @@ Class<db::DBox> decl_DBox ("db", "DBox",
"database objects."
);
static db::DBoxWithProperties *new_dbox_with_properties (const db::DBox &poly, db::properties_id_type pid)
static db::DBoxWithProperties *new_dbox_with_properties (const db::DBox &box, db::properties_id_type pid)
{
return new db::DBoxWithProperties (poly, pid);
return new db::DBoxWithProperties (box, pid);
}
Class<db::DBoxWithProperties> decl_DBoxWithProperties (decl_DBox, "db", "DBoxWithProperties",
gsi::properties_support_methods<db::DBoxWithProperties> () +
constructor ("new", &new_dbox_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_dbox_with_properties, gsi::arg ("box"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,

View File

@ -22,6 +22,7 @@
#include "gsiDecl.h"
#include "gsiDeclDbPropertiesSupport.h"
#include "dbPoint.h"
#include "dbEdge.h"
#include "dbHash.h"
@ -694,6 +695,25 @@ Class<db::Edge> decl_Edge ("db", "Edge",
"database objects like the Edge class."
);
static db::EdgeWithProperties *new_edge_with_properties (const db::Edge &edge, db::properties_id_type pid)
{
return new db::EdgeWithProperties (edge, pid);
}
Class<db::EdgeWithProperties> decl_EdgeWithProperties (decl_Edge, "db", "EdgeWithProperties",
gsi::properties_support_methods<db::EdgeWithProperties> () +
constructor ("new", &new_edge_with_properties, gsi::arg ("edge"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
"@brief A Edge object with properties attached.\n"
"This class represents a combination of a Edge object an user properties. User properties are "
"stored in form of a properties ID. Convenience methods are provided to manipulate or retrieve "
"user properties directly.\n"
"\n"
"This class has been introduced in version 0.30."
);
static db::DEdge *dedge_from_iedge (const db::Edge &e)
{
return new db::DEdge (e);
@ -740,5 +760,24 @@ Class<db::DEdge> decl_DEdge ("db", "DEdge",
"database objects like the Edge class."
);
static db::DEdgeWithProperties *new_dedge_with_properties (const db::DEdge &edge, db::properties_id_type pid)
{
return new db::DEdgeWithProperties (edge, pid);
}
Class<db::DEdgeWithProperties> decl_DEdgeWithProperties (decl_DEdge, "db", "DEdgeWithProperties",
gsi::properties_support_methods<db::DEdgeWithProperties> () +
constructor ("new", &new_dedge_with_properties, gsi::arg ("edge"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
"@brief A DEdge object with properties attached.\n"
"This class represents a combination of a DEdge object an user properties. User properties are "
"stored in form of a properties ID. Convenience methods are provided to manipulate or retrieve "
"user properties directly.\n"
"\n"
"This class has been introduced in version 0.30."
);
}

View File

@ -22,6 +22,7 @@
#include "gsiDecl.h"
#include "gsiDeclDbPropertiesSupport.h"
#include "dbEdgePair.h"
#include "dbHash.h"
@ -284,6 +285,25 @@ Class<db::EdgePair> decl_EdgePair ("db", "EdgePair",
"This class has been introduced in version 0.23.\n"
);
static db::EdgePairWithProperties *new_edge_pair_with_properties (const db::EdgePair &edge_pair, db::properties_id_type pid)
{
return new db::EdgePairWithProperties (edge_pair, pid);
}
Class<db::EdgePairWithProperties> decl_EdgePairWithProperties (decl_EdgePair, "db", "EdgePairWithProperties",
gsi::properties_support_methods<db::EdgePairWithProperties> () +
constructor ("new", &new_edge_pair_with_properties, gsi::arg ("edge_pair"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
"@brief A EdgePair object with properties attached.\n"
"This class represents a combination of a EdgePair object an user properties. User properties are "
"stored in form of a properties ID. Convenience methods are provided to manipulate or retrieve "
"user properties directly.\n"
"\n"
"This class has been introduced in version 0.30."
);
static db::DEdgePair *dedge_pair_from_iedge_pair (const db::EdgePair &e)
{
return new db::DEdgePair (e);
@ -332,4 +352,23 @@ Class<db::DEdgePair> decl_DEdgePair ("db", "DEdgePair",
"This class has been introduced in version 0.23.\n"
);
static db::DEdgePairWithProperties *new_dedge_pair_with_properties (const db::DEdgePair &edge_pair, db::properties_id_type pid)
{
return new db::DEdgePairWithProperties (edge_pair, pid);
}
Class<db::DEdgePairWithProperties> decl_DEdgePairWithProperties (decl_EdgePair, "db", "DEdgePairWithProperties",
gsi::properties_support_methods<db::DEdgePairWithProperties> () +
constructor ("new", &new_dedge_pair_with_properties, gsi::arg ("edge_pair"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
"@brief A DEdgePair object with properties attached.\n"
"This class represents a combination of a DEdgePair object an user properties. User properties are "
"stored in form of a properties ID. Convenience methods are provided to manipulate or retrieve "
"user properties directly.\n"
"\n"
"This class has been introduced in version 0.30."
);
}

View File

@ -385,14 +385,14 @@ Class<db::Path> decl_Path ("db", "Path",
"database objects."
);
static db::PathWithProperties *new_path_with_properties (const db::Path &poly, db::properties_id_type pid)
static db::PathWithProperties *new_path_with_properties (const db::Path &path, db::properties_id_type pid)
{
return new db::PathWithProperties (poly, pid);
return new db::PathWithProperties (path, pid);
}
Class<db::PathWithProperties> decl_PathWithProperties (decl_Path, "db", "PathWithProperties",
gsi::properties_support_methods<db::PathWithProperties> () +
constructor ("new", &new_path_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_path_with_properties, gsi::arg ("path"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
@ -472,14 +472,14 @@ Class<db::DPath> decl_DPath ("db", "DPath",
"database objects."
);
static db::DPathWithProperties *new_dpath_with_properties (const db::DPath &poly, db::properties_id_type pid)
static db::DPathWithProperties *new_dpath_with_properties (const db::DPath &path, db::properties_id_type pid)
{
return new db::DPathWithProperties (poly, pid);
return new db::DPathWithProperties (path, pid);
}
Class<db::DPathWithProperties> decl_DPathWithProperties (decl_DPath, "db", "DPathWithProperties",
gsi::properties_support_methods<db::DPathWithProperties> () +
constructor ("new", &new_dpath_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_dpath_with_properties, gsi::arg ("path"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,

View File

@ -793,7 +793,7 @@ static db::SimplePolygonWithProperties *new_simple_polygon_with_properties (cons
Class<db::SimplePolygonWithProperties> decl_SimplePolygonWithProperties (decl_SimplePolygon, "db", "SimplePolygonWithProperties",
gsi::properties_support_methods<db::SimplePolygonWithProperties> () +
constructor ("new", &new_simple_polygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_simple_polygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
@ -880,7 +880,7 @@ static db::DSimplePolygonWithProperties *new_dsimple_polygon_with_properties (co
Class<db::DSimplePolygonWithProperties> decl_DSimplePolygonWithProperties (decl_DSimplePolygon, "db", "DSimplePolygonWithProperties",
gsi::properties_support_methods<db::DSimplePolygonWithProperties> () +
constructor ("new", &new_dsimple_polygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_dsimple_polygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
@ -2072,7 +2072,7 @@ static db::PolygonWithProperties *new_polygon_with_properties (const db::Polygon
Class<db::PolygonWithProperties> decl_PolygonWithProperties (decl_Polygon, "db", "PolygonWithProperties",
gsi::properties_support_methods<db::PolygonWithProperties> () +
constructor ("new", &new_polygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_polygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
@ -2186,7 +2186,7 @@ static db::DPolygonWithProperties *new_dpolygon_with_properties (const db::DPoly
Class<db::DPolygonWithProperties> decl_DPolygonWithProperties (decl_DPolygon, "db", "DPolygonWithProperties",
gsi::properties_support_methods<db::DPolygonWithProperties> () +
constructor ("new", &new_dpolygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_dpolygon_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,

View File

@ -449,14 +449,14 @@ Class<db::Text> decl_Text ("db", "Text",
"database objects."
);
static db::TextWithProperties *new_text_with_properties (const db::Text &poly, db::properties_id_type pid)
static db::TextWithProperties *new_text_with_properties (const db::Text &text, db::properties_id_type pid)
{
return new db::TextWithProperties (poly, pid);
return new db::TextWithProperties (text, pid);
}
Class<db::TextWithProperties> decl_TextWithProperties (decl_Text, "db", "TextWithProperties",
gsi::properties_support_methods<db::TextWithProperties> () +
constructor ("new", &new_text_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_text_with_properties, gsi::arg ("text"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,
@ -517,14 +517,14 @@ Class<db::DText> decl_DText ("db", "DText",
"database objects."
);
static db::DTextWithProperties *new_dtext_with_properties (const db::DText &poly, db::properties_id_type pid)
static db::DTextWithProperties *new_dtext_with_properties (const db::DText &text, db::properties_id_type pid)
{
return new db::DTextWithProperties (poly, pid);
return new db::DTextWithProperties (text, pid);
}
Class<db::DTextWithProperties> decl_DTextWithProperties (decl_DText, "db", "DTextWithProperties",
gsi::properties_support_methods<db::DTextWithProperties> () +
constructor ("new", &new_dtext_with_properties, gsi::arg ("polygon"), gsi::arg ("properties_id"),
constructor ("new", &new_dtext_with_properties, gsi::arg ("text"), gsi::arg ("properties_id", db::properties_id_type (0)),
"@brief Creates a new object from a property-less object and a properties ID."
)
,

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"
)

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")

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")