I have a vtk structured grid with single scalar points data (temperature values). I am taking a planar slice out of it using vtk cutter and supplying it a constant z plane. Then, I am exporting that slice out to a gltf file. I am also trying to export out the slice texture as png. Here is my code snippet:
plane = vtk.vtkPlane()
plane.SetNormal(0.0, 0.0, 1.0)
cutter = vtk.vtkCutter()
slice = cutter.GetOutput()
mapper = vtk.vtkPolyDataMapper()
actor = vtk.vtkActor()
renderer = vtk.vtkRenderer()
render_window = vtk.vtkRenderWindow()
exporter = vtk.vtkGLTFExporter()
w2if = vtk.vtkWindowToImageFilter()
writer = vtk.vtkPNGWriter()
Firstly, the vtk render window doesn’t show temperature colors. When I open the exported GLTF in paraview, it opens in “Solid color” mode by default, and when I change that to TEXCOORD_0, it correctly shows colors corresponding to temperature values, just that the slice colors correspond to temperature range within the slice. Additionally, when I open this GLTF in a GLTF viewer, e.g. Babylon.js, it doesn’t show up with TEXCOOR_0 colors. Furthermore, what I export out as png is the render_window, while I just want to export out the slice.
My questions are:
- How to rename TEXCOORD_0 to a more appropriate attribute name, e.g. “temp”?
- How to change slice colors so that they correspond to the temperature values in the grid and not in the slice?
- How to setup gltf export such that by default it opens with TEXCOORD_O or temp in any gltf viewer.
- How to export slice texture out as a png image?