-1

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 !

Ben
  • 37
  • 11
  • Hi, welcome to SO! Please provider a [mcve] so that we could help you better! – hatef Feb 23 '17 at 10:15
  • Hi thanks for your answer, actually I haven't started yet because I want to study the feasibility of this function. I just need some potential solutions. Feel free to tell me if I am wrong. – Ben Feb 23 '17 at 12:36

3 Answers3

2

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.

Community
  • 1
  • 1
finlaybob
  • 697
  • 10
  • 30
  • Thanks, your answer is very clear and helpful ! Actually, my final goal is to create from a stl file a 3D meshing, cut this meshing and calculate the new volumes and then I will use openGL to display it on a 3D model. (like the image). It's a long term project but I am trying to progress step by step. – Ben Feb 23 '17 at 14:09
  • 1
    Cue phantom downvotes... If I've mentioned something incorrect please point it out. If it's the same person who tried to correct my grammar and I rejected it, your edits were incorrect. Also that is a poor reason to downvote. – finlaybob Feb 23 '17 at 16:16
  • @finlaybob: We all have the same unknowledge. What I think is that for most people it's easy to click on "I don't like", whatever reason they have, because expressing their opinion requires exposing their nick name. – Ripi2 Feb 24 '17 at 17:42
0

finlaybob gave you quite extensive answer but it lacked the most important part :).

Look for Constructive Solid Geometry. This is the general term used for algorithms that can add, subtract and cut triangle meshes. You'll find a lot of articles but also ready made libraries for this task. If you prefer to write it on your own or use existing lib - it's your subjective decision and I won't help you here.

When you pick your solution for CSG the rest should be much simpler:

  • Pick your target mesh format and read the mesh from the file (I believe you've already did that).
  • Either cut your mesh with planes using CSG or extrude your planes to cubes and subtract them from the mesh (depending on exact functionality your CSG has).
  • Compute volume of the rest, using suggestions from finlaybob answer.
kolenda
  • 2,741
  • 2
  • 19
  • 30
  • It would be nice to at least inform why you downvote, unless your're ashamed of your own decision. – kolenda Feb 27 '17 at 11:38
-1

If you know some mathematical representation of your model, or a combinations of submodels, well, cut sections is a matter of maths.

For any generic model, perhaps building a 3D with tetrahedra or some sort of 3D grid is a good solution, because the maths for intersections with plans are quite easy.

Ripi2
  • 7,031
  • 1
  • 17
  • 33