Boolean Operations

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Boolean Operations

Post by triplus »

I was reading a bit today regarding boolean operations and OCCT and this things stand out (release notes):
I was wondering how does/will this affect FreeCAD?

As for parallelization Intel TBB is used. I remember discussions and tests about meshing where we did a bit of testing by enabling TBB. Could we enable TBB to test this already for boolean operations? I am guessing NO but still the question remains.

Support of multiple arguments for a single Boolean operation sounds like something that could additionally improve performance?

Regarding new possibility to specify global tolerance for a Boolean operation. Would this be possible in FreeCAD? I am guessing setting this value to lower/higher precision would greatly affect performance and it could probably help in situations where currently boolean operation fail as small "artifacts/imprecisions" get in the way.

Any thoughts on this?
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Boolean Operations

Post by DeepSOIC »

triplus wrote:Fuzzy Boolean operations - possibility to specify global tolerance for a Boolean operation (http://dev.opencascade.org/index.php?q=node/1056)
Shoogen was doing something in that direction, as far as I remember...
triplus wrote:Support of multiple arguments for a single Boolean operation (http://dev.opencascade.org/index.php?q=node/1060)
I guess, that is already in action, because we have this: App.ActiveDocument.Cone.Shape.multiFuse(other shapes).
triplus wrote:Parallelization of Boolean Operations algorithm (http://dev.opencascade.org/index.php?q=node/718)
I don't remember anything about that one here on the forum... This is interesting.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Boolean Operations

Post by triplus »

Shoogen was doing something in that direction, as far as I remember...
I see. Maybe he could answer if Fuzzy could be used to overcome issues like this:
Fuzzy.png
Fuzzy.png (14.64 KiB) Viewed 5424 times
Tech.FCStd -> Boolean Cut between Sweep001 and Sweep004. I am guessing this is precision/tolerance related issue and by loosing up fuzzy tolerance that should take care of it? And probably the whole Cut operation in that thread could complete much faster if boolean tolerance would be loosen a bit? This is just speculation and i can be wrong about them. It will probably turn out this can't be used in FreeCAD but still doesn't hurt to discuss this a bit.

viewtopic.php?f=3&t=11226#p90456
I guess, that is already in action, because we have this: App.ActiveDocument.Cone.Shape.multiFuse(other shapes).
On FreeCAD level or on kernel level? Is for example operation on the kernel level done in single pass?
I don't remember anything about that one here on the forum... This is interesting.
Here we tested TBB with FreeCAD meshing operations. TBB never got enabled on PPA. But i am wondering if:

-Meshing operation multi-core efficiency with enabled TBB improved since then.
-How does having TBB support for boolean operations influence the end result.
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Boolean Operations

Post by shoogen »

In the current implementation Fuzzy booleans damage the input shapes. As a workaround the input shapes have to be duplicated beforehand.
I forcibly updated my github branch dev-fuzzyboolean. https://github.com/5263/FreeCAD/commits ... zzyboolean
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Boolean Operations

Post by triplus »

shoogen wrote:In the current implementation Fuzzy booleans damage the input shapes. As a workaround the input shapes have to be duplicated beforehand.
I forcibly updated my github branch dev-fuzzyboolean. https://github.com/5263/FreeCAD/commits ... zzyboolean
Very interesting! I am guessing to test this i would need to compile OCCT 6.9.0 and after compile your FreeCAD branch where i would set correct path to compiled OCCT 6.9.0?

Should this work or should i wait for OCE to upgrade? Well that is more or less rhetorical question as sure i will try OCCT 6.9.0 first and won't wait that long. ;)

Anyway any guidance available on how to successfully make FreeCAD (your branch) use self compiled OCCT 6.9.0 on Ubuntu?

I am guessing first i should compile OCCT 6.9.0 and probably compiling your branch shouldn't be an issue regarding following standard procedure for FreeCAD compile. A bit of a loose end is do i need to remove OCE from PPA first and is simply adding new path to self compiled OCCT 6.9.0 enough for compiled FreeCAD (your branch) to pick it up?
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Boolean Operations

Post by triplus »

OK i managed to compile dev-fuzzyboolean branch that is using compiled OCCT 6.9.0. Will do some tests tomorrow and in the following days. Very quick test seems to indicate:
  • issue #0002151 is fixed in OCCT 6.9.0.
  • Refine shape tool crashes dev-fuzzyboolean branch.
  • Fuzzy tolerance can't be used to overcome issue on above image and the Cut result in OCCT 6.9.0 is different in the first place.
But this is really quick testing and don't think of it as confirmation yet. What i a missing is a way to set tolerance before an actual boolean operation (if that is possible) to see if there is some speed difference involved when loosing the tolerance.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Boolean Operations

Post by triplus »

Today i compiled dev-fuzzyboolean branch + OCCT 6.9.0 + TBB.

As for fuzzy tolerance i don't quite understand its use compared to what i was thinking it should be doing. Will test this more in the following days.

As for parallelization if i would have to guess based on my tests only meshing is done in parallel ATM. About the tests we did back then for meshing performance i will need to test this but i think we didn't test the actual meshing operations in some tests.

As for boolean operations:
2.2 Implement the parallelism in BOA using the schema.
The Boolean Operation Algorithm consists of two parts: Intersection Part and Building Part. The implementation of parallelism has also been divided on two corresponding parts. Inside each part the levels of parallelization have been defined. Then the schema has been applied to each level.
In particular for Intersection Part almost all parts of high level have been parallelized:

intersection of bounding boxes of source shapes
computation of Vertex/Edge interferences
computation of Edge/Edge interferences
computation of Vertex/Face interferences
computation of Edge/Face interferences
computation of Face/Face interferences
computation of Split Edges
computation of p-curves

Furthermore, due to recursive nature of the Intersection Part of the Algorithm all post-treatment parts of Edge/Edge, Edge/Face, Face/Face interferences have been parallelized automatically.

As for the Building Part of the Algorithm the most time-consuming parts of high level:

building split faces
building same domain faces
building split solids
checking the results

and one level deeper:
splitting wires for faces
splitting shells for solids

have been parallelized.
I think none of this is done in parallel in FreeCAD ATM? I could be wrong. After complex boolean operations 99% of the time no parallelism is detected (CPU monitor). There is always a small amount of parallelism detected at the end of boolean operations. If i would have to guess i would say that is meshing?
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Boolean Operations

Post by triplus »

I won't mix boolean operations and meshing algorithm multi-threading efficiency discussion but for the reference in this thread i will provide results for meshing multi-threading.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Boolean Operations

Post by triplus »

As this thread is more or less about OCCT 6.9.0 i will ask here.

Does OCCT 6.9.0 "bundle" TBB or uses something else for multi-threading by default? I tried to do some tests for multi-thread vs. single thread efficiency detection but i can't "turn off" multi-threading at all. I compiled OCCT 6.9.0 with default set of flags and after compiled FreeCAD master against it. Running this macro always has intensive multi-thread phase.

I am not complaining about FreeCAD (OCCT) actually using multi-threading but i just can't figure it out what is the reason that happens. Ruining that macro in FreeCAD compiled against OCE 0.17 from daily PPA does no multi-threading.

Any ideas?
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Boolean Operations

Post by triplus »

It is probably not OpenMP as OpenMP environment variables are not respected therefore for now i will settle for "bundled TBB". OCE 0.18 probably won't do that and there will be TBB/OpenMP flags available.

Anyway in the end i used numactl to get some single thread meshing data.
Post Reply