Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Itk wasm update #25

Merged
merged 2 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: WebAssembly

on: [push,pull_request]

jobs:
Build WebAssembly:
name: Build WebAssembly
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install
run: |
npm install

- name: Build
run: |
npm run build
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@
Cleaver2
examples/.ipynb_checkpoints/
examples/triangle_mesh.vtk

wasi-build
pnpm-lock.yaml
node_modules/
emscripten-build/
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ endif()

include(FetchContent)
set(_itk_build_testing ${BUILD_TESTING})
#set(BUILD_TESTING OFF)
if(WASI OR EMSCRIPTEN)
set(BUILD_TESTING OFF CACHE BOOL "Build testing code" FORCE)
endif()
if (CMAKE_CXX_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
endif()
Expand Down Expand Up @@ -42,6 +44,9 @@ if(NOT ITK_SOURCE_DIR)
find_package(ITK REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
include(ITKModuleExternal)
if(WASI OR EMSCRIPTEN)
add_subdirectory(wasm)
endif()
else()
set(ITK_DIR ${CMAKE_BINARY_DIR})
itk_module_impl()
Expand Down
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "itk-cleaver",
"version": "1.0.0",
"description": "npm scripts to generate itk-wasm artifacts.",
"type": "module",
"scripts": {
"build": "npm run build:emscripten && npm run bindgen:typescript",
"build:emscripten": "npx itk-wasm -b emscripten-build build",
"bindgen:typescript": "npx itk-wasm -b emscripten-build bindgen --output-dir wasm/typescript --package-name itk-cleaver --package-description \"The Cleaver multimaterial tetrahedral meshing tool.\" --repository 'https://github.com/SCIInstitute/Cleaver2'",
"clean": "git clean -fdx -e node_modules"
},
"license": "Apache-2.0",
"devDependencies": {
"itk-wasm": "^1.0.0-b.70"
}
}
6 changes: 3 additions & 3 deletions examples/CMakeLists.txt → wasm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(ITKCleaverWebAssembly)
project(ITKCleaverWasm)

set(CMAKE_CXX_STANDARD 17)

Expand All @@ -25,8 +25,8 @@ find_package(ITK REQUIRED
)
include(${ITK_USE_FILE})

add_executable(ITKCleaverWasm ITKCleaverWasm.cxx)
target_link_libraries(ITKCleaverWasm PUBLIC ${ITK_LIBRARIES})
add_executable(itk-cleaver ITKCleaverWasm.cxx)
target_link_libraries(itk-cleaver PUBLIC ${ITK_LIBRARIES})

enable_testing()
add_test(NAME ITKCleaverWasmLabelImageTest
Expand Down
6 changes: 3 additions & 3 deletions examples/ITKCleaverWasm.cxx → wasm/ITKCleaverWasm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "itkPipeline.h"
#include "itkInputImage.h"
#include "itkOutputMesh.h"
#include "itkSupportInputImageTypesNoVectorImage.h"
#include "itkSupportInputImageTypes.h"
#include "itkMesh.h"

template<typename TImage>
Expand Down Expand Up @@ -98,9 +98,9 @@ class PipelineFunctor

int main( int argc, char * argv[] )
{
itk::wasm::Pipeline pipeline("Create a multi-material mesh suitable for simulation/modeling from an input label image or indicator function images", argc, argv);
itk::wasm::Pipeline pipeline("itk-cleaver", "Create a multi-material mesh suitable for simulation/modeling from an input label image or indicator function images", argc, argv);

return itk::wasm::SupportInputImageTypesNoVectorImage<PipelineFunctor,
return itk::wasm::SupportInputImageTypes<PipelineFunctor,
//uint8_t,
//int8_t,
uint16_t,
Expand Down