From e322db461d8f3d36c007f1b8f9fc48ae949a4e90 Mon Sep 17 00:00:00 2001 From: aml Date: Thu, 2 Oct 2014 12:55:08 +0400 Subject: [PATCH] 0025269: Make parallel version of boolean operations avaible from DRAW new command bsetparallelmode added. usage: bsetparallelmode [1/0]. Documentation for new command "bsetparallelmode" added. --- dox/user_guides/draw_test_harness.md | 32 +++++++++++++++++++++++---- src/BOPAlgo/BOPAlgo_Algo.cdl | 10 +++++++-- src/BOPAlgo/BOPAlgo_Algo.cxx | 28 +++++++++++++++++++++-- src/BOPTest/BOPTest_BOPCommands.cxx | 33 +++++++++++++++++++++++++++- 4 files changed, 94 insertions(+), 9 deletions(-) diff --git a/dox/user_guides/draw_test_harness.md b/dox/user_guides/draw_test_harness.md index bd66946eb5..de77550c32 100644 --- a/dox/user_guides/draw_test_harness.md +++ b/dox/user_guides/draw_test_harness.md @@ -1,4 +1,4 @@ -Draw Test Harness {#occt_user_guides__test_harness} +Draw Test Harness {#occt_user_guides__test_harness} =============================== @tableofcontents @@ -6265,7 +6265,31 @@ sr is a shape COMPOUND FORWARD Free Modified The new algorithm of Boolean operations avoids a large number of weak points and limitations presented in the old boolean operation algorithm. -@subsubsection occt_draw_7_7_1 bop, bopfuse, bopcut, boptuc, bopcommon, +@subsubsection occt_draw_7_7_1 bparallelmode + +* **bparallelmode** enable or disable parallel mode for boolean operations. Sequential computing is used by default. + +Syntax: +~~~~~ +bparallelmode [1/0] + +~~~~~ + +Without arguments, bparallelmode shows current state of parallel mode for boolean operations. + +* *0* Disable parallel mode, +* *1* Enable parallel mode + +**Example:** +~~~~~ +# Enable parallel mode for boolean operations. +bparallelmode 1 + +# Show state of parallel mode for boolean operations. +bparallelmode +~~~~~ + +@subsubsection occt_draw_7_7_2 bop, bopfuse, bopcut, boptuc, bopcommon * **bop** defines *shape1* and *shape2* subject to ulterior Boolean operations * **bopfuse** creates a new shape by a boolean operation on two existing shapes. The new shape contains both originals intact. @@ -6337,7 +6361,7 @@ bcommon s14 b c ttranslate s14 0 -40 100 ~~~~~ -@subsubsection occt_draw_7_7_2 bopsection +@subsubsection occt_draw_7_7_3 bopsection Syntax: ~~~~~ @@ -6372,7 +6396,7 @@ bopsection s bsection s2 b c ~~~~~ -@subsubsection occt_draw_7_7_3 bopcheck, bopargshape +@subsubsection occt_draw_7_7_4 bopcheck, bopargshape Syntax: ~~~~~ diff --git a/src/BOPAlgo/BOPAlgo_Algo.cdl b/src/BOPAlgo/BOPAlgo_Algo.cdl index 03b144872b..5af0c4466a 100644 --- a/src/BOPAlgo/BOPAlgo_Algo.cdl +++ b/src/BOPAlgo/BOPAlgo_Algo.cdl @@ -30,8 +30,14 @@ is ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_Algo();" Initialize (theAllocator: BaseAllocator from BOPCol) - returns Algo from BOPAlgo; - + returns Algo from BOPAlgo; + + GetParallelMode(myclass) + returns Boolean; + + SetParallelMode(myclass; + theNewMode: Boolean from Standard); + Perform(me:out) is deferred; diff --git a/src/BOPAlgo/BOPAlgo_Algo.cxx b/src/BOPAlgo/BOPAlgo_Algo.cxx index 4d1b4412aa..6a34b54332 100644 --- a/src/BOPAlgo/BOPAlgo_Algo.cxx +++ b/src/BOPAlgo/BOPAlgo_Algo.cxx @@ -22,6 +22,30 @@ #include #include +namespace +{ + Standard_Boolean myGlobalRunParallel = Standard_False; +} + +//======================================================================= +// function: +// purpose: +//======================================================================= +void BOPAlgo_Algo::SetParallelMode(Standard_Boolean theNewMode) +{ + myGlobalRunParallel = theNewMode; +} + +//======================================================================= +// function: +// purpose: +//======================================================================= +Standard_Boolean BOPAlgo_Algo::GetParallelMode() +{ + return myGlobalRunParallel; +} + + //======================================================================= // function: // purpose: @@ -31,7 +55,7 @@ BOPAlgo_Algo::BOPAlgo_Algo() myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), myErrorStatus(1), myWarningStatus(0), - myRunParallel(Standard_False) + myRunParallel(myGlobalRunParallel) {} //======================================================================= // function: @@ -43,7 +67,7 @@ BOPAlgo_Algo::BOPAlgo_Algo myAllocator(theAllocator), myErrorStatus(1), myWarningStatus(0), - myRunParallel(Standard_False) + myRunParallel(myGlobalRunParallel) {} //======================================================================= diff --git a/src/BOPTest/BOPTest_BOPCommands.cxx b/src/BOPTest/BOPTest_BOPCommands.cxx index 15cd25813d..375cad46c6 100644 --- a/src/BOPTest/BOPTest_BOPCommands.cxx +++ b/src/BOPTest/BOPTest_BOPCommands.cxx @@ -77,6 +77,8 @@ static Standard_Integer bcommon (Draw_Interpretor&, Standard_Integer, const ch static Standard_Integer bopcurves (Draw_Interpretor&, Standard_Integer, const char**); static Standard_Integer bopnews (Draw_Interpretor&, Standard_Integer, const char**); // +static Standard_Integer bparallelmode(Draw_Interpretor&, Standard_Integer, const char**); +// static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const char**); //======================================================================= @@ -108,7 +110,7 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c // theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d]", __FILE__, bopcurves, g); theCommands.Add("bopnews", "use bopnews -v[e,f]" , __FILE__, bopnews, g); - // + theCommands.Add("bparallelmode", "bparallelmode [1/0] : show / set parallel mode for boolean operations", __FILE__, bparallelmode, g); theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-ni (do not intersect)] [-s (run in non parallel mode)]", __FILE__, mkvolume , g); } @@ -692,6 +694,35 @@ Standard_Integer bopcurves (Draw_Interpretor& di, return 0; } +//======================================================================= +//function : bparallelmode +//purpose : +//======================================================================= +Standard_Integer bparallelmode(Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + if (n == 2) + { + Standard_Boolean isParallelOn = Draw::Atoi (a[1]) == 1; + if (isParallelOn == 1) + { + BOPAlgo_Algo::SetParallelMode(Standard_True); + di << "Parallel mode for boolean operations has been enabled"; + } + else + { + BOPAlgo_Algo::SetParallelMode(Standard_False); + di << "Parallel mode for boolean operations has been disabled"; + } + } + else + { + di << "Parallel mode state for boolean operations: " + << (BOPAlgo_Algo::GetParallelMode()? "enabled" : "disabled"); + } + + return 0; +} + //======================================================================= //function : mkvolume //purpose : -- 2.20.1