OpenCascade and TBB

Hello everyone,

I am writing here in the hope that I can get a solution to the problem that I am having.

I'll start with a little background. My objective is to make a program that can cut a solid, read from a STEP file, into a number of sections. The best way that come to my mind was to use Boolean operations (Cut or Common) to cut the geometry. However, for very complex CAD files this takes a very long time. Since the cutting operations are independent, I was thinking to try to do the cutting in parallel. However, I have ran into trouble.

I attach a simplified version of the program that I am currently using. In this version, the number of cuts done on X,Y and Z axis are chosen via a #define statement. Then, inside for loops, I make a solid box corresponding to the bounding box for each section, which I then use in a BRepAlgoAPI_Common operation with my main shape to obtain the section. I know this is not very efficient, and in the longer version of the software I am taking a recursive approach, but that is more difficult to parallelize, and for start I want to keep it simple. I will do that as the next step.

So I tried to use TBB tasks to parallelize the CAD cutting operations. The reason for the tasks is that I think they are the way to go for parallelizing the recursive case. However, more often than not my program crashes or freezes.

I've read the previous posts http://www.opencascade.org/org/forum/thread_21248/ and learned that I should set MMGT_OPT=0. I have also tried MMTT_REENTRANT=1. Basically:

MMGT_OPT=1, MMTT_REENTRANT=0 --> instant crash
MMGT_OPT=1, MMTT_REENTRANT=1 --> sometimes crashes and sometimes works
MMGT_OPT=0, MMTT_REENTRANT=0 --> always freezes or crashes
MMGT_OPT=0, MMTT_REENTRANT=1 --> always freezes or crashes

I am using TBB 4.0 and MSVC 2010, 32bit compilation on a 64bit Win7 machine.

Any suggestions? Any experience with such things?

Thanks!!!
Ion

Attachments: 
Forum supervisor's picture

Dear Ion,
Take into account, please the next notes:
1)Special note: for applications that use OCCT memory manager from more than one thread, on multiprocessor hardware, it is recommended to use options MMGT_OPT=2 and MMGT_REENTRANT=1
(see "Open CASCADE Technology Installation/System Environment Variables").
2)Boolean operations algorithm is still not thread-safe, although we are working on it.
So, at the moment it is under responsibility of a developer to ensure success of a final thread-safety.
If you will succeed in this way you are welcome with your contribution to the Collaborative portal - http://dev.opencascade.org.
Regards

ionlee's picture

Hi and thanks a lot for the answer.
Unfortunately, not being an expert, I currently do not not have the necessary time to try to do this myself, so I am still exploring alternatives. If doing this in parallel proves to be the only possible way, I might try it.

Thanks again,
Ion

Thorsten H's picture

>2)Boolean operations algorithm is still not thread-safe, although we are working on it.
>So, at the moment it is under responsibility of a developer to ensure success of a final thread-safety.

Does this mean
- Boolean operations are single threaded (with MMGT_OPT=2 and MMGT_REENTRANT=1) and working?
- Boolean operations are multi threaded (with MMGT_OPT=2 and MMGT_REENTRANT=1) and somtimes crashing?

Forum supervisor's picture

Dear Thorsten,
At the moment Boolean operations algorithm is not thread-safe with any settings of environment variables.
Regards

Timo Roth's picture

Dear Thorsten,

the first option you gave is the current state:
Boolean operations are single threaded (with MMGT_OPT=2 and MMGT_REENTRANT=1) and working.

Currently, no parallelism is implemented for Boolean operations.

Evgeny Lodyzhehsky's picture

Boolean operations algorithm is STILL not thread-safe.
OK.
But the topic is OpenCascade and TBB.
AFAIK Boolean operations algorithm is the part of Open Cascade.
What about the others?
Thanks.