Skip to content

Commit

Permalink
Merge pull request #982 from thewtex/input-output-access
Browse files Browse the repository at this point in the history
Input output access
  • Loading branch information
thewtex authored Oct 27, 2023
2 parents 125ad6c + f82521c commit 3bf03ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 7 additions & 0 deletions include/itkWasmExports.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ namespace itk
namespace wasm
{

// dataset index, array index
using InputArrayStoreKeyType = std::pair<uint32_t, uint32_t>;
using InputArrayStoreValueType = std::vector<uint8_t>;
using InputArrayStoreType = std::map<InputArrayStoreKeyType, InputArrayStoreValueType>;

// Function for the Pipeline Input's and Output's to set / get from the memory store

WebAssemblyInterface_EXPORT const std::string & getMemoryStoreInputJSON(uint32_t memoryIndex, uint32_t index);

WebAssemblyInterface_EXPORT const InputArrayStoreType & getMemoryInputArrayStore();

WebAssemblyInterface_EXPORT void setMemoryStoreOutputDataObject(uint32_t memoryIndex, uint32_t index, const WasmDataObject * dataObject);

WebAssemblyInterface_EXPORT void setMemoryStoreOutputArray(uint32_t memoryIndex, uint32_t index, uint32_t subIndex, size_t address, size_t size);
Expand Down
2 changes: 1 addition & 1 deletion src/itk-wasm-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import pythonWebDemoBindgen from './bindgen/python-web-demo/python-web-demo-bind

const program = new Command()

const defaultImageTag = '20231012-93cb7447'
const defaultImageTag = '20231026-19713e3a'

function processCommonOptions(wasiDefault=false) {
const options = program.opts()
Expand Down
10 changes: 6 additions & 4 deletions src/itkWasmExports.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ namespace itk
namespace wasm
{

// dataset index, array index
using InputArrayStoreKeyType = std::pair<uint32_t, uint32_t>;
using InputArrayStoreType = std::map<InputArrayStoreKeyType, std::vector<char>>;
static InputArrayStoreType inputArrayStore;

// index
Expand All @@ -43,6 +40,11 @@ const std::string & getMemoryStoreInputJSON(uint32_t memoryIndex, uint32_t index
return inputJSONStore[index];
}

const InputArrayStoreType & getMemoryInputArrayStore()
{
return inputArrayStore;
}

using OutputWasmDataObjectStoreType = std::map<uint32_t, WasmDataObject::ConstPointer>;
static OutputWasmDataObjectStoreType outputWasmDataObjectStore;

Expand Down Expand Up @@ -75,7 +77,7 @@ size_t itk_wasm_input_array_alloc(uint32_t memoryIndex, uint32_t index, uint32_t
const auto key = std::make_pair(index, subIndex);
if (inputArrayStore.count(key))
{
inputArrayStore[key] = std::vector<char>(size);
inputArrayStore[key] = InputArrayStoreValueType(size);
}
else
{
Expand Down

0 comments on commit 3bf03ab

Please sign in to comment.