[vtkusers] Rendering speed is window-size dependent - Example Script

Andrea Gavana andrea.gavana at gmail.com
Fri Jan 26 08:47:28 EST 2007


Hi All,

    I managed to put together a very small example that demonstrates
the problem. I am attaching a very small Python script, together with
the VTK data file here:

http://fs06n5.sendspace.com/dl/c5243ba232ae95758c05c8a8370602c4/45ba0437/cn12eo/VTKExample.zip

The loading process is very fast, you will see a wxNotebook with 2
pages. If you play a bit with the 2 VTKRenderWindows (switching pages
back and forth, zooming and panning), and then you try to maximize the
main frame, the rendering almost stops. It becomes *very* slow on one
of the two notebook tabs. The other seems unaffected. The unstructured
grid itself is small, so I wouldn't have expected such a huge
performance hit.

Could *please* someone try it and see if he/she gets the same result?

I am trying to test it also on ParaView, but I don't know it very well
and I don't know if it is possible to have multiple views (tabs or
splitters or whatever) at the same time.

I will try also with Mayavi2 as soon as I can get SVN access (as far
as I know, Mayavi2 is the only GUI out there that manages views with
tabs).

Thank you for your suggestions.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/
-------------- next part --------------
import wx

import vtk
from vtk.wx.wxVTKRenderWindow import wxVTKRenderWindow

class Viewer(wxVTKRenderWindow):

    def __init__(self, parent):

        wxVTKRenderWindow.__init__(self, parent, -1)

        self.ren = vtk.vtkRenderer()
        self.GetRenderWindow().AddRenderer(self.ren)
        
        reader = vtk.vtkUnstructuredGridReader()
        reader.SetFileName("VTKExample.vtk")
        reader.SetScalarsName("_I_PORV")

        surfaceMapper = vtk.vtkDataSetMapper()
        surfaceMapper.SetInputConnection(reader.GetOutputPort())
        surfaceMapper.SetScalarRange((1e3, 2e6))

        surfaceActor = vtk.vtkActor()
        surfaceActor.SetMapper(surfaceMapper)

        self.ren.AddActor(surfaceActor)
            
        self.ren.ResetCamera()
        self.ren.BackingStoreOn()


class MainFrame(wx.Frame):

    def __init__(self, parent, id, title, size):

        wx.Frame.__init__(self, parent, id, title, size=size)
        notebook = wx.Notebook(self, -1)

        for ii in xrange(2):
            page = Viewer(notebook)
            notebook.AddPage(page, "Viewer No %d"%(ii+1))

        self.CenterOnScreen()
        self.Show()

app = wx.PySimpleApp()
frame = MainFrame(None, -1, "VTK Example", (400, 400))
app.MainLoop()



More information about the vtkusers mailing list