diff --git a/package.json b/package.json index 385910c..1241366 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,11 @@ "description": "npm scripts to generate itk-wasm artifacts.", "type": "module", "scripts": { - "build": "npm run build:emscripten && npm run build:wasi", - "build:emscripten": "itk-wasm -i itkwasm/emscripten:20230315-07caf9ca build", - "build:emscripten:debug": "itk-wasm -i itkwasm/emscripten:20230315-07caf9ca-debug build -- -DCMAKE_BUILD_TYPE:STRING=Debug", - "build:wasi": "itk-wasm -i itkwasm/wasi:20230315-07caf9ca build", - "build:wasi:debug": "itk-wasm -i itkwasm/wasi:20230315-07caf9ca-debug build -- -DCMAKE_BUILD_TYPE:STRING=Debug", + "build": "npm run build:emscripten && npm run build:wasi && npm run bindgen:typescript", + "build:emscripten": "itk-wasm -i itkwasm/emscripten:20230328-71e6501e build", + "build:emscripten:debug": "itk-wasm -i itkwasm/emscripten:20230328-71e6501e-debug build -- -DCMAKE_BUILD_TYPE:STRING=Debug", + "build:wasi": "itk-wasm -i itkwasm/wasi:20230328-71e6501e build", + "build:wasi:debug": "itk-wasm -i itkwasm/wasi:20230328-71e6501e-debug build -- -DCMAKE_BUILD_TYPE:STRING=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'", "test": "npm run test:wasi", "test:wasi": "itk-wasm test --test-dir wasm", @@ -16,6 +16,6 @@ }, "license": "Apache-2.0", "devDependencies": { - "itk-wasm": "^1.0.0-b.87" + "itk-wasm": "^1.0.0-b.91" } } diff --git a/wasm/ITKCleaverWasm.cxx b/wasm/ITKCleaverWasm.cxx index 111f383..e826c78 100644 --- a/wasm/ITKCleaverWasm.cxx +++ b/wasm/ITKCleaverWasm.cxx @@ -83,7 +83,7 @@ class PipelineFunctor using InputImageType = itk::wasm::InputImage; std::vector inputImages; - pipeline.add_option("-i,--input", inputImages, "Input label image or multiple indicator function images")->type_name("INPUT_IMAGE"); + auto inputImagesOption = pipeline.add_option("-i,--input", inputImages, "Input label image or multiple indicator function images")->type_name("INPUT_IMAGE"); ITK_WASM_PRE_PARSE(pipeline); @@ -94,6 +94,7 @@ class PipelineFunctor loadedInputImages[ii] = inputImages[ii].Get(); } + inputImagesOption->required(); int result = Mesher(pipeline, loadedInputImages); return result; } diff --git a/wasm/typescript/dist/pipelines/itk-cleaver.wasm b/wasm/typescript/dist/pipelines/itk-cleaver.wasm index 666395c..9079da3 100755 Binary files a/wasm/typescript/dist/pipelines/itk-cleaver.wasm and b/wasm/typescript/dist/pipelines/itk-cleaver.wasm differ diff --git a/wasm/typescript/src/itk-cleaver-node.ts b/wasm/typescript/src/itk-cleaver-node.ts index 0610442..9be339c 100644 --- a/wasm/typescript/src/itk-cleaver-node.ts +++ b/wasm/typescript/src/itk-cleaver-node.ts @@ -35,15 +35,17 @@ async function itkCleaverNode( args.push('0') // Options args.push('--memory-io') - if (options.input.length < 1) { - throw new Error('"input" option must have a length > 0') + if (typeof options.input !== "undefined") { + if(options.input.length < 1) { + throw new Error('"input" option must have a length > 1') + } + args.push('--input') + options.input.forEach((value) => { + const inputCountString = inputs.length.toString() + inputs.push({ type: InterfaceTypes.Image, data: value as Image}) + args.push(inputCountString) + }) } - args.push('--input') - options.input.forEach((inputImage, index) => { - args.push((index+0).toString()) - inputs.push({ type: InterfaceTypes.Image, data: inputImage as Image}) - - }) if (typeof options.sigma !== "undefined") { args.push('--sigma', options.sigma.toString()) } diff --git a/wasm/typescript/src/itk-cleaver.ts b/wasm/typescript/src/itk-cleaver.ts index e44f7fa..51b74d9 100644 --- a/wasm/typescript/src/itk-cleaver.ts +++ b/wasm/typescript/src/itk-cleaver.ts @@ -39,15 +39,17 @@ async function itkCleaver( args.push('0') // Options args.push('--memory-io') - if (options.input.length < 1) { - throw new Error('"input" option must have a length > 0') + if (typeof options.input !== "undefined") { + if(options.input.length < 1) { + throw new Error('"input" option must have a length > 1') + } + args.push('--input') + options.input.forEach((value) => { + const inputCountString = inputs.length.toString() + inputs.push({ type: InterfaceTypes.Image, data: value as Image}) + args.push(inputCountString) + }) } - args.push('--input') - options.input.forEach((inputImage, index) => { - args.push((index+0).toString()) - inputs.push({ type: InterfaceTypes.Image, data: inputImage as Image}) - - }) if (typeof options.sigma !== "undefined") { args.push('--sigma', options.sigma.toString()) }