Skip to content
Advertisement

VTK rendering 2D mesh in python

so i’m trying to render a 2D mesh using vtk (in python). I have a list of tuples containing all the points and also a list of tuples containing the points of each cell. Just to experiment, I tried to create a polydata object of a square with 4 elements and render it, but i ended up with this:

square

I would like it to show the lines connecting the nodes (like a wireframe) instead of solid square.. This is the code to produce the image above:

JavaScript

I would also like to know if it’s possible to have a gridline as the background of the render window, instead of a black color, just like this:

gridline

Thanks in advance!

Advertisement

Answer

You can use MeshActor.GetProperty().SetRepresentationToWireframe() (https://www.vtk.org/doc/nightly/html/classvtkProperty.html#a2a4bdf2f46dc499ead4011024eddde5c) to render the actor as wireframe, or MeshActor.GetProperty().SetEdgeVisibility(True) to render it as solid with edges rendered as lines.

Regarding the render window background, I don’t know.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement