62 lines
6.6 KiB
HTML
62 lines
6.6 KiB
HTML
<!doctype html>
|
|
<meta charset="utf-8">
|
|
<title>Chrome native Revolution history harness</title>
|
|
<pre id="result">running</pre>
|
|
<script type="module">
|
|
import { BitbybitGeometryRuntime } from '/src/facade/geometryRuntime.ts'
|
|
import { NativeOcctHistoryWorkerProvider } from '/src/facade/nativeHistoryWorkerClient.ts'
|
|
|
|
const output = document.querySelector('#result')
|
|
const report = { schemaVersion: 1, browserId: 'chrome', crossOriginIsolated: globalThis.crossOriginIsolated === true, status: 'running' }
|
|
let runtime
|
|
let provider
|
|
try {
|
|
const profileStep = await fetch('/native-revolution-profile.step').then((response) => response.ok ? response.text() : Promise.reject(new Error(`Revolution profile fixture failed: ${response.status}`)))
|
|
runtime = new BitbybitGeometryRuntime()
|
|
const capabilities = await runtime.initialize()
|
|
provider = new NativeOcctHistoryWorkerProvider({ moduleUrl: '/native/occt-history/bitbybit-occt-history.js' })
|
|
const nativeCapabilities = await provider.initialize()
|
|
runtime.configureNativeHistory(provider)
|
|
const context = { documentId: 'chrome-native-revolution', documentVersion: 1 }
|
|
const profile = await runtime.importShape({ ...context, format: 'step', text: profileStep })
|
|
const planarProfile = { outer: [[0, 0, 0], [2, 0, 0], [2, 3, 0], [0, 3, 0]] }
|
|
const result = await runtime.revolution({ ...context, profile: planarProfile, axisOrigin: [-1, 0, 0], axisDirection: [0, 1, 0], angle: 360 })
|
|
const [quality, mass] = await Promise.all([runtime.qualityReport(result), runtime.massProperties(result)])
|
|
const markerDirectory = await navigator.storage.getDirectory()
|
|
const marker = await markerDirectory.getFileHandle('native-revolution-history-chrome-marker.json', { create: true })
|
|
const writable = await marker.createWritable()
|
|
await writable.write(JSON.stringify({ operation: 'revolution', provider: nativeCapabilities.providerId }))
|
|
await writable.close()
|
|
const records = await runtime.topologyHistory({ ...context, operationId: 'chrome-native-revolution-history', operation: 'revolution', inputs: [{ objectId: 'Profile', shape: profile }], axisOrigin: [-1, 0, 0], direction: [0, 1, 0], angle: 360, result })
|
|
const twoSidedResult = await runtime.revolution({ ...context, profile: planarProfile, axisOrigin: [-1, 0, 0], axisDirection: [0, 1, 0], angle: 180, profileRotationAngle: -60 })
|
|
const twoSidedRecords = await runtime.topologyHistory({ ...context, operationId: 'chrome-native-revolution-two-sided-history', operation: 'revolution', inputs: [{ objectId: 'Profile', shape: profile }], stages: [{ stageId: 'Revolution:stage:0', operation: 'revolution', inputObjectIds: ['Profile'], resultObjectId: 'RevolutionTwoSided', ordinal: 0 }], featureSides: [{ direction: [0, 1, 0], angle: 120 }, { direction: [0, -1, 0], angle: 60 }], axisOrigin: [-1, 0, 0], direction: [0, 1, 0], angle: 120, result: twoSidedResult })
|
|
const twoSidedStages = twoSidedRecords.stageCaptures || []
|
|
const [twoSidedQuality, twoSidedMass] = await Promise.all([runtime.qualityReport(twoSidedResult), runtime.massProperties(twoSidedResult)])
|
|
const twoSidedUnexplainedErrors = (twoSidedQuality.structuralIssues || []).filter((issue) => issue.severity === 'error' && issue.description !== 'CoEdgeDef has no Curve2D representation').length
|
|
const modified = records.filter((record) => record.relation === 'modified').length
|
|
const generated = records.filter((record) => record.relation === 'generated').length
|
|
const deleted = records.filter((record) => record.relation === 'deleted').length
|
|
const crossKind = records.filter((record) => record.resultKind && record.resultKind !== record.sourceKind).length
|
|
report.capabilities = capabilities
|
|
report.nativeCapabilities = nativeCapabilities
|
|
report.history = { recordCount: records.length, crossKindRecords: crossKind, relations: { modified, generated, deleted } }
|
|
report.twoSidedHistory = { recordCount: twoSidedRecords.length, structuralValid: twoSidedQuality.nativeKernelValid === true, graphStructuralValid: twoSidedQuality.structuralValid, graphStructuralErrors: twoSidedQuality.structuralErrors, graphStructuralWarnings: twoSidedQuality.structuralWarnings, graphStructuralIssues: twoSidedQuality.structuralIssues, unexplainedStructuralErrors: twoSidedUnexplainedErrors, solids: twoSidedQuality.solids, volume: twoSidedMass.volume, stages: twoSidedStages.map((stage) => ({ stageId: stage.stageId, operation: stage.operation, inputObjectIds: stage.inputObjectIds, resultObjectId: stage.resultObjectId, ordinal: stage.ordinal, topologyEntries: stage.topology.entries.length, recordCount: stage.records.length })) }
|
|
report.result = { structuralValid: quality.structuralValid, solids: quality.solids, volume: mass.volume }
|
|
await runtime.release(twoSidedResult)
|
|
await runtime.release(result)
|
|
await runtime.release(profile)
|
|
report.afterRelease = { shapeCount: runtime.capabilities().shapeCount, kernelReferenceCount: runtime.capabilities().kernelReferenceCount }
|
|
await markerDirectory.removeEntry('native-revolution-history-chrome-marker.json').catch(() => {})
|
|
report.status = report.crossOriginIsolated && capabilities.status === 'ready' && nativeCapabilities.availability === 'available' && nativeCapabilities.operations.includes('revolution') && nativeCapabilities.operations.includes('rotate') && records.length > 0 && modified > 0 && generated > 0 && crossKind > 0 && quality.structuralValid && quality.solids === 1 && Math.abs(mass.volume - 24 * Math.PI) <= 1e-5 && twoSidedRecords.length > 0 && twoSidedQuality.nativeKernelValid === true && twoSidedUnexplainedErrors === 0 && twoSidedQuality.solids === 1 && twoSidedStages.length === 2 && twoSidedStages[0].operation === 'rotate' && twoSidedStages[0].inputObjectIds.join(',') === 'Profile' && twoSidedStages[0].topology.entries.length > 0 && twoSidedStages[1].operation === 'revolution' && twoSidedStages[1].inputObjectIds.join(',') === `${twoSidedStages[0].resultObjectId}` && twoSidedStages[1].resultObjectId === 'RevolutionTwoSided' && twoSidedStages[1].topology.entries.length > 0 && Math.abs(twoSidedMass.volume - 12 * Math.PI) <= 1e-5 && report.afterRelease.shapeCount === 0 && report.afterRelease.kernelReferenceCount === 0 ? 'pass' : 'failed'
|
|
} catch (error) {
|
|
report.status = 'failed'
|
|
report.error = error instanceof Error ? error.message : String(error)
|
|
} finally {
|
|
provider?.dispose()
|
|
runtime?.dispose()
|
|
}
|
|
output.textContent = JSON.stringify(report, null, 2)
|
|
await fetch('/__native-revolution-history-report', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(report) })
|
|
if (report.status !== 'pass') throw new Error(report.error || 'Chrome native Revolution history harness failed.')
|
|
</script>
|