don't keep track of y-mirroring separately from x
This commit is contained in:
parent
9bc8d29b85
commit
91465b7175
20 changed files with 190 additions and 213 deletions
|
|
@ -21,7 +21,7 @@ from .. import Pattern, Ref, PatternError, Label
|
|||
from ..library import ILibraryView, LibraryView, Library
|
||||
from ..shapes import Shape, Polygon, Path
|
||||
from ..repetition import Grid
|
||||
from ..utils import rotation_matrix_2d, layer_t
|
||||
from ..utils import rotation_matrix_2d, layer_t, normalize_mirror
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -258,8 +258,8 @@ def _read_block(block) -> tuple[str, Pattern]:
|
|||
if abs(xscale) != abs(yscale):
|
||||
logger.warning('Masque does not support per-axis scaling; using x-scaling only!')
|
||||
scale = abs(xscale)
|
||||
mirrored = (yscale < 0, xscale < 0)
|
||||
rotation = numpy.deg2rad(attr.get('rotation', 0))
|
||||
mirrored, extra_angle = normalize_mirror((yscale < 0, xscale < 0))
|
||||
rotation = numpy.deg2rad(attr.get('rotation', 0)) + extra_angle
|
||||
|
||||
offset = numpy.array(attr.get('insert', (0, 0, 0)))[:2]
|
||||
|
||||
|
|
@ -291,8 +291,8 @@ def _mrefs_to_drefs(
|
|||
def mk_blockref(encoded_name: str, ref: Ref) -> None:
|
||||
rotation = numpy.rad2deg(ref.rotation) % 360
|
||||
attribs = dict(
|
||||
xscale=ref.scale * (-1 if ref.mirrored[1] else 1),
|
||||
yscale=ref.scale * (-1 if ref.mirrored[0] else 1),
|
||||
xscale=ref.scale,
|
||||
yscale=ref.scale * (-1 if ref.mirrored else 1),
|
||||
rotation=rotation,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ from .utils import is_gzipped, tmpfile
|
|||
from .. import Pattern, Ref, PatternError, LibraryError, Label, Shape
|
||||
from ..shapes import Polygon, Path
|
||||
from ..repetition import Grid
|
||||
from ..utils import layer_t, normalize_mirror, annotations_t
|
||||
from ..utils import layer_t, annotations_t
|
||||
from ..library import LazyLibrary, Library, ILibrary, ILibraryView
|
||||
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ def _gref_to_mref(ref: klamath.library.Reference) -> tuple[str, Ref]:
|
|||
offset=offset,
|
||||
rotation=numpy.deg2rad(ref.angle_deg),
|
||||
scale=ref.mag,
|
||||
mirrored=(ref.invert_y, False),
|
||||
mirrored=ref.invert_y,
|
||||
annotations=_properties_to_annotations(ref.properties),
|
||||
repetition=repetition,
|
||||
)
|
||||
|
|
@ -348,10 +348,9 @@ def _mrefs_to_grefs(refs: dict[str | None, list[Ref]]) -> list[klamath.library.R
|
|||
continue
|
||||
encoded_name = target.encode('ASCII')
|
||||
for ref in rseq:
|
||||
# Note: GDS mirrors first and rotates second
|
||||
mirror_across_x, extra_angle = normalize_mirror(ref.mirrored)
|
||||
# Note: GDS also mirrors first and rotates second
|
||||
rep = ref.repetition
|
||||
angle_deg = numpy.rad2deg(ref.rotation + extra_angle) % 360
|
||||
angle_deg = numpy.rad2deg(ref.rotation) % 360
|
||||
properties = _annotations_to_properties(ref.annotations, 512)
|
||||
|
||||
if isinstance(rep, Grid):
|
||||
|
|
@ -367,7 +366,7 @@ def _mrefs_to_grefs(refs: dict[str | None, list[Ref]]) -> list[klamath.library.R
|
|||
xy=rint_cast(xy),
|
||||
colrow=(numpy.rint(rep.a_count), numpy.rint(rep.b_count)),
|
||||
angle_deg=angle_deg,
|
||||
invert_y=mirror_across_x,
|
||||
invert_y=ref.mirrored,
|
||||
mag=ref.scale,
|
||||
properties=properties,
|
||||
)
|
||||
|
|
@ -378,7 +377,7 @@ def _mrefs_to_grefs(refs: dict[str | None, list[Ref]]) -> list[klamath.library.R
|
|||
xy=rint_cast([ref.offset]),
|
||||
colrow=None,
|
||||
angle_deg=angle_deg,
|
||||
invert_y=mirror_across_x,
|
||||
invert_y=ref.mirrored,
|
||||
mag=ref.scale,
|
||||
properties=properties,
|
||||
)
|
||||
|
|
@ -390,7 +389,7 @@ def _mrefs_to_grefs(refs: dict[str | None, list[Ref]]) -> list[klamath.library.R
|
|||
xy=rint_cast([ref.offset + dd]),
|
||||
colrow=None,
|
||||
angle_deg=angle_deg,
|
||||
invert_y=mirror_across_x,
|
||||
invert_y=ref.mirrored,
|
||||
mag=ref.scale,
|
||||
properties=properties,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ from .. import Pattern, Ref, PatternError, LibraryError, Label, Shape
|
|||
from ..library import Library, ILibrary
|
||||
from ..shapes import Path, Circle
|
||||
from ..repetition import Grid, Arbitrary, Repetition
|
||||
from ..utils import layer_t, normalize_mirror, annotations_t
|
||||
from ..utils import layer_t, annotations_t
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -494,7 +494,7 @@ def _placement_to_ref(placement: fatrec.Placement, lib: fatamorgana.OasisLayout)
|
|||
rotation = numpy.deg2rad(float(placement.angle))
|
||||
ref = Ref(
|
||||
offset=xy,
|
||||
mirrored=(placement.flip, False),
|
||||
mirrored=placement.flip,
|
||||
rotation=rotation,
|
||||
scale=float(mag),
|
||||
repetition=repetition_fata2masq(placement.repetition),
|
||||
|
|
@ -511,15 +511,14 @@ def _refs_to_placements(
|
|||
if target is None:
|
||||
continue
|
||||
for ref in rseq:
|
||||
# Note: OASIS mirrors first and rotates second
|
||||
mirror_across_x, extra_angle = normalize_mirror(ref.mirrored)
|
||||
# Note: OASIS also mirrors first and rotates second
|
||||
frep, rep_offset = repetition_masq2fata(ref.repetition)
|
||||
|
||||
offset = rint_cast(ref.offset + rep_offset)
|
||||
angle = numpy.rad2deg(ref.rotation + extra_angle) % 360
|
||||
angle = numpy.rad2deg(ref.rotation) % 360
|
||||
placement = fatrec.Placement(
|
||||
name=target,
|
||||
flip=mirror_across_x,
|
||||
flip=ref.mirrored,
|
||||
angle=angle,
|
||||
magnification=ref.scale,
|
||||
properties=annotations_to_properties(ref.annotations),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue