You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I'm not sure how to then animate changes in the color. For instance,
@mlab.animate(delay=100)
def anim():
f = mlab.gcf()
for i in range(0,data.shape[0]):
mesh.mlab_source.dataset.cell_data.scalars = data[i,:]
mesh.mlab_source.dataset.cell_data.scalars.name = 'Cell data'
mesh.mlab_source.update()
mesh2 = mlab.pipeline.set_active_attribute(mesh,cell_scalars='Cell data')
mlab.pipeline.surface(mesh2)
yield
anim()
mlab.show()
does what I would like, but it slows down rapidly as the animation progresses and eventually is unusable. Most changes I try (e.g. removing the pipeline commands) result in the image not updating at all. Is there any other option to update the face colors?
The text was updated successfully, but these errors were encountered:
I cleaned up the code a lot by creating a tvtk.PolyData manually. The other big change however, is that the documentation suggests that the PolyData.modified() method is what should be used to update the figure. However, this doesn't work for me - instead, I have to use the VTKDataSource.update() method, where the VTKDataSource wraps the PolyData and thus needs to be found by traversing the surface parents
So the final working code was
frommayaviimportmlabfromtvtk.apiimporttvtkpolydata=tvtk.PolyData(points=self.vertices, polys=self.triangles)
polydata.cell_data.scalars=np.ravel(data[:,0].copy())
polydata.cell_data.scalars.name='celldata'mesh=mlab.pipeline.surface(polydata)
@mlab.animate(delay=10)defanim():
foriinrange(0,data.shape[0]):
polydata.cell_data.scalars=np.ravel(data[:,i].copy())
polydata.cell_data.scalars.name="celldata"# polydata.modified() # does not workmesh.parent.parent.update() # worksyieldanim()
mlab.show()
Hi, I have a triangular mesh with data corresponding to face color, which I can plot using the solution from #253 e.g.
However, I'm not sure how to then animate changes in the color. For instance,
does what I would like, but it slows down rapidly as the animation progresses and eventually is unusable. Most changes I try (e.g. removing the pipeline commands) result in the image not updating at all. Is there any other option to update the face colors?
The text was updated successfully, but these errors were encountered: