perf: pattern joins skip pushing apart faces that don't meet (#437)

Pattern copies of a post joined to a body already holding the original post had
their tops in its plane, so every join first pushed faces apart (about 190 ms,
then discarded). Faces now coincide only where their boxes meet, the push-apart
retry runs once per boolean instead of twice, and splitting prism outlines skips
the sampled arc projection for points off the arc's circle.
Sensor enclosure evaluation: 3.07 s -> 1.63 s, same bodies.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Irakli KourtisandClaude Opus 5.5 authored and GitHub committed 2026-10-12 19:35:43 -04:00
1 parent 0d995c6a78
commit 01bf0e4eaf
6 files changed
+110 -52

No files matched your search

+17
View File
@@ -116,3 +116,20 @@ fn unproved_curved_boundary_between_clear_endpoints_refuses_recut() {
assert!(crate::bore_guard::boundaries_clear(&body, &[], Vec3::ZERO, Vec3::Z, 5., 14., 24., 1e-6).is_none());
assert_eq!(step_export(&[&body], "curved source").unwrap(), before);
}
/// Posts sunk into one floor have their tops in a common plane but apart: they don't
/// coincide, so joining another post doesn't go through pushing faces apart (#261).
#[test]
fn coplanar_faces_apart_from_each_other_do_not_coincide() {
let floor = box_solid(Vec3::new(0., 0., 0.), Vec3::new(80., 60., 2.)).unwrap();
let post = |x: f64| cylinder(Vec3::new(x, 30., 1.), Vec3::Z, 3., 6.).unwrap();
let with_one = boolean(&floor, &post(10.), BoolOp::Union).unwrap().unwrap();
assert!(crate::coplanar::coincident_planes(&with_one, &post(60.)).is_empty());
assert!(crate::coplanar::boolean_apart(&with_one, &post(60.), BoolOp::Union).is_none());
// A post over the first one's top does meet it there.
assert!(!crate::coplanar::coincident_planes(&with_one, &cylinder(Vec3::new(12., 30., 7.), Vec3::Z, 3., 6.).unwrap()).is_empty());
let joined = boolean(&with_one, &post(60.), BoolOp::Union).unwrap().unwrap();
let v = joined.tessellate_with(1e-3, true).unwrap().measure().volume;
let expected = 80. * 60. * 2. + 2. * std::f64::consts::PI * 9. * 5.;
assert!((v - expected).abs() < 0.5, "volume {v}, expected {expected}");
}