Wave 337/509: Tests: interference lists the pair of a solid and an imported mesh as not checked (and 3 more)
4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop. - 4a94a025c jyviko: Tests: freezing rebuilt arc borders gets its rebuild from a notch across the arc - 5cbfbe35d jyviko: Tests: interference lists the pair of a solid and an imported mesh as not checked - 5489599c0 jyviko: Tests: a face with no attachment is a rib's wall, whose feature reports no roles - f5dfb78ee jyviko: kernel: a cut's tool face blocks a planar role only where it enters the result Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
@@ -235,21 +235,40 @@ fn interference_finds_a_peg_overlapping_a_small_rib() {
|
||||
assert!((lo[0].as_f64().unwrap_or(0.0) - 19.7).abs() < 1e-6 && (hi[0].as_f64().unwrap_or(0.0) - 19.85).abs() < 1e-6, "{i}");
|
||||
}
|
||||
|
||||
/// An arc revolved up to a post ends on the post's wall, where the two bodies can't be
|
||||
/// intersected: the pair is listed as unchecked instead of passing as clear.
|
||||
/// A pair interference can't check is listed as unchecked, with its reason, instead of passing
|
||||
/// as clear. Truck could not intersect an arc revolved up to a post's wall; SMLib does, exactly,
|
||||
/// so the pair that can't be checked is now an imported mesh beside a solid.
|
||||
#[test]
|
||||
fn interference_lists_a_pair_it_could_not_check() {
|
||||
// A quarter ring revolved round z through the post, brought in as an imported mesh (an STL
|
||||
// of it): a mesh body has no exact surfaces to intersect, so its pair with the post is listed
|
||||
// as not checked, with the reason, rather than read as clear.
|
||||
let dir = std::env::temp_dir().join(format!("solidcraft-unchecked-pair-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let stl = dir.join("arc.stl");
|
||||
let mut source = Session::default();
|
||||
run(&mut source, "sketch.create", json!({"name": "Profile", "plane": "XZ"}));
|
||||
run(&mut source, "sketch.rectangle.two_point", json!({"p0": [10, 0], "p1": [15, 5]}));
|
||||
run(&mut source, "sketch.finish", json!({}));
|
||||
run(
|
||||
&mut source,
|
||||
"solid.revolve",
|
||||
json!({"sketch": "Profile", "axis": {"origin": [0, 0, 0], "dir": [0, 0, 1]}, "angle": "90 deg", "body_name": "Arc"}),
|
||||
);
|
||||
run(&mut source, "file.export", json!({"path": stl.to_string_lossy()}));
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.cylinder", json!({"base": [0, 14, -5], "radius": 4, "height": 15, "body_name": "Post"}));
|
||||
run(&mut s, "sketch.create", json!({"name": "Profile", "plane": "XZ"}));
|
||||
run(&mut s, "sketch.rectangle.two_point", json!({"p0": [10, 0], "p1": [15, 5]}));
|
||||
run(&mut s, "sketch.finish", json!({}));
|
||||
run(&mut s, "solid.revolve", json!({"sketch": "Profile", "axis": {"origin": [0, 0, 0], "dir": [0, 0, 1]}, "to": [4, 14, 2], "body_name": "Arc"}));
|
||||
run(&mut s, "file.insert_mesh", json!({"path": stl.to_string_lossy()}));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
let mesh: Vec<String> = s.world_state().unwrap().bodies.iter().filter(|b| b.body.is_mesh()).map(|b| b.name.clone()).collect();
|
||||
assert_eq!(mesh.len(), 1, "{mesh:?}");
|
||||
let i = run(&mut s, "inspect.interference", json!({}));
|
||||
assert_eq!(i["count"], 0, "{i}");
|
||||
let unchecked = i["unchecked"].as_array().cloned().unwrap_or_default();
|
||||
assert_eq!(unchecked.len(), 1, "{i}");
|
||||
assert!(unchecked[0]["reason"].as_str().is_some_and(|r| r.starts_with("not verified") && !r.contains("displacement")), "{i}");
|
||||
assert_eq!(unchecked[0]["a"].as_str(), mesh.first().map(String::as_str), "{i}");
|
||||
assert_eq!(unchecked[0]["reason"], "mesh body: not checked", "{i}");
|
||||
// Bodies that are clear of each other, or overlap plainly, leave the list empty.
|
||||
let mut s = two_cubes();
|
||||
let i = run(&mut s, "inspect.interference", json!({}));
|
||||
|
||||
@@ -75,11 +75,26 @@ fn explicit_rebind_preserves_geometry_dimensions_context_and_one_undo() {
|
||||
#[test]
|
||||
fn unsupported_face_has_explicit_fixed_alternative_and_no_live_projection() {
|
||||
let mut s = Session::default();
|
||||
// A top half Offset Face raised: no construction certificate and no exact history name yet.
|
||||
run(&mut s, "solid.box", json!({"length":40,"width":30,"height":20,"body_name":"Base"}));
|
||||
run(&mut s, "solid.split_face", json!({"faces":[[10,15,20]],"plane":{"origin":[20,0,0],"normal":[1,0,0]}}));
|
||||
run(&mut s, "solid.offset_face", json!({"faces":[[10,15,20]],"distance":5}));
|
||||
let mut pick = top_pick(&s, "Base");
|
||||
// A rib's wall: a rib reports no roles for the faces it builds (Traced::unnamed), so the
|
||||
// wall has no construction certificate and no exact history name to attach by.
|
||||
run(&mut s, "solid.box", json!({"length":40,"width":20,"height":5,"corner":[0,0,0],"body_name":"L"}));
|
||||
run(&mut s, "solid.box", json!({"length":5,"width":20,"height":40,"corner":[0,0,0],"operation":"join"}));
|
||||
run(&mut s, "sketch.create", json!({"plane":{"origin":[0,10,0],"x_dir":[1,0,0],"y_dir":[0,0,1]},"name":"RibSketch"}));
|
||||
run(&mut s, "sketch.line", json!({"points":[[5,25],[25,5]],"ids":["l1"]}));
|
||||
run(&mut s, "sketch.finish", json!({}));
|
||||
run(&mut s, "solid.rib", json!({"sketch":"RibSketch","curves":["l1"],"thickness":4}));
|
||||
let mut pick = {
|
||||
let world = s.world_state().unwrap();
|
||||
let body = world.body("L").unwrap();
|
||||
let face = body
|
||||
.body
|
||||
.faces(0.01)
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.find(|face| face.plane_normal.is_some_and(|n| n.dot(Vec3::Y) > 0.999) && (face.centroid.y - 12.0).abs() < 1e-6)
|
||||
.unwrap();
|
||||
json!({"body":"L","index":face.index,"face":[face.centroid.x,face.centroid.y,face.centroid.z]})
|
||||
};
|
||||
let before = s.doc.to_json();
|
||||
let error = s.execute("sketch.create", &json!({"plane":pick})).unwrap_err();
|
||||
assert!(error.to_string().contains("fixed"), "{error}");
|
||||
@@ -353,6 +368,10 @@ fn freezing_rebuilt_arc_borders_keeps_authored_dimension_entity_indices() {
|
||||
run(&mut s, "sketch.line", json!({"points":[format!("{arc}.end"),format!("{arc}.start")],"infer":false}));
|
||||
run(&mut s, "sketch.finish", json!({}));
|
||||
run(&mut s, "solid.extrude", json!({"sketch":profile,"distance":10,"operation":"new","body_name":"Sector"}));
|
||||
// A notch clear of the sector until `notch` moves it across the arc at 90°: then the top face's
|
||||
// arc border is rebuilt in two arcs and the notch's sides.
|
||||
run(&mut s, "parameters.add", json!({"name":"notch","expression":"30 mm"}));
|
||||
run(&mut s, "solid.box", json!({"corner":["-1 mm","notch","-1 mm"],"length":2,"width":2,"height":12,"operation":"cut","targets":["Sector"]}));
|
||||
let pick = top_pick(&s, "Sector");
|
||||
let id = run(&mut s, "sketch.create", json!({"plane":pick}))["sketch"].as_u64().unwrap();
|
||||
let circle = run(&mut s, "sketch.circle.center", json!({"center":[20,20],"radius":2}))["curves"][0].as_str().unwrap().to_owned();
|
||||
@@ -360,7 +379,8 @@ fn freezing_rebuilt_arc_borders_keeps_authored_dimension_entity_indices() {
|
||||
run(&mut s, "sketch.finish", json!({}));
|
||||
let before_count = s.model.state().sketch(id).unwrap().sketch.curves.len();
|
||||
run(&mut s, "parameters.change", json!({"name":"turn","expression":"300 deg"}));
|
||||
assert!(s.model.result(id).unwrap().error.is_none());
|
||||
run(&mut s, "parameters.change", json!({"name":"notch","expression":"9 mm"}));
|
||||
assert!(s.model.result(id).unwrap().error.is_none(), "{:?}", s.model.result(id).unwrap().error);
|
||||
let visible = s.model.state().sketch(id).unwrap().sketch.clone();
|
||||
assert_ne!(visible.curves.len(), before_count, "fixture must rebuild projected topology");
|
||||
let mut pick = top_pick(&s, "Sector");
|
||||
|
||||
@@ -225,9 +225,13 @@ impl Body {
|
||||
let mapped = guard("exact planar support lineage", || {
|
||||
let mut competing = Vec::new();
|
||||
for plane in blocker.map(actual_planes).transpose()?.into_iter().flatten().flatten() {
|
||||
// A tool face blocks a face on its plane facing either way.
|
||||
// A cut's tool face enters the result turned round (the wall of the hollow it
|
||||
// leaves), so it competes only with a face on its plane facing against it: a
|
||||
// pocket's floor, or a target face the tool sat on from outside. A tool face that
|
||||
// faces the same way as the target's face on its plane (a pocket cut down from a
|
||||
// cap, its top on the cap) is the tool's own outside and leaves the cap the cap.
|
||||
let opposing = Plane::new(plane.origin, plane.x, -plane.y).ok_or_else(|| KernelError::Invalid("invalid opposing plane".into()))?;
|
||||
competing.extend([plane, opposing]);
|
||||
competing.push(opposing);
|
||||
}
|
||||
competing.sort_by(|a, b| a.normal().x.total_cmp(&b.normal().x));
|
||||
let mut candidates = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user