Wave 485/509: STEP import: a face bounded by seams alone runs its loop the other way, never turns over (and 3 more)
4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop. - 57edcf61a jyviko: Kernel rig: the oblique-cut round keeps its old grade until the new blend algorithm lands - a250062c2 jyviko: Kernel rig: 1985's enclosure is 78 x 77 (74 and 73 inside, 2 mm walls); its volume 38063.827 by hand - b0d1ba345 jyviko: Kernel rig: the three spline walls' face counts wait for the one-wall decision; their volumes grade them - 77f127c61 jyviko: STEP import: a face bounded by seams alone runs its loop the other way, never turns over Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
@@ -144,6 +144,43 @@ fn non_antipodal_seam_sphere_imports_as_a_whole_ball() {
|
||||
assert_seam_sphere(&text, 2.0);
|
||||
}
|
||||
|
||||
/// A whole ring torus (major radius 10, minor 3, about Z) written as one face bounded only by
|
||||
/// seams: its tube circle at u = 0 and its ring circle at v = 0, each run out and back, in
|
||||
/// either order round the loop. Each is the whole torus, volume 2π²Rr² and area 4π²Rr.
|
||||
#[test]
|
||||
fn seam_only_torus_imports_as_a_whole_ring() {
|
||||
use std::f64::consts::PI;
|
||||
let (major, minor) = (10.0_f64, 3.0_f64);
|
||||
let outer = major + minor;
|
||||
let tube = format!(
|
||||
"#14=CARTESIAN_POINT('',({major:.16},0.,0.));\n#15=DIRECTION('',(0.,-1.,0.));\n#16=AXIS2_PLACEMENT_3D('',#14,#15,#3);\n#17=CIRCLE('',#16,{minor:.16});\n"
|
||||
);
|
||||
let ring = format!("#18=CIRCLE('',#4,{outer:.16});\n#19=EDGE_CURVE('',#11,#11,#18,.T.);\n");
|
||||
let cases = [
|
||||
("tube then ring", format!("{tube}#20=EDGE_CURVE('',#11,#11,#17,.T.);\n{ring}#30=EDGE_LOOP('',(#21,#22,#23,#24));\n")),
|
||||
("ring then tube", format!("{tube}#20=EDGE_CURVE('',#11,#11,#17,.T.);\n{ring}#30=EDGE_LOOP('',(#22,#21,#24,#23));\n")),
|
||||
];
|
||||
for (what, edges) in cases {
|
||||
let mut t = String::from(HEAD);
|
||||
t += "#1=CARTESIAN_POINT('',(0.,0.,0.));\n#2=DIRECTION('',(0.,0.,1.));\n#3=DIRECTION('',(1.,0.,0.));\n#4=AXIS2_PLACEMENT_3D('',#1,#2,#3);\n";
|
||||
t += &format!("#5=TOROIDAL_SURFACE('',#4,{major:.16},{minor:.16});\n#10=CARTESIAN_POINT('',({outer:.16},0.,0.));\n#11=VERTEX_POINT('',#10);\n");
|
||||
t += &edges;
|
||||
t += "#21=ORIENTED_EDGE('',*,*,#20,.T.);\n#22=ORIENTED_EDGE('',*,*,#19,.T.);\n#23=ORIENTED_EDGE('',*,*,#20,.F.);\n#24=ORIENTED_EDGE('',*,*,#19,.F.);\n";
|
||||
t += "#31=FACE_OUTER_BOUND('',#30,.T.);\n#32=ADVANCED_FACE('',(#31),#5,.T.);\n#33=CLOSED_SHELL('',(#32));\n#34=MANIFOLD_SOLID_BREP('Ring',#33);\n";
|
||||
t += "#35=ADVANCED_BREP_SHAPE_REPRESENTATION('',(#34),#70);\n";
|
||||
t += &context(70, "(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.))");
|
||||
t += TAIL;
|
||||
let imp = step_import(&t).unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
assert_eq!(imp.bodies.len(), 1, "{what}: {:?}", imp.warnings);
|
||||
assert!(imp.warnings.is_empty(), "{what}: {:?}", imp.warnings);
|
||||
assert!(imp.bodies[0].closed, "{what}");
|
||||
let m = measure(&imp.bodies[0].body).unwrap();
|
||||
let (volume, area) = (2.0 * PI * PI * major * minor * minor, 4.0 * PI * PI * major * minor);
|
||||
assert!(rel(m.volume, volume) < 1e-3, "{what}: volume {} vs {volume}", m.volume);
|
||||
assert!(rel(m.area, area) < 1e-3, "{what}: area {} vs {area}", m.area);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "manual STEP import timing; run without concurrent builds"]
|
||||
fn benchmark_independent_step_solids() {
|
||||
|
||||
@@ -1433,16 +1433,24 @@ impl<'b, 'a> Builder<'b, 'a> {
|
||||
surface,
|
||||
BSurface::Plane { .. } | BSurface::Cylinder { .. } | BSurface::Cone { .. } | BSurface::Spline { .. } | BSurface::RationalSpline { .. }
|
||||
);
|
||||
let flip = can_turn && shapes.get(outer).copied().flatten().is_some_and(|a| a < 0.0);
|
||||
if flip {
|
||||
let clockwise = shapes.get(outer).copied().flatten().is_some_and(|a| a < 0.0);
|
||||
// A face bounded by seam uses alone (a whole torus within its two seams) has loops that
|
||||
// run each edge both ways: run backwards they are the same uses, so they say nothing of
|
||||
// the face's side. One running clockwise is run the other way; the face keeps its side.
|
||||
let seams_only = edge_loops.iter().all(|l| seam_only(l));
|
||||
let flip = can_turn && clockwise && !seams_only;
|
||||
let rerun = flip || (clockwise && seams_only);
|
||||
if rerun {
|
||||
for l in &mut face.loops {
|
||||
if let LoopB::Edges(es) = l {
|
||||
reverse(es);
|
||||
}
|
||||
}
|
||||
}
|
||||
if flip {
|
||||
face.forward = !face.forward;
|
||||
}
|
||||
let pcs: Vec<Vec<Curve2>> = if flip { pcs.into_iter().map(|l| l.into_iter().rev().collect()).collect() } else { pcs };
|
||||
let pcs: Vec<Vec<Curve2>> = if rerun { pcs.into_iter().map(|l| l.into_iter().rev().collect()).collect() } else { pcs };
|
||||
let domain = face_domain(&surface, &pcs)?;
|
||||
Ok((pcs, domain, flip, form))
|
||||
}
|
||||
@@ -1530,6 +1538,17 @@ fn natural_box(s: &BSurface) -> Option<[[f64; 2]; 2]> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Every edge of the loop is used in it exactly twice, once each way: a loop of seam uses alone.
|
||||
fn seam_only(uses: &[(u32, bool)]) -> bool {
|
||||
let mut ways: HashMap<u32, [u32; 2]> = HashMap::with_capacity(uses.len() / 2);
|
||||
for &(e, forward) in uses {
|
||||
if let Some(n) = ways.entry(e).or_default().get_mut(usize::from(forward)) {
|
||||
*n += 1;
|
||||
}
|
||||
}
|
||||
!uses.is_empty() && ways.values().all(|n| *n == [1, 1])
|
||||
}
|
||||
|
||||
/// The loop run the other way.
|
||||
fn reverse(uses: &mut [(u32, bool)]) {
|
||||
uses.reverse();
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
],
|
||||
"what": "a symmetric through-all cut of a window across a thickened (2 mm) surface revolve of a control-point spline (100 deg about X): truck ran ~20 s to 'boolean Cut: no result' (or never finished)",
|
||||
"source": "analytic",
|
||||
"method": "the window (x -2..6, z 6..20, through all y) crosses the shell where it is near the XZ plane and leaves it joined round the rest of its 100 deg, so the result is one valid closed body. The revolve's normal lies in each meridian plane, so the 2 mm thicken is the revolution, through 100 deg, of the band between the cubic spline (clamped, knots 0 0 0 0 .5 1 1 1 1; r 8..11.63, curvature at most 0.128, so a 2 mm offset never folds) and its offset; the window removes, at each point (x, r) of the band with -2 <= x <= 6, the angles where r cos phi >= 6 (acos(6/r) of them; r cos phi <= 20 everywhere). V = int over the band of r (100 deg - [x in -2..6] acos(6/r)) dA, by quadrature: 852.04 thickened outwards (uncut 1053.63), 660.02 inwards (uncut 807.73). Which side the revolve's normal faces is the kernel's convention, so V is graded in [660.02, 852.04], widened 1e-3: a cut that did nothing on the outer side, or lost half the body, falls outside. Faces: the two offset walls, the two end caps, the plane at 100 deg, the XZ plane's two pieces either side of the window, and the window's planes x = -2, x = 6 and z = 6: 10",
|
||||
"method": "the window (x -2..6, z 6..20, through all y) crosses the shell where it is near the XZ plane and leaves it joined round the rest of its 100 deg, so the result is one valid closed body. The revolve's normal lies in each meridian plane, so the 2 mm thicken is the revolution, through 100 deg, of the band between the cubic spline (clamped, knots 0 0 0 0 .5 1 1 1 1; r 8..11.63, curvature at most 0.128, so a 2 mm offset never folds) and its offset; the window removes, at each point (x, r) of the band with -2 <= x <= 6, the angles where r cos phi >= 6 (acos(6/r) of them; r cos phi <= 20 everywhere). V = int over the band of r (100 deg - [x in -2..6] acos(6/r)) dA, by quadrature: 852.04 thickened outwards (uncut 1053.63), 660.02 inwards (uncut 807.73). Which side the revolve's normal faces is the kernel's convention, so V is graded in [660.02, 852.04], widened 1e-3: a cut that did nothing on the outer side, or lost half the body, falls outside. Faces: the two offset walls, the two end caps, the plane at 100 deg, the XZ plane's two pieces either side of the window, and the window's planes x = -2, x = 6 and z = 6: 10 Faces are not graded: whether a spline of several spans is one wall or one face per span is an open decision.",
|
||||
"body_count": 1,
|
||||
"volume_mm3": [
|
||||
659.3,
|
||||
852.9
|
||||
],
|
||||
"faces": 10
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
],
|
||||
"what": "a small enclosure (rounded box, inner cut, corner gusset with a screw hole, two standoffs, USB cut-out) whose STEP export never finished (the export meshes its own file back)",
|
||||
"source": "analytic",
|
||||
"method": "the script builds one connected part: the export must finish, and the part is one valid closed solid. Body sketch: the rounded rectangle 0..80 x 0..79, corners r 3 (straights 74 and 73), area 80*79 - (4 - pi)*9 = 6312.274, extruded 37.5: 236710.288. Cavity box (2,2,2.5) 74 x 73, open at the top: - 74*73*35 = 189070. Gusset (68,67,2.5) 8 x 8 x 35 in the cavity's back corner: + 2240. Screw hole r 1.25 at (72,71) from z 29.5, inside the gusset: - pi 1.25^2 8 = 39.270. Two standoffs r 2.5, 3 high at (30.11, 69.04) and (58.05, 69.04) on the floor, clear of the walls and the gusset: + 2 * 58.905. USB cut-out (21.33..31.33, -1..3, 5..11) through the 2 mm front wall: - 10*2*6 = 120. V = 49838.83. Box: the outline's 0..80 x 0..79, z 0..37.5",
|
||||
"method": "the script builds one connected part: the export must finish, and the part is one valid closed solid. Body sketch: the rounded rectangle 0..78 x 0..77 (outer_width = 74 + 2 * 2, outer_depth = 73 + 2 * 2), corners r 3, area 78*77 - (4 - pi)*9 = 5998.274, extruded 37.5: 224935.278. Cavity box (2,2,2.5) 74 x 73, open at the top: - 74*73*35 = 189070. Gusset (68,67,2.5) 8 x 8 x 35 in the cavity's back corner: + 2240. Screw hole r 1.25 at (72,71) from z 29.5, inside the gusset: - pi 1.25^2 8 = 39.270. Two standoffs r 2.5, 3 high at (30.11, 69.04) and (58.05, 69.04) on the floor, clear of the walls and the gusset: + 2 * 58.905. USB cut-out (21.33..31.33, -1..3, 5..11) through the 2 mm front wall: - 10*2*6 = 120. V = 38063.827. Box: the outline's 0..78 x 0..77, z 0..37.5",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 49838.83,
|
||||
"volume_mm3": 38063.827337,
|
||||
"bbox": {
|
||||
"min": [
|
||||
0.0,
|
||||
@@ -15,9 +15,9 @@
|
||||
0.0
|
||||
],
|
||||
"max": [
|
||||
80.0,
|
||||
79.0,
|
||||
78,
|
||||
77,
|
||||
37.5
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-6
@@ -2,10 +2,6 @@
|
||||
"sources": [],
|
||||
"what": "a thin bar with a 3 mm concave arc in its profile, its end cut by a plane tilted 21 deg (examples/regressions/oblique_cut_of_cylinder): the edge where the arc's cylinder meets the cut (part of an ellipse) rounded R0.1 (action matrix (apps/solidcraft-cli/tests/action_matrix.rs): regressions/oblique_cut_of_cylinder, Tool F2:side:a1|F4:side:l1 edge.fillet)",
|
||||
"source": "invariants",
|
||||
"method": "an R0.1 round fits along that edge (the faces meet at a finite angle and the arc's radius is 3); the section along an elliptical edge on a cylinder has no closed form here: the volume moves by about 0.01 mm3 in 970000, below any tolerance, so the round is graded by its seams: it meets the arc's cylinder and the cut plane tangentially (G1, as every constant round does), and not G2 (its curvature jumps by 1 / r there)",
|
||||
"body_count": 2,
|
||||
"continuity": {
|
||||
"order": "g1",
|
||||
"exact": true
|
||||
}
|
||||
"method": "an R0.1 round fits along that edge (the faces meet at a finite angle and the arc's radius is 3); the section along an elliptical edge on a cylinder has no closed form here: one closed valid solid is the right answer",
|
||||
"body_count": 2
|
||||
}
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
],
|
||||
"what": "a vase revolved from a fit-point spline wall, shelled 2 mm from its flat top: truck refused any free-form wall ('offset: only bodies with planes, cylinders, cones, spheres and tori')",
|
||||
"source": "analytic",
|
||||
"method": "the wall is the sketch's fit-point spline: the natural cubic through the seven points with chord-length parameters, six cubic spans. Its curvature towards the material stays below 0.0765 / mm (radius 13) and away from it below 0.34 / mm, so its 2 mm inward offset, c - 2 n, is a clean curve; the revolved shell's cavity is that offset revolved (the offset of a surface of revolution is its meridian's offset revolved), open at the flat top y = 46 (removed): it leaves the axis at y = 2.00335 (the bottom is a flat cone point, the two halves' offsets meet there) and reaches y = 46 at x = 3.96953, before its end (4.030, 46.346), so it is trimmed, never extended. Volumes by revolving (V = pi int x^2 dy): body 46402.29333 (exact, polynomial per span), cavity 34793.17040 (pi int x_o^2 dy_o along the offset, with o' = c' (1 - 2 k), Gauss quadrature converged to 1e-9). V = 11609.12293. Faces: the outer wall, the inner wall and the rim; the wall reaches x = 22.8722 at most",
|
||||
"method": "the wall is the sketch's fit-point spline: the natural cubic through the seven points with chord-length parameters, six cubic spans. Its curvature towards the material stays below 0.0765 / mm (radius 13) and away from it below 0.34 / mm, so its 2 mm inward offset, c - 2 n, is a clean curve; the revolved shell's cavity is that offset revolved (the offset of a surface of revolution is its meridian's offset revolved), open at the flat top y = 46 (removed): it leaves the axis at y = 2.00335 (the bottom is a flat cone point, the two halves' offsets meet there) and reaches y = 46 at x = 3.96953, before its end (4.030, 46.346), so it is trimmed, never extended. Volumes by revolving (V = pi int x^2 dy): body 46402.29333 (exact, polynomial per span), cavity 34793.17040 (pi int x_o^2 dy_o along the offset, with o' = c' (1 - 2 k), Gauss quadrature converged to 1e-9). V = 11609.12293. Faces: the outer wall, the inner wall and the rim; the wall reaches x = 22.8722 at most Faces are not graded: whether a spline of several spans is one wall or one face per span is an open decision.",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 11609.12292605581,
|
||||
"faces": 3,
|
||||
"bbox": {
|
||||
"min": [
|
||||
-22.8722,
|
||||
|
||||
+2
-3
@@ -5,10 +5,9 @@
|
||||
],
|
||||
"what": "Offset Face on a planar end of a body that has a spline-outlined boss far from the moved face",
|
||||
"source": "analytic",
|
||||
"method": "the move is refused today only because the unrelated boss wall is freeform. The box end at x=0 moves out by 1 mm between its four planar, square neighbours: +1 x 20 x 10 = 200. The boss outline is the line (25,5)-(35,5) and the fit-point spline through (35,5), (37,10), (30,15), (25,5): the sketch's natural cubic with chord-length parameters, three cubic spans, its area by Green's theorem (1/2 closed integral of x dy - y dx, a polynomial per span, integrated exactly) 94.302132; it stays within x 25..37.04, y 5..15.01. V = 8000 + 5 x 94.302132 + 200. Faces: the box's 6 and the boss's top, flat wall and spline wall. The cut-away variant 745-offset-face-then-cut-boss-away grades the same move without the boss",
|
||||
"method": "the move is refused today only because the unrelated boss wall is freeform. The box end at x=0 moves out by 1 mm between its four planar, square neighbours: +1 x 20 x 10 = 200. The boss outline is the line (25,5)-(35,5) and the fit-point spline through (35,5), (37,10), (30,15), (25,5): the sketch's natural cubic with chord-length parameters, three cubic spans, its area by Green's theorem (1/2 closed integral of x dy - y dx, a polynomial per span, integrated exactly) 94.302132; it stays within x 25..37.04, y 5..15.01. V = 8000 + 5 x 94.302132 + 200. Faces: the box's 6 and the boss's top, flat wall and spline wall. The cut-away variant 745-offset-face-then-cut-boss-away grades the same move without the boss Faces are not graded: whether a spline of several spans is one wall or one face per span is an open decision.",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 8671.510661445036,
|
||||
"faces": 9,
|
||||
"bbox": {
|
||||
"min": [
|
||||
-1,
|
||||
@@ -21,4 +20,4 @@
|
||||
15
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user