Byte array in vtk pipeline

Hi All,

I am looking to create a vtk pipeline that passes a byte array as data. The data array does not contain any topological structure and can be any length (it’s a custom encoding of a data array). As such I am not really sure which VTK data set type (if any) it fits best too. I was thinking vtkUnsignedCharArray but have not found examples using that in the pipeline.

If anyone can point me to an example of this sort of thing it would really help.

cheers

Kit

If you want a pipeline that only passes a vtkUnsignedCharArray, I think that the best data set type to carry it would be vtkImageData, setting its extent to be one dimensional. You can put the data array as cell data or point data as you prefer. I’m proposing to use this data set type because the entire geometry is implicit, so you won’t have anything big allocated besides your data array.

To clarify, calling N the number of elements in your data array, you can create a 1D vtkImageData of extent [0, N, 0, 0, 0, 0] and put your data array as cell data, or of extent [0, N-1, 0, 0, 0, 0] and put your data as point data.

Fair enough. I had considered using vtkTable in the same way, but I guess vtkImageData works just as well.

Thanks

Yeah, I think vtkTable would be pretty equivalent. It’s up to you to decide what you want to use I guess. The advantages of vtkImageData is that the data is spatially located: you can compute gradients, this kind of things. So this is to be considered.

One limitation of vtkImageData is that its size is limited to 2147483647 per dimension, so a 1D image can be max 2GB for byte-sized data. The vtkArrayData class is worth looking at if you want to pass an array down the pipeline.

Thanks. So I guess I would make a vtkArray contained in a vtkArrayData object.

Is there an algorithm class for vtkArrayData methods? Like an equivalent of vtkImageDataAlgorithm.

Kit

The algorithm class is vtkArrayDataAlgorithm. See vtkExtractArray as a simple example of a concrete class that operates on vtkArrayData data objects.

Ah… I just realized that vtkArrayData uses “vtkArray” instead of “vtkDataArray”. This might impact your decision about whether to use it, since “vtkArray” is a alternative way of storing array data as compared to vtkDataArray (that is, a vtkArray is not a vtkDataArray and a vtkDataArray is not a vtkArray). The vtkArray class is a special-purpose class like vtkTable.

So perhaps the easiest way to pass a vtkDataArray down the pipeline is to attach it to the vtkFieldData of an otherwise empty vtkPolyData object. What I mean is, create an empty vtkPolyData and add arrays to data->GetFieldData().