[AutoTool] add U-bend
This commit is contained in:
parent
8a45c6d8d6
commit
1070815730
2 changed files with 167 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import numpy
|
||||
from numpy import pi
|
||||
from masque import Pather, RenderPather, Library, Port
|
||||
from masque import Pather, RenderPather, Library, Pattern, Port
|
||||
from masque.builder.tools import PathTool
|
||||
|
||||
def test_pather_trace_basic() -> None:
|
||||
|
|
@ -25,6 +25,7 @@ def test_pather_trace_basic() -> None:
|
|||
# (-5000, -500) rot pi - pi/2 = pi/2
|
||||
# Add to start: (-10000, -500) rot pi/2
|
||||
assert numpy.allclose(p.pattern.ports['A'].offset, (-10000, -500))
|
||||
assert p.pattern.ports['A'].rotation is not None
|
||||
assert numpy.isclose(p.pattern.ports['A'].rotation, pi/2)
|
||||
|
||||
def test_pather_trace_to() -> None:
|
||||
|
|
@ -151,8 +152,54 @@ def test_renderpather_uturn_fallback() -> None:
|
|||
assert rp.paths['A'][1].opcode == 'L'
|
||||
|
||||
rp.render()
|
||||
assert rp.pattern.ports['A'].rotation is not None
|
||||
assert numpy.isclose(rp.pattern.ports['A'].rotation, pi)
|
||||
|
||||
def test_autotool_uturn() -> None:
|
||||
from masque.builder.tools import AutoTool
|
||||
lib = Library()
|
||||
|
||||
# Setup AutoTool with a simple straight and a bend
|
||||
def make_straight(length: float) -> Pattern:
|
||||
pat = Pattern()
|
||||
pat.rect(layer='M1', xmin=0, xmax=length, yctr=0, ly=1000)
|
||||
pat.ports['in'] = Port((0, 0), 0)
|
||||
pat.ports['out'] = Port((length, 0), pi)
|
||||
return pat
|
||||
|
||||
bend_pat = Pattern()
|
||||
bend_pat.polygon(layer='M1', vertices=[(0, -500), (0, 500), (1000, -500)])
|
||||
bend_pat.ports['in'] = Port((0, 0), 0)
|
||||
bend_pat.ports['out'] = Port((500, -500), pi/2)
|
||||
lib['bend'] = bend_pat
|
||||
|
||||
tool = AutoTool(
|
||||
straights=[AutoTool.Straight(ptype='wire', fn=make_straight, in_port_name='in', out_port_name='out')],
|
||||
bends=[AutoTool.Bend(abstract=lib.abstract('bend'), in_port_name='in', out_port_name='out', clockwise=True)],
|
||||
sbends=[],
|
||||
transitions={},
|
||||
default_out_ptype='wire'
|
||||
)
|
||||
|
||||
p = Pather(lib, tools=tool)
|
||||
p.pattern.ports['A'] = Port((0, 0), 0)
|
||||
|
||||
# CW U-turn (jog < 0)
|
||||
# R = 500. jog = -2000. length = 1000.
|
||||
# p0 = planL(length=1000) -> out at (1000, -500) rot pi/2
|
||||
# R2 = 500.
|
||||
# l2_length = abs(-2000) - abs(-500) - 500 = 1000.
|
||||
p.at('A').uturn(offset=-2000, length=1000)
|
||||
|
||||
# Final port should be at (-1000, 2000) rot pi
|
||||
# Start: (0,0) rot 0. Wire direction is rot + pi = pi (West, -x).
|
||||
# Tool planU returns (length, jog) = (1000, -2000) relative to (0,0) rot 0.
|
||||
# Rotation of pi transforms (1000, -2000) to (-1000, 2000).
|
||||
# Final rotation: 0 + pi = pi.
|
||||
assert numpy.allclose(p.pattern.ports['A'].offset, (-1000, 2000))
|
||||
assert p.pattern.ports['A'].rotation is not None
|
||||
assert numpy.isclose(p.pattern.ports['A'].rotation, pi)
|
||||
|
||||
def test_pather_trace_into() -> None:
|
||||
lib = Library()
|
||||
tool = PathTool(layer='M1', width=1000)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue