|
| 1 | +import test from 'ava' |
| 2 | +import path from 'path' |
| 3 | + |
| 4 | +import { readPointSetNode, writePointSetNode } from '../../dist/index-node.js' |
| 5 | +import { IntTypes, FloatTypes, PixelTypes } from 'itk-wasm' |
| 6 | + |
| 7 | +import { testInputPath, testOutputPath } from './common.js' |
| 8 | + |
| 9 | +const testInputFilePath = path.resolve(testInputPath, "box-points.obj"); |
| 10 | +const testOutputFilePath = path.resolve( |
| 11 | + testOutputPath, |
| 12 | + "write-point-set-test-box.obj", |
| 13 | +); |
| 14 | + |
| 15 | +const verifyPointSet = (t, pointSet) => { |
| 16 | + t.is(pointSet.pointSetType.dimension, 3); |
| 17 | + t.is(pointSet.pointSetType.pointComponentType, FloatTypes.Float32); |
| 18 | + t.is(pointSet.pointSetType.pointPixelType, PixelTypes.Vector); |
| 19 | + t.is(pointSet.numberOfPoints, 8); |
| 20 | + t.is(pointSet.numberOfPointPixels, 0); |
| 21 | +}; |
| 22 | + |
| 23 | +test('writePointSetNode writes a file path on the local filesystem', async (t) => { |
| 24 | + const pointSet = await readPointSetNode(testInputFilePath) |
| 25 | + verifyPointSet(t, pointSet) |
| 26 | + |
| 27 | + const useCompression = false |
| 28 | + const binaryFileType = false |
| 29 | + await writePointSetNode(pointSet, testOutputFilePath, { useCompression, binaryFileType }) |
| 30 | + |
| 31 | + const pointSetBack = await readPointSetNode(testOutputFilePath) |
| 32 | + verifyPointSet(t, pointSetBack) |
| 33 | +}) |
0 commit comments