Vtkimage data over vtkstrcturedgrid (performance)

Hello, i’m having issues with vtk, as i’m learning it i was asked to make some performance tests, and so i made this little program.
It createsa vtkstructuredgrid with different sizes and displays the rendering time, but i have an issue, i’m forced to create a points array. It takes a lot of memory space, so i tried to swap from vtkstructuredgrid to vtkimagedata.
There’s an issue, it seems to be the best alternative because it doesn’t require the point array, and seems to cost less memory, on the other hand i can’t quite find how to blank cells or the pixel equivalents in vtkImage data.
Is there a way to do so? Or is there another alternative to vtkstructuredgrid that does the same and uses less memory?
(A screen capture of a render example of the code that is linked to the post)

image_data.cxx (5.3 KB)

If you want to do blanking, you should use vtkUniformGrid. It is a vtkImageData with a blanking API. See here.

Thanks for the answer, i tried your solution but the blanking doesn’t seem to work, instead the cells that should be blanked are still visible and i can’t quite find why it does so?

So after testing a few possibilities, i’m stuck, when i use directly an UniformGrid i have the result on the screen attached, (code attached too) but when i use a geometryfilter on it i can see that the cell are blanked but the result is still not as expected, as i would like it to be blanking cells like with vtksctructuredgrid but with less rendering time.uniform_grid.cxx (4.9 KB)

^With uniformgrid alone

^With uniform grid + geometry filter

I think I see where the problem comes from. I’m going to try to write a fix. Do you mind using VTK master for your case?

I’m not really used to the master of VTK, but if you could just send me the fix you may be able to write, it would be awesome, thanks a lot anyway!
Sorry, i’m a bit of a newbie on vtk, i’m a trainee and i’m learning it at the moment.

See this issue

I’ll give you a link to a Merge Request with the fix. I don’t know if you can just plug it on your local VTK and make it work. You’ll have to try it yourself.

Here’s a fix.

When you visualize your vtkImageData or your vtkUniformGrid, you should use vtkDataSetSurfaceFilter right before using the mapper.

I’m curious Yohann, is there an explicit reason why you recommend vtkDataSetSurfaceFilter? With the changes I made in the last year, vtkGeometryFilter is typically much faster than vtkDataSetSurfaceFilter (especially when SMP threading is enabled - although this varies based on the type of dataset). Any feedback is welcome…

I am recommending vtkDataSetSurfaceFilter for this case because when I read the code I found an easy fix to make the blanking work. But you’re right, in the long run we should also make the geometry filter work correctly with blanked cells, and use SMP threading if possible.

Thanks, I’ll add this to the TODO list based on what you did

Hmmm there are a few things that disturb me, it took me quite a long time with my it at work to install the master vtk and so, even if i don’t use the filter i still have the blank cells with the uniform grid, which is what i wanted and the rendering times a way faster than with a structuredgrid, but i lost all my colors, even if i still plug in my lookuptable, the cells are all blue :confused: i don’t quite know why, have you got any idea? By the way, a big thanks for all the work you put to make this fix that fast!

Ok nevermind, i corrected it and finally have what i wanted with a correct blanking and colors, thanks for everything!

Hello, would it be possible (even wiser) to use a vtkSelection to obtain the same result as seen in the first message of this topic ?