<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="&#1;" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>The interactive thread *<b>can&#8217;t</b>* be the primary thread of the application, because I&#8217;m providing a library that the primary thread of the application has to call to create a window, get everything set up, and then return so that the primary application thread can continue where it left off, generating content and doing the rest of what it does. However, it shouldn&#8217;t matter which thread does the graphics: if I understand the situation correctly, all that matters is that *<b>one</b>* thread does *<b>all</b>* the graphics work &#8211; I can&#8217;t split it between two threads. So, instead of having the foreground thread to periodic rendering and the background thread do the interaction, I need to restrict the foreground thread&#8217;s activity to data-transfer only, and have the background thread pick up the new data in a timer callback and render it. Not a big deal, but it does introduce a little unwanted latency in the process (say, if the main thread provides new data *<b>right after</b>* the last timer callback determines there was no data change since the previous timer).<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Now, if there were some way I could have the main thread <i>generate some event</i> that the interactive thread could respond to as soon as it happens, rather than waiting for a timer to occur, that would mitigate my latency problem. Does VTK provide support for doing <i>this</i> in a thread-safe way?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks for the help. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>-Chris<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Shashwath T.R. [mailto:trshash@gmail.com] <br><b>Sent:</b> Friday, June 24, 2011 2:58 AM<br><b>To:</b> Chris Volpe ARA/SED<br><b>Cc:</b> vtkusers<br><b>Subject:</b> Re: [vtkusers] Multi-threaded VTK<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Right, there are obviously good reasons to want multi-threading, but the tradeoffs have to be analyzed.<br><br>Like I said earlier, in any case, the interactive thread should be the primary thread of the application. In Windows, cross-thread GUI calls (rendering, for example), are undefined.<br><br>Regards,<br>Shash<o:p></o:p></p><div><p class=MsoNormal>On Thu, Jun 23, 2011 at 5:43 PM, Chris Volpe ARA/SED &lt;<a href="mailto:cvolpe@ara.com">cvolpe@ara.com</a>&gt; wrote:<o:p></o:p></p><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>I misspoke: I said &#8220;non-rendering thread&#8221; when I meant &#8220;non-interactive thread&#8221;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>-Chris</span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span style='font-size:10.0pt'>From:</span></b><span style='font-size:10.0pt'> Chris Volpe ARA/SED <br><b>Sent:</b> Thursday, June 23, 2011 7:41 AM<br><b>To:</b> 'Shashwath T.R.'<br><b>Subject:</b> RE: [vtkusers] Multi-threaded VTK</span><o:p></o:p></p></div></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>Using a timer was my fallback approach. I wanted to avoid it because data changes are going to be driven asynchronously by the non-rendering thread.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>Thanks,</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>-Chris</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p></div><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span style='font-size:10.0pt'>From:</span></b><span style='font-size:10.0pt'> Shashwath T.R. [mailto:<a href="mailto:trshash@gmail.com" target="_blank">trshash@gmail.com</a>] </span><o:p></o:p></p><div><p class=MsoNormal><b>Sent:</b> Thursday, June 23, 2011 1:54 AM<o:p></o:p></p></div><div><p class=MsoNormal><b>To:</b> Chris Volpe ARA/SED<o:p></o:p></p></div><div><div><p class=MsoNormal><b>Subject:</b> Re: [vtkusers] Multi-threaded VTK<o:p></o:p></p></div></div></div></div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>If you're doing this in Windows, I'd definitely suggest doing it the other way around; that is, run the interactor in the main thread and the updation in the worker thread.<br><br>Generally, in Windows, the UI cannot be touched on a cross-thread call; the thread that created the UI should handle it. It's always better to run the interactor in the main thread.<br><br>In any case, for a simple azimuth change once a second, it should be possible to create a timer on the interactor and do your camera management inside the timer callback.<br><br>Regards,<br>Shash<o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>On Thu, Jun 23, 2011 at 2:11 AM, Chris Volpe ARA/SED &lt;<a href="mailto:cvolpe@ara.com" target="_blank">cvolpe@ara.com</a>&gt; wrote:<o:p></o:p></p><div><div><p>At the moment, I'm doing a very simplified version (for proof of concept) of my ultimate goal. The simplified version is to azimuth the camera by 10 degrees once a second in the main thread while showing a cone in the render window. So, no, I am not currently creating vtkObjects in the main thread once the background thread (interactor) starts..<o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p>Here's an excerpt of code from my &quot;FeatureViewer&quot; class. In my simplified proof of concept, the main program instantiates FeatureViewer and invokes the RunTest method, which sets everything up and spawns the background thread to run the interactor loop. When RunTest returns, the main program enters a loop in which it invokes CameraAzimuth once per second. You'll notice a couple references to a class called &quot;vtkCommandDelegator&quot; -- this is a template subclass of vtkCommand I wrote that allows you to specify and arbitrary method of an arbitrary class instance as the command callback. I wrote it because it seemed silly to have to create a new subclass of vtkCommand every time I want to have a callback for something.<o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p>I&#8217;ll leave out the class def and just include the relevant methods for brevity.<o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>static</span><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#030003'>DWORD</span> <span style='color:#030003'>WINAPI</span> <span style='color:#030003'>ThreadCallbackFunction</span>(<span style='color:#030003'>LPVOID</span> <span style='color:#030003'>lpParameter</span>)</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>{</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>FeatureViewer</span> *<span style='color:#030003'>This</span> = <span style='color:blue'>static_cast</span>&lt;<span style='color:#030003'>FeatureViewer</span> *&gt;(<span style='color:#030003'>lpParameter</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:green'>// Start the render window interactor in the background</span></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>This</span>-&gt;<span style='color:#030003'>InternalRunInteractor</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:blue'>return</span> 0;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:#030003'>FeatureViewer</span><span style='font-size:10.0pt;font-family:"Courier New"'>::<span style='color:#030003'>FeatureViewer</span>()</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>{</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>CS</span> = <span style='color:#030003'>vtkCriticalSection</span>::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pCam</span> = <span style='color:#030003'>NULL</span>;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}</span><o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>void</span><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#030003'>FeatureViewer</span>::<span style='color:#030003'>LockCriticalSection</span>(<span style='color:#030003'>vtkObject</span> *<span style='color:#030003'>caller</span>, <span style='color:blue'>unsigned</span> <span style='color:blue'>long</span> <span style='color:#030003'>eventID</span>, <span style='color:blue'>void</span> *<span style='color:#030003'>callData</span>)</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>{</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>CS</span>-&gt;<span style='color:#030003'>Lock</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>fprintf</span>(<span style='color:#030003'>stderr</span>,<span style='color:#A31515'>&quot;Interactor about to render\n&quot;</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>void</span><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#030003'>FeatureViewer</span>::<span style='color:#030003'>UnlockCriticalSection</span>(<span style='color:#030003'>vtkObject</span> *<span style='color:#030003'>caller</span>, <span style='color:blue'>unsigned</span> <span style='color:blue'>long</span> <span style='color:#030003'>eventID</span>, <span style='color:blue'>void</span> *<span style='color:#030003'>callData</span>)</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>{</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>fprintf</span>(<span style='color:#030003'>stderr</span>,<span style='color:#A31515'>&quot;Interactor done rendering\n&quot;</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>CS</span>-&gt;<span style='color:#030003'>Unlock</span>();</span><o:p></o:p></p><p><span style='font-size:10.0pt;font-family:"Courier New"'>}</span><o:p></o:p></p><p><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>void</span><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#030003'>FeatureViewer</span>::<span style='color:#030003'>RunInteractorInBackground</span>()</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>{</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:green'>// Start up the thread</span></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>LPSECURITY_ATTRIBUTES</span> <span style='color:#030003'>attr</span> = <span style='color:#030003'>NULL</span>;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>SIZE_T</span> <span style='color:#030003'>stackSize</span> = 0; <span style='color:green'>// default = 1 MB</span></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>DWORD</span> <span style='color:#030003'>dwCreationFlags</span> = 0;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>LPDWORD</span> <span style='color:#030003'>noThreadID</span> = <span style='color:#030003'>NULL</span>;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>HANDLE</span> <span style='color:#030003'>m_hThreadHandle</span> = <span style='color:#030003'>CreateThread</span>(<span style='color:#030003'>attr</span>, <span style='color:#030003'>stackSize</span>, <span style='color:#030003'>ThreadCallbackFunction</span>, </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:blue'>this</span>, <span style='color:#030003'>dwCreationFlags</span>, <span style='color:#030003'>noThreadID</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>void</span><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#030003'>FeatureViewer</span>::<span style='color:#030003'>InternalRunInteractor</span>()</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>{</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:green'>// Called in background thread.</span></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pIRen</span>-&gt;<span style='color:#030003'>Initialize</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pIRen</span>-&gt;<span style='color:#030003'>Start</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}</span><o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>void</span><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#030003'>FeatureViewer</span>::<span style='color:#030003'>CameraAzimuth</span>(<span style='color:blue'>double</span> <span style='color:#030003'>rot</span>)</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>{</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:green'>// Rotate camera here. Called by main thread</span></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>CS</span>-&gt;<span style='color:#030003'>Lock</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>fprintf</span>(<span style='color:#030003'>stderr</span>, <span style='color:#A31515'>&quot;About to rotate camera\n&quot;</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pCam</span>-&gt;<span style='color:#030003'>Azimuth</span>(<span style='color:#030003'>rot</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pRenWin</span>-&gt;<span style='color:#030003'>Render</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>fprintf</span>(<span style='color:#030003'>stderr</span>,<span style='color:#A31515'>&quot;Done rotating camera\n&quot;</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>CS</span>-&gt;<span style='color:#030003'>Unlock</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}</span><o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>void</span><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#030003'>FeatureViewer</span>::<span style='color:#030003'>RunTest</span>()</span><o:p></o:p></p><p><span style='font-size:10.0pt;font-family:"Courier New"'>{</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>vtkConeSource</span> *<span style='color:#030003'>cone</span> = <span style='color:#030003'>vtkConeSource</span>::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>cone</span>-&gt;<span style='color:#030003'>SetHeight</span>( 3.0 );</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>cone</span>-&gt;<span style='color:#030003'>SetRadius</span>( 1.0 );</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>cone</span>-&gt;<span style='color:#030003'>SetResolution</span>( 10 );</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>vtkPolyDataMapper</span> *<span style='color:#030003'>coneMapper</span> = <span style='color:#030003'>vtkPolyDataMapper</span>::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>coneMapper</span>-&gt;<span style='color:#030003'>SetInputConnection</span>( <span style='color:#030003'>cone</span>-&gt;<span style='color:#030003'>GetOutputPort</span>() );</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>vtkActor</span> *<span style='color:#030003'>coneActor</span> = <span style='color:#030003'>vtkActor</span>::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>coneActor</span>-&gt;<span style='color:#030003'>SetMapper</span>( <span style='color:#030003'>coneMapper</span> );</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pRen</span> = <span style='color:#030003'>vtkRenderer</span>::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pRen</span>-&gt;<span style='color:#030003'>AddActor</span>( <span style='color:#030003'>coneActor</span> );</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pRen</span>-&gt;<span style='color:#030003'>SetBackground</span>( 0.1, 0.2, 0.4 );</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pRenWin</span> = <span style='color:#030003'>vtkRenderWindow</span>::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pRenWin</span>-&gt;<span style='color:#030003'>AddRenderer</span>( <span style='color:#030003'>pRen</span> );</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pRenWin</span>-&gt;<span style='color:#030003'>SetSize</span>( 300, 300 );</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pIRen</span> = <span style='color:#030003'>vtkRenderWindowInteractor</span>::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pIRen</span>-&gt;<span style='color:#030003'>SetRenderWindow</span>(<span style='color:#030003'>pRenWin</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>vtkInteractorStyleTrackballCamera</span> *<span style='color:#030003'>style</span> = </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>vtkInteractorStyleTrackballCamera</span>::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pIRen</span>-&gt;<span style='color:#030003'>SetInteractorStyle</span>(<span style='color:#030003'>style</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>pCam = pRen-&gt;GetActiveCamera();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pStartInteractionCommand</span> = <span style='color:#030003'>vtkCommandDelegator</span>&lt;<span style='color:#030003'>FeatureViewer</span>&gt;::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pStartInteractionCommand</span>-&gt;<span style='color:#030003'>RegisterCallback</span>(<span style='color:blue'>this</span>, &amp;<span style='color:#030003'>FeatureViewer</span>::<span style='color:#030003'>LockCriticalSection</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pEndInteractionCommand</span> = <span style='color:#030003'>vtkCommandDelegator</span>&lt;<span style='color:#030003'>FeatureViewer</span>&gt;::<span style='color:#030003'>New</span>();</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>pEndInteractionCommand</span>-&gt;<span style='color:#030003'>RegisterCallback</span>(<span style='color:blue'>this</span>, &amp;<span style='color:#030003'>FeatureViewer</span>::<span style='color:#030003'>UnlockCriticalSection</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>style</span>-&gt;<span style='color:#030003'>AddObserver</span>(<span style='color:#030003'>vtkCommand</span>::<span style='color:#030003'>StartInteractionEvent</span>,<span style='color:#030003'>pStartInteractionCommand</span>);</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>style</span>-&gt;<span style='color:#030003'>AddObserver</span>(<span style='color:#030003'>vtkCommand</span>::<span style='color:#030003'>EndInteractionEvent</span>, <span style='color:#030003'>pEndInteractionCommand</span>);</span><o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#030003'>RunInteractorInBackground</span>();</span><o:p></o:p></p><p><span style='font-size:10.0pt;font-family:"Courier New"'>}</span><o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p>Thanks,<o:p></o:p></p><p>-Chris<o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p>&nbsp;<o:p></o:p></p><p>&gt; -----Original Message-----<o:p></o:p></p><p>&gt; From: Aashish Chaudhary [mailto:<a href="mailto:aashish.chaudhary@kitware.com" target="_blank">aashish.chaudhary@kitware.com</a>]<o:p></o:p></p><p>&gt; Sent: Wednesday, June 22, 2011 12:46 PM<o:p></o:p></p><p>&gt; To: Chris Volpe ARA/SED<o:p></o:p></p><p>&gt; Cc: <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><o:p></o:p></p><p>&gt; Subject: Re: [vtkusers] Multi-threaded VTK<o:p></o:p></p><div><div><p>&gt; <o:p></o:p></p><p>&gt; On Wed, Jun 22, 2011 at 12:27 PM, Chris Volpe ARA/SED &lt;<a href="mailto:cvolpe@ara.com" target="_blank">cvolpe@ara.com</a>&gt;<o:p></o:p></p><p>&gt; wrote:<o:p></o:p></p><p>&gt; &gt; I&#8217;m trying to have an application that drives scene content change on<o:p></o:p></p><p>&gt; its<o:p></o:p></p><p>&gt; &gt; own, while still allowing the user to manipulate the scene with<o:p></o:p></p><p>&gt; &gt; vtkRenderWindowInteractor. The approach I&#8217;m trying to use is to have<o:p></o:p></p><p>&gt; the<o:p></o:p></p><p>&gt; &gt; vtkRenderWindowInteractor run in a background thread, with some<o:p></o:p></p><p>&gt; concurrency<o:p></o:p></p><p>&gt; &gt; protection to keep it from invoking the rendering pipeline at the<o:p></o:p></p><p>&gt; same time<o:p></o:p></p><p>&gt; &gt; the main thread tries to do so. My application main thread creates<o:p></o:p></p><p>&gt; all the<o:p></o:p></p><p>&gt; &gt; vtk objects (actor, render window, renderer, interactor), registers a<o:p></o:p></p><p>&gt; couple<o:p></o:p></p><p>&gt; &gt; of callbacks for the interactor style&#8217;s StartInteractionEvent and<o:p></o:p></p><p>&gt; &gt; EndInteractionEvent which lock and unlock a vtkCriticalSection,<o:p></o:p></p><p>&gt; &gt; respectively, and then spawns a background thread in which the<o:p></o:p></p><p>&gt; interactor is<o:p></o:p></p><p>&gt; &gt; started. The main thread then, periodically, locks the critical<o:p></o:p></p><p>&gt; section,<o:p></o:p></p><p>&gt; &gt; makes scene changes, renders, and unlocks the critical section.<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; Although this approach seems sound in principle, I&#8217;m encountering<o:p></o:p></p><p>&gt; corruption<o:p></o:p></p><p>&gt; &gt; that leads me to believe that there is some kind of pipeline<o:p></o:p></p><p>&gt; manipulation<o:p></o:p></p><p>&gt; &gt; occurring before processing the StartInteractionEvent that is<o:p></o:p></p><p>&gt; conflicting<o:p></o:p></p><p>&gt; &gt; with what I&#8217;m doing in my main thread. Can someone with detailed<o:p></o:p></p><p>&gt; knowledge<o:p></o:p></p><p>&gt; &gt; of pipeline bowels provide some insight as to what might be going on,<o:p></o:p></p><p>&gt; and<o:p></o:p></p><p>&gt; &gt; perhaps provide an alternate course of action?<o:p></o:p></p><p>&gt; <o:p></o:p></p><p>&gt; Do you produce new vtk objects in the background thread? If yes do you<o:p></o:p></p><p>&gt; use vtkSmartPointer? That could be cause of the problem depending on<o:p></o:p></p><p>&gt; how you are passing vtk objects from one thread to another.<o:p></o:p></p><p>&gt; <o:p></o:p></p><p>&gt; Also it might help if you can attach a minimal code to reproduce the<o:p></o:p></p><p>&gt; behavior.<o:p></o:p></p><p>&gt; <o:p></o:p></p><p>&gt; Thanks<o:p></o:p></p><p>&gt; <o:p></o:p></p><p>&gt; <o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; Thanks,<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; Chris<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; --<o:p></o:p></p><p>&gt; &gt; Christopher R. Volpe,<o:p></o:p></p><p>&gt; &gt; Ph.D.<o:p></o:p></p><p>&gt; Email:<o:p></o:p></p><p>&gt; &gt; <a href="mailto:cvolpe@ara.com" target="_blank">cvolpe@ara.com</a><o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; Senior Scientist, Information Exploitation Systems &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Main<o:p></o:p></p><p>&gt; Desk:<o:p></o:p></p><p>&gt; &gt; 919-582-3300<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; Applied Research Associates,<o:p></o:p></p><p>&gt; &gt; Inc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Direct: 919-<o:p></o:p></p><p>&gt; 582-3380<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; 8537 Six Forks Rd., Suite<o:p></o:p></p><p>&gt; &gt; 6000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fax&nbsp;:<o:p></o:p></p><p>&gt; &gt; 919-582-3301<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; Raleigh, NC 27615&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Web:<o:p></o:p></p><p>&gt; &gt; <a href="http://www.ara.com/offices/NC.htm" target="_blank">http://www.ara.com/offices/NC.htm</a><o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; _______________________________________________<o:p></o:p></p><p>&gt; &gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; Visit other Kitware open-source projects at<o:p></o:p></p><p>&gt; &gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; Please keep messages on-topic and check the VTK FAQ at:<o:p></o:p></p><p>&gt; &gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt; Follow this link to subscribe/unsubscribe:<o:p></o:p></p><p>&gt; &gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; &gt;<o:p></o:p></p><p>&gt; <o:p></o:p></p><p>&gt; <o:p></o:p></p><p>&gt; <o:p></o:p></p><p>&gt; --<o:p></o:p></p><p>&gt; | Aashish Chaudhary<o:p></o:p></p><p>&gt; | R&amp;D Engineer<o:p></o:p></p><p>&gt; | Kitware Inc.<o:p></o:p></p><p>&gt; | <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><o:p></o:p></p></div></div></div></div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'><br>_______________________________________________<br>Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" 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" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p></div></div></div></div></div></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></div></body></html>