Add mirror_x to extrinsic properties
It's not implemented for Polygon shapes, since I haven't thought about how to normalize those for reflection yet
This commit is contained in:
parent
2e54cf1080
commit
032c410b43
@ -261,9 +261,9 @@ class Pattern:
|
|||||||
pat = Pattern(shapes=[shape])
|
pat = Pattern(shapes=[shape])
|
||||||
|
|
||||||
for i, values in shape_table[label][1]:
|
for i, values in shape_table[label][1]:
|
||||||
(offset, scale, rotation, dose) = values
|
(offset, scale, rotation, mirror_x, dose) = values
|
||||||
subpat = SubPattern(pattern=pat, offset=offset, scale=scale,
|
subpat = SubPattern(pattern=pat, offset=offset, scale=scale,
|
||||||
rotation=rotation, dose=dose)
|
rotation=rotation, dose=dose, mirrored=(mirror_x, False))
|
||||||
self.subpatterns.append(subpat)
|
self.subpatterns.append(subpat)
|
||||||
shapes_to_remove.append(i)
|
shapes_to_remove.append(i)
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ class Arc(Shape):
|
|||||||
width = self.width
|
width = self.width
|
||||||
|
|
||||||
return (type(self), radii, angles, width/norm_value, self.layer), \
|
return (type(self), radii, angles, width/norm_value, self.layer), \
|
||||||
(self.offset, scale/norm_value, rotation, self.dose), \
|
(self.offset, scale/norm_value, rotation, False, self.dose), \
|
||||||
lambda: Arc(radii=radii*norm_value, angles=angles, width=width*norm_value, layer=self.layer)
|
lambda: Arc(radii=radii*norm_value, angles=angles, width=width*norm_value, layer=self.layer)
|
||||||
|
|
||||||
def get_cap_edges(self) -> numpy.ndarray:
|
def get_cap_edges(self) -> numpy.ndarray:
|
||||||
|
@ -102,6 +102,6 @@ class Circle(Shape):
|
|||||||
rotation = 0.0
|
rotation = 0.0
|
||||||
magnitude = self.radius / norm_value
|
magnitude = self.radius / norm_value
|
||||||
return (type(self), self.layer), \
|
return (type(self), self.layer), \
|
||||||
(self.offset, magnitude, rotation, self.dose), \
|
(self.offset, magnitude, rotation, False, self.dose), \
|
||||||
lambda: Circle(radius=norm_value, layer=self.layer)
|
lambda: Circle(radius=norm_value, layer=self.layer)
|
||||||
|
|
||||||
|
@ -169,6 +169,6 @@ class Ellipse(Shape):
|
|||||||
scale = self.radius_y
|
scale = self.radius_y
|
||||||
angle = (self.rotation + pi / 2) % pi
|
angle = (self.rotation + pi / 2) % pi
|
||||||
return (type(self), radii, self.layer), \
|
return (type(self), radii, self.layer), \
|
||||||
(self.offset, scale/norm_value, angle, self.dose), \
|
(self.offset, scale/norm_value, angle, False, self.dose), \
|
||||||
lambda: Ellipse(radii=radii*norm_value, layer=self.layer)
|
lambda: Ellipse(radii=radii*norm_value, layer=self.layer)
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ class Path(Shape):
|
|||||||
width0 = self.width / norm_value
|
width0 = self.width / norm_value
|
||||||
|
|
||||||
return (type(self), reordered_vertices.data.tobytes(), width0, self.cap, self.layer), \
|
return (type(self), reordered_vertices.data.tobytes(), width0, self.cap, self.layer), \
|
||||||
(offset, scale/norm_value, rotation, self.dose), \
|
(offset, scale/norm_value, rotation, False, self.dose), \
|
||||||
lambda: Polygon(reordered_vertices*norm_value, width=self.width*norm_value,
|
lambda: Polygon(reordered_vertices*norm_value, width=self.width*norm_value,
|
||||||
cap=self.cap, layer=self.layer)
|
cap=self.cap, layer=self.layer)
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ class Polygon(Shape):
|
|||||||
reordered_vertices = numpy.roll(rotated_vertices, -x_min, axis=0)
|
reordered_vertices = numpy.roll(rotated_vertices, -x_min, axis=0)
|
||||||
|
|
||||||
return (type(self), reordered_vertices.data.tobytes(), self.layer), \
|
return (type(self), reordered_vertices.data.tobytes(), self.layer), \
|
||||||
(offset, scale/norm_value, rotation, self.dose), \
|
(offset, scale/norm_value, rotation, False, self.dose), \
|
||||||
lambda: Polygon(reordered_vertices*norm_value, layer=self.layer)
|
lambda: Polygon(reordered_vertices*norm_value, layer=self.layer)
|
||||||
|
|
||||||
def clean_vertices(self) -> 'Polygon':
|
def clean_vertices(self) -> 'Polygon':
|
||||||
|
@ -12,7 +12,7 @@ __author__ = 'Jan Petykiewicz'
|
|||||||
|
|
||||||
# Type definitions
|
# Type definitions
|
||||||
normalized_shape_tuple = Tuple[Tuple,
|
normalized_shape_tuple = Tuple[Tuple,
|
||||||
Tuple[numpy.ndarray, float, float, float],
|
Tuple[numpy.ndarray, float, float, bool, float],
|
||||||
Callable[[], 'Shape']]
|
Callable[[], 'Shape']]
|
||||||
|
|
||||||
# ## Module-wide defaults
|
# ## Module-wide defaults
|
||||||
@ -101,7 +101,7 @@ class Shape(metaclass=ABCMeta):
|
|||||||
(intrinsic, extrinsic, constructor). These are further broken down as:
|
(intrinsic, extrinsic, constructor). These are further broken down as:
|
||||||
intrinsic: A tuple of basic types containing all information about the instance that
|
intrinsic: A tuple of basic types containing all information about the instance that
|
||||||
is not contained in 'extrinsic'. Usually, intrinsic[0] == type(self).
|
is not contained in 'extrinsic'. Usually, intrinsic[0] == type(self).
|
||||||
extrinsic: ([x_offset, y_offset], scale, rotation, dose)
|
extrinsic: ([x_offset, y_offset], scale, rotation, mirror_across_x_axis, dose)
|
||||||
constructor: A callable (no arguments) which returns an instance of type(self) with
|
constructor: A callable (no arguments) which returns an instance of type(self) with
|
||||||
internal state equivalent to 'intrinsic'.
|
internal state equivalent to 'intrinsic'.
|
||||||
"""
|
"""
|
||||||
|
@ -131,12 +131,21 @@ 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:
|
||||||
return (type(self), self.string, self.font_path, self.mirrored, self.layer), \
|
mirror_x, mirror_y = self.mirrored
|
||||||
(self.offset, self.height / norm_value, self.rotation, self.dose), \
|
rotation = self.rotation
|
||||||
|
if mirror_x and mirror_y:
|
||||||
|
rotation += pi
|
||||||
|
elif mirror_y:
|
||||||
|
rotation += pi
|
||||||
|
mirror_x = True
|
||||||
|
rotation %= 2 * pi
|
||||||
|
return (type(self), self.string, self.font_path, self.layer), \
|
||||||
|
(self.offset, self.height / norm_value, rotation, mirror_x, self.dose), \
|
||||||
lambda: Text(string=self.string,
|
lambda: Text(string=self.string,
|
||||||
height=self.height * norm_value,
|
height=self.height * norm_value,
|
||||||
font_path=self.font_path,
|
font_path=self.font_path,
|
||||||
mirrored=self.mirrored,
|
rotation=rotation,
|
||||||
|
mirrored=(mirror_x, False),
|
||||||
layer=self.layer)
|
layer=self.layer)
|
||||||
|
|
||||||
def get_bounds(self) -> numpy.ndarray:
|
def get_bounds(self) -> numpy.ndarray:
|
||||||
|
Loading…
Reference in New Issue
Block a user