Interface TypesΒΆ

ITK-Wasm execution pipelines support the following interface types:

These interfaces types are supported in the Emscripten interface, WASI embedding interfaces, and native or virtual filesystem IO. They are intended to be forward-compatible with the WebAssembly Component Model.


The following CLI11 itk::wasm::Pipeline components can be included in a C++ to ingest and produce these interface types. For Input types, use Get() to get the corresponding C++ object value after ITK_WASM_PARSE_ARGS is called. For Output types, use Set(value) to output the value before main exits. For example,

#include "itkPipeline.h"
#include "itkInputTextStream.h"
#include "itkOutputTextStream.h"

int main(argc, char * argv[])
{
  itk::wasm::Pipeline pipeline("test-pipeline", "A test ITK Wasm Pipeline", argc, argv);

  itk::wasm::InputTextStream inputTextStream;
  pipeline.add_option("InputText", inputTextStream,
    "The input text")->required()->type_name("INPUT_TEXT_STREAM");

  itk::wasm::OutputTextStream outputTextStream;
  pipeline.add_option("OutputText", outputTextStream,
    "The output text")->required()->type_name("OUTPUT_TEXT_STREAM");


  ITK_WASM_PARSE(pipeline);


  const std::string inputTextStreamContent{ std::istreambuf_iterator<char>(inputTextStream.Get()),
                                            std::istreambuf_iterator<char>() };

  outputTextStream.Get() << inputTextStreamContent;
}
itk::wasm::InputTextStream
A text stream input. To read this data type in C++, use the resulting std::istream from Get().
itk::wasm::OutputTextStream
A text stream output. To write to this data type in C++, use the resulting std::ostream from Get().
itk::wasm::InputBinaryStream
A binary stream input. To read this data type in C++, use the resulting std::istream from Get().
itk::wasm::OutputBinaryStream
A binary stream output. To write to this data type in C++, use the resulting std::ostream from Get().
itk::wasm::InputImage<TImage>
An input image of type TImage. To access the image in C++, use Get() to get a pointer to the TImage.
itk::wasm::OutputImage<TImage>
An output image of type TImage. To set the output image in C++, use Set(image) with a pointer to the TImage.
itk::wasm::InputMesh<TMesh>
An input mesh of type TMesh. To access the mesh in C++, use Get() to get a pointer to the TMesh.
itk::wasm::OutputMesh<TMesh>
An output mesh of type TMesh. To set the output mesh in C++, use Set(mesh) with a pointer to the TMesh.
itk::wasm::InputPointSet<TPointSet>
An input point set of type TPointSet. To access the point set in C++, use Get() to get a pointer to the TPointSet.
itk::wasm::OutputPointSet<TPointSet>
An output point set of type TPointSet. To set the output point set in C++, use Set(pointSet) with a pointer to the TPointSet.
itk::wasm::InputPolyData<TPolyData>
An input polydata of type TPolyData. To access the polydata in C++, use Get() to get a pointer to the TPolyData.
itk::wasm::OutputPolyData<TPolyData>
An output polydata of type TPolyData. To set the output polydata in C++, use Set(polyData) with a pointer to the TPolyData.
itk::wasm::InputTransform<TTransform>
An input transform of type TTransform. To access the transform in C++, use Get() to get a pointer to the TTransform.
itk::wasm::OutputTransform<TTransform>
An output transform of type TTransform. To set the output transform in C++, use Set(transform) with a pointer to the TTransform.
std::string (for files)
File paths for input and output files. Use the type names INPUT_TEXT_FILE, OUTPUT_TEXT_FILE, INPUT_BINARY_FILE, or OUTPUT_BINARY_FILE. The string contains the file path that can be used with standard file I/O operations.
itk::wasm::InputTextStream (for JSON)
JSON input data. Use the type name INPUT_JSON. To read the JSON data in C++, use the resulting std::istream from Get() and parse the JSON content.
itk::wasm::OutputTextStream (for JSON)
JSON output data. Use the type name OUTPUT_JSON. To write JSON data in C++, use the resulting std::ostream from Get() and write the JSON content.

For binding generation, set the type_name an the options accordingly. The type names are:

  • INPUT_TEXT_FILE

  • OUTPUT_TEXT_FILE

  • INPUT_BINARY_FILE

  • OUTPUT_BINARY_FILE

  • INPUT_TEXT_STREAM

  • OUTPUT_TEXT_STREAM

  • INPUT_BINARY_STREAM

  • OUTPUT_BINARY_STREAM

  • INPUT_IMAGE

  • OUTPUT_IMAGE

  • INPUT_MESH

  • OUTPUT_MESH

  • INPUT_POINTSET

  • OUTPUT_POINTSET

  • INPUT_POLYDATA

  • OUTPUT_POLYDATA

  • INPUT_TRANSFORM

  • OUTPUT_TRANSFORM

  • INPUT_JSON

  • OUTPUT_JSON