How to calculate atypical object volume

I am not a mathematician but a simple programmer and came across a situation where I have to calculate different kinds of object volume. There is no specific type of object and i found that there are dozen of formulas to calculate volume like

1. Cube $$= a^3$$
2. Rectangular prism $$= a b c$$
3. Irregular prism $$= b h$$
4. Cylinder $$= b h = π r^2 h$$
5. Pyramid $$= \dfrac13 b h$$
6. Cone $$= \dfrac13 b h = \dfrac13 π r^2 h$$
7. Sphere $$= \dfrac43 π r^3$$
8. Ellipsoid $$= \dfrac43 π r_1 r_2 r_3$$

and maybe many more. But is there any general formula exists that can calculate the volume of any type of object?

• There do exist a general formula, i.e. $V=\iiint_D\,\mathrm dx\mathrm dy\mathrm dz$, but… – Saad Nov 23 '18 at 5:01
• @user302797 another horrible formula but ...? – Muhammad Faizan Khan Nov 23 '18 at 5:07
• … but of no practical use if one wants to get a value from it, unless using Monte-Carlo. – Saad Nov 23 '18 at 5:12
• It depends on how the object is specified, of course. As a programmer, you surely understand that one cannot write a program if one does not know what data structure the input is in! That said, if the shape is given as a polyhedron, you can use a certain sum over the faces. – Rahul Nov 23 '18 at 5:17