Python Algorithm Plugins and Applying Textures

In PVGeo, I am implementing a few file readers as Python Algorithm Plugins that read files containing spatial discretization, data values, and textures that can be applied to the surfaces defined.

I am curious if it is possible to directly apply the loaded texture to a VTK data object on the pipeline. I can easily create/add the texture mapping via: vtkobj.GetPointData().SetTCoords(tcoords)

But is it possible to actually associate a texture with this data object? Would I need to place a vtkTexture object on a second output port? I’d prefer to be able to explicitly define the texture for the given data object though.

I am afraid not. The texture is a “rendering” property which is intentionally separate from the data itself.

I figured this was intentionally seperated.

Would it be possible to create a second source on the pipeline that the dropdown menu for the texture picker would recognize?

I’m not sure that’s your question but if you try to figure out how to load and assign texture in Python for ParaView, you can look at that code snippet.

Create textures from files

Assign texture to a representation



Oh, awesome! I think I could implement a similar routine as paraview.servermanager is available when the vtkPythonAlgorithm is executed on the pipeline.

My new question would be: could I use an already loaded data array as the texture instead of a file? i.e. I would like to skip loading a new file but use some data already loaded as a 2D numpy array which I could convert to a VTK data object via the vtk.util.numpy_support module.

If this isn’t possible, then I could use Python’s native shutil and tempfile to temporarily write out the texture as a JPEG then delete the file after ParaView loads it up. The only issue I see with this is that there might be some strange behavior when saving/loading ParaView states.

Don’t :)! vtkPythonAlgorithm should never import paraview.servermanager. They are operating in different environments and you’ll run into crazy issues if you do so.

Conceptually, ParaVIew has two Python environments: (a) one under which the data processing code executes and (b) for scripting client-side logic to build pipelines etc (things one does in the GUI). PythonAlgorithm operates in (a) while the paraview.servermanager, paraview.simple APIs operate in (b). The two should not be mixed.

1 Like

Shucks! So I suppose I am out of options for this unless there might be a way to push the texture out on one of the vtkPythonAlgorithm's output ports?