npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@icr/polyseg-wasm

v0.4.0

Published

An extended WASM wrapper of the PolySeg VTK/C++ implementation

Downloads

11,132

Readme

ICR PolySeg-WASM: a WASM module that implements PolySeg for the Web

Introduction

The ICR PolySeg-WASM is an extended WASM wrapper for the PerkLab/PolySeg library, including C++ code repurposed from Slicer and SlicerRT.

Supported conversions

  • Planar contour to closed surface → convertContourRoiToSurface.
  • Planar contour to labelmap → convertContourRoiToLabelmap.
  • Surface to labelmap → convertSurfaceToLabelmap.
  • Labelmap to closed surface (using flying edges) → convertLabelmapToSurface.
  • Contour to Ribbon → convertContourRoiToRibbon.
  • Ribbon to Labelmap → convertRibbonToLabelmap.

Issues and feature requests

This project is under active development. Please report issues here.

Installation

$ npm install @icr/polyseg-wasm
or
$ yarn add @icr/polyseg-wasm

Usage

  • Use the provided index.js script to load the wasm module

    import ICRPolySeg from '@icr/polyseg-wasm';
    const icrPolySeg = await ICRPolySeg();
    // Initialize the module and optionally pass a callback for progress updates
    await icrPolySeg.initialize(/*{ updateProgress: updateProgressThrottled }*/);
    // Use the initialized 'instance' to invoke a conversion method
    const instance = icrPolySeg.instance;
  • Or, manually import the launcher and wasm to load the module

    import launcher from '@icr/polyseg-wasm/js';
    import wasm from '@icr/polyseg-wasm/wasm';
    // Initialize the module according to your project configuration
    ...

Usage example for planar contour to closed surface conversion

import ICRPolySeg from '@icr/polyseg-wasm';

// Initialize the module and optionally pass a callback for progress updates
const icrPolySeg = await ICRPolySeg();
await icrPolySeg.initialize(/*{ updateProgress: updateProgressThrottled }*/);

// Assuming that an ROI consists of C contours with each contour having an array of points (xyz coordinate tuples)
// Extract and join the ponints from all contours
let flatPointsArray = [];
let numPointsArray = [];
for (let c = 0; c < roi.contours.length; c++) {
    const points = roi.contours[c].points;
    numPointsArray.push(points.length);
    for (let p = 0; p < points.length; p++) {
        const point = points[p];
        flatPointsArray.push(point.x, point.y, point.z);
    }
}
// Use Float32 typed array
flatPointsArray = new Float32Array(flatPointsArray)
numPointsArray = new Float32Array(numPointsArray)

// Run the conversion using the initialized 'instance'
const result = icrPolySeg.instance.convertContourRoiToSurface(flatPointsArray, numPointsArray);

// Create a VTK mesh from the result
const polydata = vtkPolyData.newInstance();
polydata.getPoints().setData(result.points, 3);
polydata.getPolys().setData(result.polys);

Examples

To run and view the examples:

$ $ git clone https://bitbucket.org/icrimaginginformatics/polyseg-wasm.git
$ cd polyseg-wasm/examples
$ yarn install
$ yarn run start

Development

  • Clone polyseg-wasm

    $ git clone https://bitbucket.org/icrimaginginformatics/polyseg-wasm.git
  • Pull kitware/vtk-wasm Docker image

    $ docker pull kitware/vtk-wasm:v9.2.6-2743-gdcc0ce36db-20230312
  • Run build.sh:

    $ cd polyseg-wasm
    $ ./build.sh
  • If you have trouble running build.sh, please execute this command chmod +x build.sh and chmod +x build_wasm.sh to allow the shell scripts to excute in your machine.