1.7.0 • Published 8 months ago

@itk-wasm/mesh-filters v1.7.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

@itk-wasm/mesh-filters

npm version

Mesh filters to repair, remesh, subdivide, decimate, smooth, triangulate, etc.

Installation

npm install @itk-wasm/mesh-filters

Usage

Browser interface

Import:

import {
  geogramConversion,
  keepLargestComponent,
  repair,
  sliceMesh,
  smoothRemesh,
  setPipelinesBaseUrl,
  getPipelinesBaseUrl,
} from "@itk-wasm/mesh-filters"

geogramConversion

A test for reading and writing with geogram, itk::QuadEdgeMesh meshes

async function geogramConversion(
  inputMesh: Mesh,
  options: GeogramConversionOptions = {}
) : Promise<GeogramConversionResult>
ParameterTypeDescription
inputMeshMeshThe input mesh

GeogramConversionOptions interface:

PropertyTypeDescription
webWorkernull or Worker or booleanWebWorker 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.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

GeogramConversionResult interface:

PropertyTypeDescription
outputMeshMeshThe output mesh
webWorkerWorkerWebWorker used for computation.

keepLargestComponent

Keep only the largest component in the mesh.

async function keepLargestComponent(
  inputMesh: Mesh,
  options: KeepLargestComponentOptions = {}
) : Promise<KeepLargestComponentResult>
ParameterTypeDescription
inputMeshMeshThe input mesh.

KeepLargestComponentOptions interface:

PropertyTypeDescription
webWorkernull or Worker or booleanWebWorker 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.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

KeepLargestComponentResult interface:

PropertyTypeDescription
outputMeshMeshThe output mesh with only the largest component.
webWorkerWorkerWebWorker used for computation.

repair

Repair a mesh so it is 2-manifold and optionally watertight.

async function repair(
  inputMesh: Mesh,
  options: RepairOptions = {}
) : Promise<RepairResult>
ParameterTypeDescription
inputMeshMeshThe input mesh

RepairOptions interface:

PropertyTypeDescription
mergeTolerancenumberPoint merging tolerance as a percent of the bounding box diagonal.
minimumComponentAreanumberMinimum component area as a percent of the total area. Components smaller than this are removed.
maximumHoleAreanumberMaximum area of a hole as a percent of the total area. Holes smaller than this are filled.
maximumHoleEdgesnumberMaximum number of edges in a hole. Holes with fewer edges than this are filled.
maximumDegree3DistancenumberMaximum distance as a percent of the bounding box diagonal. Vertices with degree 3 that are closer than this are merged.
removeIntersectingTrianglesbooleanRemove intersecting triangles.
webWorkernull or Worker or booleanWebWorker 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.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

RepairResult interface:

PropertyTypeDescription
outputMeshMeshThe output repaired mesh.
webWorkerWorkerWebWorker used for computation.

sliceMesh

Slice a mesh along planes into polylines.

async function sliceMesh(
  inputMesh: Mesh,
  planes: JsonCompatible,
  options: SliceMeshOptions = {}
) : Promise<SliceMeshResult>
ParameterTypeDescription
inputMeshMeshThe input triangle mesh.
planesJsonCompatibleAn array of plane locations to slice the mesh. Each plane is defined by an array of 'origin' and 'spacing' values.

SliceMeshOptions interface:

PropertyTypeDescription
webWorkernull or Worker or booleanWebWorker 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.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

SliceMeshResult interface:

PropertyTypeDescription
polylinesMeshThe output mesh comprised of polylines. Cell data indicates whether part of a closed line. Point data indicates the slice index.
webWorkerWorkerWebWorker used for computation.

smoothRemesh

Smooth and remesh a mesh to improve quality.

async function smoothRemesh(
  inputMesh: Mesh,
  options: SmoothRemeshOptions = {}
) : Promise<SmoothRemeshResult>
ParameterTypeDescription
inputMeshMeshThe input mesh

SmoothRemeshOptions interface:

PropertyTypeDescription
numberPointsnumberNumber of points as a percent of the bounding box diagonal. Output may have slightly more points.
triangleShapeAdaptationnumberTriangle shape adaptation factor. Use 0.0 to disable.
triangleSizeAdaptationnumberTriangle size adaptation factor. Use 0.0 to disable.
normalIterationsnumberNumber of normal smoothing iterations.
lloydIterationsnumberNumber of Lloyd relaxation iterations.
newtonIterationsnumberNumber of Newton iterations.
newtonMnumberNumber of Newton evaluations per step for Hessian approximation.
lfsSamplesnumberNumber of samples for size adaptation if triangle size adaptation is not 0.0.
webWorkernull or Worker or booleanWebWorker 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.
noCopybooleanWhen SharedArrayBuffer's are not available, do not copy inputs.

