npm package: @itk-wasm/sub-mesh
Description: Extract a subset of a mesh given by the cell identifiers.
Latest version: 2.0.0

# @itk-wasm/sub-mesh

[![npm version](https://badge.fury.io/js/@itk-wasm%2Fsub-mesh.svg)](https://www.npmjs.com/package/@itk-wasm/sub-mesh)

> Extract a subset of a mesh given by the cell identifiers.

## Installation

```sh
npm install @itk-wasm/sub-mesh
```

## Usage

### Browser interface

Import:

```js
import {
  subMesh,
  setPipelinesBaseUrl,
  getPipelinesBaseUrl,
} from "@itk-wasm/sub-mesh"
```

#### subMesh

*Extract a subset of a mesh given by the cell identifiers.*

```ts
async function subMesh(
  mesh: Mesh,
  options: SubMeshOptions = { cellIdentifiers: [] as number[], }
) : Promise<SubMeshResult>
```

| Parameter |  Type  | Description |
| :-------: | :----: | :---------- |
|   `mesh`  | *Mesh* | Full mesh   |

**`SubMeshOptions` interface:**

|      Property     |             Type            | Description                                                                                                                                           |
| :---------------: | :-------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cellIdentifiers` |          *number[]*         | Cell identifiers for output mesh.                                                                                                                     |
|    `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.                                                                                       |

**`SubMeshResult` interface:**

|   Property  |   Type   | Description                     |
| :---------: | :------: | :------------------------------ |
|  `subMesh`  |  *Mesh*  | Sub 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 {
  subMeshNode,
} from "@itk-wasm/sub-mesh"
```

#### subMeshNode

*Extract a subset of a mesh given by the cell identifiers.*

```ts
async function subMeshNode(
  mesh: Mesh,
  options: SubMeshNodeOptions = { cellIdentifiers: [] as number[], }
) : Promise<SubMeshNodeResult>
```

| Parameter |  Type  | Description |
| :-------: | :----: | :---------- |
|   `mesh`  | *Mesh* | Full mesh   |

**`SubMeshNodeOptions` interface:**

|      Property     |    Type    | Description                       |
| :---------------: | :--------: | :-------------------------------- |
| `cellIdentifiers` | *number[]* | Cell identifiers for output mesh. |

**`SubMeshNodeResult` interface:**

|  Property |  Type  | Description |
| :-------: | :----: | :---------- |
| `subMesh` | *Mesh* | Sub mesh.   |