Search code examples
opengl3dvolume

Cut a 3D solid and calculate the new volume


I would like to cut a 3D solid by several plans, display these plans and calculate the volume between each cutting plan. For exemple, in the picture thereafter, I want to determine the volume between 2 green plans. Does anyone as an idea of how to do this ? I am using openGL but maybe another choice could be more efficient ?

3D solid with sections

[EDIT]

I finally achieved to display on a browser an stl file, calculate its volume and I can divide it into 2 stl files which represent the 2 different cuttings. I use the same algorithm again to recalculate the cutting's volume.

The hardships now, is to combine the stl files into one and create a small gap between the cuttings. All the cuttings have the same orientation so it should be easier.

If you have some ideas, let me know, Thanks !


Solution

  • Unfortunately, OpenGL does none of these things

    OpenGL is a graphics rendering library, and as such it does little else.

    Some type of CAD modelling software likely does exist to do what you have specified, but you're going to have to do some research. Search the web for "engineering cad programs"

    EDIT:

    Since you are writing the functions and the mathematics to do these tasks you mentioned and simply need a graphical representation, OpenGL is an ideal solution. A graphical representation of 3D data is one of the exact things OpenGL is good at.

    Given the additional information you've supplied, It's definitely going to be a substantial project.

    To be fairly honest - the easiest part of it will probably be the rendering.

    You'll need to be able to take the STL format data and convert it into a format OpenGL can use to render - usually triangles and vertices. Here is a good starting point.

    You'll also need to write and test the mathematical functions to derive a volume from a mesh. Here's a good starting point on this very website!

    As you progress you will find it easier to break down tasks into smaller ones and handle then individually. This is a core skill of a software developer and you should practice this as much as possible.

    While tasks like yours seem quite difficult at first as you break down the problems they become much easier to tackle.