[vtkusers] vtkUnstructuredGrid - "hiding" cells

Andrea Gavana andrea.gavana at gmail.com
Tue Nov 22 14:00:19 EST 2016

Dear All,

I'm working with a vtkUnstructuredGrid coming from a CFD simulation. The
grid is composed by hexahedron cells, and the input grid defines all
coordinates for all cells (as a Nx x Ny x Nz number if cells).

However, based on other inputs, the CFD simulator deactivates some of the
cells. Also, in my user interface built on top of VTK, I allow the user to
"filter" the grid by selecting only a certain number of layers (in the Nz
direction) or selecting an interval in the x and y direction to create a
"sub grid" of the original grid and so on.

Now, it would be nice if there was an easy way to say: "all cells outside
the user selection and all cells deactivated by the simulator should be
invisible", without creating a new vtkUnstructuredGrid every time the user
changes her selection.

At the moment I'm handling this (awkwardly) using vtkThreshold, but the
original cell ids are lost using this filter and this approach also
requires the creation of a new vtkUnstructuredGrid, hiding the full model,
adding a new actor for the new vtkUnstructuredGrid and rendering again.
Having the original grid always there (but with hidden cells) also allows
me to keep the vtkUnstructuredGrid and all the properties loaded from the
simulation files (as Numpy arrays) in sync without much gymnastics. And
also allows me to use pickers to retrieve cell ids that are in sync with
the unfiltered grid (which I very much need...).

Does anyone have a better idea on how to handle this situation?

I'm using VTK 7.0 in Python.

Thank you in advance for your suggestions.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161122/d1e59dda/attachment.html>

More information about the vtkusers mailing list