whitespace

This commit is contained in:
jan 2022-07-07 14:37:24 -07:00
parent 4d58516049
commit 599723e470
5 changed files with 276 additions and 208 deletions

View File

@ -267,10 +267,12 @@ def _read_block(block, clean_vertices: bool) -> Pattern:
} }
if 'column_count' in attr: if 'column_count' in attr:
args['repetition'] = Grid(a_vector=(attr['column_spacing'], 0), args['repetition'] = Grid(
a_vector=(attr['column_spacing'], 0),
b_vector=(0, attr['row_spacing']), b_vector=(0, attr['row_spacing']),
a_count=attr['column_count'], a_count=attr['column_count'],
b_count=attr['row_count']) b_count=attr['row_count'],
)
pat.subpatterns.append(SubPattern(**args)) pat.subpatterns.append(SubPattern(**args))
else: else:
logger.warning(f'Ignoring DXF element {element.dxftype()} (not implemented).') logger.warning(f'Ignoring DXF element {element.dxftype()} (not implemented).')

View File

@ -114,9 +114,11 @@ def write(
patterns = [p.wrap_repeated_shapes() for p in patterns] patterns = [p.wrap_repeated_shapes() for p in patterns]
# Create library # Create library
header = klamath.library.FileHeader(name=library_name.encode('ASCII'), header = klamath.library.FileHeader(
name=library_name.encode('ASCII'),
user_units_per_db_unit=logical_units_per_unit, user_units_per_db_unit=logical_units_per_unit,
meters_per_db_unit=meters_per_unit) meters_per_db_unit=meters_per_unit,
)
header.write(stream) header.write(stream)
# Get a dict of id(pattern) -> pattern # Get a dict of id(pattern) -> pattern
@ -241,7 +243,8 @@ def _read_header(stream: BinaryIO) -> Dict[str, Any]:
""" """
header = klamath.library.FileHeader.read(stream) header = klamath.library.FileHeader.read(stream)
library_info = {'name': header.name.decode('ASCII'), library_info = {
'name': header.name.decode('ASCII'),
'meters_per_unit': header.meters_per_db_unit, 'meters_per_unit': header.meters_per_db_unit,
'logical_units_per_unit': header.user_units_per_db_unit, 'logical_units_per_unit': header.user_units_per_db_unit,
} }
@ -276,10 +279,12 @@ def read_elements(
path = _gpath_to_mpath(element, raw_mode) path = _gpath_to_mpath(element, raw_mode)
pat.shapes.append(path) pat.shapes.append(path)
elif isinstance(element, klamath.elements.Text): elif isinstance(element, klamath.elements.Text):
label = Label(offset=element.xy.astype(float), label = Label(
offset=element.xy.astype(float),
layer=element.layer, layer=element.layer,
string=element.string.decode('ASCII'), string=element.string.decode('ASCII'),
annotations=_properties_to_annotations(element.properties)) annotations=_properties_to_annotations(element.properties),
)
pat.labels.append(label) pat.labels.append(label)
elif isinstance(element, klamath.elements.Reference): elif isinstance(element, klamath.elements.Reference):
pat.subpatterns.append(_ref_to_subpat(element)) pat.subpatterns.append(_ref_to_subpat(element))
@ -314,16 +319,22 @@ def _ref_to_subpat(ref: klamath.library.Reference) -> SubPattern:
a_count, b_count = ref.colrow a_count, b_count = ref.colrow
a_vector = (xy[1] - offset) / a_count a_vector = (xy[1] - offset) / a_count
b_vector = (xy[2] - offset) / b_count b_vector = (xy[2] - offset) / b_count
repetition = Grid(a_vector=a_vector, b_vector=b_vector, repetition = Grid(
a_count=a_count, b_count=b_count) a_vector=a_vector,
b_vector=b_vector,
a_count=a_count,
b_count=b_count,
)
subpat = SubPattern(pattern=None, subpat = SubPattern(
pattern=None,
offset=offset, offset=offset,
rotation=numpy.deg2rad(ref.angle_deg), rotation=numpy.deg2rad(ref.angle_deg),
scale=ref.mag, scale=ref.mag,
mirrored=(ref.invert_y, False), mirrored=(ref.invert_y, False),
annotations=_properties_to_annotations(ref.properties), annotations=_properties_to_annotations(ref.properties),
repetition=repetition) repetition=repetition,
)
subpat.identifier = (ref.struct_name.decode('ASCII'),) subpat.identifier = (ref.struct_name.decode('ASCII'),)
return subpat return subpat
@ -334,7 +345,8 @@ def _gpath_to_mpath(gpath: klamath.library.Path, raw_mode: bool) -> Path:
else: else:
raise PatternError(f'Unrecognized path type: {gpath.path_type}') raise PatternError(f'Unrecognized path type: {gpath.path_type}')
mpath = Path(vertices=gpath.xy.astype(float), mpath = Path(
vertices=gpath.xy.astype(float),
layer=gpath.layer, layer=gpath.layer,
width=gpath.width, width=gpath.width,
cap=cap, cap=cap,
@ -348,7 +360,8 @@ def _gpath_to_mpath(gpath: klamath.library.Path, raw_mode: bool) -> Path:
def _boundary_to_polygon(boundary: klamath.library.Boundary, raw_mode: bool) -> Polygon: def _boundary_to_polygon(boundary: klamath.library.Boundary, raw_mode: bool) -> Polygon:
return Polygon(vertices=boundary.xy[:-1].astype(float), return Polygon(
vertices=boundary.xy[:-1].astype(float),
layer=boundary.layer, layer=boundary.layer,
offset=numpy.zeros(2), offset=numpy.zeros(2),
annotations=_properties_to_annotations(boundary.properties), annotations=_properties_to_annotations(boundary.properties),
@ -377,31 +390,37 @@ def _subpatterns_to_refs(subpatterns: List[SubPattern]) -> List[klamath.library.
rep.a_vector * rep.a_count, rep.a_vector * rep.a_count,
b_vector * b_count, b_vector * b_count,
] ]
aref = klamath.library.Reference(struct_name=encoded_name, aref = klamath.library.Reference(
struct_name=encoded_name,
xy=numpy.round(xy).astype(int), xy=numpy.round(xy).astype(int),
colrow=(numpy.round(rep.a_count), numpy.round(rep.b_count)), colrow=(numpy.round(rep.a_count), numpy.round(rep.b_count)),
angle_deg=angle_deg, angle_deg=angle_deg,
invert_y=mirror_across_x, invert_y=mirror_across_x,
mag=subpat.scale, mag=subpat.scale,
properties=properties) properties=properties,
)
refs.append(aref) refs.append(aref)
elif rep is None: elif rep is None:
ref = klamath.library.Reference(struct_name=encoded_name, ref = klamath.library.Reference(
struct_name=encoded_name,
xy=numpy.round([subpat.offset]).astype(int), xy=numpy.round([subpat.offset]).astype(int),
colrow=None, colrow=None,
angle_deg=angle_deg, angle_deg=angle_deg,
invert_y=mirror_across_x, invert_y=mirror_across_x,
mag=subpat.scale, mag=subpat.scale,
properties=properties) properties=properties,
)
refs.append(ref) refs.append(ref)
else: else:
new_srefs = [klamath.library.Reference(struct_name=encoded_name, new_srefs = [klamath.library.Reference(
struct_name=encoded_name,
xy=numpy.round([subpat.offset + dd]).astype(int), xy=numpy.round([subpat.offset + dd]).astype(int),
colrow=None, colrow=None,
angle_deg=angle_deg, angle_deg=angle_deg,
invert_y=mirror_across_x, invert_y=mirror_across_x,
mag=subpat.scale, mag=subpat.scale,
properties=properties) properties=properties,
)
for dd in rep.displacements] for dd in rep.displacements]
refs += new_srefs refs += new_srefs
return refs return refs
@ -453,30 +472,36 @@ def _shapes_to_elements(
else: else:
extension = (0, 0) extension = (0, 0)
path = klamath.elements.Path(layer=(layer, data_type), path = klamath.elements.Path(
layer=(layer, data_type),
xy=xy, xy=xy,
path_type=path_type, path_type=path_type,
width=width, width=width,
extension=extension, extension=extension,
properties=properties) properties=properties,
)
elements.append(path) elements.append(path)
elif isinstance(shape, Polygon): elif isinstance(shape, Polygon):
polygon = shape polygon = shape
xy_closed = numpy.empty((polygon.vertices.shape[0] + 1, 2), dtype=numpy.int32) xy_closed = numpy.empty((polygon.vertices.shape[0] + 1, 2), dtype=numpy.int32)
numpy.rint(polygon.vertices + polygon.offset, out=xy_closed[:-1], casting='unsafe') numpy.rint(polygon.vertices + polygon.offset, out=xy_closed[:-1], casting='unsafe')
xy_closed[-1] = xy_closed[0] xy_closed[-1] = xy_closed[0]
boundary = klamath.elements.Boundary(layer=(layer, data_type), boundary = klamath.elements.Boundary(
layer=(layer, data_type),
xy=xy_closed, xy=xy_closed,
properties=properties) properties=properties,
)
elements.append(boundary) elements.append(boundary)
else: else:
for polygon in shape.to_polygons(): for polygon in shape.to_polygons():
xy_closed = numpy.empty((polygon.vertices.shape[0] + 1, 2), dtype=numpy.int32) xy_closed = numpy.empty((polygon.vertices.shape[0] + 1, 2), dtype=numpy.int32)
numpy.rint(polygon.vertices + polygon.offset, out=xy_closed[:-1], casting='unsafe') numpy.rint(polygon.vertices + polygon.offset, out=xy_closed[:-1], casting='unsafe')
xy_closed[-1] = xy_closed[0] xy_closed[-1] = xy_closed[0]
boundary = klamath.elements.Boundary(layer=(layer, data_type), boundary = klamath.elements.Boundary(
layer=(layer, data_type),
xy=xy_closed, xy=xy_closed,
properties=properties) properties=properties,
)
elements.append(boundary) elements.append(boundary)
return elements return elements
@ -487,7 +512,8 @@ def _labels_to_texts(labels: List[Label]) -> List[klamath.elements.Text]:
properties = _annotations_to_properties(label.annotations, 128) properties = _annotations_to_properties(label.annotations, 128)
layer, text_type = _mlayer2gds(label.layer) layer, text_type = _mlayer2gds(label.layer)
xy = numpy.round([label.offset]).astype(int) xy = numpy.round([label.offset]).astype(int)
text = klamath.elements.Text(layer=(layer, text_type), text = klamath.elements.Text(
layer=(layer, text_type),
xy=xy, xy=xy,
string=label.string.encode('ASCII'), string=label.string.encode('ASCII'),
properties=properties, properties=properties,
@ -496,7 +522,8 @@ def _labels_to_texts(labels: List[Label]) -> List[klamath.elements.Text]:
invert_y=False, invert_y=False,
width=0, width=0,
path_type=0, path_type=0,
mag=1) mag=1,
)
texts.append(text) texts.append(text)
return texts return texts

View File

@ -285,11 +285,13 @@ def read(
if isinstance(element, fatrec.Polygon): if isinstance(element, fatrec.Polygon):
vertices = numpy.cumsum(numpy.vstack(((0, 0), element.get_point_list())), axis=0) vertices = numpy.cumsum(numpy.vstack(((0, 0), element.get_point_list())), axis=0)
annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings) annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings)
poly = Polygon(vertices=vertices, poly = Polygon(
vertices=vertices,
layer=element.get_layer_tuple(), layer=element.get_layer_tuple(),
offset=element.get_xy(), offset=element.get_xy(),
annotations=annotations, annotations=annotations,
repetition=repetition) repetition=repetition,
)
pat.shapes.append(poly) pat.shapes.append(poly)
@ -308,14 +310,16 @@ def read(
element.get_extension_end()[1])) element.get_extension_end()[1]))
annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings) annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings)
path = Path(vertices=vertices, path = Path(
vertices=vertices,
layer=element.get_layer_tuple(), layer=element.get_layer_tuple(),
offset=element.get_xy(), offset=element.get_xy(),
repetition=repetition, repetition=repetition,
annotations=annotations, annotations=annotations,
width=element.get_half_width() * 2, width=element.get_half_width() * 2,
cap=cap, cap=cap,
**path_args) **path_args,
)
pat.shapes.append(path) pat.shapes.append(path)
@ -323,7 +327,8 @@ def read(
width = element.get_width() width = element.get_width()
height = element.get_height() height = element.get_height()
annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings) annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings)
rect = Polygon(layer=element.get_layer_tuple(), rect = Polygon(
layer=element.get_layer_tuple(),
offset=element.get_xy(), offset=element.get_xy(),
repetition=repetition, repetition=repetition,
vertices=numpy.array(((0, 0), (1, 0), (1, 1), (0, 1))) * (width, height), vertices=numpy.array(((0, 0), (1, 0), (1, 1), (0, 1))) * (width, height),
@ -357,7 +362,8 @@ def read(
vertices[2, 0] -= b vertices[2, 0] -= b
annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings) annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings)
trapz = Polygon(layer=element.get_layer_tuple(), trapz = Polygon(
layer=element.get_layer_tuple(),
offset=element.get_xy(), offset=element.get_xy(),
repetition=repetition, repetition=repetition,
vertices=vertices, vertices=vertices,
@ -412,7 +418,8 @@ def read(
vertices[0, 1] += width vertices[0, 1] += width
annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings) annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings)
ctrapz = Polygon(layer=element.get_layer_tuple(), ctrapz = Polygon(
layer=element.get_layer_tuple(),
offset=element.get_xy(), offset=element.get_xy(),
repetition=repetition, repetition=repetition,
vertices=vertices, vertices=vertices,
@ -422,11 +429,13 @@ def read(
elif isinstance(element, fatrec.Circle): elif isinstance(element, fatrec.Circle):
annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings) annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings)
circle = Circle(layer=element.get_layer_tuple(), circle = Circle(
layer=element.get_layer_tuple(),
offset=element.get_xy(), offset=element.get_xy(),
repetition=repetition, repetition=repetition,
annotations=annotations, annotations=annotations,
radius=float(element.get_radius())) radius=float(element.get_radius()),
)
pat.shapes.append(circle) pat.shapes.append(circle)
elif isinstance(element, fatrec.Text): elif isinstance(element, fatrec.Text):
@ -436,11 +445,13 @@ def read(
string = lib.textstrings[str_or_ref].string string = lib.textstrings[str_or_ref].string
else: else:
string = str_or_ref.string string = str_or_ref.string
label = Label(layer=element.get_layer_tuple(), label = Label(
layer=element.get_layer_tuple(),
offset=element.get_xy(), offset=element.get_xy(),
repetition=repetition, repetition=repetition,
annotations=annotations, annotations=annotations,
string=string) string=string,
)
pat.labels.append(label) pat.labels.append(label)
else: else:
@ -499,14 +510,16 @@ def _placement_to_subpat(placement: fatrec.Placement, lib: fatamorgana.OasisLayo
rotation = 0 rotation = 0
else: else:
rotation = numpy.deg2rad(float(placement.angle)) rotation = numpy.deg2rad(float(placement.angle))
subpat = SubPattern(offset=xy, subpat = SubPattern(
offset=xy,
pattern=None, pattern=None,
mirrored=(placement.flip, False), mirrored=(placement.flip, False),
rotation=rotation, rotation=rotation,
scale=float(mag), scale=float(mag),
identifier=(name,), identifier=(name,),
repetition=repetition_fata2masq(placement.repetition), repetition=repetition_fata2masq(placement.repetition),
annotations=annotations) annotations=annotations,
)
return subpat return subpat
@ -532,7 +545,8 @@ def _subpatterns_to_placements(
properties=annotations_to_properties(subpat.annotations), properties=annotations_to_properties(subpat.annotations),
x=offset[0], x=offset[0],
y=offset[1], y=offset[1],
repetition=frep) repetition=frep,
)
refs.append(ref) refs.append(ref)
return refs return refs
@ -551,13 +565,15 @@ def _shapes_to_elements(
if isinstance(shape, Circle): if isinstance(shape, Circle):
offset = numpy.round(shape.offset + rep_offset).astype(int) offset = numpy.round(shape.offset + rep_offset).astype(int)
radius = numpy.round(shape.radius).astype(int) radius = numpy.round(shape.radius).astype(int)
circle = fatrec.Circle(layer=layer, circle = fatrec.Circle(
layer=layer,
datatype=datatype, datatype=datatype,
radius=radius, radius=radius,
x=offset[0], x=offset[0],
y=offset[1], y=offset[1],
properties=properties, properties=properties,
repetition=repetition) repetition=repetition,
)
elements.append(circle) elements.append(circle)
elif isinstance(shape, Path): elif isinstance(shape, Path):
xy = numpy.round(shape.offset + shape.vertices[0] + rep_offset).astype(int) xy = numpy.round(shape.offset + shape.vertices[0] + rep_offset).astype(int)
@ -566,7 +582,8 @@ def _shapes_to_elements(
path_type = next(k for k, v in path_cap_map.items() if v == shape.cap) # reverse lookup path_type = next(k for k, v in path_cap_map.items() if v == shape.cap) # reverse lookup
extension_start = (path_type, shape.cap_extensions[0] if shape.cap_extensions is not None else None) extension_start = (path_type, shape.cap_extensions[0] if shape.cap_extensions is not None else None)
extension_end = (path_type, shape.cap_extensions[1] if shape.cap_extensions is not None else None) extension_end = (path_type, shape.cap_extensions[1] if shape.cap_extensions is not None else None)
path = fatrec.Path(layer=layer, path = fatrec.Path(
layer=layer,
datatype=datatype, datatype=datatype,
point_list=deltas, point_list=deltas,
half_width=half_width, half_width=half_width,
@ -582,13 +599,15 @@ def _shapes_to_elements(
for polygon in shape.to_polygons(): for polygon in shape.to_polygons():
xy = numpy.round(polygon.offset + polygon.vertices[0] + rep_offset).astype(int) xy = numpy.round(polygon.offset + polygon.vertices[0] + rep_offset).astype(int)
points = numpy.round(numpy.diff(polygon.vertices, axis=0)).astype(int) points = numpy.round(numpy.diff(polygon.vertices, axis=0)).astype(int)
elements.append(fatrec.Polygon(layer=layer, elements.append(fatrec.Polygon(
layer=layer,
datatype=datatype, datatype=datatype,
x=xy[0], x=xy[0],
y=xy[1], y=xy[1],
point_list=points, point_list=points,
properties=properties, properties=properties,
repetition=repetition)) repetition=repetition,
))
return elements return elements
@ -602,13 +621,15 @@ def _labels_to_texts(
repetition, rep_offset = repetition_masq2fata(label.repetition) repetition, rep_offset = repetition_masq2fata(label.repetition)
xy = numpy.round(label.offset + rep_offset).astype(int) xy = numpy.round(label.offset + rep_offset).astype(int)
properties = annotations_to_properties(label.annotations) properties = annotations_to_properties(label.annotations)
texts.append(fatrec.Text(layer=layer, texts.append(fatrec.Text(
layer=layer,
datatype=datatype, datatype=datatype,
x=xy[0], x=xy[0],
y=xy[1], y=xy[1],
string=label.string, string=label.string,
properties=properties, properties=properties,
repetition=repetition)) repetition=repetition,
))
return texts return texts
@ -648,10 +669,12 @@ def repetition_fata2masq(
) -> Optional[Repetition]: ) -> Optional[Repetition]:
mrep: Optional[Repetition] mrep: Optional[Repetition]
if isinstance(rep, fatamorgana.GridRepetition): if isinstance(rep, fatamorgana.GridRepetition):
mrep = Grid(a_vector=rep.a_vector, mrep = Grid(
a_vector=rep.a_vector,
b_vector=rep.b_vector, b_vector=rep.b_vector,
a_count=rep.a_count, a_count=rep.a_count,
b_count=rep.b_count) b_count=rep.b_count,
)
elif isinstance(rep, fatamorgana.ArbitraryRepetition): elif isinstance(rep, fatamorgana.ArbitraryRepetition):
displacements = numpy.cumsum(numpy.column_stack((rep.x_displacements, displacements = numpy.cumsum(numpy.column_stack((rep.x_displacements,
rep.y_displacements)), axis=0) rep.y_displacements)), axis=0)

View File

@ -118,10 +118,12 @@ def build(
patterns = [p.wrap_repeated_shapes() for p in patterns] patterns = [p.wrap_repeated_shapes() for p in patterns]
# Create library # Create library
lib = gdsii.library.Library(version=600, lib = gdsii.library.Library(
version=600,
name=library_name.encode('ASCII'), name=library_name.encode('ASCII'),
logical_unit=logical_units_per_unit, logical_unit=logical_units_per_unit,
physical_unit=meters_per_unit) physical_unit=meters_per_unit,
)
# Get a dict of id(pattern) -> pattern # Get a dict of id(pattern) -> pattern
patterns_by_id = {id(pattern): pattern for pattern in patterns} patterns_by_id = {id(pattern): pattern for pattern in patterns}
@ -244,7 +246,8 @@ def read(
lib = gdsii.library.Library.load(stream) lib = gdsii.library.Library.load(stream)
library_info = {'name': lib.name.decode('ASCII'), library_info = {
'name': lib.name.decode('ASCII'),
'meters_per_unit': lib.physical_unit, 'meters_per_unit': lib.physical_unit,
'logical_units_per_unit': lib.logical_unit, 'logical_units_per_unit': lib.logical_unit,
} }
@ -265,9 +268,11 @@ def read(
pat.shapes.append(path) pat.shapes.append(path)
elif isinstance(element, gdsii.elements.Text): elif isinstance(element, gdsii.elements.Text):
label = Label(offset=element.xy.astype(float), label = Label(
offset=element.xy.astype(float),
layer=(element.layer, element.text_type), layer=(element.layer, element.text_type),
string=element.string.decode('ASCII')) string=element.string.decode('ASCII'),
)
pat.labels.append(label) pat.labels.append(label)
elif isinstance(element, (gdsii.elements.SRef, gdsii.elements.ARef)): elif isinstance(element, (gdsii.elements.SRef, gdsii.elements.ARef)):
@ -341,16 +346,22 @@ def _ref_to_subpat(
b_count = element.rows b_count = element.rows
a_vector = (element.xy[1] - offset) / a_count a_vector = (element.xy[1] - offset) / a_count
b_vector = (element.xy[2] - offset) / b_count b_vector = (element.xy[2] - offset) / b_count
repetition = Grid(a_vector=a_vector, b_vector=b_vector, repetition = Grid(
a_count=a_count, b_count=b_count) a_vector=a_vector,
b_vector=b_vector,
a_count=a_count,
b_count=b_count,
)
subpat = SubPattern(pattern=None, subpat = SubPattern(
pattern=None,
offset=offset, offset=offset,
rotation=rotation, rotation=rotation,
scale=scale, scale=scale,
mirrored=(mirror_across_x, False), mirrored=(mirror_across_x, False),
annotations=_properties_to_annotations(element.properties), annotations=_properties_to_annotations(element.properties),
repetition=repetition) repetition=repetition,
)
subpat.identifier = (element.struct_name,) subpat.identifier = (element.struct_name,)
return subpat return subpat
@ -361,7 +372,8 @@ def _gpath_to_mpath(element: gdsii.elements.Path, raw_mode: bool) -> Path:
else: else:
raise PatternError(f'Unrecognized path type: {element.path_type}') raise PatternError(f'Unrecognized path type: {element.path_type}')
args = {'vertices': element.xy.astype(float), args = {
'vertices': element.xy.astype(float),
'layer': (element.layer, element.data_type), 'layer': (element.layer, element.data_type),
'width': element.width if element.width is not None else 0.0, 'width': element.width if element.width is not None else 0.0,
'cap': cap, 'cap': cap,
@ -381,7 +393,8 @@ def _gpath_to_mpath(element: gdsii.elements.Path, raw_mode: bool) -> Path:
def _boundary_to_polygon(element: gdsii.elements.Boundary, raw_mode: bool) -> Polygon: def _boundary_to_polygon(element: gdsii.elements.Boundary, raw_mode: bool) -> Polygon:
args = {'vertices': element.xy[:-1].astype(float), args = {
'vertices': element.xy[:-1].astype(float),
'layer': (element.layer, element.data_type), 'layer': (element.layer, element.data_type),
'offset': numpy.zeros(2), 'offset': numpy.zeros(2),
'annotations': _properties_to_annotations(element.properties), 'annotations': _properties_to_annotations(element.properties),
@ -483,9 +496,11 @@ def _shapes_to_elements(
xy = rint_cast(shape.vertices + shape.offset) xy = rint_cast(shape.vertices + shape.offset)
width = rint_cast(shape.width) width = rint_cast(shape.width)
path_type = next(k for k, v in path_cap_map.items() if v == shape.cap) # reverse lookup path_type = next(k for k, v in path_cap_map.items() if v == shape.cap) # reverse lookup
path = gdsii.elements.Path(layer=layer, path = gdsii.elements.Path(
layer=layer,
data_type=data_type, data_type=data_type,
xy=xy) xy=xy,
)
path.path_type = path_type path.path_type = path_type
path.width = width path.width = width
path.properties = properties path.properties = properties

View File

@ -34,7 +34,8 @@ class SubPattern(PositionableImpl, DoseableImpl, RotatableImpl, ScalableImpl, Mi
SubPattern provides basic support for nesting Pattern objects within each other, by adding SubPattern provides basic support for nesting Pattern objects within each other, by adding
offset, rotation, scaling, and associated methods. offset, rotation, scaling, and associated methods.
""" """
__slots__ = ('_pattern', __slots__ = (
'_pattern',
'_mirrored', '_mirrored',
'identifier', 'identifier',
) )