fixup! fixup! [Pather / RenderPather] move common functionality into PatherMixin; redo hierarchy
This commit is contained in:
parent
fd03e09ea1
commit
f374651bc4
@ -401,15 +401,15 @@ class BasicTool(Tool, metaclass=ABCMeta):
|
|||||||
|
|
||||||
gen_straight, sport_in, _sport_out = self.straight
|
gen_straight, sport_in, _sport_out = self.straight
|
||||||
for step in batch:
|
for step in batch:
|
||||||
straight_length, ccw, in_transition, out_transition = step.data
|
data = step.data
|
||||||
assert step.tool == self
|
assert step.tool == self
|
||||||
|
|
||||||
if step.opcode == 'L':
|
if step.opcode == 'L':
|
||||||
if in_transition:
|
if data.in_transition:
|
||||||
ipat, iport_theirs, _iport_ours = in_transition
|
ipat, iport_theirs, _iport_ours = data.in_transition
|
||||||
pat.plug(ipat, {port_names[1]: iport_theirs})
|
pat.plug(ipat, {port_names[1]: iport_theirs})
|
||||||
if not numpy.isclose(straight_length, 0):
|
if not numpy.isclose(data.straight_length, 0):
|
||||||
straight_pat_or_tree = gen_straight(straight_length, **kwargs)
|
straight_pat_or_tree = gen_straight(data.straight_length, **kwargs)
|
||||||
pmap = {port_names[1]: sport_in}
|
pmap = {port_names[1]: sport_in}
|
||||||
if isinstance(straight_pat_or_tree, Pattern):
|
if isinstance(straight_pat_or_tree, Pattern):
|
||||||
straight_pat = straight_pat_or_tree
|
straight_pat = straight_pat_or_tree
|
||||||
@ -427,11 +427,11 @@ class BasicTool(Tool, metaclass=ABCMeta):
|
|||||||
else:
|
else:
|
||||||
straight = tree <= straight_pat_or_tree
|
straight = tree <= straight_pat_or_tree
|
||||||
pat.plug(straight, pmap)
|
pat.plug(straight, pmap)
|
||||||
if ccw is not None:
|
if data.ccw is not None:
|
||||||
bend, bport_in, bport_out = self.bend
|
bend, bport_in, bport_out = self.bend
|
||||||
pat.plug(bend, {port_names[1]: bport_in}, mirrored=bool(ccw))
|
pat.plug(bend, {port_names[1]: bport_in}, mirrored=bool(data.ccw))
|
||||||
if out_transition:
|
if data.out_transition:
|
||||||
opat, oport_theirs, oport_ours = out_transition
|
opat, oport_theirs, oport_ours = data.out_transition
|
||||||
pat.plug(opat, {port_names[1]: oport_ours})
|
pat.plug(opat, {port_names[1]: oport_ours})
|
||||||
return tree
|
return tree
|
||||||
|
|
||||||
@ -578,7 +578,7 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
|||||||
itrans_dxy = self._itransition2dxy(in_transition)
|
itrans_dxy = self._itransition2dxy(in_transition)
|
||||||
|
|
||||||
out_transition = self.transitions.get(('unk' if out_ptype is None else out_ptype, stype if ccw is None else btypeo), None)
|
out_transition = self.transitions.get(('unk' if out_ptype is None else out_ptype, stype if ccw is None else btypeo), None)
|
||||||
otrans_dxy = self._otransition2dxy(in_transition, bend_angle)
|
otrans_dxy = self._otransition2dxy(out_transition, bend_angle)
|
||||||
|
|
||||||
b_transition = None
|
b_transition = None
|
||||||
if ccw is not None and btypei != stype:
|
if ccw is not None and btypei != stype:
|
||||||
@ -625,15 +625,16 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
|||||||
pat.add_port_pair(names=(port_names[0], port_names[1]))
|
pat.add_port_pair(names=(port_names[0], port_names[1]))
|
||||||
|
|
||||||
for step in batch:
|
for step in batch:
|
||||||
_stype, gen_straight, sport_in, _sport_out = step.data.straight_tuple
|
data = step.data
|
||||||
|
_stype, gen_straight, sport_in, _sport_out, _length_bounds = data.straight_tuple
|
||||||
assert step.tool == self
|
assert step.tool == self
|
||||||
|
|
||||||
if step.opcode == 'L':
|
if step.opcode == 'L':
|
||||||
if step.data.in_transition:
|
if data.in_transition:
|
||||||
ipat, iport_theirs, _iport_ours = step.data.in_transition
|
ipat, iport_theirs, _iport_ours = data.in_transition
|
||||||
pat.plug(ipat, {port_names[1]: iport_theirs})
|
pat.plug(ipat, {port_names[1]: iport_theirs})
|
||||||
if not numpy.isclose(step.data.straight_length, 0):
|
if not numpy.isclose(data.straight_length, 0):
|
||||||
straight_pat_or_tree = gen_straight(step.data.straight_length, **kwargs)
|
straight_pat_or_tree = gen_straight(data.straight_length, **kwargs)
|
||||||
pmap = {port_names[1]: sport_in}
|
pmap = {port_names[1]: sport_in}
|
||||||
if isinstance(straight_pat_or_tree, Pattern):
|
if isinstance(straight_pat_or_tree, Pattern):
|
||||||
straight_pat = straight_pat_or_tree
|
straight_pat = straight_pat_or_tree
|
||||||
@ -651,19 +652,18 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
|||||||
else:
|
else:
|
||||||
straight = tree <= straight_pat_or_tree
|
straight = tree <= straight_pat_or_tree
|
||||||
pat.plug(straight, pmap)
|
pat.plug(straight, pmap)
|
||||||
if step.data.b_transition:
|
if data.b_transition:
|
||||||
btpat, btport_bend, btport_straight = step.data.b_transition
|
btpat, btport_bend, btport_straight = data.b_transition
|
||||||
pat.plug(btpat, {port_names[1]: btport_straight})
|
pat.plug(btpat, {port_names[1]: btport_straight})
|
||||||
if step.data.ccw is not None:
|
if data.ccw is not None:
|
||||||
bend, bport_in, bport_out = step.data.bend_tuple
|
bend, bport_in, bport_out = data.bend_tuple
|
||||||
pat.plug(bend, {port_names[1]: bport_in}, mirrored=bool(step.data.ccw))
|
pat.plug(bend, {port_names[1]: bport_in}, mirrored=bool(data.ccw))
|
||||||
if step.data.out_transition:
|
if data.out_transition:
|
||||||
opat, oport_theirs, oport_ours = step.data.out_transition
|
opat, oport_theirs, oport_ours = data.out_transition
|
||||||
pat.plug(opat, {port_names[1]: oport_ours})
|
pat.plug(opat, {port_names[1]: oport_ours})
|
||||||
return tree
|
return tree
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PathTool(Tool, metaclass=ABCMeta):
|
class PathTool(Tool, metaclass=ABCMeta):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user