Skip to content

Commit

Permalink
FEATURE: Add support for layer based geometry pre-processing (#424)
Browse files Browse the repository at this point in the history
Co-authored-by: chenchienjacklin <[email protected]>
  • Loading branch information
drewm102 and chenchienjacklin authored Oct 4, 2024
1 parent 4ac5990 commit 94c2239
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [

# FIXME: add ansys-api-edb version
dependencies = [
"ansys-api-edb==1.0.7",
"ansys-api-edb==1.0.8",
"protobuf>=3.19.3,<5",
"grpcio>=1.44.0"
]
Expand Down
139 changes: 139 additions & 0 deletions src/ansys/edb/core/layout/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@
from ansys.edb.core.terminal.terminals import Terminal


def _geometry_simplifications_settings_msg(layout, layer, tol):
"""Create a GeometrySimplificationSettingsMessage."""
return layout_pb2.GeometrySimplificationSettingsMessage(
layout_layer=messages.layer_ref_property_message(layout, layer),
tolerance=messages.value_message(tol),
)


def _geometry_simplifications_settings_with_option_msg(layout, layer, tol, option):
"""Create a GeometrySimplificationSettingsWithOptionMessage."""
return layout_pb2.GeometrySimplificationSettingsWithOptionMessage(
geom_simplification_settings=_geometry_simplifications_settings_msg(layout, layer, tol),
option=option,
)


def _via_simplifications_settings_with_option_msg(
layout, layer, tol, option, simplification_method
):
"""Create a ViaSimplificationSettingsMessage."""
return layout_pb2.ViaSimplificationSettingsMessage(
geom_simplification_settings_with_option=_geometry_simplifications_settings_with_option_msg(
layout, layer, tol, option
),
simplification_method=simplification_method,
)


class Layout(ObjBase, variable_server.VariableServer):
"""Represents a layout."""

Expand Down Expand Up @@ -279,6 +307,28 @@ def layout_instance(self):
"""
return layout_instance.LayoutInstance(self.__stub.GetLayoutInstance(self.msg))

def reconstruct_arcs(self, layer, tolerance):
"""Reconstruct arcs of polygons on a layer.
Parameters
----------
layer : str or :class:`.Layer`
Layer to reconstruct arcs on.
tolerance : :class:`.Value`
Tolerance.
"""
self.__stub.ReconstructArcs(_geometry_simplifications_settings_msg(self, layer, tolerance))

def unite_primitives(self, layer):
"""Unite primitives on a layer.
Parameters
----------
layer : str or :class:`.Layer`
Layer to unite primitives on.
"""
self.__stub.UnitePrimitives(messages.layer_ref_property_message(self, layer))

def create_stride(self, filename):
"""Create a Stride model from an MCAD file.
Expand Down Expand Up @@ -325,3 +375,92 @@ def create_3d_comp(self, filename):
3D composite model created.
"""
return McadModel.create_3d_comp(layout=self, filename=filename)

def group_vias(
self,
layer,
max_grouping_distance="100um",
persistent_vias=False,
group_by_proximity=True,
check_containment=True,
):
"""Create via groups from the primitives on the specified layer.
Parameters
----------
layer : str or :class:`.Layer`
Layer containing the primitives to be grouped.
max_grouping_distance : :term:`ValueLike`
Maximum distance between vias in a via group .
persistent_vias : bool
Whether to preserve primitives during via group creation. If ``False``
primitives are deleted during via group creation.
group_by_proximity : bool
If ``True``, vias are grouped by proximity (relative position to each other).
If ``False``, vias are grouped by range (any vias within the specified maximum
grouping distance of each other are grouped)
check_containment : boo
If ``True``, the connectivity of via groups is checked and enforced to prevent
short circuits in geometry connecting to the via group. If false, vias are
grouped regardless of the connectivity of touching geometry.
"""
self.__stub.GroupVias(
layout_pb2.ViaGroupingSettingsMessage(
via_simplification_settings=_via_simplifications_settings_with_option_msg(
self, layer, max_grouping_distance, check_containment, group_by_proximity
),
persistent=persistent_vias,
)
)

def snap_vias(
self,
layer,
via_snapping_tol=3,
prim_snapping_tol="0.05um",
snap_by_area_factor=True,
remove_dangling_vias=True,
):
"""Snap vias on the specified layer to touching geometry.
Parameters
----------
layer : str or :class:`.Layer`
Layer containing the vias to be snapped.
via_snapping_tol : :term:`ValueLike`
Tolerance for snapping vias. If snap_by_area_factor is ``True``, this
value should not have a unit.
prim_snapping_tol : :term:`ValueLike`
Tolerance for snapping primitives.
snap_by_area_factor : bool
If ``True``, the via snapping tolerance is a factor of the surface area of the via.
If ``False``, the via snapping tolerance is treated as an absolute distance.
remove_dangling_vias : bool
If ``True``, vias not connected to any geometry are removed.
"""
self.__stub.SnapVias(
layout_pb2.ViaSnappingSettingsMessage(
via_simplification_settings=_via_simplifications_settings_with_option_msg(
self, layer, via_snapping_tol, remove_dangling_vias, snap_by_area_factor
),
prim_snapping_tol=messages.value_message(prim_snapping_tol),
)
)

def snap_primitives(self, layer, tol="0.05um", check_connectivity=True):
"""Snap primitives on the specified layer to touching geometry.
Parameters
----------
layer : str or :class:`.Layer`
Layer containing the primitives to be snapped.
tol : :term:`ValueLike`
Tolerance for snapping primitives.
check_connectivity : bool
If ``True``, the connectivity of primitives is checked and enforced to prevent
short circuits in geometry connecting to the primitives. If false, primitives are
grouped regardless of the connectivity of touching geometry.
"""
self.__stub.SnapPrimitives(
_geometry_simplifications_settings_with_option_msg(self, layer, tol, check_connectivity)
)

0 comments on commit 94c2239

Please sign in to comment.