Hem: the direction arrow points the way the hem builds (#4794) (#4836)

* claim: #4794

* Hem: the direction arrow points the way the hem builds (#4794)

The Hem dialog shared the edge flange's arrow, which points out of the
sheet's larger neighbouring face. A hem folds back the other way, so the
arrow pointed away from the material it adds. Flip the hem's arrow so it
matches the geometry; edge flanges keep theirs.

A regression test compares the arrow with the side the finished hem adds
material on, for both Flip states, top and bottom edge picks, and both
dialog layouts.
This commit is contained in:
raykholo
2026-10-23 13:44:17 +00:00
committed by GitHub
parent e33c371e99
commit 4c8ae5d078
2 changed files with 30 additions and 2 deletions
+3 -2
View File
@@ -716,11 +716,12 @@ pub fn for_feature(app: &SolveApp, kind: &FeatureKind) -> Option<(Kind, Vec<SelI
// ---- view ----
/// The direction an edge flange or hem grows from its first edge: out of the sheet's larger
/// neighbouring face (flipped with Flip).
/// neighbouring face for a flange, toward it for a hem (flipped with Flip).
pub fn arrow(app: &SolveApp, d: &Dialog) -> Option<Vec3> {
let Kind::Sheet(k) = &d.kind else { return None };
let flip = match k {
Sm::Flange { ty: 1, flip, .. } | Sm::Hem { flip, .. } => *flip,
Sm::Flange { ty: 1, flip, .. } => *flip,
Sm::Hem { flip, .. } => !flip,
_ => return None,
};
let Sel::Edge { body, index, point } = d.inputs.first()?.items.first()? else { return None };
+27
View File
@@ -69,6 +69,33 @@ fn flange_follows_the_picks() {
}
}
#[test]
fn hem_arrow_points_to_the_side_the_hem_builds_on() {
for mode in [crate::shell::LayoutMode::Floating, crate::shell::LayoutMode::Docked] {
for z in [0.0, 2.5] {
for flipped in [false, true] {
let mut app = plate(mode);
app.run("sheet.flange", json!({"sketch": "Base"})).unwrap();
let body = app.session.model.state().sheets[0].body.clone();
let before = app.session.world_state().body(&body).unwrap().mesh().bounds();
app.session.selection = vec![edge_sel(&app.session, Vec3::new(50.0, 0.0, z)).unwrap()];
app.start("sheet.hem");
let mut d = app.dialog.clone().unwrap();
let Kind::Sheet(Sm::Hem { flip, .. }) = &mut d.kind else { panic!("hem dialog") };
*flip = flipped;
let direction = arrow(&app, &d).unwrap();
let commands = apply_commands(&app, &d).unwrap();
run_all(&mut app, commands);
let after = app.session.world_state().body(&body).unwrap().mesh().bounds();
assert!(
direction.dot(after.center() - before.center()) > 1e-6,
"the arrow must point toward the added hem: z={z}, flip={flipped}, arrow={direction:?}, before={before:?}, after={after:?}"
);
}
}
}
}
/// Hem takes edges and an optional gap; rules make and pick a rule with its expressions.
#[test]
fn hem_and_rules() {