gdsfactory.geometry.boolean#
- gdsfactory.geometry.boolean(A: Component | ComponentReference | tuple[Component | ComponentReference, ...], B: Component | ComponentReference | tuple[Component | ComponentReference, ...], operation: str, precision: float = 0.0001, layer: LayerSpec = (1, 0)) Component [source]#
Performs boolean operations between 2 Component/Reference/list objects.
operation
should be one of {‘not’, ‘and’, ‘or’, ‘xor’, ‘A-B’, ‘B-A’, ‘A+B’}. Note that ‘A+B’ is equivalent to ‘or’, ‘A-B’ is equivalent to ‘not’, and ‘B-A’ is equivalent to ‘not’ with the operands switchedYou can also use gdsfactory.drc.boolean_klayout
- Parameters:
A – Component(/Reference) or list of Component(/References).
B – Component(/Reference) or list of Component(/References).
operation – {‘not’, ‘and’, ‘or’, ‘xor’, ‘A-B’, ‘B-A’, ‘A+B’}.
precision – float Desired precision for rounding vertex coordinates.
layer – Specific layer to put polygon geometry on.
- Returns: Component with polygon(s) of the boolean operations between
the 2 input Components performed.
Notes
‘A+B’ is equivalent to ‘or’.
‘A-B’ is equivalent to ‘not’.
‘B-A’ is equivalent to ‘not’ with the operands switched.
import gdsfactory as gf c1 = gf.components.circle(radius=10).ref() c2 = gf.components.circle(radius=9).ref() c2.movex(5) c = gf.geometry.boolean(c1, c2, operation="xor") c.plot_matplotlib()
(
Source code
,png
,hires.png
,pdf
)