Cut in pairs, using the previous result at each iteration? Combine all the set of objects first into some kind of structure?
Mikhail Sazonov Wed, 01/12/2022 - 16:54
If you ensure all cutting objects have no intersection between each other you can add all them into one compound and use it as a tool.
Otherwise, you can add all tools one by one into the algorithm, and then call one calculation. This way the algorithm will resolve all intersections between objects.
I'm using WebAssembly port. And the result is the same for both cases (seems that internally the framework also processes element by element) and much longer (~ 10 times) than in CAD Builder (instant) with the same objects.
SetRunParrallel() has no effect.
In theory, the speed should be comparable, but it might be a parallel issue. Or does CAD Builder preprocess a Shapes list somehow?
The scene is simple, Box and Cylinders looks like this :
I'm using WebAssembly port. SetRunParrallel() has no effect.
Have you built OCCT with -pthreads option by Emscripten? Though I have no idea if CAD Builder uses multithreading here and if it has any effect in this specific case.
In such small example there should be no difference if you cut one by one or in one operation. In side the objects intersect each other only if their boxes intersect. The pairs of intersecting boxes are selected using the boxes tree. So, If there are huge number of objects you should notice the difference. As for parallel flag, I would first tried to perform the algorithm without parallelization on both platforms to compare pure algorithm flow. I suspect that the code generated with emscripten is slower.
I used 20 cylinders. Yes, a small amount, but even in this example, the difference in speed is huge. Not 85% of native performance, not 2-3 times, but 10 or more.
I can't test C++ source code, only CADBuilder, so my question is rather this: does CADBuilder boolen operations somehow speed up or does the JS port slow them down?
Can you test a similar scene with SetRunParrallel(false)?
jsupload . -path box.step
jsupload . -path cylinders.step
pload MODELING XDE
testreadstep box.step a
testreadstep cylinders.step b
bclearobjects
bcleartools
chrono h reset start
baddobjects a
baddtools b
bfillds
bbop r cut
chrono h stop show
Native (vc14): 0.739 s
Firefox 95: 1.044 s
Edge 97: 0.677 s
Script 3:
jsupload . -path box.step
jsupload . -path cylinders.step
pload MODELING XDE
testreadstep box.step a
testreadstep cylinders.step b
chrono h reset start
copy a r
foreach s [explode b] { bcut r r $s }
chrono h stop show
Native (vc14): 0.419 s
Firefox 95: 2.323 s
Edge 97: 1.399 s
Draw Harness is a Tcl wrapper for OCCT C++ functionality coming with OCCT itself. It doesn't export OCCT C++ classes into JavaScript (in contrary to opencascade.js), only an interface to call Tcl commands / scripts (including commands working with 3D Viewer from ViewerTest plugin) is exposed at JavaScript level.
Does Tcl cover all possible C++ methods? That is, is it possible, using the Tcl, to do the same thing as calling C++ methods directly?
Draw Harness doesn't wrap C++ classes and their methods, it implements a dedicated procedural interface to OCCT functionality. I'm not advertising using DRAW for application development - it is just the most straightforward way to test OCCT framework functionality, as it comes with OCCT itself, covers major part of functionality and available across most platforms (including WebAssembly - hence, it is possible to compare performance / behavior within the same conditions).
Why, in your opinion, does opencascade.js work so slowly for Boolean (at least)?
I cannot say if it is slower or not as I never used it - there might be different building options, differences in code performing Boolean operations, or something else. The very way opencascade.js exposes functionality (wrapping a lot of C++ classes and their methods into JavaScript) might be an extra reason for slowing down, as well as an origin of memory leaks (due to the lack of finalizers in JavaScript, you have to delete C++ classes manually).
Wed, 01/12/2022 - 16:54
If you ensure all cutting objects have no intersection between each other you can add all them into one compound and use it as a tool.
Otherwise, you can add all tools one by one into the algorithm, and then call one calculation. This way the algorithm will resolve all intersections between objects.
Wed, 01/12/2022 - 17:46
Thanks.
Are there any differences in execution speed?
Wed, 01/12/2022 - 18:22
The most long part of computations is intersection. Please make your conclusion. And, please, share here your results.
Wed, 01/12/2022 - 18:50
I'm using WebAssembly port. And the result is the same for both cases (seems that internally the framework also processes element by element) and much longer (~ 10 times) than in CAD Builder (instant) with the same objects.
SetRunParrallel() has no effect.
In theory, the speed should be comparable, but it might be a parallel issue. Or does CAD Builder preprocess a Shapes list somehow?
The scene is simple, Box and Cylinders looks like this :
Wed, 01/12/2022 - 19:20
Have you built OCCT with -pthreads option by Emscripten? Though I have no idea if CAD Builder uses multithreading here and if it has any effect in this specific case.
Wed, 01/12/2022 - 19:29
In such small example there should be no difference if you cut one by one or in one operation. In side the objects intersect each other only if their boxes intersect. The pairs of intersecting boxes are selected using the boxes tree. So, If there are huge number of objects you should notice the difference. As for parallel flag, I would first tried to perform the algorithm without parallelization on both platforms to compare pure algorithm flow. I suspect that the code generated with emscripten is slower.
Thu, 01/13/2022 - 18:41
I used 20 cylinders. Yes, a small amount, but even in this example, the difference in speed is huge. Not 85% of native performance, not 2-3 times, but 10 or more.
I can't test C++ source code, only CADBuilder, so my question is rather this: does CADBuilder boolen operations somehow speed up or does the JS port slow them down?
Can you test a similar scene with SetRunParrallel(false)?
Thu, 01/13/2022 - 19:09
To test the scene I need the input shapes.
Also, I can test only in native code. I have no web assembly with OCCT to compare the results on the same computer.
Thu, 01/13/2022 - 19:52
box.step
cylinders.step
box_and_cylinders.step
Thu, 01/13/2022 - 21:08
I have created 3 scripts,
1) Cutting compound of cylinders
2) Adding each cylinder as a separate tool and cutting in one operation
3) Cutting sequentially one by one.
Here are the results:
Parallelization was turned off.
Fri, 01/14/2022 - 11:03
My results (using DRAW), Script 1:
Script 3:
It doesn't look "slower in 10 times" to me.
Fri, 01/14/2022 - 15:20
I tested opencascade.js
What framework is used in your example? Can it be used alongside JavaScript? I mean, is it possible to write something like:
?
Is it possible to use this port without built-in renderer? i.e. get all necessary triangulation data.
Fri, 01/14/2022 - 15:25
Draw Harness is a Tcl wrapper for OCCT C++ functionality coming with OCCT itself. It doesn't export OCCT C++ classes into JavaScript (in contrary to opencascade.js), only an interface to call Tcl commands / scripts (including commands working with 3D Viewer from ViewerTest plugin) is exposed at JavaScript level.
Fri, 01/14/2022 - 15:49
Does Tcl cover all possible C++ methods? That is, is it possible, using the Tcl, to do the same thing as calling C++ methods directly?
Why, in your opinion, does opencascade.js work so slowly for Boolean (at least)?
CascadeStudio.
Mon, 01/17/2022 - 08:12
W W wrote:
Draw Harness doesn't wrap C++ classes and their methods, it implements a dedicated procedural interface to OCCT functionality. I'm not advertising using DRAW for application development - it is just the most straightforward way to test OCCT framework functionality, as it comes with OCCT itself, covers major part of functionality and available across most platforms (including WebAssembly - hence, it is possible to compare performance / behavior within the same conditions).
I cannot say if it is slower or not as I never used it - there might be different building options, differences in code performing Boolean operations, or something else. The very way opencascade.js exposes functionality (wrapping a lot of C++ classes and their methods into JavaScript) might be an extra reason for slowing down, as well as an origin of memory leaks (due to the lack of finalizers in JavaScript, you have to delete C++ classes manually).
Thu, 01/13/2022 - 21:58
Thanks. What are the results with parallelization enabled?
Fri, 01/14/2022 - 00:16
It has no sense for this small example. Overheads exceed any benefits here.