Skip to content

Commit

Permalink
test #62 done
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenb-dev committed Oct 23, 2024
1 parent f1e1433 commit f51bef2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 67 deletions.
46 changes: 4 additions & 42 deletions src/pyedb/grpc/edb_core/modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,11 @@ def add_void(shape, void_shape):
void_shape = [void_shape]
for void in void_shape:
if isinstance(void, Primitive):
flag = shape.add_void(void)
shape._edb_object.add_void(void)
flag = True
else:
flag = shape.add_void(void)
shape._edb_object.add_void(void)
flag = True
if not flag:
return flag
return True
Expand Down Expand Up @@ -1049,46 +1051,6 @@ def _createPolygonDataFromRectangle(self, shape):
# return self._edb.geometry.polygon_data.create_from_bbox((pointA, pointB))
pass

class Shape(object):
"""Shape class.
Parameters
----------
type : str, optional
Type of the shape. Options are ``"circle"``, ``"rectangle"``, and ``"polygon"``.
The default is ``"unknown``.
pointA : optional
Lower-left corner when ``type="rectangle"``. The default is ``None``.
pointB : optional
Upper-right corner when ``type="rectangle"``. The default is ``None``.
centerPoint : optional
Center point when ``type="circle"``. The default is ``None``.
radius : optional
Radius when ``type="circle"``. The default is ``None``.
points : list, optional
List of points when ``type="polygon"``. The default is ``None``.
properties : dict, optional
Dictionary of properties associated with the shape. The default is ``{}``.
"""

def __init__(
self,
type="unknown", # noqa
pointA=None,
pointB=None,
centerPoint=None,
radius=None,
points=None,
properties={},
): # noqa
self.type = type
self.pointA = pointA
self.pointB = pointB
self.centerPoint = centerPoint
self.radius = radius
self.points = points
self.properties = properties

def parametrize_trace_width(
self,
nets_name,
Expand Down
21 changes: 11 additions & 10 deletions src/pyedb/grpc/edb_core/primitive/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def length(self):
path_length += self.width / 2
return round(path_length, 9)

def add_point(self, x, y, incremental=False):
def add_point(self, x, y, incremental=True):
"""Add a point at the end of the path.
Parameters
Expand All @@ -83,21 +83,22 @@ def add_point(self, x, y, incremental=False):
Y coordinate.
incremental: bool
Add point incrementally. If True, coordinates of the added point is incremental to the last point.
The default value is ``False``.
The default value is ``True``.
Returns
-------
bool
"""
if incremental:
x = GrpcValue(x)
y = GrpcValue(y)
points = self.center_line.points
last_point = points[-1]
x = "({})+({})".format(x.value, last_point.x.value)
y = "({})+({})".format(y.value, last_point.y.value)
points.append(GrpcPointData([x, y]))
self.center_line.points = points
points = self.center_line
points.append([x, y])
points = GrpcPolygonData(points=points)
GrpcPath.create(
layout=self.layout,
layer=self.layer,
net=self.net,
)
self.center_line = points
return True

def clone(self):
Expand Down
3 changes: 3 additions & 0 deletions src/pyedb/grpc/edb_core/primitive/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,6 @@ def in_polygon(
return True
else:
return False

def add_void(self, polygon):
return self._edb_object.add_void(polygon._edb_object)
40 changes: 25 additions & 15 deletions tests/grpc/system/test_edb_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,30 +233,40 @@ def test_modeler_create_polygon_from_shape(self, edb_examples):
assert poly_test[0].layer_name == "16_Bottom"
edbapp.close()

def test_modeler_create_trace(self):
def test_modeler_create_trace(self, edb_examples):
"""Create a trace based on a list of points."""
# Done
edbapp = edb_examples.get_si_verse()
points = [
[-0.025, -0.02],
[0.025, -0.02],
[0.025, 0.02],
]
trace = self.edbapp.modeler.create_trace(points, "1_Top")
trace = edbapp.modeler.create_trace(points, "1_Top")
assert trace
assert isinstance(trace.get_center_line(), list)
assert isinstance(trace.get_center_line(True), list)
self.edbapp["delta_x"] = "1mm"
assert trace.add_point("delta_x", "1mm", True)
assert trace.get_center_line(True)[-1][0] == "(delta_x)+(0.025)"
assert trace.add_point(0.001, 0.002)
assert trace.get_center_line()[-1] == [0.001, 0.002]

def test_modeler_add_void(self):
assert isinstance(trace.get_center_line(), list)
# TODO fixing parameters first
# edbapp["delta_x"] = "1mm"
# assert trace.add_point("delta_x", "1mm", True)
# assert trace.get_center_line(True)[-1][0] == "(delta_x)+(0.025)"
# TODO check issue #475 center_line has no setter
# assert trace.add_point(0.001, 0.002)
# assert trace.get_center_line()[-1] == [0.001, 0.002]
edbapp.close()

def test_modeler_add_void(self, edb_examples):
"""Add a void into a shape."""
plane_shape = self.edbapp.modeler.Shape("rectangle", pointA=["-5mm", "-5mm"], pointB=["5mm", "5mm"])
plane = self.edbapp.modeler.create_polygon(plane_shape, "1_Top", net_name="GND")
void = self.edbapp.modeler.create_trace([["0", "0"], ["0", "1mm"]], layer_name="1_Top", width="0.1mm")
assert self.edbapp.modeler.add_void(plane, void)
assert plane.add_void(void)
# Done
edbapp = edb_examples.get_si_verse()
plane_shape = edbapp.modeler.create_rectangle(
lower_left_point=["-5mm", "-5mm"], upper_right_point=["5mm", "5mm"], layer_name="1_Top"
)
plane = edbapp.modeler.create_polygon(plane_shape.polygon_data, "1_Top", net_name="GND")
void = edbapp.modeler.create_trace(path_list=[["0", "0"], ["0", "1mm"]], layer_name="1_Top", width="0.1mm")
assert edbapp.modeler.add_void(plane, void)
plane.add_void(void)
edbapp.close()

def test_modeler_fix_circle_void(self):
"""Fix issues when circle void are clipped due to a bug in EDB."""
Expand Down

0 comments on commit f51bef2

Please sign in to comment.