Retrieve Volume and Surface Area of a ModelNode (Surface Mesh (vtkPolyData)) - Python

Hi all,
I am a beginner and I don’t have much experience with the 3DSlicer environment and vtk libraries. I have already followed the various tutorials to get started.
My problem is the following.
I am trying to use python to retrieve model information, particularly Surface Area and Volume.
The ModelNode in my case is a Surface Mesh (vtkPolyData).
problem
I’m using:
modelnode=slicer.util.getNode(“Model_3”)
meshpolydata=modelnode.GetMesh()

From here, how do I get easily Surface Area and Volume?

Thank you,

Leonardo

I don’t know if this is the best approach but I found the solution for my problem using the vtkMassProperties
Mass = vtk.vtkMassProperties()
Mass.SetInputData(mesh)
Mass.Update()
Surface_Area=Mass.GetSurfaceArea()
Volume=Mass.GetVolume()

I hope this can be of help to someone.

Pass the polydata to vtkMassProperties, and the rest is quite straightforward.

If you check Slicer’s code they pass the polydata by a triangleFilter with a specific option before using massProperties. I don’t know why they do it but when I have to calculate a surfaceArea or volume I do it too

Hope it helps