UNPKG

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

Version:

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

155 lines (108 loc) 4.72 kB
# @itk-wasm/mesh-to-poly-data [![npm version](https://badge.fury.io/js/@itk-wasm%2Fmesh-to-poly-data.svg)](https://www.npmjs.com/package/@itk-wasm/mesh-to-poly-data) > Convert an ITK Mesh to a simple data structure compatible with vtkPolyData. ## Installation ```sh npm install @itk-wasm/mesh-to-poly-data ``` ## Usage ### Browser interface Import: ```js import { meshToPolyData, polyDataToMesh, setPipelinesBaseUrl, getPipelinesBaseUrl, } from "@itk-wasm/mesh-to-poly-data" ``` #### meshToPolyData *Convert an itk::Mesh to an itk::PolyData* ```ts async function meshToPolyData( mesh: Mesh, options: MeshToPolyDataOptions = {} ) : Promise<MeshToPolyDataResult> ``` | Parameter | Type | Description | | :-------: | :----: | :---------- | | `mesh` | *Mesh* | Input mesh | **`MeshToPolyDataOptions` interface:** | Property | Type | Description | | :---------: | :-------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------- | | `webWorker` | *null or Worker or boolean* | WebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to `false` to run in the current thread / worker. | | `noCopy` | *boolean* | When SharedArrayBuffer's are not available, do not copy inputs. | **`MeshToPolyDataResult` interface:** | Property | Type | Description | | :---------: | :--------: | :------------------------------ | | `polyData` | *PolyData* | Output polydata | | `webWorker` | *Worker* | WebWorker used for computation. | #### polyDataToMesh *Convert an itk::PolyData to an itk::Mesh* ```ts async function polyDataToMesh( polyData: PolyData, options: PolyDataToMeshOptions = {} ) : Promise<PolyDataToMeshResult> ``` | Parameter | Type | Description | | :--------: | :--------: | :------------- | | `polyData` | *PolyData* | Input polydata | **`PolyDataToMeshOptions` interface:** | Property | Type | Description | | :---------: | :-------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------- | | `webWorker` | *null or Worker or boolean* | WebWorker for computation. Set to null to create a new worker. Or, pass an existing worker. Or, set to `false` to run in the current thread / worker. | | `noCopy` | *boolean* | When SharedArrayBuffer's are not available, do not copy inputs. | **`PolyDataToMeshResult` interface:** | Property | Type | Description | | :---------: | :------: | :------------------------------ | | `mesh` | *Mesh* | Output mesh | | `webWorker` | *Worker* | WebWorker used for computation. | #### setPipelinesBaseUrl *Set base URL for WebAssembly assets when vendored.* ```ts function setPipelinesBaseUrl( baseUrl: string | URL ) : void ``` #### getPipelinesBaseUrl *Get base URL for WebAssembly assets when vendored.* ```ts function getPipelinesBaseUrl() : string | URL ``` ### Node interface Import: ```js import { meshToPolyDataNode, polyDataToMeshNode, } from "@itk-wasm/mesh-to-poly-data" ``` #### meshToPolyDataNode *Convert an itk::Mesh to an itk::PolyData* ```ts async function meshToPolyDataNode( mesh: Mesh ) : Promise<MeshToPolyDataNodeResult> ``` | Parameter | Type | Description | | :-------: | :----: | :---------- | | `mesh` | *Mesh* | Input mesh | **`MeshToPolyDataNodeResult` interface:** | Property | Type | Description | | :--------: | :--------: | :-------------- | | `polyData` | *PolyData* | Output polydata | #### polyDataToMeshNode *Convert an itk::PolyData to an itk::Mesh* ```ts async function polyDataToMeshNode( polyData: PolyData ) : Promise<PolyDataToMeshNodeResult> ``` | Parameter | Type | Description | | :--------: | :--------: | :------------- | | `polyData` | *PolyData* | Input polydata | **`PolyDataToMeshNodeResult` interface:** | Property | Type | Description | | :------: | :----: | :---------- | | `mesh` | *Mesh* | Output mesh |