No, in general case you need to subdivide an object on pyramids or tetrahedra and then calculate the total volume. See e.g. http://wwwf.imperial.ac.uk/~rn/centroid.pdf and https://www.wikiwand.com/en/Polyhedron#/Volume. Thus in GLScene it's necessary to add some common functions to calculate areas and volumes in GLVectorgeometry unit and then to implement methods in GLGomObjects and GLPolyhedron units. Then the work will be done.
PW
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What if the 3d object was loaded into GLScene from a STL file? If I understand correctly the objects in STL files are already subdivided on triangles. Is this lost after import to GLScene, or do I still have access to all the triangles for volume calculation?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just wondering, why wouldn’t a method for calculating the volume of a TmeshObject be part of GLScene? Is it beyond the scope of this library, or is it that nobody has bothered to add it yet?
Last edit: Ørjan Nilsen 2017-02-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Swein,
Well, also In GLVectorGeometry unit there are function TriangleArea(const p1, p2, p3: TAffineVector): Single; function TriangleSignedArea(const p1, p2, p3: TAffineVector): Single; function PolygonArea(const p: PAffineVectorArray; nSides: Integer): Single; function PolygonSignedArea(const p: PAffineVectorArray;
that help to calculate features of other GLObjects and not only meshes. But I agree that it’s would be useful to have more methods like Length, Area and Volume functions in TMeshObject class. The volume makes sense only for closed meshes. So give your variants to be included in GLScene after testing it on stl, 3ds etc. formats and e.g. for polyhedrons in torque demo.
PW
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Swein,
I’ve added function Volume in TGLMeshObjectList of GLVectorFileObjects unit in current SVN, so try to calculate it for your stl mesh file (e.g. ffObject.MeshObjects.Volume).
PW
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Pavel. Thank you for adding the volume function. I also noticed that you added the volume to the statusbar of GLSViewer. Now I can use GLScene for getting this information without adding anything to the librarary. But I think you have made a "copy and paste" mistake to the function. You use the same index (List[i]) for all three vectors:
Is there function in the GLScene library to calculate the volume of a 3d object?
No, in general case you need to subdivide an object on pyramids or tetrahedra and then calculate the total volume. See e.g. http://wwwf.imperial.ac.uk/~rn/centroid.pdf and https://www.wikiwand.com/en/Polyhedron#/Volume. Thus in GLScene it's necessary to add some common functions to calculate areas and volumes in GLVectorgeometry unit and then to implement methods in GLGomObjects and GLPolyhedron units. Then the work will be done.
PW
What if the 3d object was loaded into GLScene from a STL file? If I understand correctly the objects in STL files are already subdivided on triangles. Is this lost after import to GLScene, or do I still have access to all the triangles for volume calculation?
Hi.
Use MeshObjects.ExtractTriangles
Last edit: Roman 2017-01-30
Thank you for your help. By adding som lines to your procedure I get the volume of a STL file:
Just wondering, why wouldn’t a method for calculating the volume of a TmeshObject be part of GLScene? Is it beyond the scope of this library, or is it that nobody has bothered to add it yet?
Last edit: Ørjan Nilsen 2017-02-03
Hi Swein,
Well, also In GLVectorGeometry unit there are function TriangleArea(const p1, p2, p3: TAffineVector): Single; function TriangleSignedArea(const p1, p2, p3: TAffineVector): Single; function PolygonArea(const p: PAffineVectorArray; nSides: Integer): Single; function PolygonSignedArea(const p: PAffineVectorArray;
that help to calculate features of other GLObjects and not only meshes. But I agree that it’s would be useful to have more methods like Length, Area and Volume functions in TMeshObject class. The volume makes sense only for closed meshes. So give your variants to be included in GLScene after testing it on stl, 3ds etc. formats and e.g. for polyhedrons in torque demo.
PW
Hi Swein,
I’ve added function Volume in TGLMeshObjectList of GLVectorFileObjects unit in current SVN, so try to calculate it for your stl mesh file (e.g. ffObject.MeshObjects.Volume).
PW
Hi Pavel. Thank you for adding the volume function. I also noticed that you added the volume to the statusbar of GLSViewer. Now I can use GLScene for getting this information without adding anything to the librarary. But I think you have made a "copy and paste" mistake to the function. You use the same index (List[i]) for all three vectors:
Last edit: Ørjan Nilsen 2017-02-10
Swein,
Repaired, check it with your dataset
PW
I think I get the right volume for my STL files now. GLScene gives me the exact same volume for my files as I get from these two online services:
http://www.viewstl.com/
http://www.planfab.eu/price-calculator/
Last edit: Ørjan Nilsen 2017-02-13