Skip to content

Commit

Permalink
build(WASI): Fix WASI build / execution
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Mar 16, 2023
1 parent ff2a6ac commit 0b9cbfc
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -24,6 +24,9 @@ set(_itk_build_shared ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
set(cleaver_GIT_REPOSITORY "https://github.com/SCIInstitute/Cleaver2")
set(cleaver_GIT_TAG "02ba7b5fda5578b348a1dd54fb1660ef6cc7faf2")
# Add https://github.com/SCIInstitute/Cleaver2/pull/122
set(cleaver_GIT_REPOSITORY "https://github.com/thewtex/Cleaver2")
set(cleaver_GIT_TAG "2a4d7406b760e7af9f3a0d1f97d6168ddde7d1c7")
FetchContent_Declare(
cleaver_lib
GIT_REPOSITORY ${cleaver_GIT_REPOSITORY}
Expand Down
2 changes: 2 additions & 0 deletions include/itkCleaverImageToMeshFilter.hxx
Expand Up @@ -658,6 +658,8 @@ CleaverImageToMeshFilter<TInputImage, TOutputMesh>
{
delete field;
}

mesher.cleanup();
}

} // end namespace itk
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "npm run build:emscripten && npm run bindgen:typescript && npm run build:wasi",
"build:emscripten": "itk-wasm -i itkwasm/emscripten:20230214-4d22c050 build",
"build:wasi": "itk-wasm -i itkwasm/wasi:20230214-4d22c050 build",
"build:wasi": "itk-wasm -i itkwasm/wasi:20230315-baaa731f build",
"build:wasi:debug": "itk-wasm -i itkwasm/wasi:20230214-4d22c050-debug build -- -DCMAKE_BUILD_TYPE=Debug",
"bindgen:typescript": "itk-wasm -b emscripten-build bindgen --output-dir wasm/typescript --package-name @itk-wasm/cleaver --package-description \"The Cleaver multimaterial tetrahedral meshing tool.\" --repository 'https://github.com/SCIInstitute/Cleaver2'",
"clean": "git clean -fdx -e node_modules"
Expand Down
13 changes: 8 additions & 5 deletions wasm/ITKCleaverWasm.cxx
Expand Up @@ -24,7 +24,7 @@

template<typename TImage>
int
Mesher(itk::wasm::Pipeline & pipeline, std::vector<const TImage *> & inputImages)
Mesher(itk::wasm::Pipeline & pipeline, std::vector<typename TImage::ConstPointer> & inputImages)
{
using ImageType = TImage;

Expand Down Expand Up @@ -66,7 +66,9 @@ Mesher(itk::wasm::Pipeline & pipeline, std::vector<const TImage *> & inputImages

ITK_WASM_CATCH_EXCEPTION(pipeline, filter->Update());

outputTriangleMesh.Set(filter->GetOutput(1));
typename MeshType::ConstPointer triangleMesh = filter->GetOutput(1);
typename MeshType::ConstPointer mmesh = filter->GetOutput(0);
outputTriangleMesh.Set(triangleMesh);

return EXIT_SUCCESS;
}
Expand All @@ -85,10 +87,11 @@ class PipelineFunctor

ITK_WASM_PRE_PARSE(pipeline);

std::vector<const ImageType *> loadedInputImages;
for(auto image: inputImages)
std::vector<typename ImageType::ConstPointer> loadedInputImages;
loadedInputImages.resize(inputImages.size());
for(size_t ii = 0; ii < inputImages.size(); ++ii)
{
loadedInputImages.push_back(image.Get());
loadedInputImages[ii] = inputImages[ii].Get();
}

int result = Mesher<ImageType>(pipeline, loadedInputImages);
Expand Down
Binary file added wasm/mickey.nrrd
Binary file not shown.
Binary file added wasm/spheres1.nrrd
Binary file not shown.
Binary file added wasm/spheres2.nrrd
Binary file not shown.
Binary file added wasm/spheres3.nrrd
Binary file not shown.
Binary file added wasm/spheres4.nrrd
Binary file not shown.

0 comments on commit 0b9cbfc

Please sign in to comment.