UNPKG

@itk-wasm/mesh-to-poly-data

Version:

Convert an ITK Mesh to a simple data structure compatible with vtkPolyData.

66 lines (52 loc) 1.36 kB
// Generated file. To retain edits, remove this comment. import { Mesh, PolyData, InterfaceTypes, PipelineOutput, PipelineInput, runPipelineNode } from 'itk-wasm' import MeshToPolyDataNodeResult from './mesh-to-poly-data-node-result.js' import path from 'path' import { fileURLToPath } from 'url' /** * Convert an itk::Mesh to an itk::PolyData * * @param {Mesh} mesh - Input mesh * * @returns {Promise<MeshToPolyDataNodeResult>} - result object */ async function meshToPolyDataNode( mesh: Mesh ) : Promise<MeshToPolyDataNodeResult> { const desiredOutputs: Array<PipelineOutput> = [ { type: InterfaceTypes.PolyData }, ] const inputs: Array<PipelineInput> = [ { type: InterfaceTypes.Mesh, data: mesh }, ] const args = [] // Inputs const meshName = '0' args.push(meshName) // Outputs const polyDataName = '0' args.push(polyDataName) // Options args.push('--memory-io') const pipelinePath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'pipelines', 'mesh-to-poly-data') const { returnValue, stderr, outputs } = await runPipelineNode(pipelinePath, args, desiredOutputs, inputs) if (returnValue !== 0 && stderr !== "") { throw new Error(stderr) } const result = { polyData: outputs[0]?.data as PolyData, } return result } export default meshToPolyDataNode