Pyvista: bug with vtkMassProperties as pv.Cube().area return 0.0

Created on 3 Oct 2020  路  3Comments  路  Source: pyvista/pyvista

But the areas are not equal....

def get_area(mesh):
    return sum(mesh.compute_cell_sizes(length=False, area=True, volume=False,)["Area"])

import pyvista as pv

mesh = pv.Cube()
shrunk = mesh.shrink(0.8)
>>> get_area(mesh), get_area(shrunk)
(6.0, 3.840000114440919)

Also. there must be a bug with vtkMassProperties as shrunk.extract_surface().area return 0.0

_Originally posted by @banesullivan in https://github.com/pyvista/pyvista/pull/913#discussion_r499108567_

bug

All 3 comments

Perhaps we just change the area property to be:

@property
def area(self):
    return np.sum(self.compute_cell_sizes(length=False, area=True, volume=False,)["Area"])

Also. the suspect code:

>>> import pyvista as pv
>>> pv.Cube().area
0.0

whereas:

>>> np.sum(pv.Cube().compute_cell_sizes(length=False, area=True, volume=False,)["Area"])
6.0

Fixed in #933

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agramfort picture agramfort  路  3Comments

banesullivan picture banesullivan  路  6Comments

flothesof picture flothesof  路  4Comments

JiaweiZhuang picture JiaweiZhuang  路  6Comments

zhaofenqiang picture zhaofenqiang  路  5Comments