You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calculating the volume of a Box or a Cylinder seems to always return zero for Box and Cylinder objects, even though they plot just fine and seem overall well-formed. Similarly, is_closed() seems to always return False. Pyramids and Spheres work fine. I'm thinking it may be related to the fact that Boxes and Cylinders are wholly composed of non-triangular cells, since calling triangulate() causes them to give nonzero volumes (but they still don't register as closed).
importvedobox=vedo.Box()
print("Box:", box.volume(), box.is_closed())
box=box.triangulate()
print("Triangulated box:", box.volume(), box.is_closed())
cylinder=vedo.Cylinder()
print("Cylinder:", cylinder.volume(), cylinder.is_closed())
cylinder=cylinder.triangulate()
print("Triangulated cylinder:", cylinder.volume(), cylinder.is_closed())
pyramid=vedo.Pyramid()
print("Pyramid:", pyramid.volume(), pyramid.is_closed())
sphere=vedo.Sphere()
print("Sphere:", sphere.volume(), sphere.is_closed())
# expected result: all volumes are nonzero and all booleans are True# actual result:# Box: 0.0 False# Triangulated box: 6.000000000000002 False# Cylinder: 0.0 False# Triangulated cylinder: 6.211656935437641 False# Pyramid: 0.43333333333333357 True# Sphere: 4.157386497443854 True
The text was updated successfully, but these errors were encountered:
Thanks for reporting.
I've added documentation for this behavior in both is_closed() and volume() methods, but also in Box and Cylinder.
Checking whether the mesh is triangular in volume() might be computationally expensive if these methods are called in loops or for large meshes.
Calculating the volume of a Box or a Cylinder seems to always return zero for Box and Cylinder objects, even though they plot just fine and seem overall well-formed. Similarly,
is_closed()
seems to always return False. Pyramids and Spheres work fine. I'm thinking it may be related to the fact that Boxes and Cylinders are wholly composed of non-triangular cells, since callingtriangulate()
causes them to give nonzero volumes (but they still don't register as closed).The text was updated successfully, but these errors were encountered: