0024825: Fit Boolean Operation Algorithm to treat multiple arguments.
[occt.git] / src / BOPTest / BOPTest_PartitionCommands.cxx
index d01c630..d735a98 100644 (file)
@@ -117,10 +117,10 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
   // Chapter's name
   const char* g = "Partition commands";
   // Commands  
-  theCommands.Add("bfillds"  , "use bfillds [-s -t]" , __FILE__, bfillds, g);
-  theCommands.Add("bbuild"   , "use bbuild r [-s -t]", __FILE__, bbuild, g);
-  theCommands.Add("bbop"     , "use bbop r op"       , __FILE__, bbop, g);
-  theCommands.Add("bclear"   , "use bclear"          , __FILE__, bclear, g);
+  theCommands.Add("bfillds", "use bfillds [-s -t]"  , __FILE__, bfillds, g);
+  theCommands.Add("bbuild" , "use bbuild r [-s -t]" , __FILE__, bbuild, g);
+  theCommands.Add("bbop"   , "use bbop r op [-s -t]", __FILE__, bbop, g);
+  theCommands.Add("bclear" , "use bclear"           , __FILE__, bclear, g);
 }
 
 //=======================================================================
@@ -314,8 +314,8 @@ Standard_Integer bbop(Draw_Interpretor& di,
                       Standard_Integer n, 
                       const char** a) 
 { 
-  if (n!=3) {
-    di << " use bbop r op\n";
+  if (n<3) {
+    di << " use bbop r op [-s -t]\n";
     return 0;
   }
   //
@@ -326,16 +326,30 @@ Standard_Integer bbop(Draw_Interpretor& di,
   }
   //
   char buf[32];
-  Standard_Integer iErr, iOp;
+  Standard_Boolean bRunParallel, bShowTime;
+  Standard_Integer iErr, iOp, i;
   BOPAlgo_Operation aOp;
-  BOPCol_ListIteratorOfListOfShape aIt;
+  BOPCol_ListIteratorOfListOfShape aIt; 
+  BOPTime_Chronometer aChrono;
   //
   iOp=Draw::Atoi(a[2]);
   if (iOp<0 || iOp>4) {
     di << " invalid operation type\n";
+    return 0;
   }
   aOp=(BOPAlgo_Operation)iOp;
   //
+  bShowTime=Standard_False;
+  bRunParallel=Standard_True;
+  for (i=3; i<n; ++i) {
+    if (!strcmp(a[i], "-s")) {
+      bRunParallel=Standard_False;
+    }
+    else if (!strcmp(a[i], "-t")) {
+      bShowTime=Standard_True;
+    }
+  }
+  //
   BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
   //
   BOPAlgo_BOP& aBOP=BOPTest_Objects::BOP();
@@ -356,6 +370,9 @@ Standard_Integer bbop(Draw_Interpretor& di,
   }
   //
   aBOP.SetOperation(aOp);
+  aBOP.SetRunParallel(bRunParallel);
+  //
+  aChrono.Start();
   //
   aBOP.PerformWithFiller(aPF);
   iErr=aBOP.ErrorStatus();
@@ -365,6 +382,16 @@ Standard_Integer bbop(Draw_Interpretor& di,
     return 0;
   }
   //
+  aChrono.Stop();
+  //
+  if (bShowTime) {
+    Standard_Real aTime;
+    //
+    aTime=aChrono.Time();
+    Sprintf(buf, "  Tps: %7.2lf\n", aTime);
+    di << buf;
+  }
+  //
   const TopoDS_Shape& aR=aBOP.Shape();
   if (aR.IsNull()) {
     di << " null shape\n";