Selective display of some cells from a polydata

Greetings,
I create a set of vtkPolyLine, stored in a vtkCellArray, which is given to vtkPolyData::SetLines().
Then the polydata is set as input data to a vtkPolyDataMapper.
By default, all cells (all polylines) are displayed.
What I want is to display only a subset of all the polylines, from a list of cells’ ids (vtkIdType) build on my own.

How to achieve that?
I hoped to find some kind of “SetVisible(bool)” function on cells, but it doesn’t seem to exist.
The easiest seems to create a separate vtkActor for each polyline, but that seems a bit overkill.

Searching around, I found mention of “ghosts” or “filters”, but I couldn’t find any consolidated documentation nor an example I could apply to my case. I also tried to set attribute vtkDataSetAttributes::CellGhostTypes::HIDDENCELL on cell but even that is a bit obscure and doesn’t work.

Any hint is welcome :slight_smile:

Regards,

It might help if you tell us a little more about what you’re trying to do. There are lots of ways to operate on your data to only show a subset of it. Do you know the composition of the subsets before you plot them, or do you determine that while they are being visualized, for example?

“Ghost” cells are often used for finite-element simulations, where blocks are broken up and handled by different threads/processes. The process needs to know a little bit about boundary cells in order to properly compute an answer. It isn’t so much so that they can be shown or not shown.

Thanks for your reply.
The subsets are known beforehand, but which ones are to be displayed is chosen at runtime by the user. To make an analogy, you display a swarm of bees, each having a name, and the user can choose from a list which specific one(s) he wants to see - hiding the others so they don’t get in the way.

In the end I found a way by setting the alpha channel in cells’ colour to 0, but that doesn’t seem the most correct way to proceed.

This question on discourse might be of use to you.

That seems interesting indeed, thank you, I’ll play with that idea.