How to access Point coordinates as PointData arrays?

I want to use the coordinates of Points in an unstucturedGrid as part of an equation in vtkArrayCalculator.
In Paraview, I cann access the point coordinates as vector PointData using the array name ‘coords’ - which Paraview seems to provide “for free”
How do I do the same thing in VTK?
Of course I can do it manually - extract the point coordinates and add them as pointData - but are the coordinates directly avaiable without this step?



1 Like

You can get a vtkDataArray handle of the point coordinates using vtkPoints::GetData(). So you could add this data array into you point data if you wanted to. However, if I recall correctly, this array is unnamed, so you would need to name it if you want to fetch it easily from the point data once you added this array.

I don’t know how it is done in ParaView, and if it is done in a smarter way. Do you know that on the top of your head @cory.quammen or @utkarshayachit ?

Yes - doing it manually is easy enough.


The resulting vector array actually ends up being called “Points”…