[vtkusers] Python vtkLineSource vtkAppendPolyData Memory gets Crazy

Eleftherios Garyfallidis eleftherios.garyfallidis at mrc-cbu.cam.ac.uk
Fri May 22 13:17:51 EDT 2009


Dear vtk users,

I am trying to visualise about 100.000 trajectories where each 
trajectory contains from 3 to 400 line segments.
I tried in the beginning to use vtkPolyline but then I noticed that it 
would take very long time load the trajectories and also to rotate the 
datasets when visible. I found in your user list that people had similar 
problems when tried to visualise many spheres and probably that was 
because of the usage of many actors. The proposed solution was to use 
vtkAppendData and that is what I did.  Unfortunately, I watched the 
memory increasing amazingly much and although the dataset was about 
20MBytes the memory usage flew to nearly 4GBytes. I am attaching below 
the code snippet that shows the memory increase problem.

   '''
   trajs is a list of list of tuples with 3 elements (x,y,z coordinates) 
i.e. a list of trajectories  
   '''

   trajs_no=len(trajs)
   cnt = 0

   apd=vtk.vtkAppendPolyData()
  
   for traj in trajs:
        traj_no=len(traj)                 
        if traj_no > traj_thr:
                      for i in xrange(traj_no-1):

                                       line=vtk.vtkLineSource()    
                                                     
                                       line.SetPoint1(traj[i])
                                       line.SetPoint2(traj[i+1])
                                       #line.Update()
                                       apd.AddInput(line.GetOutput())
                                       del line
           cnt+=1
   
    map = vtk.vtkPolyDataMapper()
    map.SetInput(apd.GetOutput())             
    trajsActor = vtk.vtkActor()
    trajsActor.SetMapper(map)

I hope I am clear and that I am on the best way to visualize all these 
trajectories. I would very much appreciate any feedback from you guys.

Thank you,
Eleftherios





More information about the vtkusers mailing list