Forwarding the discussion back to the VTK list in case this ends up helping others.<div><br></div><div>- Wes<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Wes Turner</b> <span dir="ltr">&lt;<a href="mailto:wes.turner@kitware.com">wes.turner@kitware.com</a>&gt;</span><br>

Date: Mon, Jan 23, 2012 at 11:19 AM<br>Subject: Re: vtkRInterface question<br>To: &quot;Pugmire, Dave&quot; &lt;<a href="mailto:pugmire@ornl.gov">pugmire@ornl.gov</a>&gt;<br>Cc: &quot;<a href="mailto:jeff.baumes@kitware.com">jeff.baumes@kitware.com</a>&quot; &lt;<a href="mailto:jeff.baumes@kitware.com">jeff.baumes@kitware.com</a>&gt;, Berk Geveci &lt;<a href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>&gt;<br>

<br><br>Dave,<div><br></div><div>I don&#39;t normally use the vtkRInterface like this.  In general, I access it through the wrapper class vtkRCalculatorFilter() and provide the entire command as a single call.  Can you try a few things for me?  Put all your REval commands into a single command like:</div>


<div><br></div>RI-&gt;AssignVTKDataArrayToRVariable(input, &quot;input&quot;);<br><div>RI-&gt;EvalRScript(&quot;source(&#39;file.q&#39;)\nsave.image(file=&#39;state.RData&#39;)\nresult = foo(input)\n&quot;); </div><div><br>


</div><div>I did not think that state is reliably maintained between the multiple calls to EvalRScript and it is a good place to start looking.  If this fails, then try:</div><div><br></div><div>RI-&gt;AssignVTKDataArrayToRVariable(input, &quot;input&quot;);<br>


<div>RI-&gt;EvalRScript(&quot;source(&#39;file.q&#39;)\nsave.image(file=&#39;state.RData&#39;)\ninput&quot;); </div></div><div><br></div><div>This invocation will just print out the variable input and will allow you to determine if the variable is being set correctly.</div>


<div><br></div><div>Alternately, I am including a function we use that uses the RCalculatorFilter.  note that we set one RScript there much as I am asking you to do above. </div><div><br></div><div>If none of these work, how hard would it be to send your actual code for me to take a quick look at?  Sending &quot;file.q&quot; would allow me to take a look at your entire process, but I can always dummy up a definition of &quot;foo()&quot; if need be.</div>


<div><br></div><div>- Wes</div><div><div><div class="h5"><br><br><div class="gmail_quote">On Fri, Jan 20, 2012 at 11:07 AM, Pugmire, Dave <span dir="ltr">&lt;<a href="mailto:pugmire@ornl.gov" target="_blank">pugmire@ornl.gov</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
Tom Otahal referred me to you for questions on the vtkRInterface.<br>
I&#39;m having a lot of trouble integrating the vtkRInterface into VisIt for a particular use case.<br>
I&#39;m loading in an R script that was created by a statistician, and feeding it vtk data arrays for processing.<br>
The R script defines a function, &quot;foo()&quot;, which I then call on the vtk data array.<br>
When I make the call, it crashes. gdb isn&#39;t catching the crash either, but putting print statements in, it&#39;s dying side of the eval call on the embedded R API.<br>
<br>
Here is the odd thing. If I save the state of the R session to disk, then load this file into a stand alone R, the function call will succeed. I also added it to the RTesting suite, and it runs fine. So, it&#39;s nothing to do w/ the vtkR component, it must be in what I&#39;m doing.<br>



Any ideas on this sort of thing?<br>
<br>
Here is some code on what I&#39;m doing:<br>
<br>
<br>
vtkRInterface *RI = vtkRInterface::New();<br>
RI-&gt;EvalRScript(&quot;source(&#39;file.q&#39;)\n&quot;);<br>
RI-&gt;AssignVTKDataArrayToRVariable(&quot;input&quot;, input);<br>
RI-&gt;EvalRScript(&quot;save.image(file=&#39;state.RData&#39;)\n&quot;);<br>
<br>
RI-&gt;EvalRscript(&quot;result = foo(input)\n&quot;);<br>
<br>
RI-&gt;AssignRVariableToVTKDataArray(&quot;result&quot;, result);<br>
<br>
<br>
This will fail inside the<br>
RI-&gt;EvalRscript(&quot;result = foo(input)\n&quot;);<br>
<br>
<br>
However, if I load state.RData into an R session, I can call: result = foo(input), and it will succeed.<br>
<br>
Thanks for any insight,suggestions you might have.<br>
<span><font color="#888888"><br>
Dave<br>
<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>Technical Leader<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>

Phone: <a href="tel:518-881-4920" value="+15188814920" target="_blank">518-881-4920</a><br>
</font></span></div>
</div><br><br clear="all"><div><br></div>-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>Technical Leader<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4920<br>
</div>