Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now PyAEDT Cutout keeps the path as lines after the cutout #3801

Merged
merged 5 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,16 +720,26 @@ def test_063_create_custom_cutout(self):
edbapp.nets.nets
assert edbapp.cutout(
signal_list=["1V0"],
reference_list=["GND"],
reference_list=[
"GND",
"LVDS_CH08_N",
"LVDS_CH08_P",
"LVDS_CH10_N",
"LVDS_CH10_P",
"LVDS_CH04_P",
"LVDS_CH04_N",
],
extent_type="Bounding",
number_of_threads=4,
extent_defeature=0.001,
preserve_components_with_model=True,
keep_lines_as_path=True,
)
assert "A0_N" not in edbapp.nets.nets
assert isinstance(edbapp.nets.find_and_fix_disjoint_nets("GND", order_by_area=True), list)
assert isinstance(edbapp.nets.find_and_fix_disjoint_nets("GND", keep_only_main_net=True), list)
assert isinstance(edbapp.nets.find_and_fix_disjoint_nets("GND", clean_disjoints_less_than=0.005), list)

edbapp.close()

@pytest.mark.skipif(sys.version_info < (3, 8), reason="Method works in CPython only")
Expand Down
42 changes: 41 additions & 1 deletion pyaedt/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
maximum_iterations=10,
preserve_components_with_model=False,
simple_pad_check=True,
keep_lines_as_path=False,
):
"""Create a cutout using an approach entirely based on PyAEDT.
This method replaces all legacy cutout methods in PyAEDT.
Expand Down Expand Up @@ -1656,6 +1657,11 @@
Whether to use the center of the pad to find the intersection with extent or use the bounding box.
Second method is much slower and requires to disable multithread on padstack removal.
Default is `True`.
keep_lines_as_path : bool, optional
Whether to keep the lines as Path after they are cutout or convert them to PolygonData.
This feature works only in Electronics Desktop (3D Layout).
If the flag is set to True it can cause issues in SiWave once the Edb is imported.
MaxJPRey marked this conversation as resolved.
Show resolved Hide resolved
Default is ``False`` to generate PolygonData of cut lines.

Returns
-------
Expand Down Expand Up @@ -1745,6 +1751,7 @@
preserve_components_with_model=preserve_components_with_model,
include_partial=include_partial_instances,
simple_pad_check=simple_pad_check,
keep_lines_as_path=keep_lines_as_path,
)
if self.are_port_reference_terminals_connected():
if output_aedb_path:
Expand Down Expand Up @@ -1784,6 +1791,7 @@
preserve_components_with_model=preserve_components_with_model,
include_partial=include_partial_instances,
simple_pad_check=simple_pad_check,
keep_lines_as_path=keep_lines_as_path,
)
if result and not open_cutout_at_end and self.edbpath != legacy_path:
self.save_edb()
Expand Down Expand Up @@ -1989,6 +1997,7 @@
preserve_components_with_model=False,
include_partial=False,
simple_pad_check=True,
keep_lines_as_path=False,
):
if is_ironpython: # pragma: no cover
self.logger.error("Method working only in Cpython")
Expand Down Expand Up @@ -2026,6 +2035,7 @@
i.net_object.Delete()
reference_pinsts = []
reference_prims = []
reference_paths = []
for i in self.padstacks.instances.values():
net_name = i.net_name
id = i.id
Expand All @@ -2039,7 +2049,10 @@
if net_name not in all_list:
i.delete()
elif net_name in reference_list and not i.is_void:
reference_prims.append(i)
if keep_lines_as_path and i.type == "Path":
reference_paths.append(i)
else:
reference_prims.append(i)
self.logger.info_timer("Net clean up")
self.logger.reset_timer()

Expand Down Expand Up @@ -2087,6 +2100,20 @@
def subtract(poly, voids):
return poly.Subtract(convert_py_list_to_net_list(poly), convert_py_list_to_net_list(voids))

def clip_path(path):
result = path._edb_object.SetClipInfo(_poly, True)
if not result:
self.logger.info("Failed to clip path {}. Clipping as polygon.".format(path.id))
reference_prims.append(path)

Check warning on line 2107 in pyaedt/edb.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/edb.py#L2106-L2107

Added lines #L2106 - L2107 were not covered by tests
else:
center_points = list(path._edb_object.GetCenterLine().Points)
new_points = []
for i in range(len(center_points)):
if _poly.PointInPolygon(center_points[i]):
new_points.append(i)
if not new_points:
prims_to_delete.append(path)

def clean_prim(prim_1): # pragma: no cover
pdata = prim_1.polygon_data.edb_api
int_data = _poly.GetIntersectionType(pdata)
Expand Down Expand Up @@ -2132,6 +2159,11 @@
self.logger.info_timer("Padstack Instances removal completed")
self.logger.reset_timer()

# with ThreadPoolExecutor(number_of_threads) as pool:
# pool.map(lambda item: clip_path(item), reference_paths)

for item in reference_paths:
clip_path(item)
with ThreadPoolExecutor(number_of_threads) as pool:
pool.map(lambda item: clean_prim(item), reference_prims)

Expand All @@ -2140,6 +2172,7 @@

for prim in prims_to_delete:
prim.delete()

self.logger.info_timer("Primitives cleanup completed")
self.logger.reset_timer()

Expand Down Expand Up @@ -2175,6 +2208,7 @@
remove_single_pin_components=False,
use_pyaedt_extent_computing=False,
extent_defeature=0,
keep_lines_as_path=False,
):
"""Create a cutout using an approach entirely based on pyaedt.
It does in sequence:
Expand Down Expand Up @@ -2215,6 +2249,11 @@
extent_defeature : float, optional
Defeature the cutout before applying it to produce simpler geometry for mesh (Experimental).
It applies only to Conforming bounding box. Default value is ``0`` which disable it.
keep_lines_as_path : bool, optional
Whether to keep the lines as Path after they are cutout or convert them to PolygonData.
This feature works only in Electronics Desktop (3D Layout).
If the flag is set to True it can cause issues in SiWave once the Edb is imported.
Default is ``False`` to generate PolygonData of cut lines.

Returns
-------
Expand Down Expand Up @@ -2254,6 +2293,7 @@
remove_single_pin_components=remove_single_pin_components,
use_pyaedt_extent_computing=use_pyaedt_extent_computing,
extent_defeature=extent_defeature,
keep_lines_as_path=keep_lines_as_path,
)

@pyaedt_function_handler()
Expand Down
Loading