gdsfactory.geometry.trim#
- gdsfactory.geometry.trim(component: Component, domain: list[tuple[float, float]], precision: float = 0.0001, return_ports: bool | None = False) Component [source]#
Trim a component by another geometry, preserving the component’s layers and ports.
Useful to get a smaller component from a larger one for simulation.
- Parameters:
component – Component(/Reference).
domain – list of array-like[N][2] representing the boundary of the component to keep.
precision – float Desired precision for rounding vertex coordinates.
return_ports – whether to return the included ports or not. Ports are always renamed to avoid inheritance conflicts.
Returns: New component with layers (and possibly ports) of the component restricted to the domain.
import gdsfactory as gf c = gf.components.straight_pin(length=10, taper=None) trimmed_c = gf.geometry.trim(component=c, domain=[[0, -5], [0, 5], [5, 5], [5, -5]]) trimmed_c.plot_matplotlib()
(
Source code
,png
,hires.png
,pdf
)