[vtkusers] Using the coordinates X, Y,Z in an ArrayCalculator

Robert Maynard robert.maynard at kitware.com
Wed Apr 14 10:12:13 EDT 2010


You should be able to use scalar variables with the calculator like so:

  vtkSmartPointer<vtkArrayCalculator> calculator =
vtkSmartPointer<vtkArrayCalculator>::New();
  calculator->SetInput( input );
  calculator->SetAttributeModeToUsePointData();
  calculator->AddCoordinateScalarVariable( "coordsX", 0 );
  calculator->AddCoordinateScalarVariable( "coordsY", 1 );
  calculator->AddCoordinateScalarVariable( "coordsZ", 2 );
  calculator->SetFunction("coordsX + 1");
  calculator->SetResultArrayName("CoordsXResult");
  calculator->Update();

If you want the coordinates as a vector you can use:

  calculator->AddCoordinateVectorVariable( "coords",  0, 1, 2 );

Robert Maynard


On Wed, Apr 14, 2010 at 3:41 AM, Nicolas Courtiade <
Nicolas.Courtiade at ec-lyon.fr> wrote:

> Any suggestion anyone?
> 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.
>
>
>
>
> Nicolas Courtiade a écrit :
>
>  Hi,
>>
>> i'm new to VTK so my question may be obvious...
>>
>> 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 :
>> vtkArrayCalculator (0x3b06b40): Invalid array name: coordsX
>> When i try to calculate with other variables, no problem appears. I only
>> encounter problems when i put a coordinate in the function.
>> Does anyone know how to use the coordinates of a grid as variables in an
>> arraycalculator?
>>
>>
>> Thanks for your help
>>
>>
>> Nicolas
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>  _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100414/7017c60c/attachment.htm>


More information about the vtkusers mailing list