6 import matplotlib.pyplot
as plt
7 from matplotlib.colors
import ListedColormap
8 import matplotlib.image
as mpimg
13 my_cmap = plt.cm.get_cmap(
"turbo", 124)
17 mesh = mesh.warp_by_vector(args.wrap_vector, factor=1)
19 p = pv.Plotter(notebook=
False, off_screen=
True)
25 smooth_shading=
False, cmap=my_cmap)
29 show_edges=
True, edge_color=
'white', color=
'white')
31 p.camera_position = args.d2
32 p.camera.zoom(args.zoom)
33 p.camera.roll += args.roll
34 p.camera.azimuth += args.azimuth
35 image = p.screenshot(
'%spng' % file[:-3])
38 return not files.endswith(
'vtk')
40 if __name__ ==
'__main__':
41 parser = argparse.ArgumentParser(
42 description=
"Convert multiple vtk files to png files using the pyvista.")
44 "files", help=
"list of vtk files or a regexp mask", nargs=
'+')
45 parser.add_argument(
'-d2',
'--d2', dest=
'd2', default=
'')
46 parser.add_argument(
'-f',
'--field', dest=
'field', default=
'', type=str)
47 parser.add_argument(
'-wv',
'--wrap_vector', dest=
'wrap_vector', default=
'', type=str)
48 parser.add_argument(
'--zoom', dest=
'zoom', default=1.2, type=float)
49 parser.add_argument(
'--roll', dest=
'roll', default=0, type=float)
50 parser.add_argument(
'--azimuth', dest=
'azimuth', default=0, type=float)
51 args = parser.parse_args()
56 from pyvirtualdisplay
import Display
57 display = Display(backend=
"xvfb", visible=
False, size=(800, 800))