// Generated file. To retain edits, remove this comment. import { Mesh, JsonCompatible, InterfaceTypes, PipelineOutput, PipelineInput, runPipelineNode } from 'itk-wasm' import VtkPolyDataWriteMeshNodeOptions from './vtk-poly-data-write-mesh-node-options.js' import VtkPolyDataWriteMeshNodeResult from './vtk-poly-data-write-mesh-node-result.js' import path from 'path' import { fileURLToPath } from 'url' /** * Write an itk-wasm file format converted to an mesh file format * * @param {Mesh} mesh - Input mesh * @param {string} serializedMesh - Output mesh * @param {VtkPolyDataWriteMeshNodeOptions} options - options object * * @returns {Promise} - result object */ async function vtkPolyDataWriteMeshNode( mesh: Mesh, serializedMesh: string, options: VtkPolyDataWriteMeshNodeOptions = {} ) : Promise { const mountDirs: Set = new Set() const desiredOutputs: Array = [ { type: InterfaceTypes.JsonCompatible }, ] const inputs: Array = [ { type: InterfaceTypes.Mesh, data: mesh }, ] const args = [] // Inputs const meshName = '0' args.push(meshName) // Outputs const couldWriteName = '0' args.push(couldWriteName) const serializedMeshName = serializedMesh args.push(serializedMeshName) mountDirs.add(path.dirname(serializedMeshName)) // Options args.push('--memory-io') if (options.informationOnly) { options.informationOnly && args.push('--information-only') } if (options.useCompression) { options.useCompression && args.push('--use-compression') } if (options.binaryFileType) { options.binaryFileType && args.push('--binary-file-type') } const pipelinePath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'pipelines', 'vtk-poly-data-write-mesh') const { returnValue, stderr, outputs } = await runPipelineNode(pipelinePath, args, desiredOutputs, inputs, mountDirs) if (returnValue !== 0 && stderr !== "") { throw new Error(stderr) } const result = { couldWrite: outputs[0]?.data as JsonCompatible, } return result } export default vtkPolyDataWriteMeshNode