Skip to content

Commit

Permalink
Bug fix merge nets polygon (#3950)
Browse files Browse the repository at this point in the history
* edb intersection bug fix

* bug fix

* unit test added

* unit test added

* bug fix

* Update pyaedt/edb_core/layout.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/edb_core/layout.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/edb_core/nets.py

Co-authored-by: Kathy Pippert <[email protected]>

---------

Co-authored-by: Kathy Pippert <[email protected]>
  • Loading branch information
svandenb-dev and PipKat authored Dec 7, 2023
1 parent aa36100 commit 325cc63
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 64 deletions.
Binary file not shown.
7 changes: 7 additions & 0 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -3011,3 +3011,10 @@ def test_153_update_padstacks_after_layer_name_changed(self):
for padstack_inst in list(edbapp.padstacks.instances.values()):
assert not [lay for lay in padstack_inst.layer_range_names if lay in old_layers]
edbapp.close_edb()

def test_154_merge_polygon(self):
source_path = os.path.join(local_path, "example_models", test_subfolder, "test_merge_polygon.aedb")
target_path = os.path.join(self.local_scratch.path, "test_merge_polygon", "test.aedb")
self.local_scratch.copyfolder(source_path, target_path)
edbapp = Edb(target_path, desktop_version)
assert edbapp.nets.merge_nets_polygons(["net1", "net2"])
59 changes: 31 additions & 28 deletions pyaedt/edb_core/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,15 +1103,17 @@ def parametrize_trace_width(
return True

@pyaedt_function_handler()
def unite_polygons_on_layer(self, layer_name=None, delete_padstack_gemometries=False):
def unite_polygons_on_layer(self, layer_name=None, delete_padstack_gemometries=False, net_list=[]):
"""Try to unite all Polygons on specified layer.
Parameters
----------
layer_name : str, optional
Layer Name on which unite objects. If ``None``, all layers will be taken.
Name of layer name to unite objects on. The default is ``None``, in which case all layers are taken.
delete_padstack_gemometries : bool, optional
``True`` to delete all padstack geometry.
Whether to delete all padstack geometries. The default is ``False``.
net_list : list[str] : optional
Net list filter. The default is ``[]``, in which case all nets are taken.
Returns
-------
Expand All @@ -1135,33 +1137,34 @@ def unite_polygons_on_layer(self, layer_name=None, delete_padstack_gemometries=F
if poly.GetNet().GetName():
poly_by_nets[poly.GetNet().GetName()].append(poly)
for net in poly_by_nets:
list_polygon_data = [i.GetPolygonData() for i in poly_by_nets[net]]
all_voids = [i.Voids for i in poly_by_nets[net]]
a = self._edb.geometry.polygon_data.unite(convert_py_list_to_net_list(list_polygon_data))
for item in a:
if net in net_list or not net_list: # pragma no cover
list_polygon_data = [i.GetPolygonData() for i in poly_by_nets[net]]
all_voids = [i.Voids for i in poly_by_nets[net]]
a = self._edb.geometry.polygon_data.unite(convert_py_list_to_net_list(list_polygon_data))
for item in a:
for v in all_voids:
for void in v:
if int(item.GetIntersectionType(void.GetPolygonData())) == 2:
item.AddHole(void.GetPolygonData())
poly = self._edb.cell.primitive.polygon.create(
self._active_layout,
lay,
self._pedb.nets.nets[net],
item,
)
list_to_delete = [i for i in poly_by_nets[net]]
for v in all_voids:
for void in v:
if int(item.GetIntersectionType(void.GetPolygonData())) == 2:
item.AddHole(void.GetPolygonData())
poly = self._edb.cell.primitive.polygon.create(
self._active_layout,
lay,
self._pedb.nets.nets[net],
item,
)
list_to_delete = [i for i in poly_by_nets[net]]
for v in all_voids:
for void in v:
for poly in poly_by_nets[net]:
if int(void.GetPolygonData().GetIntersectionType(poly.GetPolygonData())) >= 2:
try:
id = list_to_delete.index(poly)
except ValueError:
id = -1
if id >= 0:
list_to_delete.pop(id)

[i.Delete() for i in list_to_delete]
for poly in poly_by_nets[net]: # pragma no cover
if int(void.GetPolygonData().GetIntersectionType(poly.GetPolygonData())) >= 2:
try:
id = list_to_delete.index(poly)
except ValueError:
id = -1
if id >= 0:
list_to_delete.pop(id)

[i.Delete() for i in list_to_delete] # pragma no cover

if delete_padstack_gemometries:
self._logger.info("Deleting Padstack Definitions")
Expand Down
40 changes: 4 additions & 36 deletions pyaedt/edb_core/nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import warnings

from pyaedt.edb_core.edb_data.nets_data import EDBNetsData
from pyaedt.edb_core.general import convert_py_list_to_net_list
from pyaedt.generic.constants import CSS4_COLORS
from pyaedt.generic.general_methods import generate_unique_name
from pyaedt.generic.general_methods import is_ironpython
Expand Down Expand Up @@ -1182,45 +1181,14 @@ def merge_nets_polygons(self, net_list):
Parameters
----------
net_list : str or list[str]
net name of list of net name.
Net name of list of net name.
Returns
list of merged polygons.
-------
operation result : bool
``True`` when successful, ``False`` when failed.
"""
if isinstance(net_list, str):
net_list = [net_list]
returned_poly = []
for net in net_list:
if net in self.nets:
net_rtree = self._edb.Geometry.RTree()
paths = [prim for prim in self.nets[net].primitives if prim.type == "Path"]
for path in paths:
path.convert_to_polygon()
polygons = [prim for prim in self.nets[net].primitives if prim.type == "Polygon"]
for polygon in polygons:
polygon_data = polygon.primitive_object.GetPolygonData()
rtree = self._edb.Geometry.RTreeObj(polygon_data, polygon.primitive_object)
net_rtree.Insert(rtree)
connected_polygons = net_rtree.GetConnectedGeometrySets()
void_list = []
for pp in list(connected_polygons):
for _pp in list(pp):
_voids = list(_pp.Obj.Voids)
void_list.extend(_pp.Obj.Voids)
for poly_list in list(connected_polygons):
layer = list(poly_list)[0].Obj.GetLayer().GetName()
net = list(poly_list)[0].Obj.GetNet()
_poly_list = convert_py_list_to_net_list([obj.Poly for obj in list(poly_list)])
merged_polygon = list(self._edb.geometry.polygon_data.unite(_poly_list))
for poly in merged_polygon:
for void in void_list:
poly.AddHole(void.GetPolygonData())
_new_poly = self._edb.cell.primitive.polygon.create(self._active_layout, layer, net, poly)
returned_poly.append(_new_poly)
for init_poly in list(list(connected_polygons)):
for _pp in list(init_poly):
_pp.Obj.Delete()
return returned_poly
return self._pedb.modeler.unite_polygons_on_layer(net_list=net_list)

0 comments on commit 325cc63

Please sign in to comment.