Wave 360/509: Kernel rig: bend table cases, JSON and CSV rows with angles, radii and K-factor allowances, and an unknown format refused (and 1 more)

2 commits, squashed; the originals stay reachable from tag archive/merge-main-develop.

- 67dd8892f jyviko: Kernel rig: bend table cases, JSON and CSV rows with angles, radii and K-factor allowances, and an unknown format refused
- 235645db5 jyviko: Kernel rig: the ellipse length's Simpson weights as a named step

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
jyviko
2026-10-29 16:59:59 -04:00
parent 88aaf50bf1
commit f226557ab1
7 changed files with 310 additions and 2 deletions
+18 -2
View File
@@ -361,7 +361,13 @@ fn dxf_layers(text: &str) -> Value {
let n = 4096;
let speed = |t: f64| (a * t.sin()).hypot(b * t.cos());
let h = sweep / n as f64;
let sum: f64 = (0..=n).map(|k| speed(t0 + k as f64 * h) * if k == 0 || k == n { 1.0 } else if k % 2 == 1 { 4.0 } else { 2.0 }).sum();
let weight = |k: usize| match k {
0 => 1.0,
k if k == n => 1.0,
k if k % 2 == 1 => 4.0,
_ => 2.0,
};
let sum: f64 = (0..=n).map(|k| speed(t0 + k as f64 * h) * weight(k)).sum();
Some(sum * h / 3.0)
}
_ => None,
@@ -809,7 +815,17 @@ mod tests {
vec![("0", "ARC"), ("8", "OUTLINE"), ("10", "0"), ("20", "0"), ("40", "2"), ("50", "270"), ("51", "0")],
vec![("0", "CIRCLE"), ("8", "CUT"), ("10", "5"), ("20", "5"), ("40", "1")],
vec![("0", "LWPOLYLINE"), ("8", "BEND_UP"), ("90", "2"), ("70", "128"), ("10", "0"), ("20", "1"), ("10", "10"), ("20", "1")],
vec![("0", "ELLIPSE"), ("8", "CUT"), ("10", "0"), ("20", "0"), ("11", "10"), ("21", "0"), ("40", "1"), ("41", "0"), ("42", "6.283185307179586")],
vec![
("0", "ELLIPSE"),
("8", "CUT"),
("10", "0"),
("20", "0"),
("11", "10"),
("21", "0"),
("40", "1"),
("41", "0"),
("42", "6.283185307179586"),
],
] {
for (c, v) in e {
t += &pair(c, v);
@@ -0,0 +1,40 @@
{
"sources": [],
"what": "sheet.export_bend_table as CSV of an 80 x 40 x 2 base with a 60 degree flange on one long edge and a hem on the other",
"source": "analytic",
"method": "T = 2, K = 0.5. Bend 1, the flange: 60 degrees up (included 120), R 2, BA = (pi/3)(2 + 1) = 3.141592654, 80 long. Bend 2, the hem on the top edge: 180 degrees down (included 0), its radius the rule's hem gap 0.01, BA = pi(0.01 + 1) = 3.173008580, 80 long",
"body_count": 1,
"files": [
{
"path": "bends.csv",
"csv": [
{
"body": "Body1",
"rule": "Steel 2",
"thickness_mm": 2.0,
"k_factor": 0.5,
"bend": 1,
"angle_deg": 60.0,
"direction": "up",
"radius_mm": 2.0,
"allowance_mm": 3.141592653589793,
"length_mm": 80.0,
"included_angle_deg": 120.0
},
{
"body": "Body1",
"rule": "Steel 2",
"thickness_mm": 2.0,
"k_factor": 0.5,
"bend": 2,
"angle_deg": 180.0,
"direction": "down",
"radius_mm": 0.01,
"allowance_mm": 3.173008580125691,
"length_mm": 80.0,
"included_angle_deg": 0.0
}
]
}
]
}
@@ -0,0 +1,79 @@
{
"commands": [
{
"command": "sheet.manage_rules",
"params": {
"name": "Steel 2",
"thickness": "2 mm",
"active": true,
"bend_radius": "2 mm",
"k_factor": 0.5
}
},
{
"command": "sketch.create",
"params": {
"plane": "XY",
"name": "Base"
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
0,
0
],
"p1": [
80,
40
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "sheet.flange",
"params": {
"type": "base",
"sketch": "Base"
}
},
{
"command": "sheet.flange",
"params": {
"type": "edge",
"edges": [
[
40,
0,
2
]
],
"height": 20,
"angle": "60 deg"
}
},
{
"command": "sheet.hem",
"params": {
"edges": [
[
40,
40,
2
]
],
"length": 8
}
},
{
"command": "sheet.export_bend_table",
"params": {
"path": "$OUT/bends.csv"
}
}
]
}
@@ -0,0 +1,33 @@
{
"sources": [],
"what": "sheet.export_bend_table as JSON of an 80 x 40 x 2 base with one 90 degree flange 20 high",
"source": "analytic",
"method": "the rule: T = 2, K = 0.5, R = 2. One bend: 90 degrees (included 180 - 90 = 90), up, radius 2, allowance BA = theta(R + K*T) = (pi/2)(2 + 1) = 4.712388980, as long as the edge, 80; flat 80 x 56.712389 x 2",
"body_count": 1,
"files": [
{
"path": "bends.json",
"json": {
"rule": "Steel 2",
"thickness": 2.0,
"k_factor": 0.5,
"flat_size_mm": [
80.0,
56.71238898038469,
2.0
],
"bends": [
{
"bend": 1,
"angle_deg": 90.0,
"included_angle_deg": 90.0,
"radius": 2.0,
"direction": "up",
"allowance": 4.71238898038469,
"length": 80.0
}
]
}
}
]
}
@@ -0,0 +1,66 @@
{
"commands": [
{
"command": "sheet.manage_rules",
"params": {
"name": "Steel 2",
"thickness": "2 mm",
"active": true,
"bend_radius": "2 mm",
"k_factor": 0.5
}
},
{
"command": "sketch.create",
"params": {
"plane": "XY",
"name": "Base"
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
0,
0
],
"p1": [
80,
40
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "sheet.flange",
"params": {
"type": "base",
"sketch": "Base"
}
},
{
"command": "sheet.flange",
"params": {
"type": "edge",
"edges": [
[
40,
0,
2
]
],
"height": 20
}
},
{
"command": "sheet.export_bend_table",
"params": {
"format": "json",
"path": "$OUT/bends.json"
}
}
]
}
@@ -0,0 +1,8 @@
{
"sources": [],
"what": "sheet.export_bend_table asked for a format it does not write (xlsx)",
"source": "invariants",
"method": "the table is written as csv or json only: any other format is refused, naming the two",
"outcome": "refused",
"refusal": "`format` must be csv or json"
}
@@ -0,0 +1,66 @@
{
"commands": [
{
"command": "sheet.manage_rules",
"params": {
"name": "Steel 2",
"thickness": "2 mm",
"active": true,
"bend_radius": "2 mm",
"k_factor": 0.5
}
},
{
"command": "sketch.create",
"params": {
"plane": "XY",
"name": "Base"
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
0,
0
],
"p1": [
80,
40
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "sheet.flange",
"params": {
"type": "base",
"sketch": "Base"
}
},
{
"command": "sheet.flange",
"params": {
"type": "edge",
"edges": [
[
40,
0,
2
]
],
"height": 20
}
},
{
"command": "sheet.export_bend_table",
"params": {
"format": "xlsx",
"path": "$OUT/bends.xlsx"
}
}
]
}