[OASIS] cleanup
This commit is contained in:
parent
48f7569c1f
commit
c18e5b8d3e
1 changed files with 75 additions and 68 deletions
|
|
@ -120,10 +120,10 @@ def build(
|
|||
layer, data_type = _mlayer2oas(layer_num)
|
||||
lib.layers += [
|
||||
fatrec.LayerName(
|
||||
nstring=name,
|
||||
layer_interval=(layer, layer),
|
||||
type_interval=(data_type, data_type),
|
||||
is_textlayer=tt,
|
||||
nstring = name,
|
||||
layer_interval = (layer, layer),
|
||||
type_interval = (data_type, data_type),
|
||||
is_textlayer = tt,
|
||||
)
|
||||
for tt in (True, False)]
|
||||
|
||||
|
|
@ -286,11 +286,11 @@ def read(
|
|||
|
||||
annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings)
|
||||
pat.polygon(
|
||||
vertices=vertices,
|
||||
layer=element.get_layer_tuple(),
|
||||
offset=element.get_xy(),
|
||||
annotations=annotations,
|
||||
repetition=repetition,
|
||||
vertices = vertices,
|
||||
layer = element.get_layer_tuple(),
|
||||
offset = element.get_xy(),
|
||||
annotations = annotations,
|
||||
repetition = repetition,
|
||||
)
|
||||
elif isinstance(element, fatrec.Path):
|
||||
vertices = numpy.cumsum(numpy.vstack(((0, 0), element.get_point_list())), axis=0)
|
||||
|
|
@ -310,13 +310,13 @@ def read(
|
|||
|
||||
annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings)
|
||||
pat.path(
|
||||
vertices=vertices,
|
||||
layer=element.get_layer_tuple(),
|
||||
offset=element.get_xy(),
|
||||
repetition=repetition,
|
||||
annotations=annotations,
|
||||
width=element.get_half_width() * 2,
|
||||
cap=cap,
|
||||
vertices = vertices,
|
||||
layer = element.get_layer_tuple(),
|
||||
offset = element.get_xy(),
|
||||
repetition = repetition,
|
||||
annotations = annotations,
|
||||
width = element.get_half_width() * 2,
|
||||
cap = cap,
|
||||
**path_args,
|
||||
)
|
||||
|
||||
|
|
@ -325,11 +325,11 @@ def read(
|
|||
height = element.get_height()
|
||||
annotations = properties_to_annotations(element.properties, lib.propnames, lib.propstrings)
|
||||
pat.polygon(
|
||||
layer=element.get_layer_tuple(),
|
||||
offset=element.get_xy(),
|
||||
repetition=repetition,
|
||||
vertices=numpy.array(((0, 0), (1, 0), (1, 1), (0, 1))) * (width, height),
|
||||
annotations=annotations,
|
||||
layer = element.get_layer_tuple(),
|
||||
offset = element.get_xy(),
|
||||
repetition = repetition,
|
||||
vertices = numpy.array(((0, 0), (1, 0), (1, 1), (0, 1))) * (width, height),
|
||||
annotations = annotations,
|
||||
)
|
||||
|
||||
elif isinstance(element, fatrec.Trapezoid):
|
||||
|
|
@ -440,11 +440,11 @@ def read(
|
|||
else:
|
||||
string = str_or_ref.string
|
||||
pat.label(
|
||||
layer=element.get_layer_tuple(),
|
||||
offset=element.get_xy(),
|
||||
repetition=repetition,
|
||||
annotations=annotations,
|
||||
string=string,
|
||||
layer = element.get_layer_tuple(),
|
||||
offset = element.get_xy(),
|
||||
repetition = repetition,
|
||||
annotations = annotations,
|
||||
string = string,
|
||||
)
|
||||
|
||||
else:
|
||||
|
|
@ -549,13 +549,13 @@ def _shapes_to_elements(
|
|||
offset = rint_cast(shape.offset + rep_offset)
|
||||
radius = rint_cast(shape.radius)
|
||||
circle = fatrec.Circle(
|
||||
layer=layer,
|
||||
datatype=datatype,
|
||||
radius=cast('int', radius),
|
||||
x=offset[0],
|
||||
y=offset[1],
|
||||
properties=properties,
|
||||
repetition=repetition,
|
||||
layer = layer,
|
||||
datatype = datatype,
|
||||
radius = cast('int', radius),
|
||||
x = offset[0],
|
||||
y = offset[1],
|
||||
properties = properties,
|
||||
repetition = repetition,
|
||||
)
|
||||
elements.append(circle)
|
||||
elif isinstance(shape, Path):
|
||||
|
|
@ -566,16 +566,16 @@ def _shapes_to_elements(
|
|||
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)
|
||||
path = fatrec.Path(
|
||||
layer=layer,
|
||||
datatype=datatype,
|
||||
point_list=cast('Sequence[Sequence[int]]', deltas),
|
||||
half_width=cast('int', half_width),
|
||||
x=xy[0],
|
||||
y=xy[1],
|
||||
extension_start=extension_start, # TODO implement multiple cap types?
|
||||
extension_end=extension_end,
|
||||
properties=properties,
|
||||
repetition=repetition,
|
||||
layer = layer,
|
||||
datatype = datatype,
|
||||
point_list = cast('Sequence[Sequence[int]]', deltas),
|
||||
half_width = cast('int', half_width),
|
||||
x = xy[0],
|
||||
y = xy[1],
|
||||
extension_start = extension_start, # TODO implement multiple cap types?
|
||||
extension_end = extension_end,
|
||||
properties = properties,
|
||||
repetition = repetition,
|
||||
)
|
||||
elements.append(path)
|
||||
else:
|
||||
|
|
@ -583,13 +583,13 @@ def _shapes_to_elements(
|
|||
xy = rint_cast(polygon.offset + polygon.vertices[0] + rep_offset)
|
||||
points = rint_cast(numpy.diff(polygon.vertices, axis=0))
|
||||
elements.append(fatrec.Polygon(
|
||||
layer=layer,
|
||||
datatype=datatype,
|
||||
x=xy[0],
|
||||
y=xy[1],
|
||||
point_list=cast('list[list[int]]', points),
|
||||
properties=properties,
|
||||
repetition=repetition,
|
||||
layer = layer,
|
||||
datatype = datatype,
|
||||
x = xy[0],
|
||||
y = xy[1],
|
||||
point_list = cast('list[list[int]]', points),
|
||||
properties = properties,
|
||||
repetition = repetition,
|
||||
))
|
||||
return elements
|
||||
|
||||
|
|
@ -606,13 +606,13 @@ def _labels_to_texts(
|
|||
xy = rint_cast(label.offset + rep_offset)
|
||||
properties = annotations_to_properties(label.annotations)
|
||||
texts.append(fatrec.Text(
|
||||
layer=layer,
|
||||
datatype=datatype,
|
||||
x=xy[0],
|
||||
y=xy[1],
|
||||
string=label.string,
|
||||
properties=properties,
|
||||
repetition=repetition,
|
||||
layer = layer,
|
||||
datatype = datatype,
|
||||
x = xy[0],
|
||||
y = xy[1],
|
||||
string = label.string,
|
||||
properties = properties,
|
||||
repetition = repetition,
|
||||
))
|
||||
return texts
|
||||
|
||||
|
|
@ -622,10 +622,12 @@ def repetition_fata2masq(
|
|||
) -> Repetition | None:
|
||||
mrep: Repetition | None
|
||||
if isinstance(rep, fatamorgana.GridRepetition):
|
||||
mrep = Grid(a_vector=rep.a_vector,
|
||||
b_vector=rep.b_vector,
|
||||
a_count=rep.a_count,
|
||||
b_count=rep.b_count)
|
||||
mrep = Grid(
|
||||
a_vector = rep.a_vector,
|
||||
b_vector = rep.b_vector,
|
||||
a_count = rep.a_count,
|
||||
b_count = rep.b_count,
|
||||
)
|
||||
elif isinstance(rep, fatamorgana.ArbitraryRepetition):
|
||||
displacements = numpy.cumsum(numpy.column_stack((
|
||||
rep.x_displacements,
|
||||
|
|
@ -647,14 +649,19 @@ def repetition_masq2fata(
|
|||
frep: fatamorgana.GridRepetition | fatamorgana.ArbitraryRepetition | None
|
||||
if isinstance(rep, Grid):
|
||||
a_vector = rint_cast(rep.a_vector)
|
||||
b_vector = rint_cast(rep.b_vector) if rep.b_vector is not None else None
|
||||
a_count = rint_cast(rep.a_count)
|
||||
b_count = rint_cast(rep.b_count) if rep.b_count is not None else None
|
||||
a_count = int(rep.a_count)
|
||||
if rep.b_count > 1:
|
||||
b_vector = rint_cast(rep.b_vector)
|
||||
b_count = int(rep.b_count)
|
||||
else:
|
||||
b_vector = None
|
||||
b_count = None
|
||||
|
||||
frep = fatamorgana.GridRepetition(
|
||||
a_vector=cast('list[int]', a_vector),
|
||||
b_vector=cast('list[int] | None', b_vector),
|
||||
a_count=cast('int', a_count),
|
||||
b_count=cast('int | None', b_count),
|
||||
a_vector = a_vector,
|
||||
b_vector = b_vector,
|
||||
a_count = a_count,
|
||||
b_count = b_count,
|
||||
)
|
||||
offset = (0, 0)
|
||||
elif isinstance(rep, Arbitrary):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue