- placement: a rigid placement moves the record and nothing else (regions, shells, loops with their pcurves, edges and their uses equal; every vertex moved; the identity's history), on a cylinder whose wall's loop uses its seam twice. - issue 2005, 616, 674, 1038, 1510, join between caps, regularization protection, history, mesh memo, display mesh: the truck reads become record reads (shells closed by edge uses, faces by the record's surfaces, vertices by the record's points, the mesher's own boundary budget); the nearly-in-plane slab of 1510 is an extruded record body. - Deleted, testing internals that are gone: issue 616's glue_joins_every_face_the_pieces_share (coplanar::glue) and the_retry_guard_refuses_changes_away_from_the_tool (boolean_guard::check_retry); issue 674's partial_contact_does_not_join_tangent_or_separated_faces (coplanar::imprint_union); issue 1038's hinted_division_matches_the_search_from_nothing (truck's vendored parameter_division); issue 1510's a_face_close_to_the_plane_but_off_it_is_not_moved (ops::off_plane). The boolean-diagnostics assertions (no retry, no tool nudge) went with capture_boolean_diagnostics; the rest of each test is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017itGh5fpMEousnZ91cYcVt
45 lines
2.4 KiB
Rust
45 lines
2.4 KiB
Rust
//! A join whose tool ends at other levels than the part, both prisms along that direction: a
|
||
//! hinge barrel under a plate's back edge, its ends flush with the sides of the leaf it hangs
|
||
//! from, the plate running on past them (#827 without its fillets). The barrel's ends lie in the
|
||
//! leaf's sides, which the B-rep boolean can't intersect, and there is no room to push them
|
||
//! apart (the plate goes on beyond them). The prisms are joined in 2D, exactly: the barrel is no
|
||
//! longer nudged (moved and turned by a hair) for the boolean to go through.
|
||
|
||
use std::f64::consts::PI;
|
||
|
||
use solidcraft_geom::Vec3;
|
||
|
||
use crate::*;
|
||
|
||
/// A 40 × 20 × 6 plate (z 5 … 11) with a 14 × 10 × 6 leaf under its back edge, 1 mm into it:
|
||
/// 5500 mm³.
|
||
fn plate_with_leaf() -> Body {
|
||
let plate = box_solid(Vec3::new(0., 0., 5.), Vec3::new(40., 20., 11.)).unwrap();
|
||
let leaf = box_solid(Vec3::new(10., 10., 0.), Vec3::new(24., 20., 6.)).unwrap();
|
||
boolean(&plate, &leaf, BoolOp::Union).unwrap().unwrap()
|
||
}
|
||
|
||
/// Barrels along x with their axis on the leaf's back bottom edge (y 20, z 0): radius 5 (its top
|
||
/// meets the plate's back edge) and 4.9, ends flush with both of the leaf's sides, with one, and
|
||
/// running on past both under the plate. A quarter of the barrel lies in the leaf (where the
|
||
/// leaf is). Each join is exact: one solid, and every vertex on a level along x of the
|
||
/// plate, the leaf or the barrel.
|
||
#[test]
|
||
fn a_barrel_between_the_sides_of_a_leaf_joins_exactly() {
|
||
let part = plate_with_leaf();
|
||
for (r, x0, x1) in [(5., 10., 24.), (4.9, 10., 24.), (5., 10., 23.), (5., 8.5, 25.5)] {
|
||
let what = format!("radius {r}, x {x0} … {x1}");
|
||
let barrel = cylinder(Vec3::new(x0, 20., 0.), Vec3::X, r, x1 - x0).unwrap();
|
||
let joined = boolean(&part, &barrel, BoolOp::Union).unwrap().unwrap();
|
||
assert_eq!(joined.shell_count(), 1, "{what}");
|
||
assert!(joined.validity().is_empty(), "{what}: {:?}", joined.validity());
|
||
let inside = (x1.min(24.) - x0.max(10.)) / 4.;
|
||
let want = 5500. + PI * r * r * (x1 - x0 - inside);
|
||
let v = joined.mesh(&crate::MeshTolerance::chord(1e-4)).unwrap().measure().volume;
|
||
assert!((v - want).abs() < want * 1e-5, "{what}: volume {v} vs {want}");
|
||
for p in joined.record().vertices.iter().map(|v| Vec3::from(v.point)) {
|
||
assert!([0., 10., 24., 40., x0, x1].iter().any(|x| (p.x - x).abs() < 1e-9), "{what}: a vertex at {p:?}");
|
||
}
|
||
}
|
||
}
|