Use normalize_mirror for all 2d-to-1d mirroring

This commit is contained in:
Jan Petykiewicz 2019-05-18 15:05:30 -07:00
parent 194a90fe7a
commit 75b42f6b63
2 changed files with 7 additions and 20 deletions

View File

@ -21,7 +21,7 @@ from .utils import mangle_name, make_dose_table
from .. import Pattern, SubPattern, GridRepetition, PatternError, Label, Shape from .. import Pattern, SubPattern, GridRepetition, PatternError, Label, Shape
from ..shapes import Polygon, Path from ..shapes import Polygon, Path
from ..utils import rotation_matrix_2d, get_bit, set_bit, vector2, is_scalar from ..utils import rotation_matrix_2d, get_bit, set_bit, vector2, is_scalar
from ..utils import remove_colinear_vertices from ..utils import remove_colinear_vertices, normalize_mirror
__author__ = 'Jan Petykiewicz' __author__ = 'Jan Petykiewicz'
@ -455,17 +455,9 @@ def _subpatterns_to_refs(subpatterns: List[SubPattern or GridRepetition]
ref = gdsii.elements.SRef(struct_name=encoded_name, ref = gdsii.elements.SRef(struct_name=encoded_name,
xy=numpy.round([subpat.offset]).astype(int)) xy=numpy.round([subpat.offset]).astype(int))
ref.strans = 0 mirror_x, extra_angle = normalize_mirror(subpat.mirrored)
ref.angle = subpat.rotation * 180 / numpy.pi ref.angle = ((subpat.rotation + extra_angle) * 180 / numpy.pi) % 360
mirror_x, mirror_y = subpat.mirrored ref.strans = set_bit(ref.strans, 15 - 0, True) if mirror_x else 0
if mirror_x and mirror_y:
ref.angle += 180
elif mirror_x:
ref.strans = set_bit(ref.strans, 15 - 0, True)
elif mirror_y:
ref.angle += 180
ref.strans = set_bit(ref.strans, 15 - 0, True)
ref.angle %= 360
ref.mag = subpat.scale ref.mag = subpat.scale
refs.append(ref) refs.append(ref)

View File

@ -5,7 +5,7 @@ from numpy import pi, inf
from . import Shape, Polygon, normalized_shape_tuple from . import Shape, Polygon, normalized_shape_tuple
from .. import PatternError from .. import PatternError
from ..utils import is_scalar, vector2, get_bit from ..utils import is_scalar, vector2, get_bit, normalize_mirror
# Loaded on use: # Loaded on use:
# from freetype import Face # from freetype import Face
@ -131,13 +131,8 @@ class Text(Shape):
return self return self
def normalized_form(self, norm_value: float) -> normalized_shape_tuple: def normalized_form(self, norm_value: float) -> normalized_shape_tuple:
mirror_x, mirror_y = self.mirrored mirror_x, rotation = normalize_mirror(self.mirrored)
rotation = self.rotation rotation += self.rotation
if mirror_x and mirror_y:
rotation += pi
elif mirror_y:
rotation += pi
mirror_x = True
rotation %= 2 * pi rotation %= 2 * pi
return (type(self), self.string, self.font_path, self.layer), \ return (type(self), self.string, self.font_path, self.layer), \
(self.offset, self.height / norm_value, rotation, mirror_x, self.dose), \ (self.offset, self.height / norm_value, rotation, mirror_x, self.dose), \