<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>The timing are all taken after the first rendering. I have a little GUI with a VTK render window and a single button. Every time I press the button new data is randomly generated and I time the rendering only process, i.e.:</div><div><br></div></div></div></div></blockquote><div><br></div><div>VTK with OpenGL2 can render 500 million cells/second on a laptop GPU. If you are seeing performance significantly off from that and think you are using a GPU then something is wrong. To do timings do not rely on GetLastRenderTimeInSeconds but rather time a render loop like ala</div><div><br></div><div>startTimer</div><div>for (i = 0; i < 500; i++)</div><div>{</div><div> renWin->Render();</div><div>}</div><div>endTimer</div><div>print elapsedTime/500;</div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div><div>grid.GetCellData().SetScalars(<wbr>data)</div><div>grid.Modified()<br></div></div><div>renwin.Render() </div></div></div></div></blockquote><div><br></div><div>The render above is a first render, in that it is the first render after you modified your data. The entire</div><div>pipeline has to be run then. You are probably timing how has the pipeline can be modified and recalaculated when you change your data.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>And I have a little rendering listener setup like this:</div><div><br></div><div><br></div><div><div>        renderer.AddObserver(vtk.vtkCo<wbr>mmand.EndEvent, self.OnEndEvent)</div><div><br></div><div><br></div><div>    def OnEndEvent(self, caller, dummy1=None, dummy2=None, dummy3=None):</div><div><br></div><div>        timeInSeconds = caller.GetLastRenderTimeInSeco<wbr>nds()</div><div>        fps = 1.0/timeInSeconds</div><div>        print timeInSeconds, fps</div></div><div><br></div><div><br></div><div>However, I realized that the simulator outputs the grid with a lot of redundant information - i.e., duplicated points. So I did the following:</div><div><br></div><div><div>        clean = vtk.vtkExtractUnstructuredGrid<wbr>()</div><div>        clean.SetInputData(grid.GetOut<wbr>put())</div><div>        clean.MergingOn()</div><div>        clean.CellClippingOn()</div><div><br></div><div>        clean.SetCellMinimum(0)</div><div>        clean.SetCellMaximum(nx*ny*nz)</div><div>        clean.Update()</div></div><div> </div><div><br></div><div>the "clean" grid contains far far far less points than the original one (as the coincident points have been merged), and the rendering is much faster - about 0.24 seconds or 4.2 fps. Now, if there was a way to tell the rendering engine to ignore the points (i.e., don't render the points, I only care about the cells...) that would be even better :-) .</div><div><br></div><div><br></div><div>Thank you again for all your hints.</div><div><br></div><div>Andrea.</div><div><br></div><div><br></div><div><br></div><div> </div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div></div><div><br></div><div><br></div></div></div><div class="gmail_extra"><div><div class="m_2131272924764224788m_-6323519616493389093gmail-h5"><br><div class="gmail_quote">On Tue, Nov 29, 2016 at 3:39 AM, Andrea Gavana <span dir="ltr"><<a href="mailto:andrea.gavana@gmail.com" target="_blank">andrea.gavana@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear All,<div><br><div class="gmail_extra"><br><div class="gmail_quote">On 28 November 2016 at 16:12, Andrea Gavana <span dir="ltr"><<a href="mailto:andrea.gavana@gmail.com" target="_blank">andrea.gavana@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi David,<div><br></div><div>    thank you for your answer. I will put some more comments inline too. Any insight or suggestion is more than welcome.</div><div class="gmail_extra"><br><div class="gmail_quote"><span class="m_2131272924764224788m_-6323519616493389093gmail-m_-5170571770281318777m_4329449808429185615gmail-">On 28 November 2016 at 15:40, David E DeMarle wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Responses inline. Mostly though, make sure you are using the "OpenGL2" rendering backend, which is the default for 7.0 and 7.1.<br></div></blockquote><div><br></div><div><br></div></span><div>I am using VTK 7.0 through the Python bindings (the official ones from the Kitware website here:</div><div><br></div><div><a href="http://www.vtk.org/download/" target="_blank">http://www.vtk.org/download/</a><br></div><div><br></div><div><br></div><div>So I was assuming that the rendering backend was already OpenGL2... is there any way to check if this is really the case?</div><div><br></div><div>Also, I have tried to load my dataset in ParaView, and ParaView seems to be doing some kind of black magic on my vtkUnstructuredGrid as I get these kind of messages when I load the vtk file:</div><div><br></div><div>
<p style="margin:0px"><span style="font-family:courier;font-size:8.25pt;color:rgb(0,0,0)">Warning: In C:\bbd\df0abce0\source-paravie<wbr>w\VTK\Rendering\VolumeOpenGL2\<wbr>vtkOpenGLProjectedTetrahedraMa<wbr>pper.cxx, line 251</span></p>
<p style="margin:0px"><span style="font-family:courier;font-size:8.25pt;color:rgb(0,0,0)">vtkOpenGLProjectedTetrahedraMa<wbr>pper (000000000D3CAA60): Missing FBO support. The algorithm may produce visual artifacts.</span></p>
<p style="margin:0px;font-family:courier;font-size:8.25pt;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-family:courier;font-size:8.25pt;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-family:courier;font-size:8.25pt;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-family:courier;font-size:8.25pt;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small">Which, I believe, is telling me that ParaView is not doing what I am doing but maybe using some kind of volume-based rendering - when I rotate the grid the (almost cube-shaped) cells becomes subdivided in small triangles, when I stop interacting with them they go back to their normal appearance. It would be nice to know what ParaView is doing though, and also what "FBO support" means :-). I also noticed that ParaView is slightly faster in changing the displayed property - maybe 2 or 3 times faster than my bare-bone script.</span></p><p style="margin:0px;font-family:courier;font-size:8.25pt;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small"><br></span></p></div></div></div></div></blockquote><div><br></div><div><br></div><div>Just to add some more information: it is true that ParaView is faster in the re-rendering when I switch to another property, but it also shows heavy visual artifacts (i.e., cells with multiple colors in them?!? - see attached screenshot). So, if I understood it correctly, ParaView uses some kind of volume rendering of my vtkUnstructuredGrid (although I didn't ask it to... should it not use the default vtkDataSetMapper?).</div><div><br></div><div>Based on my original pipeline:</div><div><br></div><div>vtkUnstructuredGrid --> vtkThreshold --> vtkDataSetMapper --> vtkActor<br></div><div><br></div><div>I have tried everything I know to speed up the re-rendering of the grid, I actually operate directly on the output of vtkThreshold (that is still a vtkUnstructuredGrid), so I simply throw away the original grid. With and without ImmediateModeRendering, with and without backface culling. My best improvements so far took the rendering time from 1.04 seconds to 0.94 seconds... so not much of an improvement :-) .</div><div><br></div><div>I am of course open to any suggestions anyone may have on the rendering part - assuming that my geometry is fixed (it is not, but I'll worry about that later...), basically only on the process:</div><div><br></div><div>vtkUnstructuredGrid.SetScalars<wbr>(my_data)</div><div>vtkUnstructuredGrid.Modified()<br></div><div>vtkRenderWindow.Render()</div><div><br></div><div>And of course - if there are other visualization strategies I may use, please shout :-)</div><div><br></div><div>Thank you.</div><div><br></div><div>Andrea.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><p style="margin:0px;font-family:courier;font-size:8.25pt;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small"></span></p><p style="margin:0px;font-family:courier;font-size:8.25pt;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small"> </span><br></p></div><div><div class="m_2131272924764224788m_-6323519616493389093gmail-m_-5170571770281318777m_4329449808429185615gmail-h5"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="m_2131272924764224788m_-6323519616493389093gmail-m_-5170571770281318777m_4329449808429185615gmail-m_910782574786711220gmail-">On Mon, Nov 28, 2016 at 7:35 AM, Andrea Gavana <span dir="ltr"><<a href="mailto:andrea.gavana@gmail.com" target="_blank">andrea.gavana@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font face="monospace, monospace">Dear All,</font><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">     I am working with some stuff coming out of CFD simulations, and in the current work the simulator produces a 3D grid (unstructured grid made of hexahedrons). The full grid is about 4 million cells, but due to other settings in the simulator the number of "active" cells in the simulation ends up being "only" 270,000. In order to visualize all this, I create a vtkUnstructuredGrid to hold the full grid, use a vtkThreshold to remove the "inactive" cells and then use a vtkDataSetMapper to visualize the resulting active grid:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">vtkUnstructuredGrid --> vtkThreshold --> vtkDataSetMapper --> vtkActor<br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">However, the rendering speed for the 270,000 cells grid is quite low - it takes about one second to display a new property by using SetScalars on the output of vtkThreshold. So I thought of using a vtkDataSetSurfaceFilter on the output of vtkThreshold to try and speed up the rendering. So, the current visualization strategy I have implemented is the following:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">vtkUnstructuredGrid --> vtkThreshold --> vtkDataSetSurfaceFilter --> vtkPolyDataMapper --> vtkActor</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">This is still as slow as my first approach, and I also have a couple of questions - which stems from my ignorance in VTK things:</font></div><div><font face="monospace, monospace"><br></font></div></div></blockquote><div><br></div></span><div>DataSetMapper internally does vtkDataSetSurfaceFilter->vtkPo<wbr>lyDataMapper when given something other than PolyData, so not surprising that it isn't faster.<br> <br></div><span class="m_2131272924764224788m_-6323519616493389093gmail-m_-5170571770281318777m_4329449808429185615gmail-m_910782574786711220gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><font face="monospace, monospace"></font></div><div><font face="monospace, monospace">1. When I load (from the simulator outputs) a new property (cell-based) and I assign its values to the original vtkUnstructuredGrid (by using SetScalars on it), do all the filters (vtkThreshold and vtkDataSetSurfaceFilter) need to be re-run? If yes, why? I am not changing the active/inactive cells nor the geometry of the grid, only assigning different scalars. And, if yes, is there any way to tell the pipeline: "look, I've only changed the scalars, there's no need to re-run all the thresholds and surface filters *again*"?</font></div><div><font face="monospace, monospace"><br></font></div></div></blockquote><div><br></div></span><div>Yes they do, since the Executive classes' Modified time tracking is not fine grained enough to know the difference, and few if any of the filters would know how to update just the changed portions.<br> <br></div><span class="m_2131272924764224788m_-6323519616493389093gmail-m_-5170571770281318777m_4329449808429185615gmail-m_910782574786711220gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><font face="monospace, monospace"></font></div><div><font face="monospace, monospace">2. Is there any other pipeline style or visualization technique in VTK or any settings whatsoever that could bring down the rendering time (memory is not that much of a concern)? Basically, what I have a the moment - in terms of timing - is as follows:</font></div><div><font face="monospace, monospace"><br></font></div></div></blockquote><div><br></div></span><div>Yes, use OpenGL"2". Modern OpenGL programming techniques make it up to hundreds of times faster than the Legacy fixed function "OpenGL" backend.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_2131272924764224788m_-6323519616493389093gmail-m_-5170571770281318777m_4329449808429185615gmail-m_910782574786711220gmail-"><div dir="ltr"><div><font face="monospace, monospace"></font></div><div><div><font face="monospace, monospace">Reading data from simulator: 0.042 seconds</font></div><div><font face="monospace, monospace">Create VTK array with data : 0.002 seconds</font></div><div><font face="monospace, monospace">Call to SetScalars         : 0.000 seconds</font></div><div><font face="monospace, monospace">Create Lookup Table        : 0.001 seconds</font></div><div><font face="monospace, monospace">Render on screen           : about 1 second</font></div><div><br></div></div><div><br></div><div><font face="monospace, monospace">Thank you in advance for any suggestion, my apologies for the long message.</font></div><span class="m_2131272924764224788m_-6323519616493389093gmail-m_-5170571770281318777m_4329449808429185615gmail-m_910782574786711220gmail-m_-1709261349134371923HOEnZb"><font color="#888888"><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Andrea.</font></div></font></span></div>
<br></span>______________________________<wbr>_________________<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/opensou<wbr>rce/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_FA<wbr>Q</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=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div></div>
<br>______________________________<wbr>_________________<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/opensou<wbr>rce/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_FA<wbr>Q</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=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><span class="m_2131272924764224788HOEnZb"><font color="#888888"><div><br></div></font></span></div></div><span class="m_2131272924764224788HOEnZb"><font color="#888888"><span class="m_2131272924764224788m_-6323519616493389093gmail-HOEnZb"><font color="#888888">-- <br><div class="m_2131272924764224788m_-6323519616493389093gmail-m_-5170571770281318777gmail_signature">Ken Martin PhD<div>Chairman & CFO<br>Kitware Inc.<br>28 Corporate Drive<br>Clifton Park NY 12065<br><a href="tel:518%20371%203971" value="+15183713971" target="_blank">518 371 3971</a><div><br></div><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>
</font></span></font></span></div>
</blockquote></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_2131272924764224788gmail_signature" data-smartmail="gmail_signature">Ken Martin PhD<div>Chairman & CFO<br>Kitware Inc.<br>28 Corporate Drive<br>Clifton Park NY 12065<br><a href="tel:518%20371%203971" value="+15183713971" target="_blank">518 371 3971</a><div><br></div><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>