Calculate the porosity and surface roughness of the powder layer

Maybe you should check if Compute Connected Surface Properties filter.

Its description is:

       Given a PolyData, computed the volume, area and centroid of one or more polygonal objects.
       An optional object IDs cell data array that maps a polygon to a specific object may be provided,
       or the objects will be identified as connected components in the input data.

But since you probably have a volume mesh, use Extract Surface and then Compute Connected Surface Properties.