@itk-wasm/mesh-to-poly-data
Version:
Convert an ITK Mesh to a simple data structure compatible with vtkPolyData.
39 lines • 1.22 kB
JavaScript
// Generated file. To retain edits, remove this comment.
import { InterfaceTypes, runPipelineNode } from 'itk-wasm';
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) {
const desiredOutputs = [
{ type: InterfaceTypes.PolyData },
];
const inputs = [
{ 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,
};
return result;
}
export default meshToPolyDataNode;
//# sourceMappingURL=mesh-to-poly-data-node.js.map