mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-03 02:25:55 +00:00
Placement tests: a body mirrored in SMLib reads back from its record valid
Since an operation's result is its record (f11c0c571), a mirrored body is
SMLib's transform read back from SMLib's export, and two SMLib defects there
made it invalid: a mirrored cylinder came back inside out the wrong way
(SmCylinder::IsNurbSurfaceCylinder; its edges 10 to 30 mm off the surface),
and every edge's own tolerance was reset to the body's (SmBrep::Transform).
Both are fixed in SMLib (fix/mirrored-cylinder-from-nurbs e02e63e, c603293,
with e008e82 for a scaled body without vertices);
this test needs the SMLib pin moved past them.
A plate with a through hole and a box with two rounds meeting at a corner,
mirrored in x = 30 and read back from their records: SMLib finds both valid
and their volumes are the originals'.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -73,3 +73,25 @@ fn periodic_step_seam_survives_identity_rotation_and_translation() {
|
||||
assert_topology(body, &rigid, [[0., 1., 0., 0.], [-1., 0., 0., 0.], [0., 0., 1., 0.], [10., 10., 30., 1.]]);
|
||||
assert_eq!(crate::step_export(&[body], "source snapshot").unwrap(), unchanged);
|
||||
}
|
||||
|
||||
/// A body mirrored in SMLib reads back from its record as the same valid solid: a plate with a
|
||||
/// through hole (the hole's cylinder comes out inside out) and a box with two rounds meeting at a
|
||||
/// corner (their intersection edge has a tolerance of its own, wider than the body's). Read back
|
||||
/// from the record, the hole's cylinder swept the wrong way about its axis 30 mm off its NURBS,
|
||||
/// and the rounds' shared edge lost its tolerance to the body's.
|
||||
#[test]
|
||||
fn mirrored_bodies_read_back_from_their_records_valid() {
|
||||
let plate = crate::box_solid(Vec3::ZERO, Vec3::new(30., 40., 20.)).unwrap();
|
||||
let hole = crate::cylinder(Vec3::new(20., 20., -5.), Vec3::Z, 5.0, 30.0).unwrap();
|
||||
let holed = crate::boolean(&plate, &hole, crate::BoolOp::Cut).unwrap().unwrap();
|
||||
let rounded = crate::fillet(&plate, &[Vec3::new(15., 0., 20.), Vec3::new(0., 0., 10.)], 3.0).unwrap();
|
||||
// The mirror in x = 30.
|
||||
let mirror = [[-1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [60., 0., 0., 1.]];
|
||||
for (what, body) in [("holed plate", holed), ("rounded box", rounded)] {
|
||||
let mirrored = transform_matrix(&body, mirror).unwrap();
|
||||
let read_back = Body::from_record(mirrored.record().clone()).unwrap();
|
||||
assert!(matches!(crate::validity(&read_back).smlib, Some(crate::SmlibCheck::Valid)), "{what}: {:?}", crate::validity(&read_back).smlib);
|
||||
let (want, got) = (crate::measure(&body).unwrap().volume, crate::measure(&read_back).unwrap().volume);
|
||||
assert!((got - want).abs() < 1e-6 * want, "{what}: volume {got}, expected {want}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user