Fold: with no fixed side the larger side stays, whichever side of the line it is on (the side areas were measured from the wrong point for one side; QA s22)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
1 parent
2ef7f908b0
commit
b2d0452656
2 files changed
+19
-1
No files matched your search
@@ -953,7 +953,8 @@ impl SheetBody {
|
||||
let mut n = Vec2::new(-d.y, d.x);
|
||||
let l0 = a2.dot(n);
|
||||
// Which side moves. A flange keeps the side its own bend is on.
|
||||
let side_area = |n: Vec2| signed_area(&clip(&pts, n * l0, n)).abs();
|
||||
let on_line = n * l0;
|
||||
let side_area = |m: Vec2| signed_area(&clip(&pts, on_line, m)).abs();
|
||||
let moves_n = match (panel, fixed) {
|
||||
(Some(j), _) => {
|
||||
let f = self.flanges.get(j).ok_or_else(|| DocError::Invalid("flange".into()))?;
|
||||
|
||||
@@ -327,3 +327,20 @@ fn flange_edges_are_named_and_follow_the_base_sketch() {
|
||||
let h = s.doc.find_feature("H").cloned().unwrap();
|
||||
assert!(h.edge_names[0].starts_with(&format!("F{id}.0:far")), "{:?}", h.edge_names);
|
||||
}
|
||||
|
||||
/// With no fixed side, the larger side stays whichever side of the line it is on (QA s22).
|
||||
#[test]
|
||||
fn fold_keeps_the_larger_side_either_way() {
|
||||
for (w, line, moving_right) in [(60.0, 40.0, true), (100.0, 40.0, false)] {
|
||||
let mut s = Session::default();
|
||||
base(&mut s, w, 40.0);
|
||||
run(&mut s, "SheetMetalFoldCmd", json!({"points": [[line, 0, 2.5], [line, 40, 2.5]]}));
|
||||
let b = bbox(&mut s);
|
||||
let (x0, x1) = (b["min"][0].as_f64().unwrap_or(0.0), b["max"][0].as_f64().unwrap_or(0.0));
|
||||
if moving_right {
|
||||
assert!(x0.abs() < 1e-6 && x1 < line + 5.0, "the left (larger) part stays: {b}");
|
||||
} else {
|
||||
assert!((x1 - w).abs() < 1e-6 && x0 > line - 5.0, "the right (larger) part stays: {b}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user