How to calculate the area of each triangle that makes up the mesh using python.

Hi, I need to understand how to calculate the area of ​​each single triangle that the mesh generates.
Once I open my .vtp file on ParaView, I apply the integrated variables filter, to get all the points that make up my image, the image I work with was generated using the vmtkSurfaceDistance function on python, which returns a vector of the distances for each node of the mesh, this function calculates the distance between a reference surface and any other surface of the same size.
The goal of my work is to evaluate the goodness of the mathematical model that generates the surface, the distance between the two surfaces tells me if the model has done a good job.
So for each triangle I would like to calculate the centroid (center of mass), calculate the distance at this point using the data at the nodes and then weigh this value for the area.
Since my image is made up of many triangles, I would like to use python on paraview to apply this method to all the triangles, for example using a for loop.
I thank you for your help.

You can use the Cell Size filter for that. Note though that there’s a bug in ParaView 5.7.0 with this filter so you should use 5.6.2 instead.

I’d recommend using numpy instead of a for loop if you want to make your operation fast.

@Andy_Bauer Do you mean this bug?

Nope. That’s a different bug specific to just some of the Lagrange cells. I fixed the bug for the Cell Size filter in 5.7.0 already.

Oh, excellent. Then it should be in 5.8.0, slated for release late January.