0025269: Make parallel version of boolean operations avaible from DRAW
authoraml <aml@opencascade.com>
Thu, 2 Oct 2014 08:55:08 +0000 (12:55 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 2 Oct 2014 09:33:43 +0000 (13:33 +0400)
new command bsetparallelmode added.
usage: bsetparallelmode [1/0].

Documentation for new command "bsetparallelmode" added.

dox/user_guides/draw_test_harness.md
src/BOPAlgo/BOPAlgo_Algo.cdl
src/BOPAlgo/BOPAlgo_Algo.cxx
src/BOPTest/BOPTest_BOPCommands.cxx

index bd66946..de77550 100644 (file)
@@ -1,4 +1,4 @@
-Draw Test Harness  {#occt_user_guides__test_harness}
+\12Draw 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:      
 ~~~~~
index 03b1448..5af0c44 100644 (file)
@@ -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;      
          
index 4d1b441..6a34b54 100644 (file)
 #include <Standard_ProgramError.hxx>
 #include <Standard_NotImplemented.hxx>
 
+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)
 {}
 
 //=======================================================================
index 15cd258..375cad4 100644 (file)
@@ -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  :