Incorrect rendering of Axes when rendering to an image file
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
The following code does not render the axes when magnification is not 1.
import sys
import vtk
print vtk.vtkVersion().GetVTKVersion()
#.SetSolidTypeToIcosahedron();
cs = vtk.vtkConeSource()
cs.SetResolution(36)
cs.SetRadius(1.0)
m = vtk.vtkPolyDataMapper()
m.SetInputData(cs.GetOutput())
p = vtk.vtkProperty()
p.SetRepresentationToWireframe()
a = vtk.vtkActor()
a.SetMapper(m)
a.SetProperty(p)
p.SetColor(0.8, .1, .9)
ren = vtk.vtkRenderer()
ren.SetBackground(0.7, 0.7, 0.7)
ren.AddViewProp(a)
ren.viewport = (0, 0, 0.5, 1.0)
axes = vtk.vtkCubeAxesActor2D()
axes.SetInputData(cs.GetOutput())
axes.SetCamera(ren.GetActiveCamera())
ren.AddViewProp(axes)
ren.GetActiveCamera().SetPosition(0.0, 2.0, 0.0)
ren.GetActiveCamera().SetFocalPoint(0.0, 0.0, 0.0)
ren.GetActiveCamera().SetParallelProjection(True)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
cs.Update()
iren.SetRenderWindow(renWin)
ren.ResetCamera()
iren.Initialize()
w2if = vtk.vtkWindowToImageFilter()
w2if.SetMagnification(int(sys.argv[1]))
w2if.SetInput(renWin)
ex = vtk.vtkPNGWriter()
ex.SetFileName('bar.png')
ex.SetInputConnection(w2if.GetOutputPort())
cs.Update()
renWin.Render()
ex.Update()
ex.Write()
iren.Start()
You can see more detail about the issue at
https://github.com/enthought/mayavi/issues/314
but the gist of the issue is, as far as I could gather, that the tiling disrupts the Ortho transformation, producing an incorrect vtkRenderer::WorldToView transformation.
I might keep digging into the issue, but not being familiar with the internals, I don't know if this is intended behavior that is supposed to be offset somewhere else.
Edited by Ben Boeckel