As per this answer, I read this research paper (very brief). To quote the answer:
This all boils down to the following simple function:
public float SignedVolumeOfTriangle(Vector p1, Vector p2, Vector p3) { var v321 = p3.X*p2.Y*p1.Z; var v231 = p2.X*p3.Y*p1.Z; var v312 = p3.X*p1.Y*p2.Z; var v132 = p1.X*p3.Y*p2.Z; var v213 = p2.X*p1.Y*p3.Z; var v123 = p1.X*p2.Y*p3.Z; return (1.0f/6.0f)*(-v321 + v231 + v312 - v132 - v213 + v123); }
and then a driver to calculate the volume of the mesh:
public float VolumeOfMesh(Mesh mesh) { var vols = from t in mesh.Triangles select SignedVolumeOfTriangle(t.P1, t.P2, t.P3); return Math.Abs(vols.Sum()); }
This seems much better than the voxel based approach for determining volume of an advanced 3D object, however, in the models I currently have available to me:
- Many of the surfaces are not complete 3D voluminous shapes, but rather hollow 2D meshes wrapped into a 3-D looking shape where the ends don't actually meet up to form a complete surface of a true 3D object.
- Some surfaces are outright flat 2D shapes.
- Are just plain messy internally.
And I'm unsure about how the algorithm will handle imperfect 3D models.
Do I need to produce models which are made up only of true, complete, voluminous 3D objects for this method to work, or will it work on common 3D models as shown above?