@tscircuit/rectdiff 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/bun-pver-release.yml +45 -24
- package/AGENTS.md +23 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +414 -191
- package/lib/RectDiffPipeline.ts +23 -0
- package/lib/solvers/OuterLayerContainmentMergeSolver/OuterLayerContainmentMergeSolver.ts +311 -0
- package/lib/solvers/RectDiffSeedingSolver/RectDiffSeedingSolver.ts +23 -23
- package/lib/solvers/RectDiffSeedingSolver/computeCandidates3D.ts +9 -10
- package/lib/solvers/RectDiffSeedingSolver/computeEdgeCandidates3D.ts +22 -19
- package/lib/solvers/RectDiffSeedingSolver/longestFreeSpanAroundZ.ts +1 -1
- package/lib/types/srj-types.ts +1 -0
- package/lib/utils/expandRectFromSeed.ts +8 -10
- package/lib/utils/isFullyOccupiedAtPoint.ts +2 -2
- package/lib/utils/rectdiff-geometry.ts +13 -20
- package/package.json +3 -1
- package/pages/pour.page.tsx +18 -0
- package/scripts/benchmark-slow-problem.ts +94 -0
- package/test-assets/bugreport49-634662.json +412 -0
- package/test-assets/keyboard4.json +16165 -0
- package/tests/solver/__snapshots__/rectDiffGridSolverPipeline.snap.svg +1 -1
- package/tests/solver/bugreport03-fe4a17/__snapshots__/bugreport03-fe4a17.snap.svg +1 -1
- package/tests/solver/bugreport08-e3ec95/__snapshots__/bugreport08-e3ec95.snap.svg +1 -1
- package/tests/solver/bugreport09-618e09/__snapshots__/bugreport09-618e09.snap.svg +1 -1
- package/tests/solver/bugreport10-71239a/__snapshots__/bugreport10-71239a.snap.svg +1 -1
- package/tests/solver/bugreport11-b2de3c/__snapshots__/bugreport11-b2de3c.snap.svg +1 -1
- package/tests/solver/bugreport22-2a75ce/__snapshots__/bugreport22-2a75ce.snap.svg +1 -1
- package/tests/solver/bugreport24-05597c/__snapshots__/bugreport24-05597c.snap.svg +1 -1
- package/tests/solver/bugreport35-191db9/__snapshots__/bugreport35-191db9.snap.svg +1 -1
- package/tests/solver/bugreport36-bf8303/__snapshots__/bugreport36-bf8303.snap.svg +1 -1
- package/tests/solver/bugreport49-634662/__snapshots__/bugreport49-634662.snap.svg +44 -0
- package/tests/solver/bugreport49-634662/bugreport49-634662.test.ts +134 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<svg width="640" height="3699" viewBox="0 0 640 3699" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" fill="white"/><g><polyline data-points="-5,-5 5,-5 5,5 -5,5 -5,-5" data-type="line" data-label="bounds" points="40,912.6666666666667 600,912.6666666666667 600,352.66666666666674 40,352.66666666666674 40,912.6666666666667" fill="none" stroke="#111827" stroke-width="5.6000000000000005"/></g><g><polyline data-points="-5,-20.208333333333332 5,-20.208333333333332 5,-10.208333333333332 -5,-10.208333333333332 -5,-20.208333333333332" data-type="line" data-label="bounds" points="40,1764.3333333333333 600,1764.3333333333333 600,1204.3333333333335 40,1204.3333333333335 40,1764.3333333333333" fill="none" stroke="#111827" stroke-width="5.6000000000000005"/></g><g><polyline data-points="-5,-35.416666666666664 5,-35.416666666666664 5,-25.416666666666664 -5,-25.416666666666664 -5,-35.416666666666664" data-type="line" data-label="bounds" points="40,2616 600,2616 600,2056 40,2056 40,2616" fill="none" stroke="#111827" stroke-width="5.6000000000000005"/></g><g><polyline data-points="-5,-50.62499999999999 5,-50.62499999999999 5,-40.62499999999999 -5,-40.62499999999999 -5,-50.62499999999999" data-type="line" data-label="bounds" points="40,3467.666666666666 600,3467.666666666666 600,2907.666666666666 40,2907.666666666666 40,3467.666666666666" fill="none" stroke="#111827" stroke-width="5.6000000000000005"/></g><g><rect data-type="rect" data-label="node" data-x="-2.15" data-y="1.905" x="171.6" y="509.1866666666667" width="56.00000000000003" height="33.60000000000002" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.15" data-y="0.635" x="171.6" y="580.3066666666667" width="56.00000000000003" height="33.60000000000002" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.15" data-y="-0.635" x="171.6" y="651.4266666666667" width="56.00000000000003" height="33.60000000000002" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.15" data-y="-1.905" x="171.6" y="722.5466666666667" width="56.00000000000003" height="33.60000000000002" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="-1.905" x="412.4" y="722.5466666666667" width="56" height="33.60000000000002" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="-0.635" x="412.4" y="651.4266666666667" width="56" height="33.60000000000002" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="0.635" x="412.4" y="580.3066666666667" width="56" height="33.60000000000002" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="1.905" x="412.4" y="509.1866666666667" width="56" height="33.60000000000002" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.1499999999999995" data-y="3.5250000000000004" x="184.48000000000002" y="417.3466666666667" width="30.24000000000001" height="35.84000000000003" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.1299999999999997" data-y="3.5250000000000004" x="241.60000000000002" y="417.3466666666667" width="30.24000000000001" height="35.84000000000003" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.9699999999999998" data-y="-0.635" x="524.4" y="653.1066666666668" width="35.84000000000003" height="30.239999999999895" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.9699999999999998" data-y="0.385" x="524.4" y="595.9866666666668" width="35.84000000000003" height="30.239999999999895" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-0.3550000000000004" data-y="-3.6025" x="40" y="756.1466666666668" width="520.24" height="156.51999999999998" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="0" data-y="1.77" x="227.60000000000002" y="453.1866666666667" width="184.79999999999995" height="160.72000000000003" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.1749999999999998" data-y="4.422499999999999" x="40" y="352.66666666666674" width="428.40000000000003" height="64.68000000000006" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-3.825" data-y="2.09" x="40" y="417.34666666666675" width="131.59999999999997" height="196.56" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.4699999999999998" data-y="2.8275" x="468.4" y="352.66666666666674" width="91.84000000000003" height="243.31999999999994" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="4.645" data-y="0" x="560.24" y="352.66666666666674" width="39.75999999999999" height="560" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="0" data-y="-1.27" x="227.60000000000002" y="651.4266666666667" width="184.79999999999995" height="104.72000000000003" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.1749999999999998" data-y="0" x="40" y="613.9066666666668" width="428.40000000000003" height="37.51999999999998" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-3.325" data-y="-1.27" x="40" y="685.0266666666668" width="187.6" height="37.51999999999998" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.4699999999999998" data-y="-1.5550000000000002" x="468.4" y="683.3466666666668" width="91.84000000000003" height="72.79999999999995" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="3.025" x="412.4" y="417.34666666666675" width="56" height="91.83999999999997" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="0.39499999999999996" data-y="3.525" x="271.84000000000003" y="417.34666666666675" width="140.55999999999995" height="35.839999999999975" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-3.825" data-y="-1.905" x="40" y="722.5466666666667" width="131.59999999999997" height="33.60000000000002" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-3.825" data-y="-0.635" x="40" y="651.4266666666667" width="131.59999999999997" height="33.60000000000002" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.4699999999999998" data-y="-0.125" x="468.4" y="626.2266666666667" width="91.84000000000003" height="26.88000000000011" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.2649999999999997" data-y="2.705" x="171.60000000000002" y="453.1866666666667" width="43.120000000000005" height="56" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.1500000000000004" data-y="-1.27" x="412.4" y="685.0266666666668" width="56.00000000000006" height="37.51999999999998" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.15" data-y="1.27" x="171.6" y="542.7866666666667" width="56.00000000000003" height="37.51999999999998" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="1.27" x="412.4" y="542.7866666666667" width="56" height="37.51999999999998" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.15" data-y="-0.6350000000000001" x="468.4" y="653.1066666666668" width="56" height="30.24000000000001" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.15" data-y="0.4949999999999999" x="468.4" y="595.9866666666668" width="56" height="17.91999999999996" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.6399999999999997" data-y="3.5249999999999995" x="214.72000000000003" y="417.3466666666668" width="26.879999999999995" height="35.83999999999992" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.7649999999999997" data-y="2.705" x="214.72000000000003" y="453.1866666666667" width="12.879999999999995" height="56" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.15" data-y="0.22499999999999998" x="468.4" y="613.9066666666668" width="56" height="12.319999999999936" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.5349999999999993" data-y="3.5249999999999995" x="171.60000000000002" y="417.3466666666668" width="12.880000000000024" height="35.83999999999992" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="0" data-y="-15.208333333333332" x="40" y="1204.3333333333335" width="560" height="559.9999999999998" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="0" data-y="-30.416666666666664" x="40" y="2056" width="560" height="560" fill="red" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-0.3550000000000004" data-y="-49.22749999999999" x="40" y="3311.1466666666665" width="520.24" height="156.51999999999953" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="0" data-y="-43.85499999999999" x="227.60000000000002" y="3008.1866666666665" width="184.79999999999995" height="160.72000000000025" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.1749999999999998" data-y="-41.20249999999999" x="40" y="2907.666666666666" width="428.40000000000003" height="64.68000000000029" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-3.825" data-y="-43.535" x="40" y="2972.3466666666664" width="131.59999999999997" height="196.5600000000004" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.4699999999999998" data-y="-42.79749999999999" x="468.4" y="2907.666666666666" width="91.84000000000003" height="243.32000000000062" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="4.645" data-y="-45.62499999999999" x="560.24" y="2907.666666666666" width="39.75999999999999" height="560" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="0" data-y="-46.894999999999996" x="227.60000000000002" y="3206.4266666666663" width="184.79999999999995" height="104.72000000000025" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.1749999999999998" data-y="-45.62499999999999" x="40" y="3168.9066666666668" width="428.40000000000003" height="37.51999999999953" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-3.325" data-y="-46.894999999999996" x="40" y="3240.0266666666666" width="187.6" height="37.51999999999953" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.4699999999999998" data-y="-47.17999999999999" x="468.4" y="3238.3466666666664" width="91.84000000000003" height="72.80000000000018" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="-42.599999999999994" x="412.4" y="2972.3466666666664" width="56" height="91.84000000000015" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="0.39499999999999996" data-y="-42.099999999999994" x="271.84000000000003" y="2972.3466666666664" width="140.55999999999995" height="35.840000000000146" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-3.825" data-y="-47.529999999999994" x="40" y="3277.546666666666" width="131.59999999999997" height="33.600000000000364" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-3.825" data-y="-46.25999999999999" x="40" y="3206.4266666666663" width="131.59999999999997" height="33.599999999999454" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.4699999999999998" data-y="-45.74999999999999" x="468.4" y="3181.2266666666665" width="91.84000000000003" height="26.88000000000011" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.2649999999999997" data-y="-42.919999999999995" x="171.60000000000002" y="3008.1866666666665" width="43.120000000000005" height="56" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.1500000000000004" data-y="-46.894999999999996" x="412.4" y="3240.0266666666666" width="56.00000000000006" height="37.51999999999953" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.15" data-y="-44.35499999999999" x="171.6" y="3097.786666666666" width="56.00000000000003" height="37.52000000000044" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="-44.35499999999999" x="412.4" y="3097.786666666666" width="56" height="37.52000000000044" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.15" data-y="-46.25999999999999" x="468.4" y="3208.1066666666657" width="56" height="30.24000000000069" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.15" data-y="-45.129999999999995" x="468.4" y="3150.9866666666667" width="56" height="17.920000000000073" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.6399999999999997" data-y="-42.099999999999994" x="214.72000000000003" y="2972.3466666666664" width="26.879999999999995" height="35.840000000000146" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.7649999999999997" data-y="-42.919999999999995" x="214.72000000000003" y="3008.1866666666665" width="12.879999999999995" height="56" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.15" data-y="-45.39999999999999" x="468.4" y="3168.9066666666668" width="56" height="12.319999999999709" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.5349999999999993" data-y="-42.099999999999994" x="171.60000000000002" y="2972.3466666666664" width="12.880000000000024" height="35.840000000000146" fill="#dbeafe" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.15" data-y="-47.529999999999994" x="171.6" y="3277.546666666666" width="56.00000000000003" height="33.600000000000364" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.15" data-y="-46.25999999999999" x="171.6" y="3206.4266666666663" width="56.00000000000003" height="33.599999999999454" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.7649999999999997" data-y="-44.989999999999995" x="214.72000000000003" y="3135.3066666666664" width="12.879999999999995" height="33.600000000000364" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.7649999999999997" data-y="-43.71999999999999" x="214.72000000000003" y="3064.1866666666665" width="12.879999999999995" height="33.599999999999454" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.2649999999999997" data-y="-44.989999999999995" x="171.60000000000002" y="3135.3066666666664" width="43.120000000000005" height="33.600000000000364" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.2649999999999997" data-y="-43.71999999999999" x="171.60000000000002" y="3064.1866666666665" width="43.120000000000005" height="33.599999999999454" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-2.1499999999999995" data-y="-42.099999999999994" x="184.48000000000002" y="2972.3466666666664" width="30.24000000000001" height="35.840000000000146" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.9699999999999998" data-y="-46.25999999999999" x="524.4000000000001" y="3208.1066666666657" width="35.83999999999992" height="30.24000000000069" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="3.9699999999999998" data-y="-45.239999999999995" x="524.4000000000001" y="3150.9866666666667" width="35.83999999999992" height="30.23999999999978" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.1500000000000004" data-y="-47.529999999999994" x="412.40000000000003" y="3277.546666666666" width="56" height="33.600000000000364" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.1500000000000004" data-y="-46.25999999999999" x="412.40000000000003" y="3206.4266666666663" width="56" height="33.599999999999454" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="-44.989999999999995" x="412.4" y="3135.3066666666664" width="56" height="33.600000000000364" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="2.15" data-y="-43.71999999999999" x="412.4" y="3064.1866666666665" width="56" height="33.599999999999454" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><g><rect data-type="rect" data-label="node" data-x="-1.13" data-y="-42.099999999999994" x="241.60000000000002" y="2972.3466666666664" width="30.24000000000001" height="35.840000000000146" fill="#e9d5ff" stroke="black" stroke-width="0.017857142857142856"/></g><text data-type="text" data-label="Layer z=0" data-x="0" data-y="6.666666666666666" x="320" y="259.3333333333334" fill="black" font-size="28" font-family="sans-serif" text-anchor="end" dominant-baseline="text-before-edge">Layer z=0</text><text data-type="text" data-label="Layer z=1" data-x="0" data-y="-8.541666666666666" x="320" y="1111" fill="black" font-size="28" font-family="sans-serif" text-anchor="end" dominant-baseline="text-before-edge">Layer z=1</text><text data-type="text" data-label="Layer z=2" data-x="0" data-y="-23.75" x="320" y="1962.6666666666667" fill="black" font-size="28" font-family="sans-serif" text-anchor="end" dominant-baseline="text-before-edge">Layer z=2</text><text data-type="text" data-label="Layer z=3" data-x="0" data-y="-38.95833333333333" x="320" y="2814.333333333333" fill="black" font-size="28" font-family="sans-serif" text-anchor="end" dominant-baseline="text-before-edge">Layer z=3</text><g id="crosshair" style="display: none"><line id="crosshair-h" y1="0" y2="3699" stroke="#666" stroke-width="0.5"/><line id="crosshair-v" x1="0" x2="640" stroke="#666" stroke-width="0.5"/><text id="coordinates" font-family="monospace" font-size="12" fill="#666"></text></g><script><![CDATA[
|
|
2
|
+
document.currentScript.parentElement.addEventListener('mousemove', (e) => {
|
|
3
|
+
const svg = e.currentTarget;
|
|
4
|
+
const rect = svg.getBoundingClientRect();
|
|
5
|
+
const x = e.clientX - rect.left;
|
|
6
|
+
const y = e.clientY - rect.top;
|
|
7
|
+
const crosshair = svg.getElementById('crosshair');
|
|
8
|
+
const h = svg.getElementById('crosshair-h');
|
|
9
|
+
const v = svg.getElementById('crosshair-v');
|
|
10
|
+
const coords = svg.getElementById('coordinates');
|
|
11
|
+
|
|
12
|
+
crosshair.style.display = 'block';
|
|
13
|
+
h.setAttribute('x1', '0');
|
|
14
|
+
h.setAttribute('x2', '640');
|
|
15
|
+
h.setAttribute('y1', y);
|
|
16
|
+
h.setAttribute('y2', y);
|
|
17
|
+
v.setAttribute('x1', x);
|
|
18
|
+
v.setAttribute('x2', x);
|
|
19
|
+
v.setAttribute('y1', '0');
|
|
20
|
+
v.setAttribute('y2', '3699');
|
|
21
|
+
|
|
22
|
+
// Calculate real coordinates using inverse transformation
|
|
23
|
+
const matrix = {"a":56,"c":0,"e":320,"b":0,"d":-56,"f":632.6666666666667};
|
|
24
|
+
// Manually invert and apply the affine transform
|
|
25
|
+
// Since we only use translate and scale, we can directly compute:
|
|
26
|
+
// x' = (x - tx) / sx
|
|
27
|
+
// y' = (y - ty) / sy
|
|
28
|
+
const sx = matrix.a;
|
|
29
|
+
const sy = matrix.d;
|
|
30
|
+
const tx = matrix.e;
|
|
31
|
+
const ty = matrix.f;
|
|
32
|
+
const realPoint = {
|
|
33
|
+
x: (x - tx) / sx,
|
|
34
|
+
y: (y - ty) / sy // Flip y back since we used negative scale
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
coords.textContent = `(${realPoint.x.toFixed(2)}, ${realPoint.y.toFixed(2)})`;
|
|
38
|
+
coords.setAttribute('x', (x + 5).toString());
|
|
39
|
+
coords.setAttribute('y', (y - 5).toString());
|
|
40
|
+
});
|
|
41
|
+
document.currentScript.parentElement.addEventListener('mouseleave', () => {
|
|
42
|
+
document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';
|
|
43
|
+
});
|
|
44
|
+
]]></script></svg>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import bugreport49 from "../../../test-assets/bugreport49-634662.json"
|
|
3
|
+
import {
|
|
4
|
+
getBounds,
|
|
5
|
+
getSvgFromGraphicsObject,
|
|
6
|
+
mergeGraphics,
|
|
7
|
+
stackGraphicsVertically,
|
|
8
|
+
type GraphicsObject,
|
|
9
|
+
type Rect,
|
|
10
|
+
} from "graphics-debug"
|
|
11
|
+
import { RectDiffPipeline } from "lib/RectDiffPipeline"
|
|
12
|
+
import { makeCapacityMeshNodeWithLayerInfo } from "tests/fixtures/makeCapacityMeshNodeWithLayerInfo"
|
|
13
|
+
import { makeSimpleRouteOutlineGraphics } from "tests/fixtures/makeSimpleRouteOutlineGraphics"
|
|
14
|
+
|
|
15
|
+
const srj = bugreport49.simple_route_json ?? bugreport49
|
|
16
|
+
|
|
17
|
+
test("bugreport49-634662 promotes contained outer-layer free nodes through copper pours", () => {
|
|
18
|
+
const solver = new RectDiffPipeline({
|
|
19
|
+
simpleRouteJson: srj,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
solver.solve()
|
|
23
|
+
|
|
24
|
+
const { meshNodes } = solver.getOutput()
|
|
25
|
+
const bridgedNodes = meshNodes.filter(
|
|
26
|
+
(node) =>
|
|
27
|
+
node.availableZ.join(",") === "0,3" &&
|
|
28
|
+
!node._containsObstacle &&
|
|
29
|
+
!node._containsTarget,
|
|
30
|
+
)
|
|
31
|
+
const remainingTopOnlyFreeNodes = meshNodes.filter(
|
|
32
|
+
(node) =>
|
|
33
|
+
node.availableZ.join(",") === "0" &&
|
|
34
|
+
!node._containsObstacle &&
|
|
35
|
+
!node._containsTarget,
|
|
36
|
+
)
|
|
37
|
+
const obstacleNodesOnBottom = meshNodes.filter(
|
|
38
|
+
(node) => node._containsObstacle && node.availableZ.includes(3),
|
|
39
|
+
)
|
|
40
|
+
const maxBottomOnlyArea = Math.max(
|
|
41
|
+
0,
|
|
42
|
+
...meshNodes
|
|
43
|
+
.filter(
|
|
44
|
+
(node) =>
|
|
45
|
+
node.availableZ.join(",") === "3" &&
|
|
46
|
+
!node._containsObstacle &&
|
|
47
|
+
!node._containsTarget,
|
|
48
|
+
)
|
|
49
|
+
.map((node) => node.width * node.height),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
expect(bridgedNodes.length).toBeGreaterThan(0)
|
|
53
|
+
expect(remainingTopOnlyFreeNodes.length).toBe(0)
|
|
54
|
+
expect(obstacleNodesOnBottom.length).toBe(0)
|
|
55
|
+
expect(maxBottomOnlyArea).toBeLessThan(1)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test("bugreport49-634662", async () => {
|
|
59
|
+
const solver = new RectDiffPipeline({
|
|
60
|
+
simpleRouteJson: srj,
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const outline = makeSimpleRouteOutlineGraphics(srj)
|
|
64
|
+
|
|
65
|
+
solver.solve()
|
|
66
|
+
|
|
67
|
+
const { meshNodes } = solver.getOutput()
|
|
68
|
+
const rectsByCombo = makeCapacityMeshNodeWithLayerInfo(meshNodes)
|
|
69
|
+
const allGraphicsObjects: GraphicsObject[] = []
|
|
70
|
+
|
|
71
|
+
for (const z of Array.from({ length: srj.layerCount }, (_, index) => index)) {
|
|
72
|
+
const layerRects: Rect[] = []
|
|
73
|
+
|
|
74
|
+
for (const [key, rects] of rectsByCombo) {
|
|
75
|
+
const layers = key
|
|
76
|
+
.split(",")
|
|
77
|
+
.map((value) => Number.parseInt(value, 10))
|
|
78
|
+
.filter((value) => !Number.isNaN(value))
|
|
79
|
+
|
|
80
|
+
if (layers.includes(z)) {
|
|
81
|
+
layerRects.push(...rects)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let labelY = 0
|
|
86
|
+
|
|
87
|
+
if (layerRects.length > 0) {
|
|
88
|
+
let maxY = -Infinity
|
|
89
|
+
|
|
90
|
+
for (const rect of layerRects) {
|
|
91
|
+
const top = rect.center.y + rect.height * (2 / 3)
|
|
92
|
+
|
|
93
|
+
if (top > maxY) maxY = top
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
labelY = maxY
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const graphics: GraphicsObject = {
|
|
100
|
+
title: `RectDiffPipeline - z${z}`,
|
|
101
|
+
texts: [
|
|
102
|
+
{
|
|
103
|
+
anchorSide: "top_right",
|
|
104
|
+
text: `Layer z=${z}`,
|
|
105
|
+
x: 0,
|
|
106
|
+
y: labelY,
|
|
107
|
+
fontSize: 0.5,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
coordinateSystem: "cartesian",
|
|
111
|
+
rects: layerRects,
|
|
112
|
+
points: [],
|
|
113
|
+
lines: [],
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
allGraphicsObjects.push(mergeGraphics(graphics, outline))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const stackedGraphics = stackGraphicsVertically(allGraphicsObjects)
|
|
120
|
+
const bounds = getBounds(stackedGraphics)
|
|
121
|
+
const boundsWidth = Math.max(1, bounds.maxX - bounds.minX)
|
|
122
|
+
const boundsHeight = Math.max(1, bounds.maxY - bounds.minY)
|
|
123
|
+
const svgWidth = 640
|
|
124
|
+
const svgHeight = Math.max(
|
|
125
|
+
svgWidth,
|
|
126
|
+
Math.ceil((boundsHeight / boundsWidth) * svgWidth),
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
const svg = getSvgFromGraphicsObject(stackedGraphics, {
|
|
130
|
+
svgWidth,
|
|
131
|
+
svgHeight,
|
|
132
|
+
})
|
|
133
|
+
await expect(svg).toMatchSvgSnapshot(import.meta.path)
|
|
134
|
+
})
|