smlib: hold back the overflow-first ordering; mitre oracles and two solidcore repros
The ordering (fork 241f7ba) is ported but off (OVERFLOW_GOES_FIRST): solidcore's cliff overflow loses the attributes of target edges its subtraction replaces, so a shortened picked edge reads as removed and is silently not rounded (2 rig cases wrong). Tests: the capi's rounds_at_a_concave_face_corner_are_mitred; overflow_goes_first (ignored, gives 6107.529369565 with it on); two ignored solidcore-only repros. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MNXLXkZLQ6T7TSi4wswcmk
This commit is contained in:
1 parent
8e93872bbb
commit
a7bb27dae5
2 files changed
+141
-1
No files matched your search
@@ -542,6 +542,13 @@ fn picked_on(b: &Brep, e: EdgeId) -> Option<(solidcore::geom::attribute::Attribu
|
||||
a.application_value::<Picked>().map(|p| (h, p.0))
|
||||
}
|
||||
|
||||
/// Whether the rounds that overflow go first ([`overflow_first`]), held back: solidcore's
|
||||
/// `SubtractRemovalRegion` loses the attributes of target edges the subtraction replaces, so a picked
|
||||
/// edge the overflow only shortened reads as removed whole and is silently left unrounded (the rig's
|
||||
/// fillets/5158-fillet-adjacent-plate-edges-as-thick-as-plate, 1706.89 against 1681.90). Off, the
|
||||
/// rounds are blended together, and those that need the order are refused.
|
||||
const OVERFLOW_GOES_FIRST: bool = false;
|
||||
|
||||
/// `overflow_first`: the rounds of [`blend_call`] when blends of several edges overflow their
|
||||
/// faces (`round_edges` stopped in the copy `w` of `body`, `picked` its picked edges, `each` their
|
||||
/// sizes). The blends that overflow on their own (each edge's alone, classified in `w`, which
|
||||
@@ -760,7 +767,7 @@ fn blend_call(
|
||||
// overflow their faces across cliffs and others fit, the overflowing ones are built
|
||||
// first, on a fresh copy, and the others then round what is left of their edges. An edge
|
||||
// the overflow removes whole is gone (`dropped`); one it cuts keeps the rest.
|
||||
let may_go_first = back.is_empty() && open == Corners::Filled && picked.len() > 1;
|
||||
let may_go_first = OVERFLOW_GOES_FIRST && back.is_empty() && open == Corners::Filled && picked.len() > 1;
|
||||
let mut stopped = None;
|
||||
let first = may_go_first.then_some(OverflowFirst { classify_only: false, stopped: &mut stopped });
|
||||
let done = blend_edges_stopping(k, &mut w, &picked, &each, section, None, &back, (open == Corners::Open).then_some(&mut patches), first)?;
|
||||
|
||||
@@ -433,6 +433,7 @@ fn a_cliff_overflow_the_fork_refuses_has_no_room() {
|
||||
/// the back upright that upright's round runs above the R21 cylinder, taking the corner's piece
|
||||
/// over it too (Simpson on 4000 spans, against a bound of its quartic end edge's tolerance).
|
||||
#[test]
|
||||
#[ignore = "core::blend::OVERFLOW_GOES_FIRST is held back: solidcore's cliff overflow loses edge attributes (an_edge_tag_crosses_a_cliff_overflow). Passes with it on: 6107.529369565"]
|
||||
fn overflow_goes_first() {
|
||||
let f = |u: f64| 0.5 * (u * (441.0 - u * u).sqrt() + 441.0 * (u / 21.0).asin());
|
||||
let w = 440f64.sqrt();
|
||||
@@ -459,6 +460,7 @@ fn overflow_goes_first() {
|
||||
native(&to_arrays(&b).unwrap()).unwrap();
|
||||
(volume(&b, 1e-8).unwrap(), d)
|
||||
});
|
||||
println!("overflow first {sizes:?}: {:.9}, expected {want:.9}", got.0);
|
||||
assert_eq!(got.1, dropped, "{sizes:?}");
|
||||
assert!((got.0 - want).abs() <= bound, "{sizes:?}: {} vs {want}", got.0);
|
||||
#[cfg(feature = "native")]
|
||||
@@ -472,6 +474,137 @@ fn overflow_goes_first() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The capi's `rounds_at_a_concave_face_corner_are_mitred` (`fixes.fillet_mitre_concave_face_corners`,
|
||||
/// fork 4f06e72): each edge loses (convex) or gains (concave) the spandrel r²(1 - π/4) along its
|
||||
/// length, and in the quadrant beyond both walls the mitred rounds take or add r³(5/3 - π/2): a
|
||||
/// 60 x 40 x 10 plate's 30 x 20 x 5 pocket rim at r2 (15 faces) and r5 (11), a 60 x 60 x 5 plate's
|
||||
/// 20 x 20 x 15 boss root at r4 (15). And the pocket rim chamfered 5.5, past the pocket's depth:
|
||||
/// 21000 - (50 d² + 4/3 d³).
|
||||
#[test]
|
||||
fn rounds_at_a_concave_face_corner_are_mitred() {
|
||||
let made = |a: Body, b: Body, op| boolean(&a, &b, op).unwrap().unwrap();
|
||||
let pocket =
|
||||
|| made(make_box([0.0; 3], [60.0, 40.0, 10.0]).unwrap(), make_box([15.0, 10.0, 5.0], [30.0, 20.0, 6.0]).unwrap(), BooleanOp::Subtract);
|
||||
let boss = || made(make_box([0.0; 3], [60.0, 60.0, 5.0]).unwrap(), make_box([20.0, 20.0, 5.0], [20.0, 20.0, 15.0]).unwrap(), BooleanOp::Union);
|
||||
let rim = [[30.0, 10.0, 10.0], [30.0, 30.0, 10.0], [15.0, 20.0, 10.0], [45.0, 20.0, 10.0]];
|
||||
let root = [[30.0, 20.0, 5.0], [40.0, 30.0, 5.0], [30.0, 40.0, 5.0], [20.0, 30.0, 5.0]];
|
||||
let want = |v0: f64, length: f64, r: f64, sign: f64| v0 + sign * (length * r * r * (1.0 - PI / 4.0) + 4.0 * r * r * r * (5.0 / 3.0 - PI / 2.0));
|
||||
for (body, edges, r, v, faces) in [
|
||||
(pocket(), rim, 2.0, want(21000.0, 100.0, 2.0, -1.0), 15),
|
||||
(pocket(), rim, 5.0, want(21000.0, 100.0, 5.0, -1.0), 11),
|
||||
(boss(), root, 4.0, want(24000.0, 80.0, 4.0, 1.0), 15),
|
||||
] {
|
||||
let b = blend(&body, Blend::Round, &edges, &[r], 0.1, &[], &[], Corners::Filled).unwrap();
|
||||
native(&to_arrays(&b).unwrap()).unwrap();
|
||||
let got = volume(&b, 1e-12).unwrap();
|
||||
println!("mitred r{r}: {} faces, {got:.9}, expected {v:.9}", counts(&b).unwrap()[0]);
|
||||
assert_eq!(counts(&b).unwrap()[0], faces, "r{r}");
|
||||
assert!(rel(got, v) < 2e-8, "r{r}: {got} vs {v}");
|
||||
}
|
||||
// Through the flat arrays, as bodies reach a blend in the app (pocket_chamfer_on_a_boolean_body).
|
||||
let d = 5.5;
|
||||
let flat = super::from_arrays(&to_arrays(&pocket()).unwrap()).unwrap();
|
||||
let b = blend(&flat, Blend::Chamfer, &rim, &[d], 0.1, &[], &[], Corners::Filled).unwrap();
|
||||
let (got, v) = (volume(&b, 1e-8).unwrap(), 21000.0 - (50.0 * d * d + 4.0 / 3.0 * d * d * d));
|
||||
println!("mitred chamfer {d}: {got:.9}, expected {v:.9}");
|
||||
assert!(rel(got, v) < 1e-8, "{got} vs {v}");
|
||||
}
|
||||
|
||||
/// Solidcore alone: edge attributes across a cliff overflow. A 40 x 30 x 10 block notched below its
|
||||
/// top at (40, 0), its front and right top edges rounded r8 (their rails run off over the notch).
|
||||
/// The back and left top edges are each trimmed 8 by those rounds: (0, 30)-(32, 30) and (0, 8)-(0, 30)
|
||||
/// at z = 10, and each piece keeps its edge's attribute (`Behavior::Copy`), as on the fork.
|
||||
#[test]
|
||||
#[ignore = "solidcore bug: SubtractRemovalRegion loses the attributes of target edges it replaces (next-pin/bugs/cliff-overflow-loses-edge-attributes.md)"]
|
||||
fn an_edge_tag_crosses_a_cliff_overflow() {
|
||||
use solidcore::blend::fillet_executive::session::FilletSession;
|
||||
use solidcore::boolean::api_brep::boolean_difference;
|
||||
use solidcore::geom::attribute::{Attribute, Behavior};
|
||||
use solidcore::primitive::api_primitives::create_box;
|
||||
use solidcore::topology::{Brep, EdgeId, edge, vertex};
|
||||
use solidcore::{EntityRef, Kernel, Point3};
|
||||
fn between(b: &Brep, a: Point3, q: Point3) -> Option<EdgeId> {
|
||||
b.edges().ids().find(|&e| {
|
||||
let (s, t) = edge::start_end_vertices(b, e).unwrap();
|
||||
let (s, t) = (vertex::point(b, s.unwrap()).unwrap(), vertex::point(b, t.unwrap()).unwrap());
|
||||
(s.distance(a) < 1e-6 && t.distance(q) < 1e-6) || (s.distance(q) < 1e-6 && t.distance(a) < 1e-6)
|
||||
})
|
||||
}
|
||||
let p = Point3::new;
|
||||
let mut k = Kernel::default();
|
||||
k.fixes.fillet_refuse_rails_leaving_faces = true;
|
||||
k.fixes.fillet_trace_reaches_rails = true;
|
||||
k.fixes.fillet_rail_end_on_continued_surface = true;
|
||||
k.fixes.fillet_cliff_overflow = true;
|
||||
let block = create_box(&mut k, Point3::ZERO, 40.0, 30.0, 10.0).unwrap();
|
||||
let notch = create_box(&mut k, p(35.0, -1.0, -1.0), 6.0, 6.0, 4.0).unwrap();
|
||||
let mut b = boolean_difference(&mut k, block, notch).unwrap();
|
||||
const ID: u64 = 0x7000_0001;
|
||||
let edge_at = |b: &Brep, a, q| between(b, a, q).unwrap();
|
||||
for (a, q, v) in [(p(0.0, 30.0, 10.0), p(40.0, 30.0, 10.0), 1), (p(0.0, 0.0, 10.0), p(0.0, 30.0, 10.0), 2)] {
|
||||
let e = edge_at(&b, a, q);
|
||||
b.add_attribute(EntityRef::Edge(e), Attribute::long(ID, v, Behavior::Copy)).unwrap();
|
||||
}
|
||||
let rounds = [edge_at(&b, p(0.0, 0.0, 10.0), p(40.0, 0.0, 10.0)), edge_at(&b, p(40.0, 0.0, 10.0), p(40.0, 30.0, 10.0))];
|
||||
let mut s = FilletSession::new(&mut k, &mut b).unwrap();
|
||||
s.prepare_constant_radius_edges(&mut k, &rounds, 8.0, 1, 1, 1.0).unwrap();
|
||||
s.do_fillet(&mut k).unwrap();
|
||||
drop(s);
|
||||
b.refresh_cached_topology();
|
||||
for (a, q, which) in [(p(0.0, 30.0, 10.0), p(32.0, 30.0, 10.0), "back"), (p(0.0, 8.0, 10.0), p(0.0, 30.0, 10.0), "left")] {
|
||||
let e = edge_at(&b, a, q);
|
||||
assert!(b.entity_attributes(EntityRef::Edge(e)).iter().any(|(_, x)| x.attribute_id() == ID), "the {which} edge lost its attribute");
|
||||
}
|
||||
}
|
||||
|
||||
/// Solidcore alone: the pocket rim chamfered 5.5, as `fillet_mitre_concave_face_corners`' own test
|
||||
/// does it, with `keep_operand_uv_trims` on too, on the body the boolean gives:
|
||||
/// 21000 - (50 d² + 4/3 d³) = 19265.666666667 (the fork, and the same body through the flat
|
||||
/// arrays). Refused: error 3, Corner Edge Computation Failure.
|
||||
#[test]
|
||||
#[ignore = "solidcore bug: next-pin/bugs/chamfer-boolean-body-keep-operand-uv-trims.md"]
|
||||
fn pocket_chamfer_on_a_boolean_body() {
|
||||
use solidcore::blend::fillet_executive::session::FilletSession;
|
||||
use solidcore::boolean::api_brep::boolean_difference;
|
||||
use solidcore::primitive::api_primitives::create_box;
|
||||
use solidcore::topology::{EdgeId, edge, vertex};
|
||||
use solidcore::{Kernel, Point3};
|
||||
let p = Point3::new;
|
||||
let mut k = Kernel::default();
|
||||
k.fixes.fillet_refuse_rails_leaving_faces = true;
|
||||
k.fixes.fillet_trace_reaches_rails = true;
|
||||
k.fixes.fillet_rail_end_on_continued_surface = true;
|
||||
k.fixes.fillet_cliff_overflow = true;
|
||||
k.fixes.fillet_mitre_concave_face_corners = true;
|
||||
k.fixes.keep_operand_uv_trims = true;
|
||||
let plate = create_box(&mut k, Point3::ZERO, 60.0, 40.0, 10.0).unwrap();
|
||||
let cut = create_box(&mut k, p(15.0, 10.0, 5.0), 30.0, 20.0, 6.0).unwrap();
|
||||
let mut b = boolean_difference(&mut k, plate, cut).unwrap();
|
||||
let c = [p(15.0, 10.0, 10.0), p(45.0, 10.0, 10.0), p(45.0, 30.0, 10.0), p(15.0, 30.0, 10.0)];
|
||||
let on = |x: Point3, a: Point3, q: Point3| (x.distance(a) < 1e-9 || x.distance(q) < 1e-9);
|
||||
let ids: Vec<EdgeId> = (0..4)
|
||||
.map(|i| {
|
||||
let (a, q) = (c[i], c[(i + 1) % 4]);
|
||||
b.edges()
|
||||
.ids()
|
||||
.find(|&e| {
|
||||
let (s, t) = edge::start_end_vertices(&b, e).unwrap();
|
||||
on(vertex::point(&b, s.unwrap()).unwrap(), a, q) && on(vertex::point(&b, t.unwrap()).unwrap(), a, q) && s != t
|
||||
})
|
||||
.unwrap()
|
||||
})
|
||||
.collect();
|
||||
let mut s = FilletSession::new(&mut k, &mut b).unwrap();
|
||||
s.prepare_constant_radius_edges(&mut k, &ids, 5.5, 0, 1, 1.0).unwrap();
|
||||
let r = s.do_fillet(&mut k);
|
||||
assert!(r.is_ok(), "{} {}", s.error_info().code, s.error_info().comment);
|
||||
drop(s);
|
||||
b.refresh_cached_topology();
|
||||
let v = volume(&Body::new(b), 1e-8).unwrap();
|
||||
let d: f64 = 5.5;
|
||||
assert!(rel(v, 21000.0 - (50.0 * d * d + 4.0 / 3.0 * d * d * d)) < 1e-8, "{v}");
|
||||
}
|
||||
|
||||
/// The corner of r5 rounds at (60, 40, 20) on a 60 x 40 x 20 box, set back 8 and left open: the
|
||||
/// box's six faces and the three rounds (9 faces, 30 edges, 22 vertices), a sheet, and one hole
|
||||
/// of twelve edges (each section and face curve in two), chained end to start, each beside a face
|
||||
|
||||
Reference in new issue
Block a user