Round the corners of these polygons and fractures them into
polygons with less vertices if necessary.
Parameters:
radius (number, array-like) – Radius of the corners. If number: all corners filleted by
that amount. If array: specify fillet radii on a
per-polygon basis (length must be equal to the number of
polygons in this PolygonSet). Each element in the array
can be a number (all corners filleted by the same amount) or
another array of numbers, one per polygon vertex.
Alternatively, the array can be flattened to have one radius
per PolygonSet vertex.
points_per_2pi (integer) – Number of vertices used to approximate a full circle. The
number of vertices in each corner of the polygon will be the
fraction of this number corresponding to the angle
encompassed by that corner with respect to 2 pi.
max_points (integer) – Maximal number of points in each resulting polygon (at least
5, otherwise the resulting polygon is not fractured).
precision (float) – Desired precision for rounding vertice coordinates in case
of fracturing.
Round the corners of these polygons and fractures them into
polygons with less vertices if necessary.
Parameters:
radius (number, array-like) – Radius of the corners. If number: all corners filleted by
that amount. If array: specify fillet radii on a
per-polygon basis (length must be equal to the number of
polygons in this PolygonSet). Each element in the array
can be a number (all corners filleted by the same amount) or
another array of numbers, one per polygon vertex.
Alternatively, the array can be flattened to have one radius
per PolygonSet vertex.
points_per_2pi (integer) – Number of vertices used to approximate a full circle. The
number of vertices in each corner of the polygon will be the
fraction of this number corresponding to the angle
encompassed by that corner with respect to 2 pi.
max_points (integer) – Maximal number of points in each resulting polygon (at least
5, otherwise the resulting polygon is not fractured).
precision (float) – Desired precision for rounding vertice coordinates in case
of fracturing.
Round the corners of these polygons and fractures them into
polygons with less vertices if necessary.
Parameters:
radius (number, array-like) – Radius of the corners. If number: all corners filleted by
that amount. If array: specify fillet radii on a
per-polygon basis (length must be equal to the number of
polygons in this PolygonSet). Each element in the array
can be a number (all corners filleted by the same amount) or
another array of numbers, one per polygon vertex.
Alternatively, the array can be flattened to have one radius
per PolygonSet vertex.
points_per_2pi (integer) – Number of vertices used to approximate a full circle. The
number of vertices in each corner of the polygon will be the
fraction of this number corresponding to the angle
encompassed by that corner with respect to 2 pi.
max_points (integer) – Maximal number of points in each resulting polygon (at least
5, otherwise the resulting polygon is not fractured).
precision (float) – Desired precision for rounding vertice coordinates in case
of fracturing.
Represent a circle, ellipse, ring or their sections.
Parameters:
center (array-like[2]) – Coordinates of the center of the circle/ring.
radius (number, array-like[2]) – Radius of the circle/outer radius of the ring. To build an
ellipse an array of 2 numbers can be used, representing the
radii in the horizontal and vertical directions.
inner_radius (number, array-like[2]) – Inner radius of the ring. To build an elliptical hole, an array
of 2 numbers can be used, representing the radii in the
horizontal and vertical directions.
initial_angle (number) – Initial angle of the circular/ring section (in radians).
final_angle (number) – Final angle of the circular/ring section (in radians).
tolerance (float) – Approximate curvature resolution. The number of points is
automatically calculated.
number_of_points (integer or None) – Manually define the number of vertices that form the object
(polygonal approximation). Overrides tolerance.
max_points (integer) – If the number of points in the element is greater than
max_points, it will be fractured in smaller polygons with
at most max_points each. If max_points is zero no fracture
will occur.
layer (integer) – The GDSII layer number for this element.
datatype (integer) – The GDSII datatype for this element (between 0 and 255).
Notes
The original GDSII specification supports only a maximum of 199
vertices per polygon.
Round the corners of these polygons and fractures them into
polygons with less vertices if necessary.
Parameters:
radius (number, array-like) – Radius of the corners. If number: all corners filleted by
that amount. If array: specify fillet radii on a
per-polygon basis (length must be equal to the number of
polygons in this PolygonSet). Each element in the array
can be a number (all corners filleted by the same amount) or
another array of numbers, one per polygon vertex.
Alternatively, the array can be flattened to have one radius
per PolygonSet vertex.
points_per_2pi (integer) – Number of vertices used to approximate a full circle. The
number of vertices in each corner of the polygon will be the
fraction of this number corresponding to the angle
encompassed by that corner with respect to 2 pi.
max_points (integer) – Maximal number of points in each resulting polygon (at least
5, otherwise the resulting polygon is not fractured).
precision (float) – Desired precision for rounding vertice coordinates in case
of fracturing.
text (string) – The text to be converted in geometric objects.
size (number) – Height of the character. The width of a character and the
distance between characters are this value multiplied by 5 / 9
and 8 / 9, respectively. For vertical text, the distance is
multiplied by 11 / 9.
position (array-like[2]) – Text position (lower left corner).
horizontal (bool) – If True, the text is written from left to right; if
False, from top to bottom.
angle (number) – The angle of rotation of the text.
layer (integer) – The GDSII layer number for these elements.
datatype (integer) – The GDSII datatype for this element (between 0 and 255).
Round the corners of these polygons and fractures them into
polygons with less vertices if necessary.
Parameters:
radius (number, array-like) – Radius of the corners. If number: all corners filleted by
that amount. If array: specify fillet radii on a
per-polygon basis (length must be equal to the number of
polygons in this PolygonSet). Each element in the array
can be a number (all corners filleted by the same amount) or
another array of numbers, one per polygon vertex.
Alternatively, the array can be flattened to have one radius
per PolygonSet vertex.
points_per_2pi (integer) – Number of vertices used to approximate a full circle. The
number of vertices in each corner of the polygon will be the
fraction of this number corresponding to the angle
encompassed by that corner with respect to 2 pi.
max_points (integer) – Maximal number of points in each resulting polygon (at least
5, otherwise the resulting polygon is not fractured).
precision (float) – Desired precision for rounding vertice coordinates in case
of fracturing.
direction ('+x', '-x', '+y', '-y' or number) – Direction or angle (in radians) of rotation of the
segment.
final_width (number) – If set, the paths of this segment will have their widths
linearly changed from their current value to this one.
final_distance (number) – If set, the distance between paths is linearly change from
its current value to this one along this segment.
axis_offset (number) – If set, the paths will be offset from their direction by
this amount.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If
the number of layers in the list is less than the number
of paths, the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between
0 and 255). If the number of datatypes in the list is less
than the number of paths, the list is repeated.
initial_angle (number) – Initial angle of the curve (in radians).
final_angle (number) – Final angle of the curve (in radians).
tolerance (float) – Approximate curvature resolution. The number of points is
automatically calculated.
number_of_points (integer or None) – Manually define the number of vertices that form the object
(polygonal approximation). Overrides tolerance.
max_points (integer) – If the number of points in the element is greater than
max_points, it will be fractured in smaller polygons with
at most max_points each. If max_points is zero no
fracture will occur.
final_width (number) – If set, the paths of this segment will have their widths
linearly changed from their current value to this one.
final_distance (number) – If set, the distance between paths is linearly change from
its current value to this one along this segment.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If
the number of layers in the list is less than the number of
paths, the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between 0
and 255). If the number of datatypes in the list is less
than the number of paths, the list is repeated.
Returns:
out – This object.
Return type:
Path
Notes
The original GDSII specification supports only a maximum of 199
vertices per polygon.
angle ('r', 'l', 'rr', 'll' or number) – Angle (in radians) of rotation of the path. The values
‘r’ and ‘l’ represent 90-degree turns cw and ccw,
respectively; the values ‘rr’ and ‘ll’ represent analogous
180-degree turns.
tolerance (float) – Approximate curvature resolution. The number of points is
automatically calculated.
number_of_points (integer or None) – Manually define the number of vertices that form the object
(polygonal approximation). Overrides tolerance.
max_points (integer) – If the number of points in the element is greater than
max_points, it will be fractured in smaller polygons with
at most max_points each. If max_points is zero no
fracture will occur.
final_width (number) – If set, the paths of this segment will have their widths
linearly changed from their current value to this one.
final_distance (number) – If set, the distance between paths is linearly change from
its current value to this one along this segment.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If
the number of layers in the list is less than the number of
paths, the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between 0
and 255). If the number of datatypes in the list is less
than the number of paths, the list is repeated.
Returns:
out – This object.
Return type:
Path
Notes
The original GDSII specification supports only a maximum of 199
vertices per polygon.
curve_function will be evaluated uniformly in the interval
[0, 1] at least number_of_points times. More points will be
added to the curve at the midpoint between evaluations if that
points presents error larger than tolerance.
Parameters:
curve_function (callable) – Function that defines the curve. Must be a function of one
argument (that varies from 0 to 1) that returns a 2-element
array with the coordinates of the curve.
curve_derivative (callable) – If set, it should be the derivative of the curve function.
Must be a function of one argument (that varies from 0 to 1)
that returns a 2-element array. If None, the derivative
will be calculated numerically.
tolerance (number) – Acceptable tolerance for the approximation of the curve
function by a finite number of evaluations.
number_of_evaluations (integer) – Initial number of points where the curve function will be
evaluated. According to tolerance, more evaluations will
be performed.
max_points (integer) – Elements will be fractured until each polygon has at most
max_points. If max_points is less than 4, no fracture
will occur.
final_width (number or function) – If set to a number, the paths of this segment will have
their widths linearly changed from their current value to
this one. If set to a function, it must be a function of
one argument (that varies from 0 to 1) and returns the width
of the path.
final_distance (number or function) – If set to a number, the distance between paths is linearly
change from its current value to this one. If set to a
function, it must be a function of one argument (that varies
from 0 to 1) and returns the width of the path.
relative (bool) – If True, the return values of curve_function are used as
offsets from the current path position, i.e., to ensure a
continuous path, curve_function(0) must be (0, 0).
Otherwise, they are used as absolute coordinates.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If
the number of layers in the list is less than the number of
paths, the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between 0
and 255). If the number of datatypes in the list is less
than the number of paths, the list is repeated.
Returns:
out – This object.
Return type:
Path
Notes
The norm of the vector returned by curve_derivative is not
important. Only the direction is used.
The original GDSII specification supports only a maximum of 199
vertices per polygon.
A Bezier curve is added to the path starting from its current
position and finishing at the last point in the points array.
Parameters:
points (array-like[N][2]) – Control points defining the Bezier curve.
tolerance (number) – Acceptable tolerance for the approximation of the curve
function by a finite number of evaluations.
number_of_evaluations (integer) – Initial number of points where the curve function will be
evaluated. According to tolerance, more evaluations will
be performed.
max_points (integer) – Elements will be fractured until each polygon has at most
max_points. If max_points is zero no fracture will
occur.
final_width (number or function) – If set to a number, the paths of this segment will have
their widths linearly changed from their current value to
this one. If set to a function, it must be a function of
one argument (that varies from 0 to 1) and returns the width
of the path.
final_distance (number or function) – If set to a number, the distance between paths is linearly
change from its current value to this one. If set to a
function, it must be a function of one argument (that varies
from 0 to 1) and returns the width of the path.
relative (bool) – If True, all coordinates in the points array are used as
offsets from the current path position, i.e., if the path is
at (1, -2) and the last point in the array is (10, 25), the
constructed Bezier will end at (1 + 10, -2 + 25) = (11, 23).
Otherwise, the points are used as absolute coordinates.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If
the number of layers in the list is less than the number of
paths, the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between 0
and 255). If the number of datatypes in the list is less
than the number of paths, the list is repeated.
Returns:
out – This object.
Return type:
Path
Notes
The original GDSII specification supports only a maximum of 199
vertices per polygon.
Add a smooth interpolating curve through the given points.
Uses the Hobby algorithm [1]_ to calculate a smooth
interpolating curve made of cubic Bezier segments between each
pair of points.
Parameters:
points (array-like[N][2]) – Vertices in the interpolating curve.
angles (array-like[N + 1] or None) – Tangent angles at each point (in radians). Any angles
defined as None are automatically calculated.
curl_start (number) – Ratio between the mock curvatures at the first point and at
its neighbor. A value of 1 renders the first segment a good
approximation for a circular arc. A value of 0 will better
approximate a straight segment. It has no effect for closed
curves or when an angle is defined for the first point.
curl_end (number) – Ratio between the mock curvatures at the last point and at
its neighbor. It has no effect for closed curves or when an
angle is defined for the first point.
t_in (number or array-like[N + 1]) – Tension parameter when arriving at each point. One value
per point or a single value used for all points.
t_out (number or array-like[N + 1]) – Tension parameter when leaving each point. One value per
point or a single value used for all points.
cycle (bool) – If True, calculates control points for a closed curve,
with an additional segment connecting the first and last
points.
tolerance (number) – Acceptable tolerance for the approximation of the curve
function by a finite number of evaluations.
number_of_evaluations (integer) – Initial number of points where the curve function will be
evaluated. According to tolerance, more evaluations will
be performed.
max_points (integer) – Elements will be fractured until each polygon has at most
max_points. If max_points is zero no fracture will
occur.
final_widths (array-like[M]) – Each element corresponds to the final width of a segment in
the whole curve. If an element is a number, the paths of
this segment will have their widths linearly changed to this
value. If a function, it must be a function of one argument
(that varies from 0 to 1) and returns the width of the path.
The length of the array must be equal to the number of
segments in the curve, i.e., M = N - 1 for an open curve and
M = N for a closed one.
final_distances (array-like[M]) – Each element corresponds to the final distance between paths
of a segment in the whole curve. If an element is a number,
the distance between paths is linearly change to this value.
If a function, it must be a function of one argument (that
varies from 0 to 1) and returns the width of the path. The
length of the array must be equal to the number of segments
in the curve, i.e., M = N - 1 for an open curve and M = N
for a closed one.
relative (bool) – If True, all coordinates in the points array are used as
offsets from the current path position, i.e., if the path is
at (1, -2) and the last point in the array is (10, 25), the
constructed curve will end at (1 + 10, -2 + 25) = (11, 23).
Otherwise, the points are used as absolute coordinates.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If
the number of layers in the list is less than the number of
paths, the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between 0
and 255). If the number of datatypes in the list is less
than the number of paths, the list is repeated.
Returns:
out – This object.
Return type:
Path
Notes
The original GDSII specification supports only a maximum of 199
vertices per polygon.
Round the corners of these polygons and fractures them into
polygons with less vertices if necessary.
Parameters:
radius (number, array-like) – Radius of the corners. If number: all corners filleted by
that amount. If array: specify fillet radii on a
per-polygon basis (length must be equal to the number of
polygons in this PolygonSet). Each element in the array
can be a number (all corners filleted by the same amount) or
another array of numbers, one per polygon vertex.
Alternatively, the array can be flattened to have one radius
per PolygonSet vertex.
points_per_2pi (integer) – Number of vertices used to approximate a full circle. The
number of vertices in each corner of the polygon will be the
fraction of this number corresponding to the angle
encompassed by that corner with respect to 2 pi.
max_points (integer) – Maximal number of points in each resulting polygon (at least
5, otherwise the resulting polygon is not fractured).
precision (float) – Desired precision for rounding vertice coordinates in case
of fracturing.
Series of geometric objects that form a polygonal path or a
collection of parallel polygonal paths.
Deprecated since version 1.4: PolyPath is deprecated in favor of FlexPath and will be removed
in a future version of Gdspy.
Parameters:
points (array-like[N][2]) – Points along the center of the path.
width (number or array-like[N]) – Width of the path. If an array is given, width at each
endpoint.
number_of_paths (positive integer) – Number of parallel paths to create simultaneously.
distance (number or array-like[N]) – Distance between the centers of adjacent paths. If an array is
given, distance at each endpoint.
corners ('miter' or 'bevel') – Type of joins.
ends ('flush', 'round', 'extended') – Type of end caps for the paths.
max_points (integer) – The paths will be fractured in polygons with at most
max_points (must be at least 4). If max_points is zero no
fracture will occur.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If the
number of layers in the list is less than the number of paths,
the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between 0 and
255). If the number of datatypes in the list is less than the
number of paths, the list is repeated.
Notes
The bevel join will give strange results if the number of paths is
greater than 1.
Round the corners of these polygons and fractures them into
polygons with less vertices if necessary.
Parameters:
radius (number, array-like) – Radius of the corners. If number: all corners filleted by
that amount. If array: specify fillet radii on a
per-polygon basis (length must be equal to the number of
polygons in this PolygonSet). Each element in the array
can be a number (all corners filleted by the same amount) or
another array of numbers, one per polygon vertex.
Alternatively, the array can be flattened to have one radius
per PolygonSet vertex.
points_per_2pi (integer) – Number of vertices used to approximate a full circle. The
number of vertices in each corner of the polygon will be the
fraction of this number corresponding to the angle
encompassed by that corner with respect to 2 pi.
max_points (integer) – Maximal number of points in each resulting polygon (at least
5, otherwise the resulting polygon is not fractured).
precision (float) – Desired precision for rounding vertice coordinates in case
of fracturing.
Series of geometric objects that form a path or a collection of
parallel paths with Manhattan geometry.
Deprecated since version 1.4: L1Path is deprecated in favor of FlexPath and will be removed
in a future version of Gdspy.
Parameters:
initial_point (array-like[2]) – Starting position of the path.
direction ('+x', '+y', '-x', '-y') – Starting direction of the path.
width (number) – The initial width of each path.
length (array-like) – Lengths of each section to add.
turn (array-like) – Direction to turn before each section. The sign indicate the
turn direction (ccw is positive), and the modulus is a
multiplicative factor for the path width after each turn. Must
have 1 element less then length.
number_of_paths (positive integer) – Number of parallel paths to create simultaneously.
distance (number) – Distance between the centers of adjacent paths.
max_points (integer) – The paths will be fractured in polygons with at most
max_points (must be at least 6). If max_points is zero no
fracture will occur.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If the
number of layers in the list is less than the number of paths,
the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between 0 and
255). If the number of datatypes in the list is less than the
number of paths, the list is repeated.
Variables:
x (number) – Final position of the path in the x direction.
y (number) – Final position of the path in the y direction.
direction ('+x', '-x', '+y', '-y' or number) – Direction or angle (in radians) the path points to. The
numerical angle is returned only after a rotation of the object.
Round the corners of these polygons and fractures them into
polygons with less vertices if necessary.
Parameters:
radius (number, array-like) – Radius of the corners. If number: all corners filleted by
that amount. If array: specify fillet radii on a
per-polygon basis (length must be equal to the number of
polygons in this PolygonSet). Each element in the array
can be a number (all corners filleted by the same amount) or
another array of numbers, one per polygon vertex.
Alternatively, the array can be flattened to have one radius
per PolygonSet vertex.
points_per_2pi (integer) – Number of vertices used to approximate a full circle. The
number of vertices in each corner of the polygon will be the
fraction of this number corresponding to the angle
encompassed by that corner with respect to 2 pi.
max_points (integer) – Maximal number of points in each resulting polygon (at least
5, otherwise the resulting polygon is not fractured).
precision (float) – Desired precision for rounding vertice coordinates in case
of fracturing.
This class keeps information about the constructive parameters of
the path and calculates its boundaries only upon request.
It can be stored as a proper path element in the GDSII format,
unlike Path. In this case, the width must be constant along the
whole path.
Parameters:
points (array-like[N][2]) – Points along the center of the path.
width (number, list) – Width of each parallel path being created. The number of
parallel paths being created is defined by the length of this
list.
offset (number, list) – Offsets of each parallel path from the center. If width is
not a list, the length of this list is used to determine the
number of parallel paths being created. Otherwise, offset must
be a list with the same length as width, or a number, which is
used as distance between adjacent paths.
corners ('natural', 'miter', 'bevel', 'round', 'smooth', 'circular bend', callable, list) – Type of joins. A callable must receive 6 arguments (vertex and
direction vector from both segments being joined, the center
and width of the path) and return a list of vertices that make
the join. A list can be used to define the join for each
parallel path.
ends ('flush', 'extended', 'round', 'smooth', 2-tuple, callable, list) – Type of end caps for the paths. A 2-element tuple represents
the start and end extensions to the paths. A callable must
receive 4 arguments (vertex and direction vectors from both
sides of the path and return a list of vertices that make the
end cap. A list can be used to define the end type for each
parallel path.
bend_radius (number, list) – Bend radii for each path when corners is ‘circular bend’.
It has no effect for other corner types.
tolerance (number) – Tolerance used to draw the paths and calculate joins.
precision (number) – Precision for rounding the coordinates of vertices when
fracturing the final polygonal boundary.
max_points (integer) – If the number of points in the polygonal path boundary is
greater than max_points, it will be fractured in smaller
polygons with at most max_points each. If max_points is
zero no fracture will occur.
gdsii_path (bool) – If True, treat this object as a GDSII path element.
Otherwise, it will be converted into polygonal boundaries when
required.
width_transform (bool) – If gdsii_path is True, this flag indicates whether the width
of the path should transform when scaling this object. It has
no effect when gdsii_path is False.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If the
number of layers in the list is less than the number of paths,
the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between 0 and
255). If the number of datatypes in the list is less than the
number of paths, the list is repeated.
Notes
The value of tolerance should not be smaller than precision,
otherwise there would be wasted computational effort in calculating
the paths.
Convert this object to a series of GDSII elements.
If FlexPath.gdsii_path is True, GDSII path elements are
created instead of boundaries. Such paths do not support
variable widths, but their memeory footprint is smaller than
full polygonal boundaries.
Parameters:
multiplier (number) – A number that multiplies all dimensions written in the GDSII
elements.
Returns:
out – The GDSII binary string that represents this object.
end_point (array-like[2]) – End position of the straight segment.
width (number, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. A list can be used where each
element defines the width for one of the parallel paths in
this object. This argument has no effect if the path was
created with gdsii_path True.
offset (number, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). A list
can be used where each element defines the absolute offset
(not offset increase) for one of the parallel paths in this
object.
relative (bool) – If True, end_point is used as an offset from the current
path position, i.e., if the path is at (1, -2) and the
end_point is (10, 25), the segment will be constructed
from (1, -2) to (1 + 10, -2 + 25) = (11, 23). Otherwise,
end_point is used as an absolute coordinate.
initial_angle (number) – Initial angle of the arc.
final_angle (number) – Final angle of the arc.
width (number, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. A list can be used where each
element defines the width for one of the parallel paths in
this object. This argument has no effect if the path was
created with gdsii_path True.
offset (number, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). A list
can be used where each element defines the absolute offset
(not offset increase) for one of the parallel paths in this
object.
The initial angle of the arc is calculated from the last path
segment.
Parameters:
radius (number) – Radius of the circular arc.
angle ('r', 'l', 'rr', 'll' or number) – Angle (in radians) of rotation of the path. The values
‘r’ and ‘l’ represent 90-degree turns cw and ccw,
respectively; the values ‘rr’ and ‘ll’ represent analogous
180-degree turns.
width (number, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. A list can be used where each
element defines the width for one of the parallel paths in
this object. This argument has no effect if the path was
created with gdsii_path True.
offset (number, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). A list
can be used where each element defines the absolute offset
(not offset increase) for one of the parallel paths in this
object.
curve_function (callable) – Function that defines the curve. Must be a function of one
argument (that varies from 0 to 1) that returns a 2-element
Numpy array with the coordinates of the curve.
width (number, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. A list can be used where each
element defines the width for one of the parallel paths in
this object. This argument has no effect if the path was
created with gdsii_path True.
offset (number, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). A list
can be used where each element defines the absolute offset
(not offset increase) for one of the parallel paths in this
object.
relative (bool) – If True, the return values of curve_function are used as
offsets from the current path position, i.e., to ensure a
continuous path, curve_function(0) must be (0, 0).
Otherwise, they are used as absolute coordinates.
A Bezier curve is added to the path starting from its current
position and finishing at the last point in the points array.
Parameters:
points (array-like[N][2]) – Control points defining the Bezier curve.
width (number, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. A list can be used where each
element defines the width for one of the parallel paths in
this object. This argument has no effect if the path was
created with gdsii_path True.
offset (number, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). A list
can be used where each element defines the absolute offset
(not offset increase) for one of the parallel paths in this
object.
relative (bool) – If True, all coordinates in the points array are used as
offsets from the current path position, i.e., if the path is
at (1, -2) and the last point in the array is (10, 25), the
constructed Bezier will end at (1 + 10, -2 + 25) = (11, 23).
Otherwise, the points are used as absolute coordinates.
Add a smooth interpolating curve through the given points.
Uses the Hobby algorithm [1]_ to calculate a smooth
interpolating curve made of cubic Bezier segments between each
pair of points.
Parameters:
points (array-like[N][2]) – Vertices in the interpolating curve.
angles (array-like[N + 1] or None) – Tangent angles at each point (in radians). Any angles
defined as None are automatically calculated.
curl_start (number) – Ratio between the mock curvatures at the first point and at
its neighbor. A value of 1 renders the first segment a good
approximation for a circular arc. A value of 0 will better
approximate a straight segment. It has no effect for closed
curves or when an angle is defined for the first point.
curl_end (number) – Ratio between the mock curvatures at the last point and at
its neighbor. It has no effect for closed curves or when an
angle is defined for the first point.
t_in (number or array-like[N + 1]) – Tension parameter when arriving at each point. One value
per point or a single value used for all points.
t_out (number or array-like[N + 1]) – Tension parameter when leaving each point. One value per
point or a single value used for all points.
cycle (bool) – If True, calculates control points for a closed curve,
with an additional segment connecting the first and last
points.
width (number, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. A list can be used where each
element defines the width for one of the parallel paths in
this object. This argument has no effect if the path was
created with gdsii_path True.
offset (number, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). A list
can be used where each element defines the absolute offset
(not offset increase) for one of the parallel paths in this
object.
relative (bool) – If True, all coordinates in the points array are used as
offsets from the current path position, i.e., if the path is
at (1, -2) and the last point in the array is (10, 25), the
constructed curve will end at (1 + 10, -2 + 25) = (11, 23).
Otherwise, the points are used as absolute coordinates.
Returns:
out – This object.
Return type:
FlexPath
Notes
Arguments width and offset are repeated for each cubic
Bezier that composes this path element.
This class keeps information about the constructive parameters of
the path and calculates its boundaries only upon request. The
benefits are that joins and path components can be calculated
automatically to ensure continuity (except in extreme cases).
It can be stored as a proper path element in the GDSII format,
unlike Path. In this case, the width must be constant along the
whole path.
The downside of RobustPath is that it is more computationally
expensive than the other path classes.
Parameters:
initial_point (array-like[2]) – Starting position of the path.
width (number, list) – Width of each parallel path being created. The number of
parallel paths being created is defined by the length of this
list.
offset (number, list) – Offsets of each parallel path from the center. If width is
not a list, the length of this list is used to determine the
number of parallel paths being created. Otherwise, offset must
be a list with the same length as width, or a number, which is
used as distance between adjacent paths.
ends ('flush', 'extended', 'round', 'smooth', 2-tuple, list) – Type of end caps for the paths. A 2-element tuple represents
the start and end extensions to the paths. A list can be used
to define the end type for each parallel path.
tolerance (number) – Tolerance used to draw the paths and calculate joins.
precision (number) – Precision for rounding the coordinates of vertices when
fracturing the final polygonal boundary.
max_points (integer) – If the number of points in the polygonal path boundary is
greater than max_points, it will be fractured in smaller
polygons with at most max_points each. If max_points is
zero no fracture will occur.
max_evals (integer) – Limit to the maximal number of evaluations when calculating each
path component.
gdsii_path (bool) – If True, treat this object as a GDSII path element.
Otherwise, it will be converted into polygonal boundaries when
required.
width_transform (bool) – If gdsii_path is True, this flag indicates whether the width
of the path should transform when scaling this object. It has
no effect when gdsii_path is False.
layer (integer, list) – The GDSII layer numbers for the elements of each path. If the
number of layers in the list is less than the number of paths,
the list is repeated.
datatype (integer, list) – The GDSII datatype for the elements of each path (between 0 and
255). If the number of datatypes in the list is less than the
number of paths, the list is repeated.
Notes
The value of tolerance should not be smaller than precision,
otherwise there would be wasted computational effort in calculating
the paths.
Convert this object to a series of GDSII elements.
If RobustPath.gdsii_path is True, GDSII path elements are
created instead of boundaries. Such paths do not support
variable widths, but their memeory footprint is smaller than
full polygonal boundaries.
Parameters:
multiplier (number) – A number that multiplies all dimensions written in the GDSII
elements.
Returns:
out – The GDSII binary string that represents this object.
end_point (array-like[2]) – End position of the straight segment.
width (number, callable, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. If this is callable, it must be a
function of one argument (that varies from 0 to 1) that
returns the width of the path. A list can be used where
each element (number or callable) defines the width for one
of the parallel paths in this object.
offset (number, callable, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). If this
is callable, it must be a function of one argument (that
varies from 0 to 1) that returns the offset increase. A
list can be used where each element (number or callable)
defines the absolute offset (not offset increase) for one
of the parallel paths in this object.
relative (bool) – If True, end_point is used as an offset from the current
path position, i.e., if the path is at (1, -2) and the
end_point is (10, 25), the segment will be constructed
from (1, -2) to (1 + 10, -2 + 25) = (11, 23). Otherwise,
end_point is used as an absolute coordinate.
initial_angle (number) – Initial angle of the arc.
final_angle (number) – Final angle of the arc.
width (number, callable, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. If this is callable, it must be a
function of one argument (that varies from 0 to 1) that
returns the width of the path. A list can be used where
each element (number or callable) defines the width for one
of the parallel paths in this object.
offset (number, callable, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). If this
is callable, it must be a function of one argument (that
varies from 0 to 1) that returns the offset increase. A
list can be used where each element (number or callable)
defines the absolute offset (not offset increase) for one
of the parallel paths in this object.
The initial angle of the arc is calculated from an average of
the current directions of all parallel paths in this object.
Parameters:
radius (number) – Radius of the circular arc.
angle ('r', 'l', 'rr', 'll' or number) – Angle (in radians) of rotation of the path. The values
‘r’ and ‘l’ represent 90-degree turns cw and ccw,
respectively; the values ‘rr’ and ‘ll’ represent analogous
180-degree turns.
width (number, callable, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. If this is callable, it must be a
function of one argument (that varies from 0 to 1) that
returns the width of the path. A list can be used where
each element (number or callable) defines the width for one
of the parallel paths in this object.
offset (number, callable, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). If this
is callable, it must be a function of one argument (that
varies from 0 to 1) that returns the offset increase. A
list can be used where each element (number or callable)
defines the absolute offset (not offset increase) for one
of the parallel paths in this object.
curve_function (callable) – Function that defines the curve. Must be a function of one
argument (that varies from 0 to 1) that returns a 2-element
Numpy array with the coordinates of the curve.
curve_derivative (callable) – If set, it should be the derivative of the curve function.
Must be a function of one argument (that varies from 0 to 1)
that returns a 2-element Numpy array. If None, the
derivative will be calculated numerically.
width (number, callable, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. If this is callable, it must be a
function of one argument (that varies from 0 to 1) that
returns the width of the path. A list can be used where
each element (number or callable) defines the width for one
of the parallel paths in this object.
offset (number, callable, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). If this
is callable, it must be a function of one argument (that
varies from 0 to 1) that returns the offset increase. A
list can be used where each element (number or callable)
defines the absolute offset (not offset increase) for one
of the parallel paths in this object.
relative (bool) – If True, the return values of curve_function are used as
offsets from the current path position, i.e., to ensure a
continuous path, curve_function(0) must be (0, 0).
Otherwise, they are used as absolute coordinates.
A Bezier curve is added to the path starting from its current
position and finishing at the last point in the points array.
Parameters:
points (array-like[N][2]) – Control points defining the Bezier curve.
width (number, callable, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. If this is callable, it must be a
function of one argument (that varies from 0 to 1) that
returns the width of the path. A list can be used where
each element (number or callable) defines the width for one
of the parallel paths in this object.
offset (number, callable, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). If this
is callable, it must be a function of one argument (that
varies from 0 to 1) that returns the offset increase. A
list can be used where each element (number or callable)
defines the absolute offset (not offset increase) for one
of the parallel paths in this object.
relative (bool) – If True, all coordinates in the points array are used as
offsets from the current path position, i.e., if the path is
at (1, -2) and the last point in the array is (10, 25), the
constructed Bezier will end at (1 + 10, -2 + 25) = (11, 23).
Otherwise, the points are used as absolute coordinates.
Add a smooth interpolating curve through the given points.
Uses the Hobby algorithm [1]_ to calculate a smooth
interpolating curve made of cubic Bezier segments between each
pair of points.
Parameters:
points (array-like[N][2]) – Vertices in the interpolating curve.
angles (array-like[N + 1] or None) – Tangent angles at each point (in radians). Any angles
defined as None are automatically calculated.
curl_start (number) – Ratio between the mock curvatures at the first point and at
its neighbor. A value of 1 renders the first segment a good
approximation for a circular arc. A value of 0 will better
approximate a straight segment. It has no effect for closed
curves or when an angle is defined for the first point.
curl_end (number) – Ratio between the mock curvatures at the last point and at
its neighbor. It has no effect for closed curves or when an
angle is defined for the first point.
t_in (number or array-like[N + 1]) – Tension parameter when arriving at each point. One value
per point or a single value used for all points.
t_out (number or array-like[N + 1]) – Tension parameter when leaving each point. One value per
point or a single value used for all points.
cycle (bool) – If True, calculates control points for a closed curve,
with an additional segment connecting the first and last
points.
width (number, callable, list) – If a number, all parallel paths are linearly tapered to this
width along the segment. If this is callable, it must be a
function of one argument (that varies from 0 to 1) that
returns the width of the path. A list can be used where
each element (number or callable) defines the width for one
of the parallel paths in this object.
offset (number, callable, list) – If a number, all parallel paths offsets are linearly
increased by this amount (which can be negative). If this
is callable, it must be a function of one argument (that
varies from 0 to 1) that returns the offset increase. A
list can be used where each element (number or callable)
defines the absolute offset (not offset increase) for one
of the parallel paths in this object.
relative (bool) – If True, all coordinates in the points array are used as
offsets from the current path position, i.e., if the path is
at (1, -2) and the last point in the array is (10, 25), the
constructed curve will end at (1 + 10, -2 + 25) = (11, 23).
Otherwise, the points are used as absolute coordinates.
Returns:
out – This object.
Return type:
RobustPath
Notes
Arguments width and offset are repeated for each cubic
Bezier that composes this path element.
The uppercase version of the methods considers that all coordinates
are absolute, whereas the lowercase considers that they are relative
to the current end point of the curve.
Parameters:
x (number) – X-coordinate of the starting point of the curve. If this is a
complex number, the value of y is ignored and the starting
point becomes (x.real,x.imag).
y (number) – Y-coordinate of the starting point of the curve.
tolerance (number) – Tolerance used to calculate a polygonal approximation to the
curve.
Notes
In all methods of this class that accept coordinate pairs, a single
complex number can be passed to be split into its real and imaginary
parts.
This feature can be useful in expressing coordinates in polar form.
All commands follow the SVG 2 specification, except for elliptical
arcs and smooth interpolating curves, which are inspired by the
Metapost syntax.
xy (numbers) – Coordinate pairs. Each set of 3 pairs are interpreted as
the control point at the beginning of the curve, the control
point at the end of the curve and the endpoint of the curve.
xy (numbers) – Coordinate pairs. Each set of 3 pairs are interpreted as
the control point at the beginning of the curve, the control
point at the end of the curve and the endpoint of the curve.
All coordinates are relative to the current end point.
xy (numbers) – Coordinate pairs. Each set of 2 pairs are interpreted as
the control point at the end of the curve and the endpoint
of the curve. The control point at the beginning of the
curve is assumed to be the reflection of the control point
at the end of the last curve relative to the starting point
of the curve. If the previous curve is not a cubic Bezier,
the control point is coincident with the starting point.
xy (numbers) – Coordinate pairs. Each set of 2 pairs are interpreted as
the control point at the end of the curve and the endpoint
of the curve. The control point at the beginning of the
curve is assumed to be the reflection of the control point
at the end of the last curve relative to the starting point
of the curve. If the previous curve is not a cubic Bezier,
the control point is coincident with the starting point.
All coordinates are relative to the current end point.
xy (numbers) – Coordinate pairs. Each set of 2 pairs are interpreted as
the control point and the endpoint of the curve.
All coordinates are relative to the current end point.
xy (numbers) – Coordinates of the endpoints of the curves. The control
point is assumed to be the reflection of the control point
of the last curve relative to the starting point of the
curve. If the previous curve is not a quadratic Bezier,
the control point is coincident with the starting point.
xy (numbers) – Coordinates of the endpoints of the curves. The control
point is assumed to be the reflection of the control point
of the last curve relative to the starting point of the
curve. If the previous curve is not a quadratic Bezier,
the control point is coincident with the starting point.
All coordinates are relative to the current end point.
xy (numbers) – Coordinate pairs. The last coordinate is the endpoint of
curve and all other are control points. All coordinates are
relative to the current end point.
Add a smooth interpolating curve through the given points.
Uses the Hobby algorithm [1]_ to calculate a smooth
interpolating curve made of cubic Bezier segments between each
pair of points.
Parameters:
points (array-like[N][2]) – Vertices in the interpolating curve.
angles (array-like[N + 1] or None) – Tangent angles at each point (in radians). Any angles
defined as None are automatically calculated.
curl_start (number) – Ratio between the mock curvatures at the first point and at
its neighbor. A value of 1 renders the first segment a good
approximation for a circular arc. A value of 0 will better
approximate a straight segment. It has no effect for closed
curves or when an angle is defined for the first point.
curl_end (number) – Ratio between the mock curvatures at the last point and at
its neighbor. It has no effect for closed curves or when an
angle is defined for the first point.
t_in (number or array-like[N + 1]) – Tension parameter when arriving at each point. One value
per point or a single value used for all points.
t_out (number or array-like[N + 1]) – Tension parameter when leaving each point. One value per
point or a single value used for all points.
cycle (bool) – If True, calculates control points for a closed curve,
with an additional segment connecting the first and last
points.
Add a smooth interpolating curve through the given points.
Uses the Hobby algorithm [1]_ to calculate a smooth
interpolating curve made of cubic Bezier segments between each
pair of points.
Parameters:
points (array-like[N][2]) – Vertices in the interpolating curve (relative to teh current
endpoint).
angles (array-like[N + 1] or None) – Tangent angles at each point (in radians). Any angles
defined as None are automatically calculated.
curl_start (number) – Ratio between the mock curvatures at the first point and at
its neighbor. A value of 1 renders the first segment a good
approximation for a circular arc. A value of 0 will better
approximate a straight segment. It has no effect for closed
curves or when an angle is defined for the first point.
curl_end (number) – Ratio between the mock curvatures at the last point and at
its neighbor. It has no effect for closed curves or when an
angle is defined for the first point.
t_in (number or array-like[N + 1]) – Tension parameter when arriving at each point. One value
per point or a single value used for all points.
t_out (number or array-like[N + 1]) – Tension parameter when leaving each point. One value per
point or a single value used for all points.
cycle (bool) – If True, calculates control points for a closed curve,
with an additional segment connecting the first and last
points.
Text that can be used to label parts of the geometry or display
messages. The text does not create additional geometry, it’s meant
for display and labeling purposes only.
Parameters:
text (string) – The text of this label.
position (array-like[2]) – Text anchor position.
anchor ('n', 's', 'e', 'w', 'o', 'ne', 'nw'...) – Position of the anchor relative to the text.
rotation (number) – Angle of rotation of the label (in degrees).
magnification (number) – Magnification factor for the label.
x_reflection (bool) – If True, the label is reflected parallel to the x direction
before being rotated (not supported by LayoutViewer).
layer (integer) – The GDSII layer number for these elements.
texttype (integer) – The GDSII text type for the label (between 0 and 63).
Variables:
text (string) – The text of this label.
position (array-like[2]) – Text anchor position.
anchor (int) – Position of the anchor relative to the text.
rotation (number) – Angle of rotation of the label (in degrees).
magnification (number) – Magnification factor for the label.
x_reflection (bool) – If True, the label is reflected parallel to the x direction
before being rotated (not supported by LayoutViewer).
layer (integer) – The GDSII layer number for these elements.
texttype (integer) – The GDSII text type for the label (between 0 and 63).
Execute any boolean operation between 2 polygons or polygon sets.
Parameters:
operand1 (PolygonSet, CellReference, CellArray or iterable) – First operand. If this is an iterable, each element must be a
PolygonSet, CellReference, CellArray, or an
array-like[N][2] of vertices of a polygon.
operand2 (None, PolygonSet, CellReference, CellArray or iterable) – Second operand. If this is an iterable, each element must be a
PolygonSet, CellReference, CellArray, or an
array-like[N][2] of vertices of a polygon.
operation ({'or', 'and', 'xor', 'not'}) – Boolean operation to be executed. The ‘not’ operation returns
the difference operand1-operand2.
precision (float) – Desired precision for rounding vertice coordinates.
max_points (integer) – If greater than 4, fracture the resulting polygons to ensure
they have at most max_points vertices. This is not a
tessellating function, so this number should be as high as
possible. For example, it should be set to 199 for polygons
being drawn in GDSII files.
layer (integer) – The GDSII layer number for the resulting element.
datatype (integer) – The GDSII datatype for the resulting element (between 0 and
255).
polygons (PolygonSet, CellReference, CellArray or iterable) – Polygons to be offset. If this is an iterable, each element
must be a PolygonSet, CellReference, CellArray, or an
array-like[N][2] of vertices of a polygon.
distance (number) – Offset distance. Positive to expand, negative to shrink.
join ('miter', 'bevel', 'round') – Type of join used to create the offset polygon.
tolerance (number) – For miter joints, this number must be at least 2 and it
represents the maximal distance in multiples of offset between
new vertices and their original position before beveling to
avoid spikes at acute joints. For round joints, it indicates
the curvature resolution in number of points per full circle.
precision (float) – Desired precision for rounding vertex coordinates.
join_first (bool) – Join all paths before offsetting to avoid unnecessary joins in
adjacent polygon sides.
max_points (integer) – If greater than 4, fracture the resulting polygons to ensure
they have at most max_points vertices. This is not a
tessellating function, so this number should be as high as
possible. For example, it should be set to 199 for polygons
being drawn in GDSII files.
layer (integer) – The GDSII layer number for the resulting element.
datatype (integer) – The GDSII datatype for the resulting element (between 0 and
255).
Returns:
out – Return the offset shape as a set of polygons.
Slice polygons and polygon sets at given positions along an axis.
Parameters:
polygons (PolygonSet, CellReference, CellArray or iterable) – Operand of the slice operation. If this is an iterable, each
element must be a PolygonSet, CellReference, CellArray,
or an array-like[N][2] of vertices of a polygon.
position (number or list of numbers) – Positions to perform the slicing operation along the specified
axis.
axis (0 or 1) – Axis along which the polygon will be sliced.
precision (float) – Desired precision for rounding vertice coordinates.
layer (integer, list) – The GDSII layer numbers for the elements between each division.
If the number of layers in the list is less than the number of
divided regions, the list is repeated.
datatype (integer, list) – The GDSII datatype for the resulting element (between 0 and
255). If the number of datatypes in the list is less than the
number of divided regions, the list is repeated.
Returns:
out – Result of the slicing operation, with N = len(positions) + 1.
Each PolygonSet comprises all polygons between 2 adjacent
slicing positions, in crescent order.
Test whether each of the points is within the given set of polygons.
Parameters:
points (array-like[N][2] or sequence of array-like[N][2]) – Coordinates of the points to be tested or groups of points to be
tested together.
polygons (PolygonSet, CellReference, CellArray or iterable) – Polygons to be tested against. If this is an iterable, each
element must be a PolygonSet, CellReference, CellArray,
or an array-like[N][2] of vertices of a polygon.
short_circuit ({'any', 'all'}) – If points is a sequence of point groups, testing within each
group will be short-circuited if any of the points in the group
is inside (‘any’) or outside (‘all’) the polygons. If points
is simply a sequence of points, this parameter has no effect.
precision (float) – Desired precision for rounding vertice coordinates.
Returns:
out – Tuple of booleans indicating if each of the points or point
groups is inside the set of polygons.
The function or callable test is called for each polygon in
the cell. If its return value evaluates to True, the
corresponding polygon is removed from the cell.
Parameters:
test (callable) – Test function to query whether a polygon should be removed.
The function is called with arguments:
(points,layer,datatype)
The function or callable test is called for each FlexPath
or RobustPath in the cell. If its return value evaluates to
True, the corresponding label is removed from the cell.
Parameters:
test (callable) – Test function to query whether a path should be removed.
The function is called with the path as the only argument.
The function or callable test is called for each label in
the cell. If its return value evaluates to True, the
corresponding label is removed from the cell.
Parameters:
test (callable) – Test function to query whether a label should be removed.
The function is called with the label as the only argument.
by_spec (bool) – If True, the return value is a dictionary with the
polygons of each individual pair (layer, datatype).
depth (integer or None) – If not None, defines from how many reference levels to
retrieve polygons. References below this level will result
in a bounding box. If by_spec is True the key will be the
name of this cell.
Returns:
out – List containing the coordinates of the vertices of each
polygon, or dictionary with the list of polygons (if
by_spec is True).
Return type:
list of array-like[N][2] or dictionary
Note
Instances of FlexPath and RobustPath are also included in
the result by computing their polygonal boundary.
Return the list of polygons created by this reference.
Parameters:
by_spec (bool) – If True, the return value is a dictionary with the
polygons of each individual pair (layer, datatype).
depth (integer or None) – If not None, defines from how many reference levels to
retrieve polygons. References below this level will result
in a bounding box. If by_spec is True the key will be the
name of the referenced cell.
Returns:
out – List containing the coordinates of the vertices of each
polygon, or dictionary with the list of polygons (if
by_spec is True).
Return type:
list of array-like[N][2] or dictionary
Note
Instances of FlexPath and RobustPath are also included in
the result by computing their polygonal boundary.
Return the list of polygons created by this reference.
Parameters:
by_spec (bool) – If True, the return value is a dictionary with the
polygons of each individual pair (layer, datatype).
depth (integer or None) – If not None, defines from how many reference levels to
retrieve polygons. References below this level will result
in a bounding box. If by_spec is True the key will be
name of the referenced cell.
Returns:
out – List containing the coordinates of the vertices of each
polygon, or dictionary with the list of polygons (if
by_spec is True).
Return type:
list of array-like[N][2] or dictionary
Note
Instances of FlexPath and RobustPath are also included in
the result by computing their polygonal boundary.
The dimensions actually written on the GDSII file will be the
dimensions of the objects created times the ratio
unit/precision. For example, if a circle with radius 1.5 is
created and we set GdsLibrary.unit to 1.0e-6 (1 um) and
GdsLibrary.precision to 1.0e-9` (1 nm), the radius of the
circle will be 1.5 um and the GDSII file will contain the
dimension 1500 nm.
Parameters:
outfile (file or string) – The file (or path) where the GDSII stream will be written.
It must be opened for writing operations in binary format.
cells (iterable) – The cells or cell names to be included in the library. If
None, all cells are used.
timestamp (datetime object) – Sets the GDSII timestamp. If None, the current time is
used.
binary_cells (iterable of bytes) – Iterable with binary data for GDSII cells (from
get_binary_cells, for example).
Notes
Only the specified cells are written. The user is responsible
for ensuring all cell dependencies are satisfied.
infile (file or string) – GDSII stream file (or path) to be imported. It must be
opened for reading in binary format.
units ({'convert', 'import', 'skip'}) – Controls how to scale and use the units in the imported
file. ‘convert’: the imported geometry is scaled to
this library units. ‘import’: the unit and precision in
this library are replaced by those from the imported file.
‘skip’: the imported geometry is not scaled and units
are not replaced; the geometry is imported in the user
units of the file.
rename (dictionary) – Dictionary used to rename the imported cells. Keys and
values must be strings.
rename_template (string) – Template string used to rename the imported cells. Appiled
only if the cell name is not in the rename dictionary.
Examples: ‘prefix-{name}’, ‘{name}-suffix’
layers (dictionary) – Dictionary used to convert the layers in the imported cells.
Keys and values must be integers.
datatypes (dictionary) – Dictionary used to convert the datatypes in the imported
cells. Keys and values must be integers.
texttypes (dictionary) – Dictionary used to convert the text types in the imported
cells. Keys and values must be integers.
Returns:
out – This object.
Return type:
GdsLibrary
Notes
Not all features from the GDSII specification are currently
supported. A warning will be produced if any unsupported
features are found in the imported file.
The dimensions actually written on the GDSII file will be the
dimensions of the objects created times the ratio unit/precision.
For example, if a circle with radius 1.5 is created and we set
unit to 1.0e-6 (1 um) and precision to 1.0e-9 (1 nm), the radius
of the circle will be 1.5 um and the GDSII file will contain the
dimension 1500 nm.
Parameters:
outfile (file or string) – The file (or path) where the GDSII stream will be written. It
must be opened for writing operations in binary format.
name (string) – Name of the GDSII library (file).
unit (number) – Unit size for the objects in the library (in meters).
precision (number) – Precision for the dimensions of the objects in the library (in
meters).
timestamp (datetime object) – Sets the GDSII timestamp. If None, the current time is
used.
Notes
This class can be used for incremental output of the geometry in
case the complete layout is too large to be kept in memory all at
once.
Examples
>>> writer=gdspy.GdsWriter('out-file.gds',unit=1.0e-6,... precision=1.0e-9)>>> foriinrange(10):... cell=gdspy.Cell('C{}'.format(i),True)... # Add the contents of this cell...... writer.write_cell(cell)... # Clear the memory: erase Cell objects and any other objects... # that won't be needed.... delcell>>> writer.close()
The dimensions actually written on the GDSII file will be the
dimensions of the objects created times the ratio unit/precision.
For example, if a circle with radius 1.5 is created and we set
unit to 1.0e-6 (1 um) and precision to 1.0e-9 (1 nm), the radius
of the circle will be 1.5 um and the GDSII file will contain the
dimension 1500 nm.
Parameters:
outfile (file or string) – The file (or path) where the GDSII stream will be written. It
must be opened for writing operations in binary format.
cells (array-like) – The sequence of cells or cell names to be included in the
library. If None, all cells are used.
name (string) – Name of the GDSII library.
unit (number) – Unit size for the objects in the library (in meters).
precision (number) – Precision for the dimensions of the objects in the library (in
meters).
timestamp (datetime object) – Sets the GDSII timestamp. If None, the current time is
used.
binary_cells (iterable of bytes) – Iterable with binary data for GDSII cells (from
get_binary_cells, for example).
The hash is generated based only on the contents of the cells in the
GDSII library, ignoring any timestamp records present in the file
structure.
Parameters:
filename (string) – Full path to the GDSII file.
engine (hashlib-like engine) – The engine that executes the hashing algorithm. It must provide
the methods update and hexdigest as defined in the hashlib
module. If None, the default hashlib.sha1() is used.
Returns:
out – The hash corresponding to the library contents in hex format.