picking glyphs vtkGlyph3DMapper

Can anyone suggest what’s the right picker to use for finding out the top-most glyph at a glyph from a vtkGlyph3DMapper?

I tried to use vtkCellPicker, but it never seems to return any hits from the glyphs, only from other actors. There’s an old mailing list post that seems to suggest using vtkGlyph3D, which I can’t do because I need to independently rotate and scale the glyphs. This merge request strongly implies that it’s possible to pick cells, but maybe not with vtkCellPicker?

The fact that SelectionIdArray exists makes me think that it’s possible to do what I want, but I can’t figure out what picker to use (for single pixel top visible glyph and area all included glyphs).

We’ve implemented glyph display and efficient glyph picking in 3D Slicer, which now works interactively up to about a few ten thousands glyphs, displayed synchronized in several 2D and 3D. It was a lot of work, quite painful, and we ended up almost completely rewriting the VTK widgets infrastructure. See performance with 1k then with 10k glyphs in this demo video:

We used various selection/picking approaches for different problems. For example, we need extremely quick visibility check for all glyphs to show/hide glyph labels - we use hardware picker for that. However, when we hover over with the mouse over a glyph, we want to pick it even when we are exactly on top of it (because the glyph may be too small, so hitting it with the mouse can be really hard), so we do a closest point search for all the visible glyphs in screen coordinates. We only use cell picker when placing the glyph or moving it on the surface of other actors.

You can find the source code here and here. It’s quite complicated, so probably you cannot easily use these classes in your application (unless you use 3D Slicer as a basis of your application), but maybe you can take some ideas from it.

A very “rough” method would be to use a vtkPointPicker, since the input to the glyph mapper is a set of points. You could play with the SetTolerance(tol) of the picker to control how close the mouse has to be to the glyph point. You can also use PickFromListOn() and AddPickList(actor) to restrict picking to certain actor(s).

Honestly, I don’t know how well vtkPointPicker will work in this situation, so take this suggestion with a grain of salt.

And also need to ensure you only attempt to pick visible glyphs, update the appearance of the picked glyph, play nicely with other interactors and widgets, etc.

By way of summary, I never was able to get things to work with vtkGlyph3DMapper. However, vtkProgrammableGlyphFilter did eventually work, using vtkIdFilter to attach IDs to glyphs so I could match both point (vtkCellPicker) and area (vtkAreaPicker + vtkExtractGeometry) picking information to underlying glyphs.