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"><<a href="mailto:wes.turner@kitware.com">wes.turner@kitware.com</a>></span><br>
Date: Mon, Jan 23, 2012 at 11:19 AM<br>Subject: Re: vtkRInterface question<br>To: "Pugmire, Dave" <<a href="mailto:pugmire@ornl.gov">pugmire@ornl.gov</a>><br>Cc: "<a href="mailto:jeff.baumes@kitware.com">jeff.baumes@kitware.com</a>" <<a href="mailto:jeff.baumes@kitware.com">jeff.baumes@kitware.com</a>>, Berk Geveci <<a href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>><br>
<br><br>Dave,<div><br></div><div>I don'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->AssignVTKDataArrayToRVariable(input, "input");<br><div>RI->EvalRScript("source('file.q')\nsave.image(file='state.RData')\nresult = foo(input)\n"); </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->AssignVTKDataArrayToRVariable(input, "input");<br>
<div>RI->EvalRScript("source('file.q')\nsave.image(file='state.RData')\ninput"); </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 "file.q" would allow me to take a look at your entire process, but I can always dummy up a definition of "foo()" 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"><<a href="mailto:pugmire@ornl.gov" target="_blank">pugmire@ornl.gov</a>></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'm having a lot of trouble integrating the vtkRInterface into VisIt for a particular use case.<br>
I'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, "foo()", which I then call on the vtk data array.<br>
When I make the call, it crashes. gdb isn't catching the crash either, but putting print statements in, it'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's nothing to do w/ the vtkR component, it must be in what I'm doing.<br>
Any ideas on this sort of thing?<br>
<br>
Here is some code on what I'm doing:<br>
<br>
<br>
vtkRInterface *RI = vtkRInterface::New();<br>
RI->EvalRScript("source('file.q')\n");<br>
RI->AssignVTKDataArrayToRVariable("input", input);<br>
RI->EvalRScript("save.image(file='state.RData')\n");<br>
<br>
RI->EvalRscript("result = foo(input)\n");<br>
<br>
RI->AssignRVariableToVTKDataArray("result", result);<br>
<br>
<br>
This will fail inside the<br>
RI->EvalRscript("result = foo(input)\n");<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>