1

So I have an STL file of a sphere that is cut in half. I want to find the volume of the inside of the file, but since it isn't 'water-tight' I can't find an accurate volume. Using the volume Trimesh function, the result of the volume changes at different rotational angles of the file.

For example, when I check for volume with no rotation, the volume is 1.872. But after rotating it 90, 90, 90 along the x,y,z, the volume of the file is now 2.044. What can I do to get the true inside volume of my cut sphere file without it changing when it's being rotated.

Current code to find volume:

import trimesh

my_mesh = trimesh.load('path/to/mesh/half_sphere.stl')
print(my_mesh.volume)
Forrest
  • 157
  • 14

1 Answers1

2

So without being "watertight" the volume of a surface doesn't have a lot of meaning. You could find the volume of the oriented bounding box (mesh.bounding_box_oriented.volume) or bounding sphere (mesh.bounding_sphere.volume). I think you're probably best off either trying to close the mesh by hand, or dealing with it in terms of surface area (mesh.area).

Mike DH
  • 31
  • 2
  • Thank you. I actually ended up just using the convex hull of each mesh which made them watertight. It wasn't exactly what I was looking for but ended up working fine with what I wanted – Forrest Nov 04 '19 at 16:59