SmoothRemeshResult interface:

PropertyTypeDescription
outputMeshMeshThe output repaired mesh.
webWorkerWorkerWebWorker used for computation.

setPipelinesBaseUrl

Set base URL for WebAssembly assets when vendored.

function setPipelinesBaseUrl(
  baseUrl: string | URL
) : void

getPipelinesBaseUrl

Get base URL for WebAssembly assets when vendored.

function getPipelinesBaseUrl() : string | URL

Node interface

Import:

import {
  geogramConversionNode,
  keepLargestComponentNode,
  repairNode,
  sliceMeshNode,
  smoothRemeshNode,
} from "@itk-wasm/mesh-filters"

geogramConversionNode

A test for reading and writing with geogram, itk::QuadEdgeMesh meshes

async function geogramConversionNode(
  inputMesh: Mesh
) : Promise<GeogramConversionNodeResult>
ParameterTypeDescription
inputMeshMeshThe input mesh

GeogramConversionNodeResult interface:

PropertyTypeDescription
outputMeshMeshThe output mesh

keepLargestComponentNode

Keep only the largest component in the mesh.

async function keepLargestComponentNode(
  inputMesh: Mesh
) : Promise<KeepLargestComponentNodeResult>
ParameterTypeDescription
inputMeshMeshThe input mesh.

KeepLargestComponentNodeResult interface:

PropertyTypeDescription
outputMeshMeshThe output mesh with only the largest component.

repairNode

Repair a mesh so it is 2-manifold and optionally watertight.

async function repairNode(
  inputMesh: Mesh,
  options: RepairNodeOptions = {}
) : Promise<RepairNodeResult>
ParameterTypeDescription
inputMeshMeshThe input mesh

RepairNodeOptions interface:

PropertyTypeDescription
mergeTolerancenumberPoint merging tolerance as a percent of the bounding box diagonal.
minimumComponentAreanumberMinimum component area as a percent of the total area. Components smaller than this are removed.
maximumHoleAreanumberMaximum area of a hole as a percent of the total area. Holes smaller than this are filled.
maximumHoleEdgesnumberMaximum number of edges in a hole. Holes with fewer edges than this are filled.
maximumDegree3DistancenumberMaximum distance as a percent of the bounding box diagonal. Vertices with degree 3 that are closer than this are merged.
removeIntersectingTrianglesbooleanRemove intersecting triangles.

RepairNodeResult interface:

PropertyTypeDescription
outputMeshMeshThe output repaired mesh.

sliceMeshNode

Slice a mesh along planes into polylines.

async function sliceMeshNode(
  inputMesh: Mesh,
  planes: JsonCompatible
) : Promise<SliceMeshNodeResult>
ParameterTypeDescription
inputMeshMeshThe input triangle mesh.
planesJsonCompatibleAn array of plane locations to slice the mesh. Each plane is defined by an array of 'origin' and 'spacing' values.

SliceMeshNodeResult interface:

PropertyTypeDescription
polylinesMeshThe output mesh comprised of polylines. Cell data indicates whether part of a closed line. Point data indicates the slice index.

smoothRemeshNode

Smooth and remesh a mesh to improve quality.

async function smoothRemeshNode(
  inputMesh: Mesh,
  options: SmoothRemeshNodeOptions = {}
) : Promise<SmoothRemeshNodeResult>
ParameterTypeDescription
inputMeshMeshThe input mesh

SmoothRemeshNodeOptions interface:

PropertyTypeDescription
numberPointsnumberNumber of points as a percent of the bounding box diagonal. Output may have slightly more points.
triangleShapeAdaptationnumberTriangle shape adaptation factor. Use 0.0 to disable.
triangleSizeAdaptationnumberTriangle size adaptation factor. Use 0.0 to disable.
normalIterationsnumberNumber of normal smoothing iterations.
lloydIterationsnumberNumber of Lloyd relaxation iterations.
newtonIterationsnumberNumber of Newton iterations.
newtonMnumberNumber of Newton evaluations per step for Hessian approximation.
lfsSamplesnumberNumber of samples for size adaptation if triangle size adaptation is not 0.0.

SmoothRemeshNodeResult interface:

PropertyTypeDescription
outputMeshMeshThe output repaired mesh.
1.7.0

8 months ago

1.6.0

9 months ago

0.2.0

10 months ago

0.1.0

10 months ago