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

7
tests/surface.test.ts Normal file
View File

@@ -0,0 +1,7 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { createSurfaceDocument } from '../src/facade/surface'
test('surface creates Bezier/BSpline/loft/fill/offset patches, trims and sews C0 edges', () => { const surface = createSurfaceDocument(); surface.addBezier('bezier', [[[0, 0, 0], [0, 1, 0]], [[1, 0, 0], [1, 1, 0]]]); surface.addBspline('spline', [[[1, 0, 0], [1, 1, 0]], [[2, 0, 0], [2, 1, 0]]], { degreeU: 1, degreeV: 1 }); surface.trim('spline', [0, 0.8], [0, 1]); assert.deepEqual(surface.continuity('bezier', 'spline').relation, 'C0'); assert.deepEqual(surface.sew(['bezier', 'spline']), ['bezier', 'spline']); const loft = surface.loft('loft', [[[0, 0, 0], [1, 0, 0]], [[0, 0, 1], [1, 0, 1]]]); const fill = surface.fill('fill', [[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]]); const offset = surface.offset('fill', 'offset', 2); assert.equal(loft.kind, 'loft'); assert.equal(fill.kind, 'bezier'); assert.equal(offset.poles[0][0][2], 2); assert.equal(surface.topologyRefs('fill').length, 4); assert.equal(surface.analyze().patches, 5); assert.match(surface.exportObj(), /^v /m) })
test('surface rejects invalid grids and trim bounds', () => { const surface = createSurfaceDocument(); assert.throws(() => surface.addBezier('bad', [[[0, 0, 0]]]), /2x2/); surface.addBezier('ok', [[[0, 0, 0], [0, 1, 0]], [[1, 0, 0], [1, 1, 0]]]); assert.throws(() => surface.trim('ok', [0.8, 0.2], [0, 1]), /trim bounds/) })