I just tried to test the vector_cut_plane
feature of mayavi:
import numpy as np
from mayavi import mlab
x, y, z = np.mgrid[0:1:20j, 0:1:20j, 0:1:20j]
u = np.sin(np.pi*x) * np.cos(np.pi*z)
v = -2*np.sin(np.pi*y) * np.cos(2*np.pi*z)
w = np.cos(np.pi*x)*np.sin(np.pi*z) + np.cos(np.pi*y)*np.sin(2*np.pi*z)
src = mlab.pipeline.vector_field(u, v, w)
mlab.pipeline.vector_cut_plane(src, mask_points=2, scale_factor=3)
mlab.show()
However it doesn't seem to work, since the vector field cut doesn't follow the red frame:
Here is the related screencast: http://dropcanvas.com/tqaxc
Any idea what I made wrong?
I met the same problem with Mayavi2 4.4.3 on a linux ubuntu 16.04:
I found the solution here: https://github.com/enthought/mayavi/issues/164
Edit the file (as root): /usr/lib/python2.7/dist-packages/mayavi/components/cutter.py
And add at the end of the file the following 2 lines:
def _cut_function_changed(self):
self.cutter.cut_function.on_trait_change(self.cutter.update, "normal, origin")
BEWARE of the indentation, if you are not familiar with python: 3 spaces for me. One empty after the precedent "def" line.
Let me know if it helps.
Yours
Yves Delhaye