You should be able to use scalar variables with the calculator like so:<div><br></div><div><div> vtkSmartPointer<vtkArrayCalculator> calculator = vtkSmartPointer<vtkArrayCalculator>::New(); </div><div> calculator->SetInput( input );</div>
<div> calculator->SetAttributeModeToUsePointData();</div><div> calculator->AddCoordinateScalarVariable( "coordsX", 0 );</div><div> calculator->AddCoordinateScalarVariable( "coordsY", 1 );</div>
<div> calculator->AddCoordinateScalarVariable( "coordsZ", 2 ); </div><div> calculator->SetFunction("coordsX + 1");</div><div> calculator->SetResultArrayName("CoordsXResult");</div>
<div> calculator->Update();</div><div><br></div><div>If you want the coordinates as a vector you can use:</div><div><br></div><div> calculator->AddCoordinateVectorVariable( "coords", 0, 1, 2 );</div><div>
<br></div>Robert Maynard<br>
<br><br><div class="gmail_quote">On Wed, Apr 14, 2010 at 3:41 AM, Nicolas Courtiade <span dir="ltr"><<a href="mailto:Nicolas.Courtiade@ec-lyon.fr">Nicolas.Courtiade@ec-lyon.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Any suggestion anyone?<br>
i just found a mail from Clinton Stimpson ( [vtk-developers] vtkArrayCalculator enhancement ), who encountered the same problem and planed to implement the ability to use a point's location in the formula. I don't know if it has been done yet or if there is an other way to do this.<br>
<font color="#888888">
<br>
<br>
<br>
<br>
Nicolas Courtiade a écrit :</font><div><div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
i'm new to VTK so my question may be obvious...<br>
<br>
I'm trying to calculate the cylindrical R with an arraycalculator. My problem is that vtk doesn't seem to recognize the variables coordsX, coordsY and coordsZ in the formula of the function. The error message is :<br>
vtkArrayCalculator (0x3b06b40): Invalid array name: coordsX<br>
When i try to calculate with other variables, no problem appears. I only encounter problems when i put a coordinate in the function.<br>
Does anyone know how to use the coordinates of a grid as variables in an arraycalculator?<br>
<br>
<br>
Thanks for your help<br>
<br>
<br>
Nicolas<br>
<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><br>
<br>
</blockquote>
_______________________________________________<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><br>
</div></div></blockquote></div><br></div>