<div dir="ltr"><div>Unfortunately changing the points causes a lot of recomputation for cell coloring which is what you are using. It is because the changing points could make a triangle become degenerate (which opengl does not count as a cell, while VTK does)</div><div><br></div><div>If you have the memory on the GPU you could instead create an array of actors, each with their own mappers and polydata and then loop over them by changing their visibility (e.g. all are visibleOff except the current time step).  If that fits in memory it should be very fast.<br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Nov 17, 2018 at 2:20 PM Flagada <<a href="mailto:flagada15@gmail.com">flagada15@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi all !</div><div>I am trying to animate a mesh deformation with quite a large number of nodes (about 300000).</div><div>For
 now the best solution I have found is to make a list containing the 
vtkpoints for each animation frame and loop by changing the vtkpoints of
 the displayed polydata (or unstructuredgrid).</div><div>On a simple 
model without applying any color to the cells I can obtain an animation 
rate of about 50fps wich is a good frame rate for me.</div><div>But if I apply colors with a PolyData.GetCellData().SetScalars() the framerate goes down to 13fps.</div><div>Does
 anybody knows if it could be a better method to display mesh animation 
or to improve the display rate of a mesh with colors ?</div><div><br></div><div>Here below is the python code I use.<br></div><div>It draws a disk of 800x400 nodes and if you press on F1 it animates a kind of sinus wave.</div><div>First
 it calculate each frame, then it display the animation without color 
and finally it display the animation with random color on cells.</div><div><br></div><div>Thanks !<br></div><div><br></div><div>############################<br><br>import vtk<br>import math<br>from time import time<br>import random<br><br>############################<br># Creating disk mesh<br>disk = vtk.vtkDiskSource()<br>disk.SetInnerRadius(0.1)<br>disk.SetOuterRadius(2.0)<br>disk.SetRadialResolution(400)<br>disk.SetCircumferentialResolution(800)<br>disk.Update()<br>PolyData = disk.GetOutput()<br><br>print("%d nodes" % PolyData.GetNumberOfPoints())<br>print("%d elms" % PolyData.GetNumberOfCells())<br><br># Setup actor and mapper<br>mapper = vtk.vtkPolyDataMapper()<br>mapper.SetInputData(PolyData)<br>actor = vtk.vtkActor()<br>actor.SetMapper(mapper)<br> <br># Setup render window, renderer, interactor and camera<br>renderer = vtk.vtkRenderer()<br>renderWindow = vtk.vtkRenderWindow()<br>renderWindow.AddRenderer(renderer)<br>renderWindowInteractor = vtk.vtkRenderWindowInteractor()<br>renderWindowInteractor.SetRenderWindow(renderWindow)<br>style = vtk.vtkInteractorStyleTrackballCamera()<br>renderWindowInteractor.SetInteractorStyle(style)<br>camera = vtk.vtkCamera()<br>camera.Elevation(-45)<br>renderer.SetActiveCamera(camera)<br><br>#################################<br><br>def KeyPress(object, event):<br>   if object.GetInteractor().GetKeySym() == "F1":<br>       # Calculate each frame and store the vtkPoints into vtkPointsList<br>       PolyData = disk.GetOutput()<br>       vtkPointsList = {}<br>      <br>       print("Calculate...")<br>      <br>       for ph in range(0, 360, 20):<br>         start_time = time()<br>         vtkPointsList[ph] = vtk.vtkPoints()<br>         vtkPointsList[ph].DeepCopy(PolyData.GetPoints())<br>         for i in range(0, PolyData.GetNumberOfPoints()):<br>           NodePos = vtkPointsList[ph].GetPoint(i)<br>           vtkPointsList[ph].SetPoint(i, NodePos[0], NodePos[1], 0.3 * math.sin(NodePos[0] * 2 + ph * math.pi / 180))<br>         PolyData.SetPoints(vtkPointsList[ph])<br>         renderWindow.Render()<br>      <br>       print("Done. Animate.")<br>      <br>       # First animation without color<br>       start_time = time()<br>       for ph in range(0, 360, 20):<br>         PolyData.SetPoints(vtkPointsList[ph])<br>         renderWindow.Render()<br>       print("%.2f FPS" % (18 / (time() - start_time)))<br>      <br>       # Activate cells colors<br>       ELMcolors = vtk.vtkUnsignedCharArray()<br>       ELMcolors.SetNumberOfComponents(3)<br>       ELMcolors.SetName("Colors")<br>       for i in range(0, PolyData.GetNumberOfCells()):<br>         ELMcolors.InsertNextTuple([random.random() * 255, random.random() * 255, random.random() * 255])<br>       PolyData.GetCellData().SetScalars(ELMcolors)<br>      <br>       # Second animation with color<br>       start_time = time()<br>       for ph in range(0, 360, 20):<br>         PolyData.SetPoints(vtkPointsList[ph])<br>         renderWindow.Render()<br>       print("%.2f FPS" % (18 / (time() - start_time)))<br>      <br>####################################<br>      <br>style.AddObserver("KeyPressEvent", KeyPress)<br><br>renderer.AddActor(actor)<br>renderWindow.Render()<br>renderer.ResetCamera()<br>renderWindowInteractor.Start()<br><br>############################</div></div></div></div></div></div>

</div>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Ken Martin PhD<div>Distinguished Engineer<br><span style="font-size:12.8px">Kitware Inc.</span><br></div><div>101 East Weaver Street<br>Carrboro, North Carolina<br>
27510 USA<br><br><div><span style="font-size:10pt;font-family:Tahoma,sans-serif">This communication,
including all attachments, contains confidential and legally privileged
information, and it is intended only for the use of the addressee.  Access to this email by anyone else is
unauthorized. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken in reliance on it is prohibited and may be
unlawful. If you received this communication in error please notify us
immediately and destroy the original message. 
Thank you.</span></div></div></div></div></div></div></div>