itk-wasm
itk-wasm copied to clipboard
Support vtkPolyData as input in run pipeline browser
Hi! I have created a pipeline that modifies vtkPolyData. Now I'm trying to find the best way to pass a vtkPolyData to runPipelineBrowser as an input. However vtkPolyData is not a supported IOType as input (it is for output). Why is this?
I have considered the following options as workarounds:
- Use/write a function to convert the vtkPolyData to an ITK mesh. Are there any functions available that can do this efficiently? I'm not a big fan of this approach as in the C code I would have to convert the mesh again to a vtkPolydata.
- Pass the points and the cells as binary arrays and build the Polydata from these arrays again in C++. I'm not very comfortable with C++ so any help/examples would be appreciated.
I can imagine that these options are not really optimal so I would be happy the hear what the better approach is!
Hi @a3VonG !
I have created a pipeline that modifies vtkPolyData.
Nice!
However vtkPolyData is not a supported IOType as input (it is for output). Why is this?
Correct -- we are missing the C++ code for this, identified in issue https://github.com/InsightSoftwareConsortium/itk-js/issues/254, we need a vtkJSONDataSetReader
similar to the current vtkJSONDataSetWriter
.
Use/write a function to convert the vtkPolyData to an ITK mesh. Are there any functions available that can do this efficiently?
Not currently, but see the classes:
- https://github.com/InsightSoftwareConsortium/ITKVtkGlue/blob/master/include/itkMeshToVTKUnstructuredGridFilter.h
- https://github.com/InsightSoftwareConsortium/ITKMeshToPolyData/blob/master/include/itkMeshToPolyDataFilter.h
for references to go the other direction.
Pass the points and the cells as binary arrays and build the Polydata from these arrays again in C++. I'm not very comfortable with C++ so any help/examples would be appreciated.
Yes, this is preferred -- we need a vtkJSONDataSetReader
supporting PolyData.
The conversion function functions are demonstrated here: https://kitware.github.io/vtk-js/examples/ItkWasmGeometry.html