Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Export test: a box exports as its grid mesh (124 triangles), not 12 (#12781)

PaddleStroke11abdba1baec
diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs
index c2bc14a1ad..57459f6185 100644
--- a/crates/engine/src/cmd/file.rs
+++ b/crates/engine/src/cmd/file.rs
@@ -1393,13 +1393,18 @@ mod tests {
assert_eq!(r["bytes"].as_u64(), Some(bytes.len() as u64), "{cmd}");
assert!(bytes.starts_with(signature), "{cmd}");
}
- // The triangles `file.export` writes (the 80-byte header holds the file's name): a box is
- // 12 triangles, 84 + 50 bytes each.
+ // The triangles `file.export` writes (the 80-byte header holds the file's name), 84 + 50
+ // bytes each. The mesher lays each planar face out as a regular grid whose sides are at
+ // most a fifth of the body's diagonal (kernel test `a_box_is_a_regular_grid_on_every_face`):
+ // 22.9 / 5 = 4.58 mm, so 5 × 3 × 2 cells along 20 × 10 × 5, two triangles each.
s.execute("file.export", &json!({"path": at("box.stl")})).unwrap();
assert_eq!(std::fs::read(at("StlBinary.txt")).unwrap()[80..], std::fs::read(at("box.stl")).unwrap()[80..]);
- assert_eq!(std::fs::metadata(at("box.stl")).unwrap().len(), 84 + 50 * 12);
+ let triangles = 2 * 2 * (5 * 3 + 5 * 2 + 3 * 2);
+ let stl = std::fs::read(at("box.stl")).unwrap();
+ assert_eq!(u32::from_le_bytes([stl[80], stl[81], stl[82], stl[83]]), u32::try_from(triangles).unwrap());
+ assert_eq!(stl.len(), 84 + 50 * triangles);
let obj = std::fs::read_to_string(at("Obj.txt")).unwrap();
- assert_eq!(obj.lines().filter(|l| l.starts_with("f ")).count(), 12, "{obj}");
+ assert_eq!(obj.lines().filter(|l| l.starts_with("f ")).count(), triangles, "{obj}");
let r = s.execute("file.export_urdf", &json!({"path": at("robot.urdf")})).unwrap();
assert_eq!(r["format"], "Urdf");
assert!(std::fs::read_to_string(at("robot.urdf")).unwrap().contains("<robot"));
diff --git a/tests/KNOWN_FAILING_TESTS b/tests/KNOWN_FAILING_TESTS
index 85ffd43933..db68619aed 100644
--- a/tests/KNOWN_FAILING_TESTS
+++ b/tests/KNOWN_FAILING_TESTS
@@ -12,7 +12,6 @@ solidcraft-cli::naming_corpus::corpus_designs_name_alike_every_build_and_fail_wh
solidcraft-doc::eval::cost_tests::a_tap_marking_searches_only_the_bodies_near_it main's mesh-based version (#10303) not taken; the exact replacement is to come
solidcraft-doc::eval::cost_tests::a_tap_marking_still_searches_the_bodies_within_its_reach main's mesh-based version (#10303) not taken; the exact replacement is to come
solidcraft-engine::cmd::edit::tests::inserting_variable_fillet_control_preserves_parameters_at_existing_positions solidcore refuses a variable fillet whose law has a corner (solidcore#430)
-solidcraft-engine::cmd::file::tests::each_format_has_an_export_command_of_its_own the box's planar faces are meshed into 124 triangles, not 12 (the STL is 6284 bytes, the test counts 84 + 50 x 12), as on SMLib
solidcraft-engine::extent_tests::cut_to_the_far_side_of_a_curved_wall main's mesh-based version (#8634) not taken; the exact replacement is to come
solidcraft-engine::face_name_tests::a_join_that_makes_the_body_bigger_leaves_round_walls_it_never_touched_alone main's edge lookup by a stored point (#11286) finds the edge on the display mesh (edge_near on the body's mesh), not taken; the exact replacement is to come
solidcraft-engine::hole_face_tests::a_hole_wider_than_the_part_says_it_removes_all_of_it a 40 mm hole at (10, 10) touches the plate's edge y = 30 at one point; the kernel parts the plate there into 2 bodies, the test wants truck's 1, as on SMLib