Utility functions for geometric transformations and layer manipulation.
Note
Copyright 2009-2012 Lucas Heitzmann Gabrielli
Copyright 2013 Andrew G. Mark
gdsCAD (based on gdspy) is released under the terms of the GNU GPL
translate(obj, displacement) | Translate an object, 2D vector, or a sequence of 2D vectors by the given vector |
rotate(obj, theta[, center]) | Rotate an object by given angle |
reflect(obj, axis[, origin, reverse_seq]) | Reflect an object in the x or y axis |
scale(obj, k[, origin, reverse_seq]) | Scale the pt or sequence of pts by the factor k |
split_layers(cell, old_layers) | Split the artwork in a cell between two copies according by layer. |
relayer(cell, old_layers, new_layer) | Move any elements in old_layers to new_layer |
These are old gdspy functions that no longer work, but may some day prove useful again
chop(polygon, position, axis) | BROKEN: Slice polygon at a given position along a given axis. |
slice(layer, objects, position, axis[, datatype]) | BROKEN Slice polygons and polygon sets at given positions along an axis. |
boolean(layer, objects, operation[, ...]) | BROKEN Execute any boolean operation on polygons and polygon sets. |
Utility functions for geometric transformations and layer manipulation.
Note
Copyright 2009-2012 Lucas Heitzmann Gabrielli
Copyright 2013 Andrew G. Mark
gdsCAD (based on gdspy) is released under the terms of the GNU GPL
BROKEN Execute any boolean operation on polygons and polygon sets.
Parameters
Returns
Notes
Since operation receives a list of integers as input, it can be somewhat more general than boolean operations only. See the examples below.
Because of roundoff errors there are a few cases when this function can cause segmentation faults. If that happens, increasing the value of eps might help.
Examples
>>> circle = gdspy.Round(0, (0, 0), 10)
>>> triangle = gdspy.Round(0, (0, 0), 12, number_of_points=3)
>>> bad_poly = gdspy.L1Path(1, (0, 0), '+y', 2,
[6, 4, 4, 8, 4, 5, 10], [-1, -1, -1, 1, 1, 1])
>>> union = gdspy.boolean(1, [circle, triangle],
lambda cir, tri: cir or tri)
>>> intersection = gdspy.boolean(1, [circle, triangle],
lambda cir, tri: cir and tri)
>>> subtraction = gdspy.boolean(1, [circle, triangle],
lambda cir, tri: cir and not tri)
>>> multi_xor = gdspy.boolean(1, [badPath], lambda p: p % 2)
BROKEN: Slice polygon at a given position along a given axis.
Parameters
Returns
Reflect an object in the x or y axis
Parameters: |
|
---|---|
Returns: | a reflected copy of obj |
Sequences of points are reversed to maintain the same sense as the original sequence.
Move any elements in old_layers to new_layer
Parameters: |
|
---|---|
Returns: | A copy of the relayered Cell |
TODO: use same labelling scheme found in GdsImport
Rotate an object by given angle
Parameters: |
|
---|---|
Returns: | A rotated copy of obj |
Scale the pt or sequence of pts by the factor k
Parameters: |
|
---|---|
Returns: | a scaled copy of obj |
The factor k can be a scalar or 2D vector allowing non-uniform scaling Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass. The center of mass is calculated only for the points, not by the area of the polygon they define.
Sequences of points are reversed if necessary to maintain the same sense as the original sequence.
BROKEN Slice polygons and polygon sets at given positions along an axis.
Parameters
Returns
Examples
>>> ring = gdspy.Round(1, (0, 0), 10, inner_radius = 5)
>>> result = gdspy.slice(1, ring, [-7, 7], 0)
>>> cell.add(result[1])
Split the artwork in a cell between two copies according by layer.
Parameters: |
|
---|---|
Returns: | A tuple of two cells |
TODO: use same labelling scheme found in GdsImport
split_layers() provides a convenient method of separating layers in a Cell into different Cells. It creates two copies of cell based on the list of layers in old_layers. Any artwork found on the layers of old_layers is moved to the first cell, and any artwork not found on the layers of old_layers is moved to the second layer. The existing heirarchy is maintained, however any empty Cells or references are removed.