# Volume inside a closed 2D Mesh?

Posted 9 years ago
3592 Views
|
|
0 Total Likes
|
 Hello!I would like to calculate the volume inside a closed 2D Mesh (imported from an .stl model). I have tried to use Region functions, or integrate over the ploted mesh, but I've been only able to calculate the area of the mesh (and not the volume inside). Any idea on how to solve my problem?Thanks!
 Does the 2D mesh represent a triangulation, being the border of a convex and simply connected area? If the answer is yes, yes, yes, then you can gain from each triangle in the mesh an inequality, then put all inequalities connected by logical AND into Boole and Integrate that Boole.Let's do that for the simplest 2D mesh enclosing a 3D area, the tetrahedron:  In:= Clear[r] r = Tetrahedron[{{0, 0, 0}, {2, -1, 5}, {4, 3, 1}, {5, 4, 4}}]; Graphics3D[r, Axes -> True] In:= Volume[r] Out= 16/3 let's leave the comfort zone a little bit In:= Integrate[1, {x, y, z} \[Element] r] Out= 16/3 now even a bit more In:= RegionBounds[r] Out= {{0, 5}, {-1, 4}, {0, 5}} In:= Integrate[Boole[RegionMember[r, {x, y, z}]], {x, Min[r[[1, All, 1]]], Max[r[[1, All, 1]]]}, {y, Min[r[[1, All, 2]]], Max[r[[1, All, 2]]]}, {z, Min[r[[1, All, 3]]], Max[r[[1, All, 3]]]}] Out= 16/3 still using a built-in function like RegionMember. Get rid of it by using the inequalities defined by the faces of the tetrahedron In:= (* get four plane equations with **right** orientation *) Integrate[ Boole[(Dot[Cross[r[[1, 2]] - r[[1, 1]], r[[1, 3]] - r[[1, 1]]], {x, y, z} - r[[1, 1]]] >= 0) && (Dot[Cross[r[[1, 3]] - r[[1, 2]], r[[1, 4]] - r[[1, 2]]], {x, y, z} - r[[1, 2]]] <= 0) && (Dot[Cross[r[[1, 3]] - r[[1, 1]], r[[1, 4]] - r[[1, 1]]], {x, y, z} - r[[1, 1]]] >= 0) && (Dot[Cross[r[[1, 2]] - r[[1, 1]], r[[1, 4]] - r[[1, 1]]], {x, y, z} - r[[1, 1]]] <= 0)], {x, Min[r[[1, All, 1]]], Max[r[[1, All, 1]]]}, {y, Min[r[[1, All, 2]]], Max[r[[1, All, 2]]]}, {z, Min[r[[1, All, 3]]], Max[r[[1, All, 3]]]}] Out= 16/3