feat: preserve body history and placed modelling workflows

Record ownership transfers in the timeline so earlier Join/Cut membership,
world placement, machining data and styles survive component moves, edits,
independent copying, undo and reopening. Preserve pending positions in history
snapshots and keep constructor transfers ordered during feature redefinition.

Retain shallow sheet pockets and exact planar intersection islands through
unfold/refold, with depth-aware flat previews and DXF export. Store explicit
3D wire coordinate spaces and migrate known legacy provenance without moving
saved points or analytic fits.

Infer unique eligible cylindrical Emboss targets, align Revolve manipulators
with actual extent geometry, and discard obsolete preview errors after input
correction. Certify constructed and immutable imported face styles using exact
source metadata while preserving legacy face names. Upgrade designs to format10
with bounded validation and geometry-preserving legacy migration.
This commit is contained in:
bherbruck committed 2026-10-11 03:59:12 -04:00
1 parent 0398a813c8
commit c1d819f235
86 files changed
+6011 -488

No files matched your search

+124
View File
@@ -127,6 +127,130 @@ fn flat_exports_use_the_save_picker() {
assert_eq!(picks[1].1, vec!["dxf"]);
}
#[test]
fn shallow_pocket_overlay_labels_depth_without_drawing_a_through_void() {
let mut app = plate();
app.run("sheet.flange", json!({"sketch": "Base"})).unwrap();
app.run("sketch.create", json!({"plane": "XY", "name": "Pocket"})).unwrap();
app.run("sketch.rectangle.two_point", json!({"p0": [20, 20], "p1": [30, 30]})).unwrap();
app.run("sketch.finish", json!({})).unwrap();
app.run("solid.extrude", json!({"sketch": "Pocket", "distance": 1, "operation": "cut"})).unwrap();
let flat = app.session.execute("sheet.flat_pattern", &json!({})).unwrap();
assert_eq!(flat["cutouts"], json!([]));
assert_eq!(flat["pockets"][0]["depth_mm"], 1.0);
app.start("sheet.flat_pattern");
let mut dialog = app.dialog.clone().unwrap();
let Kind::Sheet(Sm::FlatPattern { data, .. }) = &mut dialog.kind else { panic!("flat dialog") };
*data = Some(Ok(flat));
let ctx = egui::Context::default();
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::new("flat-pocket-test")));
assert!(overlay(&painter, Rect::from_min_size(Pos2::ZERO, vec2(1400.0, 900.0)), &dialog));
});
output.textures_delta.clear();
let texts: Vec<&str> = output
.shapes
.iter()
.filter_map(|s| match &s.shape {
egui::Shape::Text(text) => Some(text.galley.text()),
_ => None,
})
.collect();
assert!(texts.contains(&"Bottom pocket: 1 mm deep"));
assert!(texts.contains(&"Pocket boundary (material remains)"));
let paths: Vec<_> = output
.shapes
.iter()
.filter_map(|s| match &s.shape {
egui::Shape::Path(path) => Some(path),
_ => None,
})
.collect();
assert!(!paths.is_empty(), "the retained sheet outline is drawn");
assert!(paths.iter().all(|p| p.fill == Color32::TRANSPARENT), "pockets must not be rendered as filled voids");
let lines = output.shapes.iter().filter(|s| matches!(s.shape, egui::Shape::LineSegment { .. })).count();
assert!(lines > 6, "pocket contours and legend use dashed lines, not through-cut strokes");
}
#[test]
fn flat_pattern_islands_fit_before_the_actual_command_panel() {
let mut app = plate();
app.run("sheet.flange", json!({"sketch": "Base"})).unwrap();
app.run("sketch.create", json!({"plane": "XY", "name": "Retain"})).unwrap();
for x in [20, 60] {
app.run("sketch.rectangle.two_point", json!({"p0": [x, 20], "p1": [x + 10, 30]})).unwrap();
}
app.run("sketch.finish", json!({})).unwrap();
app.run("solid.extrude", json!({"sketch": "Retain", "profiles": "all", "through_all": true, "direction": "symmetric", "operation": "intersect"}))
.unwrap();
let flat = app.session.execute("sheet.flat_pattern", &json!({})).unwrap();
assert_eq!(flat["outline"].as_array().unwrap().len(), 2);
app.start("sheet.flat_pattern");
let mut dialog = app.dialog.clone().unwrap();
let Kind::Sheet(Sm::FlatPattern { data, .. }) = &mut dialog.kind else { panic!("flat dialog") };
*data = Some(Ok(flat));
let ctx = egui::Context::default();
let id = egui::Id::new(("sc_dialog", "FLAT PATTERN"));
let mut output = egui::FullOutput::default();
for _ in 0..3 {
output = ctx.run_ui(egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(1400.0, 900.0))), ..Default::default() }, |ui| {
crate::frame::docked("FLAT PATTERN", id, pos2(1400.0, 294.0), 540.0, crate::frame::Width::Normal).min_width(360.0).show(ui.ctx(), |ui| {
ui.label("Flat size: 50 × 10 × 2.5 mm");
});
let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Background, egui::Id::new("island-fit")));
assert!(overlay(&painter, Rect::from_min_max(pos2(250.0, 126.0), pos2(1400.0, 832.0)), &dialog));
});
output.textures_delta.clear();
}
let panel = ctx.memory(|m| m.area_rect(id)).unwrap();
let outlines: Vec<_> = output
.shapes
.iter()
.filter_map(|s| match &s.shape {
egui::Shape::Path(p) if p.closed && p.fill == Color32::TRANSPARENT => Some(p),
_ => None,
})
.collect();
assert_eq!(outlines.len(), 2, "both retained islands are drawn");
assert!(
outlines.iter().flat_map(|p| &p.points).all(|p| p.x <= panel.left() - 19.0),
"both complete islands must remain exposed before the command panel: {panel:?}"
);
}
#[test]
fn pocket_export_button_uses_the_picker_and_preserves_depth_layers() {
let mut h = crate::scenario::Harness::new();
for (command, params) in [
("sketch.create", json!({"plane":"XY","name":"Base"})),
("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[100,60]})),
("sketch.finish", json!({})),
("sheet.flange", json!({"sketch":"Base"})),
("sketch.create", json!({"plane":"XY","name":"Pocket"})),
("sketch.rectangle.two_point", json!({"p0":[20,20],"p1":[30,30]})),
("sketch.finish", json!({})),
("solid.extrude", json!({"sketch":"Pocket","distance":1,"operation":"cut"})),
] {
h.app.run(command, params).unwrap();
}
let path = h.dir.join("picked-pocket.dxf");
let chosen = path.to_string_lossy().into_owned();
h.app.services.pick_save = Some(Box::new(move |name, extensions| {
assert!(name.ends_with("-Body1.dxf"));
assert_eq!(extensions, &["dxf"]);
Some(chosen.clone())
}));
h.app.start("sheet.flat_pattern");
h.settle();
let undo = h.app.session.undo.len();
h.step(&json!({"widget":"Export DXF…"})).unwrap();
let exported = std::fs::read_to_string(&path).expect("actual Export DXF button writes the picker destination");
assert!(exported.contains("POCKET_BOTTOM_Z0.000000_TO_1.000000_MM"));
assert!(exported.contains("OUTLINE"));
assert_eq!(h.app.session.undo.len(), undo, "export does not alter the part");
assert!(h.app.dialog.is_some(), "export keeps the flat viewer open");
}
#[test]
#[cfg(not(target_arch = "wasm32"))]
fn bend_table_picker_writes_the_current_body() {