28 lines
885 B
Luau
28 lines
885 B
Luau
-- tools/fixtures/_step_encode: run by tools/fixtures/step.py (luau CLI, repo root): decodes every STEP case with our
|
|
-- reader and writes it back with our writer, printing "case_<i>.step\t<hex>" lines for OCCT (through gmsh) to read.
|
|
local Step = require("@rosetta/cad/step")
|
|
local Bytes = require("@rosetta/core/Bytes")
|
|
local Cases = require("@tests/gen/step_cases")
|
|
|
|
local HEX = {}
|
|
for i = 0, 255 do
|
|
HEX[i] = string.format("%02x", i)
|
|
end
|
|
local function hex(s: string): string
|
|
local out = table.create(#s)
|
|
for i = 1, #s do
|
|
out[i] = HEX[string.byte(s, i)]
|
|
end
|
|
return table.concat(out)
|
|
end
|
|
|
|
for i, c in Cases do
|
|
local cad, err = Step.decode(Bytes.reader(buffer.fromstring(c.data)))
|
|
if cad then
|
|
local out = assert(Step.encode(cad))
|
|
print(string.format("case_%d.step\t%s", i, hex(buffer.tostring(out))))
|
|
else
|
|
print("skipped " .. c.name .. ": " .. tostring(err))
|
|
end
|
|
end
|