ws-3d2/step: cad/step (ISO 10303-21 read/write + injected B-rep plug-in)

- src/Formats/cad/step: Part 21 editions 1-3 parsed into Types.Cad fully in-library (header, named DATA sections,
  complex instances, every parameter kind, string escapes to UTF-8, comments, ANCHOR/REFERENCE/SIGNATURE kept raw);
  writer round-trips at the entity level (integral reals keep their real-ness via a list metatable mark).
- B-rep plug-in: a small injected table { read, write, tessellate } (or brep-luau's { Step, StepBrep, StepWrite, Tess }
  as is), taken from opts.brep / opts.plugins.brep; Step.toBodies / fromBodies / tessellate (-> Scene, z up, mm).
- Types.luau: StepEntity gains optional parts (complex instances) and section (edition 3); backward compatible.
- init.luau (api): withHooks also passes opts.plugins = F.plugins to decoders/encoders unless given; new facades
  F.cad.toBodies / fromBodies / tessellate (pass F.plugins, pcall, Err-wrapped). Backward compatible.
- tests/cad/step.luau + tools/fixtures/step.py: OCCT (gmsh) generated and public STEP files, Python census, OCCT reads
  our output back, brep-luau through a generated tests/gen/.luaurc alias (luau only), fuzz.
- tools/bench.luau: step parse / write lines.
This commit is contained in:
4DBug committed 2026-10-31 09:33:58 -05:00
1 parent 646d18f056
commit 443a7e45cb
12 files changed
+2154 -2

No files matched your search

+19
View File
@@ -535,3 +535,22 @@ do
Webp.encode(img, { effort = 1 })
end)
end
do
-- STEP (tools/fixtures/step.py): the largest case, parse and write
local Step = require("@formats/cad/step")
local SC = require("@tests/gen/step_cases")
local big = SC[1]
for _, c in SC do
if #c.data > #big.data then
big = c
end
end
local data = buffer.fromstring(big.data)
local cad = assert(Step.decode(Bytes.reader(data)))
bench(string.format("step parse (%.1f MB)", #big.data / 1e6), 3, #big.data, function()
Step.decode(Bytes.reader(data))
end)
bench("step write", 3, #big.data, function()
Step.encode(cad)
end)
end