Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Wave 254/509: kernel-ladder: 07/016 is a refusal; 07/018 the same corner with r2; cases.py makes 013 (and 2 more)

jyviko9ae514b41f85
diff --git a/crates/smlib/SMLIB_REV b/crates/smlib/SMLIB_REV
index bd15aba72a..ca36ab7eb5 100644
--- a/crates/smlib/SMLIB_REV
+++ b/crates/smlib/SMLIB_REV
@@ -1 +1 @@
-f06b48a8da20ee659679e9622f73a42b1a7ab3a8
+a15b5a2885384a9d10e76a68ba8b79526faccb09
diff --git a/tests/kernel-cases/ladder/07-fillets/013-corner-setback/expected.json b/tests/kernel-cases/ladder/07-fillets/013-corner-setback/expected.json
index d62cece2e1..34149c7607 100644
--- a/tests/kernel-cases/ladder/07-fillets/013-corner-setback/expected.json
+++ b/tests/kernel-cases/ladder/07-fillets/013-corner-setback/expected.json
@@ -21,6 +21,6 @@
]
},
"tolerance": {
- "rel": 0.001192
+ "rel": 0.00119391703234033
}
}
diff --git a/tests/kernel-cases/ladder/07-fillets/016-corner-three-sequential-r5-r3-r7/expected.json b/tests/kernel-cases/ladder/07-fillets/016-corner-three-sequential-r5-r3-r7/expected.json
index c2d865f92a..576216d880 100644
--- a/tests/kernel-cases/ladder/07-fillets/016-corner-three-sequential-r5-r3-r7/expected.json
+++ b/tests/kernel-cases/ladder/07-fillets/016-corner-three-sequential-r5-r3-r7/expected.json
@@ -1,7 +1,7 @@
{
"sources": [],
- "what": "rounds r5 and r3 on the two top edges at a corner, then r7 on the vertical edge under them",
+ "what": "rounds r5 and r3 on the two top edges at a corner, then r7 on the vertical edge under them: refused, the r7 cannot exist",
"source": "invariants",
- "method": "three unequal radii at one corner, one after another; the vertical edge stays sharp below the two top rounds (x=60, y=40, z from 0 to 15), so it can be picked at z=8; one valid body",
- "body_count": 1
+ "method": "the r7 runs on (tangent chain) up the side x=60 along its arc on the r5 round, a circle of radius 5 about the r5 axis: the r7's contact line on that face would be the arc offset 7 towards its centre, radius 5 - 7 < 0, so the blend passes through itself; and along the seam of the r5 and r3 rounds no ball over r3 fits the r3 round. No such round exists, so the right answer is a clean refusal (SMLib: no room for the rolling ball). 018 is the same corner with a radius that fits.",
+ "outcome": "refused"
}
diff --git a/tests/kernel-cases/ladder/07-fillets/018-corner-three-sequential-r5-r3-r2/expected.json b/tests/kernel-cases/ladder/07-fillets/018-corner-three-sequential-r5-r3-r2/expected.json
new file mode 100644
index 0000000000..f1ac914a9d
--- /dev/null
+++ b/tests/kernel-cases/ladder/07-fillets/018-corner-three-sequential-r5-r3-r2/expected.json
@@ -0,0 +1,20 @@
+{
+ "sources": [],
+ "what": "rounds r5 and r3 on the two top edges at a corner, then r2 on the vertical edge under them, run on up into the corner",
+ "source": "invariants",
+ "method": "as 016 with a radius that fits (r < 3, the smaller top round): the r2 runs up the vertical edge and on along the side's arc on the r5 round and the seam between the two rounds, tapering to a point where they become tangent. Faces: the box's 6 and the two top rounds, + 3 for the r2 (along the vertical edge, up the arc, along the seam); one valid body inside the box",
+ "body_count": 1,
+ "faces": 11,
+ "bbox": {
+ "min": [
+ 0,
+ 0,
+ 0
+ ],
+ "max": [
+ 60,
+ 40,
+ 20
+ ]
+ }
+}
diff --git a/tests/kernel-cases/ladder/07-fillets/018-corner-three-sequential-r5-r3-r2/recipe.json b/tests/kernel-cases/ladder/07-fillets/018-corner-three-sequential-r5-r3-r2/recipe.json
new file mode 100644
index 0000000000..0dba98b4a9
--- /dev/null
+++ b/tests/kernel-cases/ladder/07-fillets/018-corner-three-sequential-r5-r3-r2/recipe.json
@@ -0,0 +1,45 @@
+{
+ "base": "../../01-primitives/001-box",
+ "commands": [
+ {
+ "command": "solid.fillet",
+ "params": {
+ "edges": [
+ [
+ 30,
+ 40,
+ 20
+ ]
+ ],
+ "radius": 5
+ }
+ },
+ {
+ "command": "solid.fillet",
+ "params": {
+ "edges": [
+ [
+ 60,
+ 20,
+ 20
+ ]
+ ],
+ "radius": 3,
+ "tangent_chain": false
+ }
+ },
+ {
+ "command": "solid.fillet",
+ "params": {
+ "edges": [
+ [
+ 60,
+ 40,
+ 8
+ ]
+ ],
+ "radius": 2
+ }
+ }
+ ]
+}
diff --git a/tests/kernel-cases/ladder/11-cumulative-parts/003-threaded-flange/expected.json b/tests/kernel-cases/ladder/11-cumulative-parts/003-threaded-flange/expected.json
index ee716837de..9e742b7d52 100644
--- a/tests/kernel-cases/ladder/11-cumulative-parts/003-threaded-flange/expected.json
+++ b/tests/kernel-cases/ladder/11-cumulative-parts/003-threaded-flange/expected.json
@@ -1,7 +1,23 @@
{
"sources": [],
"what": "the flange with a modelled M30 thread on its hub, between the round and the chamfer, and M8 tapped holes in the disk",
- "source": "invariants",
- "method": "a thread meeting a round and a chamfer, tapped holes; one valid body",
- "body_count": 1
+ "source": "analytic",
+ "method": "the hub's cylinder (r15) runs from the r3 round at its root (z 13) to the 1.5 chamfer at its top (z 28.5): the M30 groove (P 3.5) stops w = 1.632286 clear of the round, a shoulder (06/007's rule), and runs out through the chamfer, a free end (06/006's): it removes the stock less 2 pi int int r m(r) dr dz over z 13 + w..28.5 at r 15 and the chamfer (r 15 - (z - 28.5)); the bore r8 is inside the root r 13.1. The M8 tap drills (6.75) go through the 10 mm disk at r 28, 90 deg + k 120, clear of the bolt holes (30 deg apart): 3 pi 3.375^2 10. Bbox: the flange's",
+ "body_count": 1,
+ "volume_mm3": 52978.060766654,
+ "bbox": {
+ "min": [
+ -40,
+ -40,
+ 0
+ ],
+ "max": [
+ 40,
+ 40,
+ 30
+ ]
+ },
+ "tolerance": {
+ "rel": 0.0001
+ }
}
diff --git a/tests/kernel-cases/ladder/11-cumulative-parts/004-housing/expected.json b/tests/kernel-cases/ladder/11-cumulative-parts/004-housing/expected.json
index 86d052e430..c5cc3e2c26 100644
--- a/tests/kernel-cases/ladder/11-cumulative-parts/004-housing/expected.json
+++ b/tests/kernel-cases/ladder/11-cumulative-parts/004-housing/expected.json
@@ -1,7 +1,23 @@
{
"sources": [],
"what": "the running part with every tier: back wall, boss, slot, spline window, tapped holes, rounds, chamfers, shell, vents, and a modelled M16 thread on the boss",
- "source": "invariants",
- "method": "the last case carries every tier; one valid body",
- "body_count": 1
+ "source": "analytic",
+ "method": "10/008 less the M16 groove on the boss: its cylinder runs from the r1 root round (z 21, a shoulder: the groove stops w = 0.932735 clear of it) to the 1 mm top chamfer (z 29, run out through it, a free end); the groove's root r 6.917 stays outside the boss's 1.5 wall's inside (r 6.5), so it cuts the wall only. Bbox: the part's",
+ "body_count": 1,
+ "volume_mm3": 15138.532607554,
+ "bbox": {
+ "min": [
+ 0,
+ 0,
+ 0
+ ],
+ "max": [
+ 60,
+ 40,
+ 35
+ ]
+ },
+ "tolerance": {
+ "rel": 0.0001
+ }
}
diff --git a/tests/kernel-cases/ladder/ladder.json b/tests/kernel-cases/ladder/ladder.json
index 4f0bf30706..e0a41cba5e 100644
--- a/tests/kernel-cases/ladder/ladder.json
+++ b/tests/kernel-cases/ladder/ladder.json
@@ -139,7 +139,8 @@
"ladder/07-fillets/014-curved-edge-r2",
"ladder/07-fillets/003-tangent-chain-r3",
"ladder/07-fillets/017-part-rounds",
- "ladder/07-fillets/013-corner-setback"
+ "ladder/07-fillets/013-corner-setback",
+ "ladder/07-fillets/018-corner-three-sequential-r5-r3-r2"
],
"tier": "07-fillets",
"what": "constant, variable and corner fillets"
diff --git a/tools/kernel-ladder/cases.py b/tools/kernel-ladder/cases.py
index 95db394807..5150837020 100644
--- a/tools/kernel-ladder/cases.py
+++ b/tools/kernel-ladder/cases.py
@@ -813,9 +813,12 @@ case(T7, "010-corner-unequal-r7-r3", "an r7 vertical round at a corner, then r3
"r7 arc's top edge as a torus quarter: Pappus, the section (1-pi/4) 3^2 with its centroid 3 (10-3pi)/(12-3pi) in from the wall, at radius 7 - that, over pi/2 (as 003). "
"Faces: 6 planes + the r7 cylinder + the r3 chain's cylinder, torus, cylinder; edges: 5 round the bottom, 5 round the top, 5 vertical (two r7 tangent lines, the box's "
"three other verticals), the chain's three on the walls and two end arcs, its two seams; vertices from Euler (V - E + F = 2): 14", base=B1)
-case(T7, "016-corner-three-sequential-r5-r3-r7", "rounds r5 and r3 on the two top edges at a corner, then r7 on the vertical edge under them",
- [F([corner[0]], 5), F([corner[1]], 3, tangent_chain=False), F([[60, 40, 8]], 7)], {"body_count": 1},
- "three unequal radii at one corner, one after another; the vertical edge stays sharp below the two top rounds (x=60, y=40, z from 0 to 15), so it can be picked at z=8; one valid body", base=B1, source="invariants")
+case(T7, "016-corner-three-sequential-r5-r3-r7", 'rounds r5 and r3 on the two top edges at a corner, then r7 on the vertical edge under them: refused, the r7 cannot exist',
+ [F([corner[0]], 5), F([corner[1]], 3, tangent_chain=False), F([[60, 40, 8]], 7)], {"outcome": "refused"},
+ "the r7 runs on (tangent chain) up the side x=60 along its arc on the r5 round, a circle of radius 5 about the r5 axis: the r7's contact line on that face would be the arc offset 7 towards its centre, radius 5 - 7 < 0, so the blend passes through itself; and along the seam of the r5 and r3 rounds no ball over r3 fits the r3 round. No such round exists, so the right answer is a clean refusal (SMLib: no room for the rolling ball). 018 is the same corner with a radius that fits.", base=B1, source="invariants")
+case(T7, "018-corner-three-sequential-r5-r3-r2", 'rounds r5 and r3 on the two top edges at a corner, then r2 on the vertical edge under them, run on up into the corner',
+ [F([corner[0]], 5), F([corner[1]], 3, tangent_chain=False), F([[60, 40, 8]], 2)], {"body_count": 1, "faces": 11, "bbox": BBOX},
+ "as 016 with a radius that fits (r < 3, the smaller top round): the r2 runs up the vertical edge and on along the side's arc on the r5 round and the seam between the two rounds, tapering to a point where they become tangent. Faces: the box's 6 and the two top rounds, + 3 for the r2 (along the vertical edge, up the arc, along the seam); one valid body inside the box", base=B1, source="invariants")
case(T7, "011-chain-ending-at-corner", "r5 rounds on two top edges meeting at a corner whose vertical edge stays sharp",
[F([corner[0], corner[1]], 5)],
{"body_count": 1, "volume_mm3": VB - SPANDREL * 25 * 100 + 125 * (5 / 3 - PI / 2), "faces": 8, "edges": 17, "vertices": 11, "bbox": BBOX, "tolerance": {"rel": 1e-5}},
@@ -847,8 +850,14 @@ case(T7, "012-variable-into-rounded-corner", "a vertical r5 round, then a variab
"cylinder: as a constant r5 tube that takes int_0^5 sqrt(25 - v^2)(5 - sqrt(25 - v^2)) dv = 125 pi/4 - 250/3 = %.6f; with its radius still growing at 4/55 per mm, %.6f "
"(numerical, the round's section against the cylinder). V lies between: graded as the interval's middle with its half width as the tolerance. Faces 6 + 2; edges 18, "
"vertices 12 (5 round the bottom, 5 vertical, 5 round the top face, the round's line on the back wall, its end arc on x = 0, its trim on the cylinder)" % (ext_const, ext_grow), base=B1)
-missing(T7, "013-corner-setback", "three r5 rounds at a corner with setbacks of 8 mm along each edge", "solid.fillet has no corner setback distances",
- "the setback corner patch would be graded by invariants")
+# 013: convex, so in the corner cube C (side 8) it lies between the hull of its sections on C's faces and the rounds' prisms.
+v13out = VB - SPANDREL * 25 * (60 + 40 + 20 - 15) - 125 * (1 - PI / 6) - (512 - 225 * SPANDREL - 125 * (1 - PI / 6))
+v13lo, v13hi = v13out + 299.0201, v13out + 512 - 225 * SPANDREL - 125 * (math.sqrt(2) - 1)
+case(T7, "013-corner-setback", 'three r5 rounds at the corner (60,40,20) with setbacks of 8 mm along each edge',
+ [F(corner, 5, setbacks=[{"vertex": [60, 40, 20], "distance": 8}])],
+ {"body_count": 1, "volume_mm3": (v13lo + v13hi) / 2, "faces": 15, "edges": 36, "vertices": 23, "bbox": BBOX,
+ "tolerance": {"rel": (v13hi - v13lo) / (v13hi + v13lo) + 1e-6}},
+ "outside the corner cube C = [52,60]x[32,40]x[12,20] the body is the sphere corner's (009: V0 = 47377.120025868, of which 512 - 225 (1-pi/4) - 125 (1-pi/6) lies in C); the body is convex, so in C it holds the hull of its points on C's faces (the rounds' sections at the setback planes x=52, y=32, z=12 and the cube's corners outside the patch: 299.0201 by a hull of the sections sampled, below the true hull) and lies within the planes tangent to it along those sections, the three rounds' prisms (512 - 225 (1-pi/4) - 125 (sqrt2-1): the corner cube of r keeps the cylinders' common octant (2-sqrt2) r^3). The volume is the middle of [47271.9757, 47384.8935] with that half width as its tolerance. The box is unchanged. SMLib's setback patch is two quadrilaterals per side meeting at its centre: 6 box faces, 3 rounds, 6 patch pieces; vertices: 4 untouched box corners, 2 at each round's far end, the 6 section ends (where the patch starts, 8 from the vertex along each edge), the 6 side middles and the centre (23); edges by Euler, 23 + 15 - 2", base=B1, source="invariants")
case(T7, "014-curved-edge-r2", "an r2 round on the top edge of a cylinder r10 h20",
[cyl([0, 0, 0], 10, 20, body_name="Part"), F([[10, 0, 20]], 2)],
{"body_count": 1, "volume_mm3": PI * 100 * 20 - SPANDREL * 4 * 2 * PI * (10 - XBAR * 2), "faces": 4},
@@ -1090,12 +1099,21 @@ FL = sketch(vplane([0, 0, 0]), line([[8, 0], [40, 0], [40, 10], [15, 10], [15, 3
case(T11, "002-flange", "a revolved flange and hub with a bore, six bolt holes, a hub chamfer and a hub-root round", FL,
{"body_count": 1, "volume_mm3": Vf, "faces": 14},
"pi((40^2-8^2)10 + (15^2-8^2)20) - 6 pi 4^2 10 - 1.125 * 2 pi 14.5 (chamfer, Pappus) + (1-pi/4) 9 * 2 pi (15 + 3(10-3pi)/(12-3pi)) (concave round)")
+w30 = ext_half_width(30, 3.5)
case(T11, "003-threaded-flange", "the flange with a modelled M30 thread on its hub, between the round and the chamfer, and M8 tapped holes in the disk",
[thr([15, 0, 20], designation="M30"), H(position=[0, 28, 10], thread="M8", name="Tap"), C("solid.pattern.circular", features=["Tap"], axis="Z", count=3)],
- {"body_count": 1}, "a thread meeting a round and a chamfer, tapped holes; one valid body", base=up(T11, "002-flange"), source="invariants")
+ {"body_count": 1, "volume_mm3": Vf - groove(30, 3.5, [(13 + w30, 28.5, lambda z: 15), (28.5, 30, lambda z: 15 - (z - 28.5))]) - 3 * PI * 3.375 ** 2 * 10,
+ "bbox": {"min": [-40, -40, 0], "max": [40, 40, 30]}, "tolerance": {"rel": 1e-4}},
+ "the hub's cylinder (r15) runs from the r3 round at its root (z 13) to the 1.5 chamfer at its top (z 28.5): the M30 groove (P 3.5) stops w = %.6f clear of the round, "
+ "a shoulder (06/007's rule), and runs out through the chamfer, a free end (06/006's): it removes the stock less 2 pi int int r m(r) dr dz over z 13 + w..28.5 at r 15 and the chamfer "
+ "(r 15 - (z - 28.5)); the bore r8 is inside the root r 13.1. The M8 tap drills (6.75) go through the 10 mm disk at r 28, 90 deg + k 120, clear of the bolt holes (30 deg apart): "
+ "3 pi 3.375^2 10. Bbox: the flange's" % w30, base=up(T11, "002-flange"))
case(T11, "004-housing", "the running part with every tier: back wall, boss, slot, spline window, tapped holes, rounds, chamfers, shell, vents, and a modelled M16 thread on the boss",
- [thr([23, 15, 25], designation="M16")], {"body_count": 1},
- "the last case carries every tier; one valid body", base=C10, source="invariants")
+ [thr([23, 15, 25], designation="M16")],
+ {"body_count": 1, "volume_mm3": V9 - 4 * PI * 1.5 ** 2 * 1.5 - groove(16, 2, [(21 + w16, 29, lambda z: 8), (29, 30, lambda z: 8 - (z - 29))]),
+ "bbox": {"min": [0, 0, 0], "max": [60, 40, 35]}, "tolerance": {"rel": 1e-4}},
+ "10/008 less the M16 groove on the boss: its cylinder runs from the r1 root round (z 21, a shoulder: the groove stops w = %.6f clear of it) to the 1 mm top chamfer "
+ "(z 29, run out through it, a free end); the groove's root r 6.917 stays outside the boss's 1.5 wall's inside (r 6.5), so it cuts the wall only. Bbox: the part's" % w16, base=C10)
# manifest: tiers in order, cases in authoring order until --record sorts them by time
WHAT = {