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