Animation doesn't update or produces vtk errors

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Animation doesn't update or produces vtk errors

Nikolaus Rath
Hi,

I'm trying to make a video of particle trajectories. Unfortunately, I can't seem to get it to work quite right. Here's a very simple
example:


---snip---
#!/usr/bin/env python

from __future__ import absolute_import, division, print_function
from mayavi import mlab
import numpy as np
import math

alpha = np.linspace(0, 2*math.pi, 100)  

xs = np.empty((len(alpha), 2))
ys = np.empty_like(xs)
zs = np.zeros_like(xs)

xs[:, 0] = 0
xs[:, 1] = 10*np.cos(alpha)
ys[:, 0] = 0
ys[:, 1] = 10*np.sin(alpha)

mlab.points3d(0,0,0)
plt = mlab.points3d(xs[0], ys[0], zs[0])

@mlab.animate(delay=100)
def anim():
    f = mlab.gcf()
    while True:
        for (x, y, z) in zip(xs, ys, zs):
            print('Updating scene...')
            plt.mlab_source.x = x
            plt.mlab_source.y = y
            plt.mlab_source.z = z            
            #plt.mlab_source.set(x=x, y=y, z=z)
            
            f.scene.render()
            yield
        

anim()
mlab.show()
---snip---

If I run this script, it shows a window with the two points and the animation GUI. It also prints a continous stream of "Updating
Scene..." messages on the terminal. However, the scene doesn't show any movement at all.

If, instead of the mlab_source.x = assignments, I uncommend the call to mlab_source.set(), the plot is updating, but I'm getting a stream of

Updating scene...
ERROR: In /build/buildd-vtk_5.8.0-13+b1-amd64-HQvOIO/vtk-5.8.0/Filtering/vtkExecutive.cxx, line 756
vtkStreamingDemandDrivenPipeline (0x68c6870): Algorithm vtkAssignAttribute(0x68c3b20) returned failure for request: vtkInformation (0x6c9b9c0)
  Debug: Off
  Modified Time: 852875
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_DATA_OBJECT
  FORWARD_DIRECTION: 0
  ALGORITHM_AFTER_FORWARD: 1


errors on my terminal.


What am I doing wrong? I'm using Python 2.7, Mayavi 4.1, VTK 5.8.


Best,
-Nikolaus



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Animation doesn't update or produces vtk errors

Gael Varoquaux
I believe that you need to run the code that does the animation inside an
event loop.

Either you use IPython for this purpose, or you can use mlab.show as an
additional decorator on the function that does the animation, as in
http://docs.enthought.com/mayavi/mayavi/mlab.html#running-mlab-scripts

Hope this helps,

Gaël
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Animation doesn't update or produces vtk errors

Nikolaus Rath
Gael Varoquaux <[hidden email]> writes:
> I believe that you need to run the code that does the animation inside an
> event loop.
>
> Either you use IPython for this purpose, or you can use mlab.show as an
> additional decorator on the function that does the animation, as in
> http://docs.enthought.com/mayavi/mayavi/mlab.html#running-mlab-scripts

Hmm. Neither @mlab.show nor running in ipython --gui wx seem to make any
difference.


Best,

   -Nikolaus

--
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Animation doesn't update or produces vtk errors

Gael Varoquaux
On Sat, Jan 12, 2013 at 05:28:23PM -0800, Nikolaus Rath wrote:
> Hmm. Neither @mlab.show nor running in ipython --gui wx seem to make any
> difference.

In ipython --gui wx your script works for me.

G
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Animation doesn't update or produces vtk errors

Nikolaus Rath
Gael Varoquaux <[hidden email]> writes:
> On Sat, Jan 12, 2013 at 05:28:23PM -0800, Nikolaus Rath wrote:
>> Hmm. Neither @mlab.show nor running in ipython --gui wx seem to make any
>> difference.
>
> In ipython --gui wx your script works for me.

Which Python, iPython, Mayavi and VTK version do you use?


Thanks,

   -Nikolaus

--
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev