Compare commits

..

2 Commits

2 changed files with 6 additions and 15 deletions

View File

@ -278,14 +278,6 @@ class PatherMixin(metaclass=ABCMeta):
angle = (port_dst.rotation - port_src.rotation) % (2 * pi) angle = (port_dst.rotation - port_src.rotation) % (2 * pi)
def get_jog(ccw: SupportsBool, length: float) -> float:
tool = self.tools.get(portspec_src, self.tools[None])
in_ptype = 'unk' # Could use port_src.ptype, but we're assuming this is after one bend already...
tree2 = tool.path(ccw, length, in_ptype=in_ptype, port_names=('A', 'B'), out_ptype=out_ptype, **kwargs)
top2 = tree2.top_pattern()
jog = rotation_matrix_2d(top2['A'].rotation) @ (top2['B'].offset - top2['A'].offset)
return jog[1] * [-1, 1][int(bool(ccw))]
dst_extra_args = {'out_ptype': out_ptype} dst_extra_args = {'out_ptype': out_ptype}
if plug_destination: if plug_destination:
dst_extra_args['plug_into'] = portspec_dst dst_extra_args['plug_into'] = portspec_dst
@ -309,8 +301,8 @@ class PatherMixin(metaclass=ABCMeta):
self.path_to(portspec_src, None, y=yd, **dst_args) self.path_to(portspec_src, None, y=yd, **dst_args)
else: else:
# S-bend, delegate to implementations # S-bend, delegate to implementations
tj, _ = port_src.measure_travel(port_dst) (travel, jog), _ = port_src.measure_travel(port_dst)
self.pathS(*tj, **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

@ -552,7 +552,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
if numpy.isclose(jog, 0): if numpy.isclose(jog, 0):
return numpy.zeros(2) return numpy.zeros(2)
sbend_pat_or_tree = sbend.fn(jog) sbend_pat_or_tree = sbend.fn(abs(jog))
sbpat = sbend_pat_or_tree if isinstance(sbend_pat_or_tree, Pattern) else sbend_pat_or_tree.top_pattern() sbpat = sbend_pat_or_tree if isinstance(sbend_pat_or_tree, Pattern) else sbend_pat_or_tree.top_pattern()
dxy, _ = sbpat[sbend.in_port_name].measure_travel(sbpat[sbend.out_port_name]) dxy, _ = sbpat[sbend.in_port_name].measure_travel(sbpat[sbend.out_port_name])
return dxy return dxy
@ -802,15 +802,15 @@ class AutoTool(Tool, metaclass=ABCMeta):
if data.b_transition: if data.b_transition:
pat.plug(data.b_transition.abstract, {port_names[1]: data.b_transition.our_port_name}) pat.plug(data.b_transition.abstract, {port_names[1]: data.b_transition.our_port_name})
if not numpy.isclose(data.jog_remaining, 0): if not numpy.isclose(data.jog_remaining, 0):
sbend_pat_or_tree = data.sbend.fn(data.jog_remaining, **(gen_kwargs | data.gen_kwargs)) sbend_pat_or_tree = data.sbend.fn(abs(data.jog_remaining), **(gen_kwargs | data.gen_kwargs))
pmap = {port_names[1]: data.sbend.in_port_name} pmap = {port_names[1]: data.sbend.in_port_name}
if isinstance(sbend_pat_or_tree, Pattern): if isinstance(sbend_pat_or_tree, Pattern):
pat.plug(sbend_pat_or_tree, pmap, append=True) pat.plug(sbend_pat_or_tree, pmap, append=True, mirrored=data.jog_remaining < 0)
else: else:
sbend_tree = sbend_pat_or_tree sbend_tree = sbend_pat_or_tree
top = sbend_tree.top() top = sbend_tree.top()
sbend_tree.flatten(top) sbend_tree.flatten(top)
pat.plug(sbend_tree[top], pmap, append=True) pat.plug(sbend_tree[top], pmap, append=True, mirrored=data.jog_remaining < 0)
if data.out_transition: if data.out_transition:
pat.plug(data.out_transition.abstract, {port_names[1]: data.out_transition.our_port_name}) pat.plug(data.out_transition.abstract, {port_names[1]: data.out_transition.our_port_name})
return tree return tree
@ -831,7 +831,6 @@ class AutoTool(Tool, metaclass=ABCMeta):
in_ptype = in_ptype, in_ptype = in_ptype,
out_ptype = out_ptype, out_ptype = out_ptype,
) )
tree, pat = Library.mktree(SINGLE_USE_PREFIX + 'pathS') tree, pat = Library.mktree(SINGLE_USE_PREFIX + 'pathS')
pat.add_port_pair(names=port_names, ptype='unk' if in_ptype is None else in_ptype) pat.add_port_pair(names=port_names, ptype='unk' if in_ptype is None else in_ptype)
self._renderS(data=data, tree=tree, port_names=port_names, gen_kwargs=kwargs) self._renderS(data=data, tree=tree, port_names=port_names, gen_kwargs=kwargs)