Export 3MF with B-rep face tags (#834)

3MF export carries each triangle's B-rep face tag.
This commit is contained in:
Irakli Kourtis authored and GitHub committed 2026-10-13 16:29:09 -04:00
1 parent ff7a347013
commit 5d661fa2af
10 files changed
+286 -47

No files matched your search

+1 -1
View File
@@ -45,7 +45,7 @@ pub static COMMANDS: &[CommandSpec] = &[
CommandSpec::new("file.export", "Export", export)
.icon("export")
.noundo()
.params("path; format?: stl|stla|obj|step|3mf|json (default from extension); bodies?: [names] (JSON exports the complete design)"),
.params("path; format?: stl|stla|obj|step|3mf|3mf-tagged|json (default from extension; 3mf-tagged: 3MF whose triangles carry their B-rep face, at full precision, for meshing and analysis tools; docs/formats/3mf-face-tags.md); bodies?: [names] (JSON exports the complete design)"),
CommandSpec::new("file.save_mesh", "Save As Mesh", save_stl).icon("export").noundo().params("path; bodies?: [names]; ascii?: bool"),
];
+8
View File
@@ -1168,6 +1168,14 @@ fn threemf_export_open_insert() {
let p = dir.join("Parts.3MF");
run(&mut s, "file.export", json!({"path": p.to_string_lossy()}));
let want = volume(&mut s);
// With face tags it is still a 3MF any reader opens, with the same bodies.
let tagged = dir.join("tagged.3mf");
let r = run(&mut s, "file.export", json!({"path": tagged.to_string_lossy(), "format": "3mf-tagged"}));
assert_eq!(r["format"], "ThreeMfTagged", "{r}");
let mut t = Session::default();
let r = run(&mut t, "doc.open", json!({"path": tagged.to_string_lossy()}));
assert_eq!(r["bodies"].as_array().unwrap().len(), 2, "{r}");
assert!(rel(volume(&mut t), want) < 2e-3, "{} vs {want}", volume(&mut t));
let mut m = Session::default();
let r = run(&mut m, "doc.open", json!({"path": p.to_string_lossy()}));