-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: feat(transform-io): add readTransform, writeTransform
And support code.
- Loading branch information
Showing
28 changed files
with
728 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cypress/screenshots/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
defaultCommandTimeout: 40000, | ||
setupNodeEvents(on, config) { | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export const demoServer = "http://localhost:5181"; | ||
|
||
export function verifyTestLinearTransform(transformList) { | ||
cy.expect(transformList.length).to.equal(1); | ||
const transform = transformList[0]; | ||
cy.expect(transform.transformType.transformParameterization).to.equal( | ||
"Affine" | ||
); | ||
cy.expect(transform.transformType.parametersValueType).to.equal("float64"); | ||
cy.expect(transform.transformType.inputDimension).to.equal(3); | ||
cy.expect(transform.transformType.outputDimension).to.equal(3); | ||
cy.expect(transform.numberOfParameters).to.equal(12); | ||
cy.expect(transform.numberOfFixedParameters).to.equal(3); | ||
cy.deepEqual(transform.fixedParameters, new Float64Array([0, 0, 0])); | ||
cy.deepEqual( | ||
transform.parameters, | ||
new Float64Array([ | ||
0.65631490118447, 0.5806583745824385, -0.4817536741017158, | ||
-0.7407986817430222, 0.37486398378429736, -0.5573995934598175, | ||
-0.14306664045479867, 0.7227121458012518, 0.676179776908723, | ||
-65.99999999999997, 69.00000000000004, 32.000000000000036, | ||
]) | ||
); | ||
} |
72 changes: 72 additions & 0 deletions
72
packages/transform-io/typescript/cypress/e2e/read-transform.ty.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { demoServer, verifyMesh } from './common.ts' | ||
|
||
describe('read-mesh', () => { | ||
beforeEach(function() { | ||
cy.visit(demoServer) | ||
|
||
const testPathPrefix = '../test/data/input/' | ||
|
||
const testImageFiles = [ | ||
'cow.vtk' | ||
] | ||
testImageFiles.forEach((fileName) => { | ||
cy.readFile(`${testPathPrefix}${fileName}`, null).as(fileName) | ||
}) | ||
}) | ||
|
||
it('Reads an mesh File in the demo', function () { | ||
cy.get('sl-tab[panel="readMesh-panel"]').click() | ||
|
||
const testFile = { contents: new Uint8Array(this['cow.vtk']), fileName: 'cow.vtk' } | ||
cy.get('#readMeshInputs input[name="serialized-mesh-file"]').selectFile([testFile,], { force: true }) | ||
cy.get('#readMesh-serialized-mesh-details').should('contain', '35,32') | ||
|
||
cy.get('#readMeshInputs sl-button[name="run"]').click() | ||
|
||
cy.get('#readMesh-mesh-details').should('contain', 'meshType') | ||
}) | ||
|
||
it('Reads an mesh BinaryFile', function () { | ||
cy.window().then(async (win) => { | ||
const arrayBuffer = new Uint8Array(this['cow.vtk']).buffer | ||
const { mesh, webWorker } = await win.meshIo.readMesh({ data: new Uint8Array(arrayBuffer), path: 'cow.vtk' }) | ||
webWorker.terminate() | ||
verifyMesh(mesh) | ||
}) | ||
}) | ||
|
||
it('Reads an mesh File', function () { | ||
cy.window().then(async (win) => { | ||
const arrayBuffer = new Uint8Array(this['cow.vtk']).buffer | ||
const cowFile = new win.File([arrayBuffer], 'cow.vtk') | ||
const { mesh, webWorker } = await win.meshIo.readMesh(cowFile) | ||
webWorker.terminate() | ||
verifyMesh(mesh) | ||
}) | ||
}) | ||
|
||
it('Reads re-uses a WebWorker', function () { | ||
cy.window().then(async (win) => { | ||
const arrayBuffer = new Uint8Array(this['cow.vtk']).buffer | ||
const cowFile = new win.File([arrayBuffer], 'cow.vtk') | ||
const { webWorker } = await win.meshIo.readMesh(cowFile) | ||
const { mesh } = await win.meshIo.readMesh(cowFile, { webWorker }) | ||
webWorker.terminate() | ||
verifyMesh(mesh) | ||
}) | ||
}) | ||
|
||
it('Throws a catchable error for an invalid file', { defaultCommandTimeout: 120000 }, function () { | ||
cy.window().then(async (win) => { | ||
const invalidArray = new Uint8Array([21, 4, 4, 4, 4, 9, 5, 0, 82, 42]) | ||
const invalidBlob = new win.Blob([invalidArray]) | ||
const invalidFile = new win.File([invalidBlob], 'invalid.file') | ||
try { | ||
const { webWorker, mesh } = await win.meshIo.readMesh(invalidFile) | ||
webWorker.terminate() | ||
} catch (error) { | ||
cy.expect(error.message).to.equal('Could not find IO for: invalid.file') | ||
} | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.