File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed
tidy3d/components/geometry Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change 22
22
]
23
23
24
24
25
- def flatten_groups (* geometries : GeometryType ) -> GeometryType :
25
+ def flatten_groups (* geometries : GeometryType , flatten_nonunion_type : bool = False ) -> GeometryType :
26
26
"""Iterates over all geometries, flattening groups and unions.
27
27
28
28
Parameters
29
29
----------
30
- *geometries: GeometryType
30
+ *geometries : GeometryType
31
31
Geometries to flatten.
32
32
33
- Returns
34
- -------
35
- :class:`Geometry`
36
- Geometries after flattening groups and unions."""
33
+ flatten_nonunion_type : bool = False
34
+ If ``False``, only flatten geometry unions (and ``GeometryGroup``). If ``True``, flatten
35
+ all clip operations.
36
+
37
+ Yields
38
+ ------
39
+ GeometryType
40
+ Geometries after flattening groups and unions.
41
+ """
37
42
for geometry in geometries :
38
43
if isinstance (geometry , base .GeometryGroup ):
39
- yield from flatten_groups (* geometry .geometries )
40
- elif isinstance (geometry , base .ClipOperation ) and geometry .operation == "union" :
41
- yield from flatten_groups (geometry .geometry_a , geometry .geometry_b )
44
+ yield from flatten_groups (
45
+ * geometry .geometries , flatten_nonunion_type = flatten_nonunion_type
46
+ )
47
+ elif isinstance (geometry , base .ClipOperation ) and (
48
+ flatten_nonunion_type or geometry .operation == "union"
49
+ ):
50
+ yield from flatten_groups (
51
+ geometry .geometry_a ,
52
+ geometry .geometry_b ,
53
+ flatten_nonunion_type = flatten_nonunion_type ,
54
+ )
42
55
else :
43
56
yield geometry
44
57
You can’t perform that action at this time.
0 commit comments