Visualize field of data-derived polygonal surfaces with individual textures ("rich glyphs")

Hi, I have long tried to find a good way of doing this - I want to show a field of “rich glyphs”, more complicated than the TensorGlyph class but following a similar idea. I want to show a field of glyphs with a base geometry (e.g. sphere), but I want to be able to distort the geometry of each glyph based on my array of data (e.g., a grid where at every grid point we have defined a function value at each spherical coordinate, which may be pre-calculated or dynamically calculated) and color each face or vertex of the glyph based on the data as well (possible stored in some kind of texture array).

I want the end result to be something like this, which I did in Mayavi by painstakingly creating separate PolyData Pipelines on spherical grids and then translating, distorting and coloring them.


The closest I have been able to find is something like vtkProgrammableGlyphfilter which seems to allow distortion of the geometry of each glyph, but I have not found any examples of how to leverage this class, or anything similar to it, in ParaView, or really any usage examples of it beyond the unit tests, or exactly how powerful it is.

I don’t really care how complicated it would be to achieve this, as long as I don’t have to set up a separate pipeline for each and every “glyph”. It seems to me that in principle this should be possible since something like it is already doable with e.g. the “scale by vector component” feature of the 3DGlyph Representation, I just want more fine-grained control over the shape, and also control over the texture.

Thanks in advance!

Have you tried the Glyph With Custom Source Filter in ParaView?
In the filter properties, you can apply custom scaling according to a given data array.

I have, I don’t recall it being possible to distort each vertex in a glyph by any obvious means though? Is it also possible to apply a custom texture to each glyph, based on the same or a similar data array?

The Programmable Filter is documented in Chapter 5 of the ParaView Reference Manual.

If you are ever looking for the ParaView documentation, you can get to it by opening ParaView and selecting the menu item HelpParaView Guide.

Yeah, I’m a heavy user of Python filters, but can I use the vtkProgrammableGlyphFilter directly through it? Are there any examples of how to use similar vtk objects?

EDIT: I think I figured out a way - apply a Glyph filter, then modify the Points attribute of Input in a Python Programmable Filter. E.g.

inp = inputs[0]


pts = inp.Points.reshape(66,66,66, 50, 3).copy()
import numpy as np
grid = np.ascontiguousarray(np.mgrid[0:66:1, 0:66:1, 0:66:1].T)

pts[..., 0] = 1.25 * grid[..., 0] - 0.25 * pts[..., 0]
output.SetPoints(pts.reshape(-1, 3))

to flatten the x-direction. I think this will work for my purposes, if I figure out how to apply textures.

Edit 2: I did it! Basically followed the logic above, imported my own Python modules for calculating the things, and just dynamically calculated what everything should be. Until now it was really unclear to me how mapping colors to glyph surfaces worked, I didn’t realize it was as simple as “one value per Point”, it would be very nice if this kind of behaviour was more clearly documented somewhere.

1 Like