Sectioning in general
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
- Pauvres_honteux
- Posts: 728
- Joined: Sun Feb 16, 2014 12:05 am
- Location: Far side of the moon
Sectioning in general
This thread will revolve around the sectioning problem in general, primarely for assys but also single parts. That is, how to program to make the sectioning extreamly lean on CPU-clock cycles.
PR #4074 The section cut feature
Background: commercial CAD-programs create sections in a blink of an eye, no matter how large of a model one reads up into memory.
These sections can be made to show the section border and are filled, this slows it down a tiiiny bit, but is hardly noticeble.
Section area calculations and edge to edge/point measurement(distance/angle/nearest/furthest point) are instant.
All of the above leads me to belive they do not only relay on the Gpu to achive that, they must have found a way around the brute force of boolean operations, but how? That is the question!
What tricks can be used to cram even more info from the Gpu? Any mathematical voodo?
What do we know and what can be figured out?
Edited: added clarification.
PR #4074 The section cut feature
Background: commercial CAD-programs create sections in a blink of an eye, no matter how large of a model one reads up into memory.
These sections can be made to show the section border and are filled, this slows it down a tiiiny bit, but is hardly noticeble.
Section area calculations and edge to edge/point measurement(distance/angle/nearest/furthest point) are instant.
All of the above leads me to belive they do not only relay on the Gpu to achive that, they must have found a way around the brute force of boolean operations, but how? That is the question!
What tricks can be used to cram even more info from the Gpu? Any mathematical voodo?
What do we know and what can be figured out?
Edited: added clarification.
Last edited by Pauvres_honteux on Sat Jun 26, 2021 4:54 am, edited 1 time in total.
- Pauvres_honteux
- Posts: 728
- Joined: Sun Feb 16, 2014 12:05 am
- Location: Far side of the moon
Sectioning in general
The usual suspects
realthunder wrote:
wmayer wrote:
ickby wrote:
Quaoar wrote:
tanderson69 wrote:
DeepSOIC wrote:
- tanderson69
- Veteran
- Posts: 1626
- Joined: Thu Feb 18, 2010 1:07 am
Re: Sectioning in general
I don't know, but I wouldn't assume the GPU is involved based upon just performance. The commercial modellers are significantly faster and would expect the same for sectioning. I don't know how the sectioning is done in freecad, but just off the top of my head: I would wrap all the solids to be sectioned into a compound that will be 1 argument to the section operation. The other would the section plane/shape. This eliminates any intersections between all solids to section and does it all in one operation. If this is still to slow, I would try to determine if the the booleans have 'exclude intersections by bounding box' or BVH and go from there. Maybe the exclusion tests could benefit from gpu and mesh data?Pauvres_honteux wrote: ↑Wed Jun 23, 2021 6:52 am All of the above leads me to belive they do not only relay on the Gpu to achive that, they must have found a way around the brute force of boolean operations, but how? That is the question!
What tricks can be used to cram even more info from the Gpu? Any mathematical voodo?
- Pauvres_honteux
- Posts: 728
- Joined: Sun Feb 16, 2014 12:05 am
- Location: Far side of the moon
Re: Sectioning in general
That reminded me, sectioning is usually done in an Assembly, not in a Part, if that matters?tanderson69 wrote: ↑Thu Jun 24, 2021 5:06 pm ... wrap all the solids to be sectioned into a compound.
So there are tricks up FreeCADs sleeve after all?
Please elaborate on this one so more programmers can chime in.
That "BVH", what does it stand for?
This sounds like an intresting trick! Perhaps a little extra elaboration on this one?tanderson69 wrote: ↑Thu Jun 24, 2021 5:06 pm Maybe the exclusion tests could benefit from gpu and mesh data?
Re: Sectioning in general
I think this is the link you'd like to have in your initial post https://forum.freecadweb.org/viewtopic.php?f=17&t=52441
edit: Would've been nice to ping the author of this PR too.
edit: Would've been nice to ping the author of this PR too.
uwestoehr wrote:
Regards / Viele Grüße
Max
Max
- Pauvres_honteux
- Posts: 728
- Joined: Sun Feb 16, 2014 12:05 am
- Location: Far side of the moon
Re: Sectioning in general
Ohh, sorry to say but, that discussion is what triggered this thread.
This thread will hopefully dig way deeper into the dark art of Gpu programming than what was done before. I'd say we should dig at least as deep so we can find some Balrogs down there!
Re: Sectioning in general
I think that GPU is not involved in the calculations, as a section is done in the "modeling engine" OCCT and not in the "visualization engine" that is Coin3D (Pivy).
Other commercial CAD use a different "modeling engine" and generally the code of this engines are not "public domain" so seeing "how things are done" in commercial software is not so easy.
One of the most "hidden secret" about Open source software is that sources are public, and anyone could submit PR or other "error reports" maybe with a "proposed modification" of the source code.
Commercial CAD at his best could accept "error reports", and maybe "it will be better if things will be done in this way".
As usual not to criticize, only to state that "Open source" is different from "closed source", and with "Open sources" there is more "room for improvement" especially if the improvements are done by "coders" that are also "user" of the program.
I think that many newcomers that are here because some commercial software is "becoming very expensive" are not used to the "open source" paradigm.
Regards
Carlo D.
Other commercial CAD use a different "modeling engine" and generally the code of this engines are not "public domain" so seeing "how things are done" in commercial software is not so easy.
One of the most "hidden secret" about Open source software is that sources are public, and anyone could submit PR or other "error reports" maybe with a "proposed modification" of the source code.
Commercial CAD at his best could accept "error reports", and maybe "it will be better if things will be done in this way".
As usual not to criticize, only to state that "Open source" is different from "closed source", and with "Open sources" there is more "room for improvement" especially if the improvements are done by "coders" that are also "user" of the program.
I think that many newcomers that are here because some commercial software is "becoming very expensive" are not used to the "open source" paradigm.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- tanderson69
- Veteran
- Posts: 1626
- Joined: Thu Feb 18, 2010 1:07 am
Re: Sectioning in general
BVH
I interpreted the initial post for making section views for drawings, where you would want an exact representation. I see some responses linking to dynamic section views where an approximate representation from mesh data is desired. I think it is important to be specific on what we are talking about.
- Pauvres_honteux
- Posts: 728
- Joined: Sun Feb 16, 2014 12:05 am
- Location: Far side of the moon
Re: Sectioning in general
I added clarificarion to the initial post, see if it's adequate.tanderson69 wrote: ↑Fri Jun 25, 2021 3:32 pm I interpreted the initial post for making section views for drawings...
This "mesh" should we interpret it as a visual mesh only existing in Gpu or as a "real" mesh? I mean, if you zoom in enough(like redicously) you will se that all faces are built up by rombs split in half.tanderson69 wrote: ↑Fri Jun 25, 2021 3:32 pm ... dynamic section views where an approximate representation from mesh data is desired.
That "BVH"-thing seems to be very lean on hardware resources. Could you possibly give an example of BVH versus Gpu-sectioning and/or Cpu-sectioning?
Code exmples aren't nessecery, but if you've got some, we won't say no to them.
Maybe all geometry should be wrapped by this BVH at creation time, so it's not nessecery when sectioning is in action?
Re: Sectioning in general
No there is a little misunderstanding.
FreeCAD didn't use a mesh to retain the model data, only if you transform some external data that is done using a mesh the solid will resemble a mesh.
OCCT retain the data using cruves to define boundaries, so the curve could be recalculated and scaled if needed without losing in precision.
But what you see in the 3d view is not supplied by OCCT but is supplied by the "visualization engine" that is "Coin 3D" using the Pivy python library.
The model visualization is done using a mesh (created by Coin3D) and have the triangulation, the precision of this triangulation could be controlled using some properties in the View Tab.
When you do some cut, is the OCCT engine that have to do the cut, recreating the faces that are not part of the original model, and creating a different model that have complex faces but these faces are stored using appropriate "portion of curves" so in the worst case a new curve has to be calculated and also boundaries has to be calculated too.
It is not immediate to catch this point, some help could be reading the OCCT documentation.
https://dev.opencascade.org/doc/occt-7. ... algos.html
There is no a complete interface to the OCCT functions (methods) in FreeCAD, but it is quite complete.
Hope it helps.
Regards
Carlo D.
FreeCAD didn't use a mesh to retain the model data, only if you transform some external data that is done using a mesh the solid will resemble a mesh.
OCCT retain the data using cruves to define boundaries, so the curve could be recalculated and scaled if needed without losing in precision.
But what you see in the 3d view is not supplied by OCCT but is supplied by the "visualization engine" that is "Coin 3D" using the Pivy python library.
The model visualization is done using a mesh (created by Coin3D) and have the triangulation, the precision of this triangulation could be controlled using some properties in the View Tab.
When you do some cut, is the OCCT engine that have to do the cut, recreating the faces that are not part of the original model, and creating a different model that have complex faces but these faces are stored using appropriate "portion of curves" so in the worst case a new curve has to be calculated and also boundaries has to be calculated too.
It is not immediate to catch this point, some help could be reading the OCCT documentation.
https://dev.opencascade.org/doc/occt-7. ... algos.html
There is no a complete interface to the OCCT functions (methods) in FreeCAD, but it is quite complete.
Hope it helps.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/