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

**URL:** https://discourse.paraview.org/t/visualize-field-of-data-derived-polygonal-surfaces-with-individual-textures-rich-glyphs/12446
**Category:** ParaView Support
**Created:** [July 4, 2023, 6:40pm UTC](https://discourse.paraview.org/t/visualize-field-of-data-derived-polygonal-surfaces-with-individual-textures-rich-glyphs/12446 "2023-07-04T18:40:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![leoniel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/fbc32d/32.png) [@leoniel](https://discourse.paraview.org/u/leoniel)
#### Post date: [July 4, 2023, 6:40pm UTC](https://discourse.paraview.org/t/visualize-field-of-data-derived-polygonal-surfaces-with-individual-textures-rich-glyphs/12446/1 "2023-07-04T18:40:03Z")

</div>

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.

![image](https://discourse.paraview.org/uploads/default/original/2X/b/b05b6d545d5d3153984d305996c9923bb794c214.jpeg)

The closest I have been able to find is something like [vtkProgrammableGlyphfilter](https://vtk.org/doc/nightly/html/classvtkProgrammableGlyphFilter.html#aa7dd85bae0f494a60a30dd025e31a399) 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!

---

<div class="post-metadata">

### Author: ![Francois\_Mazen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/francois_mazen/32/6483_2.png) [@Francois\_Mazen](https://discourse.paraview.org/u/Francois_Mazen)
#### Post date: [July 5, 2023, 10:01am UTC](https://discourse.paraview.org/t/visualize-field-of-data-derived-polygonal-surfaces-with-individual-textures-rich-glyphs/12446/2 "2023-07-05T10:01:57Z")

</div>

Have you tried the [Glyph With Custom Source](https://docs.paraview.org/en/latest/UsersGuide/filteringData.html#glyph-with-custom-source) Filter in ParaView?  
In the filter properties, you can apply custom scaling according to a given data array.

---

<div class="post-metadata">

### Author: ![leoniel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/fbc32d/32.png) [@leoniel](https://discourse.paraview.org/u/leoniel)
#### Post date: [July 5, 2023, 10:20am UTC](https://discourse.paraview.org/t/visualize-field-of-data-derived-polygonal-surfaces-with-individual-textures-rich-glyphs/12446/3 "2023-07-05T10:20:51Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [July 5, 2023, 11:32am UTC](https://discourse.paraview.org/t/visualize-field-of-data-derived-polygonal-surfaces-with-individual-textures-rich-glyphs/12446/4 "2023-07-05T11:32:19Z")

</div>

The `Programmable Filter` is documented in Chapter 5 of the _ParaView Reference Manual_.

[https://docs.paraview.org/en/latest/ReferenceManual/pythonProgrammableFilter.html](https://docs.paraview.org/en/latest/ReferenceManual/pythonProgrammableFilter.html)

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

---

<div class="post-metadata">

### Author: ![leoniel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/fbc32d/32.png) [@leoniel](https://discourse.paraview.org/u/leoniel)
#### Post date: [July 5, 2023, 11:55am UTC](https://discourse.paraview.org/t/visualize-field-of-data-derived-polygonal-surfaces-with-individual-textures-rich-glyphs/12446/5 "2023-07-05T11:55:02Z")

</div>

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.

```auto
inp = inputs[0]

print(inp.Points.shape)

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.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/a/abc4dfd7485cb792d45a1a508425de4321ce6ce9.jpeg)
