STEP export: AP242 file of our own, names, colours, components as assemblies

Our writer assembles the file: AP242 header and contexts, a product per part
(or per component, with NEXT_ASSEMBLY_USAGE_OCCURRENCE and item-defined
placements per occurrence), named solids, surface colours as styled items,
ADVANCED_FACE for advanced breps. truck now writes only each body's B-rep,
which we copy in; identical geometric entities are written once and shared.
Designs with components export as assemblies (bodies in component frames).

step_validate also rejects unreferenced non-root entities. Tests: the sample
plate and a component assembly export, validate and read back with no
warnings and the same volume, area and face counts; the oracle replay checks
area and faces too (39 rebuildable cases pass). An independent Part 21
parser (step-p21, run outside the repo) accepts our exports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
bherbruckandClaude Opus 5.5 committed 2026-10-08 00:16:52 +00:00
1 parent dd7485503a
commit 9330ee5698
10 files changed
+682 -14

No files matched your search

+11 -2
View File
@@ -62,8 +62,8 @@ where
mt::BSplineCurve::try_new(mt::KnotVec::from(knots), ctrl).ok()
}
/// STEP (ISO 10303-21) text for the given bodies.
pub fn step_export(bodies: &[&Body], system: &str) -> Result<String> {
/// truck's STEP text for the given bodies (geometry and topology; product data is ours).
pub(crate) fn truck_step(bodies: &[&Body], system: &str) -> Result<String> {
if bodies.is_empty() {
return Err(KernelError::Invalid("nothing to export".into()));
}
@@ -77,3 +77,12 @@ pub fn step_export(bodies: &[&Body], system: &str) -> Result<String> {
Ok(out::CompleteStepDisplay::new(models, header).to_string())
})
}
/// STEP (ISO 10303-21, AP242) text for the given bodies as one part (`Body1`…, with the
/// bodies' colours).
pub fn step_export(bodies: &[&Body], system: &str) -> Result<String> {
let list: Vec<crate::ExportBody> =
bodies.iter().enumerate().map(|(i, b)| crate::ExportBody { name: format!("Body{}", i + 1), body: b, color: b.color() }).collect();
let header = crate::StepHeader { organization: system.to_string(), ..Default::default() };
crate::step_out::step_export_bodies(&list, &header)
}