mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-03 18:45:55 +00:00
ui, cli tests: probes ask for the exact point class
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NvoxKQ2rEZvcXNQnhE3Sgs
This commit is contained in:
@@ -9,7 +9,7 @@ use solidcraft_engine::geom::Vec3;
|
||||
use crate::scenario::Harness;
|
||||
|
||||
fn solid_at(h: &Harness, p: Vec3) -> bool {
|
||||
h.app.session.model.state().bodies.iter().any(|b| b.body.contains(p))
|
||||
h.app.session.model.state().bodies.iter().any(|b| b.body.classify_point(p).unwrap() == solidcraft_engine::kernel::PointClass::Inside)
|
||||
}
|
||||
|
||||
fn screen(h: &mut Harness, p: Vec3) -> [f64; 2] {
|
||||
|
||||
@@ -67,7 +67,7 @@ fn last_hole(h: &Harness) -> (u64, Vec3) {
|
||||
}
|
||||
|
||||
fn solid_at(h: &Harness, p: Vec3) -> bool {
|
||||
h.app.session.model.state().bodies.iter().any(|b| b.body.contains(p))
|
||||
h.app.session.model.state().bodies.iter().any(|b| b.body.classify_point(p).unwrap() == solidcraft_engine::kernel::PointClass::Inside)
|
||||
}
|
||||
|
||||
const MIDDLE: Vec3 = Vec3::new(20.0, 15.0, 20.0);
|
||||
|
||||
@@ -390,7 +390,7 @@ fn face_places(h: &Harness) -> Vec<(String, Vec3)> {
|
||||
|
||||
/// Whether the model holds material at `p`.
|
||||
fn solid_at(h: &Harness, p: Vec3) -> bool {
|
||||
h.app.session.model.state().bodies.iter().any(|b| b.body.contains(p))
|
||||
h.app.session.model.state().bodies.iter().any(|b| b.body.classify_point(p).unwrap() == solidcraft_engine::kernel::PointClass::Inside)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -61,7 +61,7 @@ fn type_into(h: &mut Harness, handle: &str, text: &str) {
|
||||
|
||||
/// Whether the model holds material at `p`.
|
||||
fn solid_at(h: &Harness, p: Vec3) -> bool {
|
||||
h.app.session.model.state().bodies.iter().any(|b| b.body.contains(p))
|
||||
h.app.session.model.state().bodies.iter().any(|b| b.body.classify_point(p).unwrap() == solidcraft_engine::kernel::PointClass::Inside)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -233,7 +233,7 @@ fn feature_mirror_picks_clear_preview_and_replay_the_source_cut() {
|
||||
h.step(&json!({"until":{"dialog":null,"features":4}})).unwrap();
|
||||
let state = h.app.session.world_state().unwrap();
|
||||
assert_eq!(state.bodies.len(), 1, "a mirrored hole cuts the plate instead of copying it");
|
||||
assert!(!state.bodies[0].body.contains(Vec3::new(70.0, 25.0, 2.5)));
|
||||
assert_eq!(state.bodies[0].body.classify_point(Vec3::new(70.0, 25.0, 2.5)).unwrap(), solidcraft_engine::kernel::PointClass::Outside);
|
||||
let mirror = h.app.session.doc.features.last().unwrap().id;
|
||||
let reopened = crate::dialogs::for_feature(&h.app, mirror, None).unwrap();
|
||||
assert_eq!(reopened.inputs[0].accept, crate::selection::FEATURES);
|
||||
@@ -255,7 +255,7 @@ fn a_face_extrude_keeps_the_picked_body_when_faces_coincide() {
|
||||
let after = app.session.model.state();
|
||||
assert_eq!(after.bodies.len(), 2);
|
||||
assert!(after.body("Other").unwrap().body.same(&before.body("Other").unwrap().body));
|
||||
assert!(after.body("Wall").unwrap().body.contains(Vec3::new(49.0, 15.0, 10.0)));
|
||||
assert_eq!(after.body("Wall").unwrap().body.classify_point(Vec3::new(49.0, 15.0, 10.0)).unwrap(), solidcraft_engine::kernel::PointClass::Inside);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -59,11 +59,15 @@ fn to_object_noop_preserves_cut_targets_and_untargeted_body() {
|
||||
let before_a = cut_volume(&state);
|
||||
let removed = 0.5 * (15.0f64.powi(2) - 10.0f64.powi(2)) * 5.0 * std::f64::consts::FRAC_PI_2;
|
||||
assert!((before_a - (2000.0 - removed)).abs() < 0.2, "cut results {:?}: {before_a}", state.bodies.iter().map(|b| &b.name).collect::<Vec<_>>());
|
||||
let in_cut_stock = |p| state.bodies.iter().filter(|b| b.name != "B").any(|b| b.body.contains(p));
|
||||
let in_cut_stock =
|
||||
|p| state.bodies.iter().filter(|b| b.name != "B").any(|b| b.body.classify_point(p).unwrap() == solidcraft_engine::kernel::PointClass::Inside);
|
||||
assert!(in_cut_stock(solidcraft_engine::geom::Vec3::new(2.0, 2.0, 2.0)));
|
||||
assert!(in_cut_stock(solidcraft_engine::geom::Vec3::new(18.0, 2.0, 18.0)));
|
||||
assert!(!in_cut_stock(solidcraft_engine::geom::Vec3::new(9.0, 2.0, 9.0)));
|
||||
assert!(state.body("B").unwrap().body.contains(solidcraft_engine::geom::Vec3::new(9.0, 2.0, 9.0)));
|
||||
assert_eq!(
|
||||
state.body("B").unwrap().body.classify_point(solidcraft_engine::geom::Vec3::new(9.0, 2.0, 9.0)).unwrap(),
|
||||
solidcraft_engine::kernel::PointClass::Inside
|
||||
);
|
||||
let before_bounds: Vec<_> = state.bodies.iter().map(|b| (b.name.clone(), b.mesh().bounds())).collect();
|
||||
let undo = h.app.session.undo.len();
|
||||
open(&mut h);
|
||||
|
||||
@@ -307,8 +307,8 @@ fn canonical_symmetric_ring_preview_drag_and_reopen_match_material() {
|
||||
let commands = crate::dialogs::apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();
|
||||
let preview = h.app.session.preview_world(&commands).unwrap();
|
||||
let body = &preview.after.body("Main").unwrap().body;
|
||||
assert!(body.contains(solidcraft_engine::geom::Vec3::new(3.0, 5.0, 0.0)));
|
||||
assert!(!body.contains(solidcraft_engine::geom::Vec3::new(0.0, 5.0, 3.0)));
|
||||
assert_eq!(body.classify_point(solidcraft_engine::geom::Vec3::new(3.0, 5.0, 0.0)).unwrap(), solidcraft_engine::kernel::PointClass::Inside);
|
||||
assert_eq!(body.classify_point(solidcraft_engine::geom::Vec3::new(0.0, 5.0, 3.0)).unwrap(), solidcraft_engine::kernel::PointClass::Outside);
|
||||
let bounds = preview.after.body("Main").unwrap().mesh().bounds();
|
||||
assert!((bounds.min.x - 2.0f64.sqrt()).abs() < 0.02 && (bounds.max.x - 4.0).abs() < 0.02, "{bounds:?}");
|
||||
assert!((bounds.min.z + 2.0 * 2.0f64.sqrt()).abs() < 0.02 && (bounds.max.z - 2.0 * 2.0f64.sqrt()).abs() < 0.02);
|
||||
@@ -347,9 +347,12 @@ fn reversed_axis_to_object_canvas_sweep_and_preview_follow_the_quarter_target()
|
||||
let preview = h.app.session.preview_world(&commands).unwrap();
|
||||
let result = preview.after.body("Main").unwrap();
|
||||
assert_eq!(result.mesh().bounds(), before);
|
||||
assert!(result.body.contains(solidcraft_engine::geom::Vec3::new(p, 2.5, p)));
|
||||
assert_eq!(result.body.classify_point(solidcraft_engine::geom::Vec3::new(p, 2.5, p)).unwrap(), solidcraft_engine::kernel::PointClass::Inside);
|
||||
for (x, z) in [(-p, p), (-p, -p), (p, -p)] {
|
||||
assert!(!result.body.contains(solidcraft_engine::geom::Vec3::new(x, 2.5, z)));
|
||||
assert_eq!(
|
||||
result.body.classify_point(solidcraft_engine::geom::Vec3::new(x, 2.5, z)).unwrap(),
|
||||
solidcraft_engine::kernel::PointClass::Outside
|
||||
);
|
||||
}
|
||||
assert!((kernel::measure(&result.body).unwrap().volume - expected_volume(90.0)).abs() < 0.03);
|
||||
h.step(&json!({"widget":"OK"})).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user