[AutoTool] support min/max length for straight segments
This commit is contained in:
parent
f374651bc4
commit
899d05217e
@ -443,7 +443,8 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
|||||||
for generating straight paths, and a table of pre-rendered `transitions` for converting
|
for generating straight paths, and a table of pre-rendered `transitions` for converting
|
||||||
from non-native ptypes.
|
from non-native ptypes.
|
||||||
"""
|
"""
|
||||||
straights: list[tuple[str, Callable[[float], Pattern] | Callable[[float], Library], str, str]]
|
straights: list[tuple[str, Callable[[float], Pattern] | Callable[[float], Library], str, str, tuple[float, float]]]
|
||||||
|
# TODO add min length?
|
||||||
|
|
||||||
bends: list[abstract_tuple_t] # Assumed to be clockwise
|
bends: list[abstract_tuple_t] # Assumed to be clockwise
|
||||||
""" `clockwise_bend_abstract, in_port_name, out_port_name` """
|
""" `clockwise_bend_abstract, in_port_name, out_port_name` """
|
||||||
@ -566,9 +567,10 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
|||||||
) -> tuple[Port, LData]:
|
) -> tuple[Port, LData]:
|
||||||
# TODO check all the math for L-shaped bends
|
# TODO check all the math for L-shaped bends
|
||||||
|
|
||||||
|
success = False
|
||||||
for straight_tuple in self.straights:
|
for straight_tuple in self.straights:
|
||||||
stype = straight_tuple[0]
|
stype = straight_tuple[0]
|
||||||
|
straight_bounds = straight_tuple[-1]
|
||||||
for bend_tuple in self.bends:
|
for bend_tuple in self.bends:
|
||||||
bend_dxy, bend_angle = self._bend2dxy(bend_tuple, ccw)
|
bend_dxy, bend_angle = self._bend2dxy(bend_tuple, ccw)
|
||||||
btypei = bend_tuple[0][bend_tuple[1]].ptype
|
btypei = bend_tuple[0][bend_tuple[1]].ptype
|
||||||
@ -587,9 +589,10 @@ class AutoTool(Tool, metaclass=ABCMeta):
|
|||||||
|
|
||||||
straight_length = length - bend_dxy[0] - itrans_dxy[0] - btrans_dxy[0] - otrans_dxy[0]
|
straight_length = length - bend_dxy[0] - itrans_dxy[0] - btrans_dxy[0] - otrans_dxy[0]
|
||||||
bend_run = bend_dxy[1] + itrans_dxy[1] + btrans_dxy[1] + otrans_dxy[1]
|
bend_run = bend_dxy[1] + itrans_dxy[1] + btrans_dxy[1] + otrans_dxy[1]
|
||||||
if straight_length >= 0:
|
success = straight_bounds[0] <= straight_length < straight_bounds[1]
|
||||||
|
if success:
|
||||||
break
|
break
|
||||||
if straight_length >= 0:
|
if success:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# Failed to break
|
# Failed to break
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user