A cut ending in a face of its target no longer leaves the hole closed by a skin (#2827)
A cut whose tool ends exactly on a face of the target (a hole cut from a pocket's floor up to the plate's top face) could come out of the general boolean with the target's face whole over the hole and the tool's end face under it: a skin of no thickness that keeps the hole closed. No volume shows it and the sampled membership checks see the hole either way, so the result was kept. The result check now refuses a body with a planar face lying back to back on another of its own planar faces with nothing behind part of it (`coplanar::has_skin`), and the retries take the cut. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -997,3 +997,38 @@ fn prism_edge_in_a_round_cornered_slab_end_face_joins() {
|
||||
assert!((got - (prism + slab - shared)).abs() < 1e-3 * got, "r {r}: {got} vs {}", prism + slab - shared);
|
||||
}
|
||||
}
|
||||
|
||||
/// A cut from a face up to the plate's top face, its tool's end lying in that face: the boolean
|
||||
/// of the bodies as they lie left the hole closed by a skin of no thickness (the plate's top face
|
||||
/// whole over the hole, the tool's end face under it), which no volume shows and which was kept.
|
||||
/// The hole is open, and the cut takes the whole tool: the circle of radius 3.04 the two
|
||||
/// profiles make, from the barrel cut's floor at z 1.6 up to the plate's top at z 2.8.
|
||||
#[test]
|
||||
fn cut_up_to_the_plate_top_face_opens_the_hole() {
|
||||
let mut script: Value = serde_json::from_str(include_str!("../../../examples/regressions/cut_up_to_face_leaves_skin.json")).unwrap();
|
||||
let s = replay_value(&script);
|
||||
assert!(s.model.results.iter().all(|r| r.error.is_none()), "{:?}", s.model.results);
|
||||
let state = s.model.state();
|
||||
let body = &state.body("Body7").unwrap().body;
|
||||
assert!(body.validity().is_empty(), "{:?}", body.validity());
|
||||
let skin: Vec<f64> = body
|
||||
.faces(1e-4)
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.filter(|f| f.plane_normal.is_some_and(|n| n.z < -0.999) && (f.centroid.z - 2.8).abs() < 1e-6)
|
||||
.map(|f| f.area)
|
||||
.collect();
|
||||
assert!(skin.is_empty(), "faces at z 2.8 facing down, areas {skin:?} mm²");
|
||||
// The same design without the cut.
|
||||
script["commands"].as_array_mut().unwrap().pop();
|
||||
let before = replay_value(&script);
|
||||
let fine = |s: &Session| s.model.state().body("Body7").unwrap().body.tessellate(1e-5).unwrap().measure().volume;
|
||||
let (removed, want) = (fine(&before) - fine(&s), std::f64::consts::PI * 3.04 * 3.04 * 1.2);
|
||||
assert!((removed - want).abs() < 0.01, "removed {removed} mm³, want {want}");
|
||||
}
|
||||
|
||||
fn replay_value(script: &Value) -> Session {
|
||||
let mut s = Session::default();
|
||||
s.run_script(script).unwrap();
|
||||
s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user