Skip to content
Snippets Groups Projects
Create_png.py 830 B
Newer Older
  • Learn to ignore specific revisions
  • #!/usr/bin/env python
    
    # first argument is Mayavi mv file name
    # then focus point coordinates : xf yf zy
    # then camera angles and distance : phi theta dist
    # then png file name
    
    import mayavi
    import vtk
    import math
    import sys
    
    v=mayavi.mayavi()
    v.root.geometry("1270x824")
    v.root.update()
    v.load_visualization(sys.argv[1])
    v.renwin.ren.ResetCamera()
    
    xf=float(sys.argv[2])
    yf=float(sys.argv[3])
    zf=float(sys.argv[4])
    phi=float(sys.argv[5])/180.*math.pi
    theta=float(sys.argv[6])/180.*math.pi
    dist=float(sys.argv[7])
    xc=xf+dist*math.cos(phi)*math.cos(theta)
    yc=yf+dist*math.sin(phi)*math.cos(theta)
    zc=zf+dist*math.sin(theta)
    
    v.renwin.camera.SetPosition(xc,yc,zc)
    v.renwin.camera.SetViewUp(0,0,1)
    v.renwin.camera.SetFocalPoint(xf,yf,zf)
    v.renwin.camera.SetClippingRange(0.001,1000)
    v.renwin.Render()
    v.renwin.save_png(sys.argv[8])