Looking for optimal 3D grid with regular Z axis and arbitrary XY


I have a dataset wich has regular Z axis and arbytrary X and Y axes. If Z axis were also arbitrary then to display my dataset I would use vtkStructuredGrid and in this case I would need to set X,Y,Z coordinates for each point.
But since Z is regular (i.e. Z = Z_start, Z_start+dZ, …, Z_end) it is enough to set X, Y coordinates for each Z-series to define all coordinates of my dataset.

Is there something like vtkImageData where I set X,Y coordinates for each Z-series (Z series is a single vector from Z_start to Z_end) and Z is defined as Z_start, dZ, Z_end?

The simple answer is no, there isn’t. It would be necessary to generate all the extra points and use either vtkStructuredGrid or vtkUnstructuredGrid.

1 Like

@dgobbi thank you!
And if every axis X,Y,Z has regular spacing so it could almost be visualized via vtkImageData but there are some missing data (missing some Z-series) at some XY coordinates. Do I need to somehow restore missing Z-series to display it as a vtkImageData or use vtkStructuredGrid or there is some more elegant way?

So it’s essentially a sparse image, with sparsity only in XY? The solution is going to depend on how you want to visualize it. Typically, VTK uses vtkUnstructuredGrid to represent sparse data but that’s not ideal (especially for volume rendering). It almost sounds like you want something like a masked vtkImageData.

Probably the most straightforward thing it to create a vtkImageData, and set all the unused values to some special value that doesn’t appear anywhere in your data. For example, for 16-bit data a value of -32678. For float, you could even use NAN. Then, when you display the data, use a lookup table that maps your special value to “transparent” (i.e. alpha value of zero). This might not work perfectly due to interpolation, but it might be worth a try.

1 Like

Thank you!

Yes. At some XY points there are no Z-series (like a vertical gaps).
I’m trying to avoid using vtkStructuredGrid beacause it should take about 4 times more than vtkImageData.
Probably transparency for NAN values may help.

I don’t know whether I understood what you want, but if have something similar:

These are sparse columns containing z-series. I used vtkPolyData for data set and vtkTubeFilter to turn the series into tubes. Of course you can SetNumberOfSides( 4 ) to achieve a blocky grid-like appearance.

1 Like

The code to render tubes from poly lines is here: https://github.com/PauloCarvalhoRJ/gammaray/blob/master/viewer3d/view3dbuilders.cpp . Look for a method called buildForAttributeFromSegmentSet.

1 Like

@Paulo_Carvalho Thank you! I’m definately going to try it

1 Like

You can also vtkTubeFilter::SetCapping( true ) to give a solid appearance to the columns.