feat: establish reproducible FreeCAD web compatibility baseline

This commit is contained in:
2026-08-10 16:11:38 -04:00
parent e5a5d74dbc
commit b962a5c3b5
733 changed files with 349081 additions and 647 deletions

View File

@@ -27,6 +27,17 @@ export function validateGoldenOperation(operation, label = 'operation') {
if (!positive(operation.radius)) throw new RangeError(`${label} sphere radius must be positive.`)
} else if (operation.type === 'cone') {
if (!finite(operation.radius1) || operation.radius1 < 0 || !finite(operation.radius2) || operation.radius2 < 0 || operation.radius1 + operation.radius2 <= 0 || !positive(operation.height) || !positive(operation.angle) || operation.angle > 360) throw new RangeError(`${label} cone parameters are invalid.`)
} else if (operation.type === 'ellipsoid') {
if (!positive(operation.radius1) || !positive(operation.radius2) || !finite(operation.radius3) || operation.radius3 < 0 || !finite(operation.angle1) || !finite(operation.angle2) || operation.angle1 < -90 || operation.angle2 > 90 || operation.angle1 >= operation.angle2 || !positive(operation.angle3) || operation.angle3 > 360) throw new RangeError(`${label} ellipsoid parameters are invalid.`)
} else if (operation.type === 'torus') {
if (!positive(operation.radius1) || !positive(operation.radius2) || operation.radius2 >= operation.radius1 || !finite(operation.angle1) || !finite(operation.angle2) || operation.angle1 < -180 || operation.angle2 > 180 || operation.angle1 >= operation.angle2 || !positive(operation.angle3) || operation.angle3 > 360) throw new RangeError(`${label} torus parameters are invalid.`)
} else if (operation.type === 'prism') {
if (!Number.isInteger(operation.polygon) || operation.polygon < 3 || operation.polygon > 10000 || !positive(operation.circumradius) || !positive(operation.height) || !finite(operation.firstAngle) || !finite(operation.secondAngle) || Math.abs(operation.firstAngle) >= 90 || Math.abs(operation.secondAngle) >= 90) throw new RangeError(`${label} prism parameters are invalid.`)
} else if (operation.type === 'wedge') {
const values = ['xmin', 'ymin', 'zmin', 'z2min', 'x2min', 'xmax', 'ymax', 'zmax', 'z2max', 'x2max'].map((key) => operation[key])
if (!values.every(finite) || operation.xmax <= operation.xmin || operation.ymax <= operation.ymin || operation.zmax <= operation.zmin || operation.z2max < operation.z2min || operation.x2max < operation.x2min) throw new RangeError(`${label} wedge parameters are invalid.`)
} else if (operation.type === 'helix') {
if (!positive(operation.pitch) || !positive(operation.height) || !positive(operation.radius) || !finite(operation.angle) || Math.abs(operation.angle) >= 90 || !finite(operation.segmentLength) || operation.segmentLength < 0) throw new RangeError(`${label} helix parameters are invalid.`)
} else if (operation.type === 'cut' || operation.type === 'fuse' || operation.type === 'common') {
validateGoldenOperation(operation.base, `${label}.base`)
validateGoldenOperation(operation.tool, `${label}.tool`)
@@ -40,9 +51,10 @@ export function validateGoldenScenario(scenario, expectedId) {
validateGoldenOperation(scenario.operation, scenario.id)
if (!scenario.tolerance || !positive(scenario.tolerance.linear) || !positive(scenario.tolerance.scalar)) throw new RangeError(`${scenario.id} requires positive linear and scalar tolerances.`)
if (!scenario.expected || typeof scenario.expected !== 'object' || Array.isArray(scenario.expected)) throw new TypeError(`${scenario.id} requires expected output.`)
const allowedShapeTypes = new Set(['Solid', 'Compound'])
if (scenario.expected.isNull !== false || scenario.expected.isValid !== true || !allowedShapeTypes.has(scenario.expected.shapeType) || !Number.isInteger(scenario.expected.solids) || scenario.expected.solids < 1) {
throw new RangeError(`${scenario.id} must declare a valid non-null oracle containing at least one Solid.`)
const allowedShapeTypes = new Set(['Solid', 'Compound', 'Shell', 'Face', 'Wire', 'Edge'])
const solidExpected = scenario.expected.shapeType === 'Solid' || scenario.expected.shapeType === 'Compound'
if (scenario.expected.isNull !== false || scenario.expected.isValid !== true || !allowedShapeTypes.has(scenario.expected.shapeType) || !Number.isInteger(scenario.expected.solids) || (solidExpected ? scenario.expected.solids < 1 : scenario.expected.solids !== 0)) {
throw new RangeError(`${scenario.id} must declare a valid non-null oracle with a shape-compatible Solid count.`)
}
}