Skip to content

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

Wave 409/509: Kernel tests: a slot narrower than the taper closes partway up and builds; a closing hole is refused (and 3 more)

jyvikoeda02a5ee74b
diff --git a/crates/engine/src/cmd/features_more_tests.rs b/crates/engine/src/cmd/features_more_tests.rs
index 2c7b0fef6b..70af3e8168 100644
--- a/crates/engine/src/cmd/features_more_tests.rs
+++ b/crates/engine/src/cmd/features_more_tests.rs
@@ -1786,7 +1786,10 @@ fn fillet_edges_meeting_at_the_front_corner_of_the_arc() {
}
/// The long top front edge rounded, then the small front-left upright as a fillet of its own
-/// (as in the app): the new round ends in the earlier one, taking off what both take together.
+/// (as in the app). The upright's tangent chain (the Fillet default, since 84bd2daad) runs on
+/// through the first round's end, the quarter circle on the left face, to the top-left edge, so
+/// the second fillet rounds the upright and the top-left edge: it takes off what the three edges
+/// take together.
#[test]
fn fillet_the_long_edge_then_the_small_left_edge() {
let mut s = knife_edge_part();
@@ -1795,7 +1798,7 @@ fn fillet_the_long_edge_then_the_small_left_edge() {
run(&mut s, "solid.fillet", json!({"edges": [[0.0, -21.0, 5.0]], "radius": 2}));
let one_by_one = before - planned(&s);
let mut s = knife_edge_part();
- run(&mut s, "solid.fillet", json!({"edges": [[20.0, -21.0, 10.0], [0.0, -21.0, 5.0]], "radius": 2}));
+ run(&mut s, "solid.fillet", json!({"edges": [[20.0, -21.0, 10.0], [0.0, -21.0, 5.0], [0.0, -10.0, 10.0]], "radius": 2}));
let together = before - planned(&s);
// Within the display meshes' accuracy (the two are built of different faces).
assert!(rel(one_by_one, together) < 2e-4, "one by one {one_by_one} vs together {together}");
diff --git a/crates/kernel/src/blend_corner.rs b/crates/kernel/src/blend_corner.rs
index 6adf0666e7..cdaec4f8dd 100644
--- a/crates/kernel/src/blend_corner.rs
+++ b/crates/kernel/src/blend_corner.rs
@@ -223,12 +223,17 @@ mod tests {
#[test]
fn three_rounds_at_a_corner() {
let (bx, a, b, c) = setup();
- // Two rounds meeting in a mitre, then the third edge: a sphere octant.
+ // Two rounds meeting in a mitre, then the third edge with its tangent chain, as the Fillet
+ // feature asks for it (84bd2daad): the mitre's seam leaves c's end along c, so the chain
+ // is c and the seam, and the corner is a sphere octant. The cube less its three rounds
+ // (each (1 − π/4) r² over its 18 mm straight part) and the corner's 2 mm cube less the
+ // octant (r³ (1 − π/6)).
let ab = fillet(&bx, &[a, b], 2.0).unwrap();
- let r = fillet(&ab, &[c], 2.0).unwrap();
+ let r = fillet(&ab, &crate::tangent_chain(&ab, &[c]).unwrap(), 2.0).unwrap();
let sphere = 8000.0 - 3.0 * (1.0 - std::f64::consts::FRAC_PI_4) * 4.0 * 18.0 - 8.0 * (1.0 - std::f64::consts::PI / 6.0);
assert_eq!(r.face_count(), 10);
- assert!((vol(&r) - sphere).abs() < 0.05, "{} vs {sphere}", vol(&r));
+ assert!(r.validity().is_empty(), "{:?}", r.validity());
+ assert!((vol(&r) - sphere).abs() < 1e-11 * sphere, "{} vs {sphere}", vol(&r));
assert!(kink(&r) < 0.01);
// Different radii: a smooth patch over the corner, slightly more than the strips take.
for (rs, sel) in [((2.0, 2.0, 3.0), fillet(&ab, &[c], 3.0)), ((2.0, 3.0, 4.0), fillet_radii(&bx, &[(a, 2.0), (b, 3.0), (c, 4.0)]))] {
diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs
index 7e8be3d44c..534322e7fb 100644
--- a/crates/kernel/src/tests.rs
+++ b/crates/kernel/src/tests.rs
@@ -738,10 +738,11 @@ fn tapered_extrude_between_with_a_foot() {
);
}
-/// A taper steeper than a profile's details is refused, and says why: a slot narrower than the
-/// taper closes; a ring's hole smaller than it closes.
+/// A taper steeper than a profile's details: a slot narrower than the taper closes partway up
+/// and the solid builds, the slot's walls meeting above where its end wall closes to a point; a
+/// ring's hole smaller than the taper closes the whole hole and is refused, saying why.
#[test]
-fn tapered_extrude_refuses_a_taper_steeper_than_the_details() {
+fn tapered_extrude_closes_a_narrow_slot_and_refuses_a_closing_hole() {
let slot = Loop2::polygon(&[
Vec2::new(0.0, 0.0),
Vec2::new(10.0, 0.0),
@@ -752,9 +753,18 @@ fn tapered_extrude_refuses_a_taper_steeper_than_the_details() {
Vec2::new(4.9, 10.0),
Vec2::new(0.0, 10.0),
]);
- let e = extrude_tapered(&Plane::XY, &Region2 { outer: slot, holes: vec![] }, 2.0, 1.0, 10f64.to_radians(), crate::DraftCorner::default())
- .unwrap_err();
- assert!(e.to_string().contains("the taper closes the profile"), "{e}");
+ let a = 10f64.to_radians();
+ let b = extrude_tapered(&Plane::XY, &Region2 { outer: slot, holes: vec![] }, 2.0, 1.0, a, crate::DraftCorner::default()).unwrap();
+ assert!(b.validity().is_empty(), "{:?}", b.validity());
+ // Every wall moves out of the material by z·t at height z (t = tan 10°): the 10 mm square
+ // grows to 10 + 2zt, so the solid without the slot is ∫₀² (10 + 2zt)² dz
+ // = ((10 + 4t)³ − 1000) / (6t). The slot narrows to 0.2 − 2zt, its length staying 8 (its end
+ // wall and the square's side both move up by zt), and it closes at z = 0.1/t (0.567, below
+ // the top): it takes ∫ 8 (0.2 − 2zt) dz over 0..0.1/t = 0.08/t.
+ let t = a.tan();
+ let v = ((10.0 + 4.0 * t).powi(3) - 1000.0) / (6.0 * t) - 0.08 / t;
+ let m = measure(&b).unwrap();
+ assert!(rel(m.volume, v) < 1e-6, "{} vs {v}", m.volume);
let ring = Region2 { outer: Loop2::circle(Vec2::ZERO, 5.0), holes: vec![Loop2::circle(Vec2::ZERO, 0.3).reversed()] };
let e = extrude_tapered(&Plane::XY, &ring, 2.0, 1.0, 10f64.to_radians(), crate::DraftCorner::default()).unwrap_err();
assert!(e.to_string().contains("the taper closes the profile"), "{e}");
diff --git a/crates/smlib/src/ffi/sweeps.rs b/crates/smlib/src/ffi/sweeps.rs
index 0a21a893eb..9da3b75f6e 100644
--- a/crates/smlib/src/ffi/sweeps.rs
+++ b/crates/smlib/src/ffi/sweeps.rs
@@ -16,7 +16,7 @@ use super::{ERR_ARG, RawBrep, new_brep};
pub const CURVE_LINE: i64 = 1;
pub const CURVE_ARC: i64 = 2;
pub const CURVE_NURBS: i64 = 3;
-pub const CURVE_MAX_CURVES: usize = 4096;
+pub const CURVE_MAX_CURVES: usize = 16_384;
pub const CURVE_MAX_DEGREE: usize = 25;
pub const CURVE_MAX_POINTS: usize = 100_000;