public static (double volume, IDPoint3 center)? GetVolumeAndMassCenter(this ITriObject triObject) { try { double Volume = 0; IDPoint3 Center = MaxGlobal.DPoint3.Create(0, 0, 0); for (int i = 0; i < triObject.Mesh.NumFaces; i++) { IFace face = triObject.Mesh.Faces[i]; IDPoint3 vert2 = MaxGlobal.DPoint3.Create(triObject.Mesh.GetVert((int)face.GetVert(2))); IDPoint3 vert1 = MaxGlobal.DPoint3.Create(triObject.Mesh.GetVert((int)face.GetVert(1))); IDPoint3 vert0 = MaxGlobal.DPoint3.Create(triObject.Mesh.GetVert((int)face.GetVert(0))); vert1.Subtract(vert0); vert2.Subtract(vert0); double dV = MaxGlobal.DotProd( MaxGlobal.CrossProd( vert1.Subtract(vert0), vert2.Subtract(vert0)) , vert0); Volume += dV; Center = Center.Add((vert0.Add(vert1).Add(vert2)).MultiplyBy(dV)); } Volume = Volume / 6; Center = Center.DivideBy(24); Center = Center.DivideBy(Volume); return(Volume, Center); } catch { return(null); } }