[PathTool] fix pathtool L-shape
This commit is contained in:
parent
83ec64158a
commit
56e401196a
2 changed files with 19 additions and 3 deletions
|
|
@ -1244,7 +1244,7 @@ class PathTool(Tool, metaclass=ABCMeta):
|
||||||
port_names: tuple[str, str] = ('A', 'B'),
|
port_names: tuple[str, str] = ('A', 'B'),
|
||||||
**kwargs, # noqa: ARG002 (unused)
|
**kwargs, # noqa: ARG002 (unused)
|
||||||
) -> Library:
|
) -> Library:
|
||||||
out_port, dxy = self.planL(
|
out_port, _data = self.planL(
|
||||||
ccw,
|
ccw,
|
||||||
length,
|
length,
|
||||||
in_ptype=in_ptype,
|
in_ptype=in_ptype,
|
||||||
|
|
@ -1252,7 +1252,12 @@ class PathTool(Tool, metaclass=ABCMeta):
|
||||||
)
|
)
|
||||||
|
|
||||||
tree, pat = Library.mktree(SINGLE_USE_PREFIX + 'traceL')
|
tree, pat = Library.mktree(SINGLE_USE_PREFIX + 'traceL')
|
||||||
pat.path(layer=self.layer, width=self.width, vertices=[(0, 0), (length, 0)])
|
vertices: list[tuple[float, float]]
|
||||||
|
if ccw is None:
|
||||||
|
vertices = [(0.0, 0.0), (length, 0.0)]
|
||||||
|
else:
|
||||||
|
vertices = [(0.0, 0.0), (length, 0.0), tuple(out_port.offset)]
|
||||||
|
pat.path(layer=self.layer, width=self.width, vertices=vertices)
|
||||||
|
|
||||||
if ccw is None:
|
if ccw is None:
|
||||||
out_rot = pi
|
out_rot = pi
|
||||||
|
|
@ -1263,7 +1268,7 @@ class PathTool(Tool, metaclass=ABCMeta):
|
||||||
|
|
||||||
pat.ports = {
|
pat.ports = {
|
||||||
port_names[0]: Port((0, 0), rotation=0, ptype=self.ptype),
|
port_names[0]: Port((0, 0), rotation=0, ptype=self.ptype),
|
||||||
port_names[1]: Port(dxy, rotation=out_rot, ptype=self.ptype),
|
port_names[1]: Port(out_port.offset, rotation=out_rot, ptype=self.ptype),
|
||||||
}
|
}
|
||||||
|
|
||||||
return tree
|
return tree
|
||||||
|
|
|
||||||
|
|
@ -119,3 +119,14 @@ def test_renderpather_rename_port(rpather_setup: tuple[RenderPather, PathTool, L
|
||||||
assert_allclose(path_shape.vertices, [[0, 0], [0, -10], [0, -20]], atol=1e-10)
|
assert_allclose(path_shape.vertices, [[0, 0], [0, -10], [0, -20]], atol=1e-10)
|
||||||
assert "new_start" in rp.ports
|
assert "new_start" in rp.ports
|
||||||
assert_allclose(rp.ports["new_start"].offset, [0, -20], atol=1e-10)
|
assert_allclose(rp.ports["new_start"].offset, [0, -20], atol=1e-10)
|
||||||
|
|
||||||
|
|
||||||
|
def test_pathtool_traceL_bend_geometry_matches_ports() -> None:
|
||||||
|
tool = PathTool(layer=(1, 0), width=2, ptype="wire")
|
||||||
|
|
||||||
|
tree = tool.traceL(True, 10)
|
||||||
|
pat = tree.top_pattern()
|
||||||
|
path_shape = cast("Path", pat.shapes[(1, 0)][0])
|
||||||
|
|
||||||
|
assert_allclose(path_shape.vertices, [[0, 0], [10, 0], [10, 1]], atol=1e-10)
|
||||||
|
assert_allclose(pat.ports["B"].offset, [10, 1], atol=1e-10)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue