Compare commits

..

3 Commits

6 changed files with 19 additions and 16 deletions

View File

@ -352,16 +352,17 @@ class Pather(Builder, PatherMixin):
except NotImplementedError: except NotImplementedError:
# Fall back to drawing two L-bends # Fall back to drawing two L-bends
ccw0 = jog > 0 ccw0 = jog > 0
kwargs_no_out = (kwargs | {'out_ptype': None}) kwargs_no_out = kwargs | {'out_ptype': None}
t_tree0 = tool.path( ccw0, length / 2, port_names=tool_port_names, in_ptype=in_ptype, **kwargs_no_out) t_tree0 = tool.path( ccw0, length / 2, port_names=tool_port_names, in_ptype=in_ptype, **kwargs_no_out)
t_pat0 = t_tree0.top_pattern() t_pat0 = t_tree0.top_pattern()
(_, jog0), _ = t_pat0[tool_port_names[0]].measure_travel(t_pat0[tool_port_names[1]]) (_, jog0), _ = t_pat0[tool_port_names[0]].measure_travel(t_pat0[tool_port_names[1]])
t_tree1 = tool.path(not ccw0, jog - jog0, port_names=tool_port_names, in_ptype=t_pat0[tool_port_names[1]].ptype, **kwargs) t_tree1 = tool.path(not ccw0, abs(jog - jog0), port_names=tool_port_names, in_ptype=t_pat0[tool_port_names[1]].ptype, **kwargs)
t_pat1 = t_tree1.top_pattern() t_pat1 = t_tree1.top_pattern()
(_, jog1), _ = t_pat1[tool_port_names[0]].measure_travel(t_pat1[tool_port_names[1]]) (_, jog1), _ = t_pat1[tool_port_names[0]].measure_travel(t_pat1[tool_port_names[1]])
self.path(portspec, ccw0, length - jog1, **kwargs_no_out) kwargs_plug = kwargs | {'plug_into': plug_into}
self.path(portspec, not ccw0, jog - jog0, **kwargs) self.path(portspec, ccw0, length - abs(jog1), **kwargs_no_out)
self.path(portspec, not ccw0, abs(jog - jog0), **kwargs_plug)
return self return self
tname = self.library << tree tname = self.library << tree

View File

@ -321,7 +321,7 @@ class PatherMixin(PortList, metaclass=ABCMeta):
else: else:
# S-bend, delegate to implementations # S-bend, delegate to implementations
(travel, jog), _ = port_src.measure_travel(port_dst) (travel, jog), _ = port_src.measure_travel(port_dst)
self.pathS(portspec_src, -travel, jog, **dst_args) self.pathS(portspec_src, -travel, -jog, **dst_args)
elif numpy.isclose(angle, 0): elif numpy.isclose(angle, 0):
raise BuildError('Don\'t know how to route a U-bend yet (TODO)!') raise BuildError('Don\'t know how to route a U-bend yet (TODO)!')
else: else:

View File

@ -488,12 +488,13 @@ class RenderPather(PatherMixin):
ccw0 = jog > 0 ccw0 = jog > 0
kwargs_no_out = (kwargs | {'out_ptype': None}) kwargs_no_out = (kwargs | {'out_ptype': None})
t_port0, _ = tool.planL( ccw0, length / 2, in_ptype=in_ptype, **kwargs_no_out) t_port0, _ = tool.planL( ccw0, length / 2, in_ptype=in_ptype, **kwargs_no_out)
(_, jog0), _ = Port((0, 0), 0).measure_travel(t_port0) jog0 = Port((0, 0), 0).measure_travel(t_port0)[0][1]
t_port1, _ = tool.planL(not ccw0, jog - jog0, in_ptype=t_port0.ptype, **kwargs) t_port1, _ = tool.planL(not ccw0, abs(jog - jog0), in_ptype=t_port0.ptype, **kwargs)
(_, jog1), _ = Port((0, 0), 0).measure_travel(t_port1) jog1 = Port((0, 0), 0).measure_travel(t_port1)[0][1]
self.path(portspec, ccw0, length - jog1, **kwargs_no_out) kwargs_plug = kwargs | {'plug_into': plug_into}
self.path(portspec, not ccw0, jog - jog0, **kwargs) self.path(portspec, ccw0, length - abs(jog1), **kwargs_no_out)
self.path(portspec, not ccw0, abs(jog - jog0), **kwargs_plug)
return self return self
out_port.rotate_around((0, 0), pi + port_rot) out_port.rotate_around((0, 0), pi + port_rot)

View File

@ -768,6 +768,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
l2_err: BuildError | None = err l2_err: BuildError | None = err
else: else:
l2_err = None l2_err = None
raise NotImplementedError('TODO need to handle ldata below')
if not success: if not success:
# Failed to break # Failed to break

View File

@ -1169,12 +1169,13 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable):
ports[new_name] = port ports[new_name] = port
for name, port in ports.items(): for name, port in ports.items():
p = port.deepcopy() pp = port.deepcopy()
if mirrored: if mirrored:
p.mirror() pp.mirror()
p.rotate_around(pivot, rotation) pp.offset[1] *= -1
p.translate(offset) pp.rotate_around(pivot, rotation)
self.ports[name] = p pp.translate(offset)
self.ports[name] = pp
if append: if append:
if isinstance(other, Abstract): if isinstance(other, Abstract):

View File

@ -100,7 +100,6 @@ class Port(PositionableImpl, Rotatable, PivotableImpl, Copyable, Mirrorable):
return self return self
def mirror(self, axis: int = 0) -> Self: def mirror(self, axis: int = 0) -> Self:
self.offset[1 - axis] *= -1
if self.rotation is not None: if self.rotation is not None:
self.rotation *= -1 self.rotation *= -1
self.rotation += axis * pi self.rotation += axis * pi