<span style>I have posted a version of this program to the users mailing list before but got minimal response. Since I have discovered a different memory leak in rendering. These two memory leaks are making my program extremely unstable, as they get magnified when rendering large objects. I'm stuck in my development cycle until these rendering issues get resolved, as a result I am very motivated to provide any extra comments, data, work that I can to help fix this problem.</span><div style>
<br></div><div style>Reproduced below is a test program that causes 2 memory issues in Windows 7 (both x86 and x64). Please let me know if you can reproduce these problems or not, and if you can fix them. Currently I'm hooking in GDCM as well (although not in this test program), so I cannot easily move to VTK 6 as GDCM currently does not compile for VTK 6, so if these bugs can be fixed on the release branch, that would be amazing.</div>
<div style><br></div><div style>Again, please contact me if you have any questions or would like more information.</div><div style><br></div><div style>Thanks</div><div style><br></div><div style><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><QtGui/QApplication></span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><QMainWindow></span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><QVTKWidget2.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkImageViewer2.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkImageData.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkPointData.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkGenericOpenGLRenderWindow.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkSphereSource.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkPolyDataMapper.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkActor.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkRenderer.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkRenderWindow.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">This</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">program</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">shows</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">2</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">separate</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">bugs</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">with</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">rendering.</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">/**</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">First,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">if</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">you</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">run</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">program</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">as</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">provided,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">and</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">either</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">move</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouse</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">over</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">image</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">or</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">press</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouse,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">notice</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">that</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">memory</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">stays</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">constant.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">The</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">first</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">bug</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">involves</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">consuming</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">memory</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">on</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">a</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">render</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">command</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">when</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">we're</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">just</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">rendering</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">an</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">image.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">In</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">order</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">to</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">see</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">this,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">comment</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">in</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">commented</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">out</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">line</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">in</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouseMoveEvent</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">method.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">Notice</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">that</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">as</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">you</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouse</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">around</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">memory</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">now</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">increases.</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">The</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">second</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">bug</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">involves</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">rendering</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">after</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">an</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">actor</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">has</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">been</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">added.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">If</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">you</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">comment</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">in</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">one</span><span style="color:rgb(192,192,192)"> </span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">commented</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">out</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">line</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">in</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mousePressEvent,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">you</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">now</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">see</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">memory</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">jump</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">significantly</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">after</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">each</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouse</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">press.</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">I'm</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">testing</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">these</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">on</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">Qt</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">4.8.0</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">x64</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">Windows</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">VS</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">2008,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">VTK</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">pulled</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">from</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">git</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">release</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">branch,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">tag</span><span style="color:rgb(192,192,192)"> </span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">5.10.0-rc1. I'm monitoring the memory using the Windows Task Manager.</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*/</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">class</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MyQVTKWidget2</span><span style="color:rgb(192,192,192)"> </span>:<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">public</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QVTKWidget2</span><span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkRenderer</span>><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">renderer</span>;</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">public</span>:</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MyQVTKWidget2</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageViewer2</span>><span style="color:rgb(192,192,192)"> </span>imageViewer,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QWidget</span><span style="color:rgb(192,192,192)"> </span>*parent<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>)<span style="color:rgb(192,192,192)"> </span>:<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QVTKWidget2</span>(parent)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">this</span>-><span style="color:rgb(128,0,0)">imageViewer</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>imageViewer;</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">renderer</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkRenderer</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic">GetRenderWindow</span>()-><span style="font-style:italic">AddRenderer</span>(<span style="color:rgb(128,0,0)">renderer</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">virtual</span><span style="color:rgb(192,192,192)"> </span>~<span style="font-style:italic">MyQVTKWidget2</span>()<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic">mouseMoveEvent</span>(<span style="color:rgb(128,0,128)">QMouseEvent</span><span style="color:rgb(192,192,192)"> </span>*)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span>i=<span style="color:rgb(0,0,128)">0</span>;<span style="color:rgb(192,192,192)"> </span>i<<span style="color:rgb(0,0,128)">1000</span>;<span style="color:rgb(192,192,192)"> </span>++i)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//imageViewer->Render();</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic">mousePressEvent</span>(<span style="color:rgb(128,0,128)">QMouseEvent</span><span style="color:rgb(192,192,192)"> </span>*)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkSphereSource</span>><span style="color:rgb(192,192,192)"> </span>sphereSource<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkSphereSource</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>sphereSource-><span style="font-style:italic">Update</span>();</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span>i=<span style="color:rgb(0,0,128)">0</span>;<span style="color:rgb(192,192,192)"> </span>i<<span style="color:rgb(0,0,128)">1000</span>;<span style="color:rgb(192,192,192)"> </span>++i)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkPolyDataMapper</span>><span style="color:rgb(192,192,192)"> </span>mapper<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkPolyDataMapper</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>mapper->SetInput(sphereSource->GetOutput());</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>mapper-><span style="font-style:italic">Update</span>();</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkActor</span>><span style="color:rgb(192,192,192)"> </span>actor<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkActor</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>actor-><span style="font-style:italic">SetMapper</span>(mapper);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">renderer</span>->AddActor(actor);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//renderer->Render();</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">renderer</span>->RemoveActor(actor);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">private</span>:</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageViewer2</span>><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">imageViewer</span>;</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">};</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span>main(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span>argc,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">char</span><span style="color:rgb(192,192,192)"> </span>*argv[])<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QApplication</span><span style="color:rgb(192,192,192)"> </span>a(argc,<span style="color:rgb(192,192,192)"> </span>argv);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageData</span>><span style="color:rgb(192,192,192)"> </span>imageData<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageData</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageData-><span style="font-style:italic">SetExtent</span>(<span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">100</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">100</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">100</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageData-><span style="font-style:italic">SetOrigin</span>(<span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageData-><span style="font-style:italic">SetSpacing</span>(<span style="color:rgb(0,0,128)">1</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageData-><span style="font-style:italic">AllocateScalars</span>();</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>imageData->GetPointData()->GetScalars()-><span style="font-style:italic">FillComponent</span>(<span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageViewer2</span>><span style="color:rgb(192,192,192)"> </span>imageViewer<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageViewer2</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageViewer-><span style="font-style:italic">SetInput</span>(imageData);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MyQVTKWidget2</span><span style="color:rgb(192,192,192)"> </span>*widget<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MyQVTKWidget2</span>(imageViewer);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageViewer-><span style="font-style:italic">SetRenderWindow</span>(widget-><span style="font-style:italic">GetRenderWindow</span>());</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QMainWindow</span><span style="color:rgb(192,192,192)"> </span>mainWindow;</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>mainWindow.setGeometry(<span style="color:rgb(0,0,128)">200</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">200</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">300</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">300</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>mainWindow.setCentralWidget(widget);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>mainWindow.show();</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">return</span><span style="color:rgb(192,192,192)"> </span>a.exec();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">}</pre></div>