SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Delete Face asks for its faces instead of failing (#2167) (#3296)
rlartot689038d187a9
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rsindex a815204a58..89a5b5e1fe 100644--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@ -232,6 +232,8 @@ pub enum Kind {},/// Move planar faces onto a target plane or face.ReplaceFace,+ /// Take faces off a body; the neighbouring faces close the gap (#2167).+ DeleteFaces,/// Boundary Fill: the cells the tool bodies make (a point inside, a description, filled/// or not), found again when the tools change.BoundaryFill {@@ -576,6 +578,7 @@ impl Dialog {Kind::ReplaceFace,vec![SelInput::new("Faces", PLANAR_FACES, true), SelInput::new("Target", PLANES | PLANAR_FACES, false)],),+ "face.delete" => Dialog::new(Kind::DeleteFaces, vec![SelInput::new("Faces", FACES, true)]),"solid.boundary_fill" => {Dialog::new(Kind::BoundaryFill { operation: 0, cells: Vec::new(), of: Vec::new() }, vec![SelInput::new("Tools", BODIES, true)])}@@ -878,6 +881,7 @@ impl Dialog {| Kind::Rib { .. }| Kind::Emboss { .. }| Kind::ReplaceFace+ | Kind::DeleteFaces| Kind::Align { .. }| Kind::Remove| Kind::PathPattern { .. }@@ -1505,6 +1509,7 @@ fn title(k: &Kind) -> &'static str {Kind::Rib { web: true, .. } => "WEB",Kind::Emboss { .. } => "EMBOSS",Kind::ReplaceFace => "REPLACE FACE",+ Kind::DeleteFaces => "DELETE FACE",Kind::Align { .. } => "ALIGN",Kind::BoundaryFill { .. } => "BOUNDARY FILL",Kind::Remove => "REMOVE",@@ -2835,7 +2840,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {enter |= field(ui, t);ui.end_row();}- Kind::Split | Kind::ReplaceFace | Kind::Remove | Kind::Midplane | Kind::Construct { t: None, .. } => {}+ Kind::Split | Kind::ReplaceFace | Kind::DeleteFaces | Kind::Remove | Kind::Midplane | Kind::Construct { t: None, .. } => {}Kind::MeshConvert { tolerance } => {row_label(ui, "Tolerance");enter |= field(ui, tolerance);@@ -4247,6 +4252,10 @@ fn dialog_commands(app: &SolveApp, d: &Dialog) -> Result<Vec<(String, Value)>, S}("solid.replace_face", p)}+ Kind::DeleteFaces => {+ need(0, "faces")?;+ ("face.delete", json!({"faces": face_points(0)}))+ }Kind::Align { flip } => {need(0, "bodies")?;need(1, "what to move from")?;@@ -5589,6 +5598,17 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option<usize>) -> Option<Dia}d}+ FeatureKind::DeleteFace { faces, body, heal } => {+ let mut d = start("face.delete")?;+ if let Some(inp) = d.inputs.first_mut() {+ inp.items = faces.iter().filter_map(|p| face_sel(s, p.0)).collect();+ }+ if let Some(b) = body {+ d.extra.insert("body".into(), json!(b));+ }+ d.extra.insert("heal".into(), json!(heal));+ d+ }FeatureKind::Remove { bodies } => {let mut d = start("solid.remove")?;if let Some(inp) = d.inputs.first_mut() {diff --git a/crates/ui-egui/src/preselect_tests.rs b/crates/ui-egui/src/preselect_tests.rsindex c1d0a8af89..5f6ef61720 100644--- a/crates/ui-egui/src/preselect_tests.rs+++ b/crates/ui-egui/src/preselect_tests.rs@@ -1946,6 +1946,37 @@ fn every_construct_tool_opens_a_dialog_instead_of_failing() {}}+/// #2167: Delete Face asks for its faces instead of failing with "`faces` must be a list of+/// points or face names". Started with nothing selected it opens a dialog; with a face picked+/// first it takes that face, and OK takes the fillet off.+#[test]+fn delete_face_asks_for_faces_and_takes_the_preselected_one() {+ let mut h = crate::scenario::Harness::new();+ h.app.run("solid.box", json!({"length":40,"width":30,"height":20,"body_name":"B"})).unwrap();+ h.app.run("solid.fillet", json!({"edges":[[40,15,20]],"radius":5})).unwrap();+ let volume = |h: &crate::scenario::Harness| h.app.session.world_state().body("B").unwrap().mesh().measure().volume;+ let filleted = volume(&h);++ h.app.session.selection.clear();+ h.app.start("face.delete");+ h.frames(1);+ let status = h.app.status.as_ref().map(|s| s.0.clone()).unwrap_or_default();+ assert!(!status.contains("must be a list"), "{status}");+ assert!(h.app.dialog.as_ref().is_some_and(|d| !d.inputs.is_empty()), "Delete Face opens a dialog that asks for faces");+ crate::dialogs::cancel(&mut h.app);++ // A point on the fillet's surface, 45 degrees round from its axis (35, y, 15).+ let r = 5.0 * std::f64::consts::FRAC_1_SQRT_2;+ let point = Vec3::new(35.0 + r, 15.0, 15.0 + r);+ h.app.session.selection = vec![crate::dialogs::face_sel(&h.app.session, point).expect("the fillet face")];+ h.app.start("face.delete");+ h.frames(1);+ assert_eq!(h.app.dialog.as_ref().unwrap().inputs[0].items.len(), 1, "the selected face fills the input");+ h.step(&json!({"key":"Enter"})).unwrap();+ assert!(h.app.dialog.is_none(), "{:?}", h.app.dialog.as_ref().and_then(|d| d.error.clone()));+ assert!(volume(&h) > filleted + 1.0, "the rounded edge is square again");+}+/// #2494: two planes selected first, Axis Through Two Planes takes both and makes the axis/// where they meet.#[test]