]> OCCT Git - occt-copy.git/commitdiff
Introduce BOPAlgo_ParallelAlgo which has myRange as a field to be used in parallel... CR21264_1
authoremv <emv@opencascade.com>
Fri, 2 Jul 2021 14:03:54 +0000 (17:03 +0300)
committeremv <emv@opencascade.com>
Tue, 13 Jul 2021 09:25:47 +0000 (12:25 +0300)
Provide suitable way of keeping the progress steps of operations.
Give meaningful names to progress scopes.
Propagate progress indicator into deeper methods of BOA.
Add progress indicator to BOPAlgo_BuilderFace and BOPAlgo_WireSplitter, BOPAlgo_BuilderSolid and BOPAlgo_ShellSplitter

54 files changed:
src/BOPAlgo/BOPAlgo_Algo.cxx
src/BOPAlgo/BOPAlgo_Algo.hxx
src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.cxx
src/BOPAlgo/BOPAlgo_ArgumentAnalyzer.hxx
src/BOPAlgo/BOPAlgo_BOP.cxx
src/BOPAlgo/BOPAlgo_BOP.hxx
src/BOPAlgo/BOPAlgo_Builder.cxx
src/BOPAlgo/BOPAlgo_Builder.hxx
src/BOPAlgo/BOPAlgo_BuilderArea.hxx
src/BOPAlgo/BOPAlgo_BuilderFace.cxx
src/BOPAlgo/BOPAlgo_BuilderFace.hxx
src/BOPAlgo/BOPAlgo_BuilderSolid.cxx
src/BOPAlgo/BOPAlgo_BuilderSolid.hxx
src/BOPAlgo/BOPAlgo_Builder_1.cxx
src/BOPAlgo/BOPAlgo_Builder_2.cxx
src/BOPAlgo/BOPAlgo_Builder_3.cxx
src/BOPAlgo/BOPAlgo_Builder_4.cxx
src/BOPAlgo/BOPAlgo_CellsBuilder.cxx
src/BOPAlgo/BOPAlgo_CheckerSI.cxx
src/BOPAlgo/BOPAlgo_CheckerSI.hxx
src/BOPAlgo/BOPAlgo_CheckerSI_1.cxx
src/BOPAlgo/BOPAlgo_MakerVolume.cxx
src/BOPAlgo/BOPAlgo_MakerVolume.hxx
src/BOPAlgo/BOPAlgo_PaveFiller.cxx
src/BOPAlgo/BOPAlgo_PaveFiller.hxx
src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx
src/BOPAlgo/BOPAlgo_Section.cxx
src/BOPAlgo/BOPAlgo_Section.hxx
src/BOPAlgo/BOPAlgo_ShellSplitter.cxx
src/BOPAlgo/BOPAlgo_ShellSplitter.hxx
src/BOPAlgo/BOPAlgo_Splitter.cxx
src/BOPAlgo/BOPAlgo_Tools.cxx
src/BOPAlgo/BOPAlgo_Tools.hxx
src/BOPAlgo/BOPAlgo_WireSplitter.cxx
src/BOPAlgo/BOPAlgo_WireSplitter.hxx
src/BOPTest/BOPTest_BOPCommands.cxx
src/BOPTest/BOPTest_PartitionCommands.cxx
src/BRepAlgoAPI/BRepAlgoAPI_BooleanOperation.cxx
src/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Check.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Common.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Common.hxx
src/BRepAlgoAPI/BRepAlgoAPI_Cut.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Fuse.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Section.cxx
src/BRepFeat/BRepFeat_Builder.cxx
src/BRepFeat/BRepFeat_Builder.hxx

index 1fd54eced92a78520eba97607d3e40777ed12aaa..794a32eb10004664e151169e6e69e22176bc3241 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <BOPAlgo_Algo.hxx>
 
+#include <TColStd_MapOfInteger.hxx>
+
 //=======================================================================
 // function: 
 // purpose: 
@@ -60,3 +62,67 @@ void BOPAlgo_Algo::CheckResult()
 {
   GetReport()->Clear(Message_Fail);
 }
+
+//=======================================================================
+// function: analyzeProgress
+// purpose: 
+//=======================================================================
+void BOPAlgo_Algo::analyzeProgress(const Standard_Real theWhole,
+                                   BOPAlgo_PISteps& theSteps) const
+{
+  Standard_Real aWhole = theWhole;
+
+  // Fill progress steps for constant operations
+  fillPIConstants(theWhole, theSteps);
+
+  TColStd_Array1OfReal& aSteps = theSteps.ChangeSteps();
+  TColStd_MapOfInteger aMIConst;
+  for (Standard_Integer i = aSteps.Lower(); i <= aSteps.Upper(); ++i)
+  {
+    if (aSteps(i) > 0.)
+    {
+      aMIConst.Add(i);
+      aWhole -= aSteps(i);
+    }
+  }
+
+  // Fill progress steps for other operations
+  fillPISteps(theSteps);
+
+  Standard_Real aSum = 0.;
+  for (Standard_Integer i = aSteps.Lower(); i <= aSteps.Upper(); ++i)
+  {
+    if (!aMIConst.Contains(i))
+    {
+      aSum += aSteps(i);
+    }
+  }
+
+  // Normalize steps
+  if (aSum > 0.)
+  {
+    for (Standard_Integer i = aSteps.Lower(); i <= aSteps.Upper(); ++i)
+    {
+      if (!aMIConst.Contains(i))
+      {
+        aSteps(i) = aWhole * aSteps(i) / aSum;
+      }
+    }
+  }
+}
+
+//=======================================================================
+// function: fillPIConstants
+// purpose: 
+//=======================================================================
+void BOPAlgo_Algo::fillPIConstants (const Standard_Real, BOPAlgo_PISteps&) const
+{
+}
+
+//=======================================================================
+// function: fillPISteps
+// purpose: 
+//=======================================================================
+void BOPAlgo_Algo::fillPISteps(BOPAlgo_PISteps&) const
+{
+}
index 029bb00e24fb08fb2977032486c16edd19362495..ba5c0fd60fdeb3165e3d3e181d5f3c7bd6a8b079 100644 (file)
 #include <Standard_DefineAlloc.hxx>
 #include <Standard_Handle.hxx>
 #include <Message_ProgressRange.hxx>
-#include <NCollection_Array1.hxx>
+#include <TColStd_Array1OfReal.hxx>
 
 #include <BOPAlgo_Options.hxx>
 
+class BOPAlgo_PISteps;
+
 //! The class provides the root interface for the algorithms in Boolean Component.<br>
 class BOPAlgo_Algo : public BOPAlgo_Options
 {
@@ -33,9 +35,9 @@ public:
 
   DEFINE_STANDARD_ALLOC
 
-  Standard_EXPORT virtual void Perform(const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) {};
-
-  Standard_EXPORT virtual void Perform() {};
+  //! The main method to implement the operation
+  //! Providing the range allows to enable Progress indicator User break functionalities.
+  Standard_EXPORT virtual void Perform(const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) = 0;
 
 protected:
 
@@ -51,12 +53,102 @@ protected:
   //! Checks the obtained result
   Standard_EXPORT virtual void CheckResult();
 
-  //! Analyze progress steps
-  virtual NCollection_Array1<Standard_Real> AnalyzeProgress()
+protected: //! @name Analyzing operations to fill progress indicator
+
+  //! Analyze progress steps of the whole operation.
+  //! @param theWhole - sum of progress of all operations.
+  //! @oaram theSteps - steps of the operations supported by PI
+  //!
+  //! To use this method, one has to override the following methods:
+  //! * fillPIConstants - method filling values for constant operations.
+  //! * fillPISteps - method filling steps for the rest of operations.
+  Standard_EXPORT void analyzeProgress(const Standard_Real theWhole,
+                                       BOPAlgo_PISteps& theSteps) const;
+
+  //! Fills the values for constant operations - the operations having constant relative running time.
+  //! @param theWhole - sum of all operations supported by PI, i.e. the value to normalize the steps to, if necessary.
+  //! @param theSteps - steps of the operations supported by PI
+  Standard_EXPORT virtual void fillPIConstants(const Standard_Real theWhole,
+                                               BOPAlgo_PISteps& theSteps) const;
+
+  //! Fills the values for the operations dependent on the inputs.
+  //! Filled values may not be normalized to represent percentage of total running time.
+  //! The values should just correlate to each other.
+  //! E.g. if progress depends on the number of input shapes, the values may look like this:
+  //! step1 = number_of_input_vertices;
+  //! step2 = 2 * number_of_input_edges;
+  //! step3 = 10 * number_of_input_faces.
+  //! Normalization of this values will be done automatically in analyzeProgress() method.
+  Standard_EXPORT virtual void fillPISteps(BOPAlgo_PISteps& theSteps) const;
+};
+
+//! Additional root class to provide interface to be launched from parallel vector.
+//! It already has the range as a field, and has to be used with cautious to create
+//! scope from the range only once.
+class BOPAlgo_ParallelAlgo : public BOPAlgo_Algo
+{
+public:
+  DEFINE_STANDARD_ALLOC
+
+  //! The main method to implement the operation
+  Standard_EXPORT virtual void Perform() = 0;
+
+public:
+  //! Sets the range for a single run
+  void SetProgressRange(const Message_ProgressRange& theRange)
   {
-    return NCollection_Array1<Standard_Real>();
-  };
+    myProgressRange = theRange;
+  }
+
+private:
+  //! Disable the range enabled method
+  virtual void Perform(const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) {};
 
+protected:
+  Message_ProgressRange myProgressRange;
+};
+
+//! Class for representing the relative contribution of each step of
+//! the operation to the whole progress
+class BOPAlgo_PISteps
+{
+public:
+  //! Constructor
+  BOPAlgo_PISteps(const Standard_Integer theNbOp)
+    : mySteps(0, theNbOp - 1)
+  {
+    for (Standard_Integer i = 0; i < theNbOp; ++i)
+    {
+      mySteps(i) = 0.;
+    }
+  }
+
+  //! Returns the steps
+  const TColStd_Array1OfReal& Steps() const { return mySteps; }
+  //! Returns modifiable steps
+  TColStd_Array1OfReal& ChangeSteps() { return mySteps; }
+
+  //! Returns the step assigned to the operation
+  void SetStep(const Standard_Integer theOperation, const Standard_Real theStep)
+  {
+    if (theOperation >= mySteps.Lower() && theOperation <= mySteps.Upper())
+    {
+      mySteps(theOperation) = theStep;
+    }
+  }
+
+  //! Returns the step assigned to the operation
+  Standard_Real GetStep(const Standard_Integer theOperation)
+  {
+    if (theOperation < mySteps.Lower() || theOperation > mySteps.Upper())
+    {
+      return 0.;
+    }
+    return mySteps(theOperation);
+  }
+
+protected:
+  TColStd_Array1OfReal mySteps;
 };
 
 #endif // _BOPAlgo_Algo_HeaderFile
index ca43fb573a43df649fcd22cc4b2ad33f090dbde0..9a79159b94ccf3d7f72c3131a7ab4a1f598f4db3 100644 (file)
@@ -153,7 +153,7 @@ void BOPAlgo_ArgumentAnalyzer::Prepare()
 // ================================================================================
 void BOPAlgo_ArgumentAnalyzer::Perform(const Message_ProgressRange& theRange)
 {
-  Message_ProgressScope aPS(theRange, "Analyze", 1);
+  Message_ProgressScope aPS(theRange, "Analyze shapes", 10);
   try {
     OCC_CATCH_SIGNALS
     myResult.Clear();
@@ -175,7 +175,7 @@ void BOPAlgo_ArgumentAnalyzer::Perform(const Message_ProgressRange& theRange)
     //
     // 3. Test self-interference
     if(mySelfInterMode) {
-      TestSelfInterferences();
+      TestSelfInterferences(aPS.Next(8));
       if (UserBreak(aPS))
       {
         return;
@@ -350,8 +350,9 @@ void BOPAlgo_ArgumentAnalyzer::TestTypes()
 //function : TestSelfInterferences
 //purpose  : 
 //=======================================================================
-void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences()
+void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS(theRange, NULL, (!myShape1.IsNull() && !myShape2.IsNull() ? 2 : 1));
   Standard_Integer ii;
   //
   for(ii = 0; ii < 2; ii++) {
@@ -376,7 +377,7 @@ void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences()
     aChecker.SetRunParallel(myRunParallel);
     aChecker.SetFuzzyValue(myFuzzyValue);
     //
-    aChecker.Perform();
+    aChecker.Perform(aPS.Next());
     Standard_Boolean hasError = aChecker.HasErrors();
     //
     const BOPDS_DS& aDS=*(aChecker.PDS());
index fa2f528da44c00b9da2a838dfdd2307a8ea9e35c..2c127cf55ebd37ed6a38f76f2d5584322d1c2166 100644 (file)
@@ -114,7 +114,7 @@ protected:
   
   Standard_EXPORT void TestTypes();
   
-  Standard_EXPORT void TestSelfInterferences();
+  Standard_EXPORT void TestSelfInterferences(const Message_ProgressRange& theRange);
   
   Standard_EXPORT void TestSmallEdge();
   
index 733df41a0040b171a98d7d33aa35b25b02495f9f..d2f920ccfed7fd527f6e7c8bca22a66fd383f0cb 100644 (file)
@@ -387,7 +387,7 @@ void BOPAlgo_BOP::Perform(const Message_ProgressRange& theRange)
   pPF=new BOPAlgo_PaveFiller(aAllocator);
   pPF->SetArguments(aLS);
   pPF->SetRunParallel(myRunParallel);
-  Message_ProgressScope aPS(theRange, "Performing result of BOP operation", 10);
+  Message_ProgressScope aPS(theRange, "Performing Boolean operation", 10);
 
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
@@ -404,12 +404,24 @@ void BOPAlgo_BOP::Perform(const Message_ProgressRange& theRange)
   PerformInternal(*pPF, aPS.Next(1));
 }
 
+//=======================================================================
+// function: fillPIConstants
+// purpose: 
+//=======================================================================
+void BOPAlgo_BOP::fillPIConstants (const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const
+{
+  theSteps.SetStep (PIOperation_BuildShape, (myOperation == BOPAlgo_FUSE ? 10. : 5.) * theWhole / 100.);
+}
+
 //=======================================================================
 //function : PerformInternal1
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Message_ProgressRange& theRange)
+void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller,
+                                   const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS (theRange, "Building the result of Boolean operation", 100);
+
   myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
   myDS=myPaveFiller->PDS();
   myContext=myPaveFiller->Context();
@@ -432,16 +444,17 @@ void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Me
   {
     Standard_Boolean bDone = TreatEmptyShape();
     if (bDone) {
-      PrepareHistory();
+      PrepareHistory (theRange);
       return;
     }
   }
   //
-  Message_ProgressScope aPS(theRange, "PerformInternal", 100);
-  NCollection_Array1<Standard_Real> aSteps = BOPAlgo_Builder::AnalyzeProgress();
+  BOPAlgo_PISteps aSteps (PIOperation_Last);
+  analyzeProgress (100, aSteps);
+
   // 3. Fill Images
   // 3.1 Vertices
-  FillImagesVertices(aPS.Next(aSteps(0)));
+  FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
   if (HasErrors()) {
     return;
   }
@@ -451,7 +464,7 @@ void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Me
     return;
   }
   // 3.2 Edges
-  FillImagesEdges(aPS.Next(aSteps(1)));
+  FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
   if (HasErrors()) {
     return;
   }
@@ -462,7 +475,7 @@ void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Me
   }
   //
   // 3.3 Wires
-  FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps(2)));
+  FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps.GetStep(PIOperation_TreatWires)));
   if (HasErrors()) {
     return;
   }
@@ -473,7 +486,7 @@ void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Me
   }
   //
   // 3.4 Faces
-  FillImagesFaces(aPS.Next(aSteps(3)));
+  FillImagesFaces(aPS.Next(aSteps.GetStep(PIOperation_TreatFaces)));
   if (HasErrors()) {
     return;
   }
@@ -484,7 +497,7 @@ void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Me
   }
   //
   // 3.5 Shells
-  FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(4)));
+  FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps.GetStep(PIOperation_TreatShells)));
   if (HasErrors()) {
     return;
   }
@@ -495,7 +508,7 @@ void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Me
   }
   //
   // 3.6 Solids
-  FillImagesSolids(aPS.Next(aSteps(5)));
+  FillImagesSolids(aPS.Next(aSteps.GetStep(PIOperation_TreatSolids)));
   if (HasErrors()) {
     return;
   }
@@ -506,7 +519,7 @@ void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Me
   }
   //
   // 3.7 CompSolids
-  FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(aSteps(6)));
+  FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(aSteps.GetStep(PIOperation_TreatCompsolids)));
   if (HasErrors()) {
     return;
   }
@@ -517,7 +530,7 @@ void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Me
   }
   //
   // 3.8 Compounds
-  FillImagesCompounds(aPS.Next(aSteps(7)));
+  FillImagesCompounds(aPS.Next(aSteps.GetStep(PIOperation_TreatCompounds)));
   if (HasErrors()) {
     return;
   }
@@ -528,23 +541,28 @@ void BOPAlgo_BOP::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, const Me
   }
   //
   // 4.BuildShape;
-  BuildShape();
+  BuildShape(aPS.Next(aSteps.GetStep(PIOperation_BuildShape)));
   if (HasErrors()) {
     return;
   }
   // 
   // 5.History
-  PrepareHistory();
+  PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
+  if (HasErrors()) {
+    return;
+  }
   //
   // 6 Post-treatment 
-  PostTreat();
+  PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
 }
 //=======================================================================
 //function : BuildRC
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BOP::BuildRC()
+void BOPAlgo_BOP::BuildRC(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS(theRange, NULL, 1);
+
   TopAbs_ShapeEnum aType;
   TopoDS_Compound aC;
   BRep_Builder aBB;
@@ -566,6 +584,10 @@ void BOPAlgo_BOP::BuildRC()
     return;
   }
   //
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   // B. Common, Cut, Cut21
   //
   Standard_Integer i, j, aNb, iDim;
@@ -594,6 +616,11 @@ void BOPAlgo_BOP::BuildRC()
     }
   }
   //
+  if (UserBreak(aPS))
+  {
+    return;
+  }
+  //
   bCheckEdges = Standard_False;
   //
   // get splits of building elements
@@ -728,6 +755,10 @@ void BOPAlgo_BOP::BuildRC()
     return;
   }
   //
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   // The squats around degenerated edges
   Standard_Integer nVD;
   TopTools_IndexedMapOfShape aMVC;
@@ -773,8 +804,10 @@ void BOPAlgo_BOP::BuildRC()
 //function : BuildShape
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BOP::BuildShape()
+void BOPAlgo_BOP::BuildShape(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS(theRange, NULL, 10.);
+
   if (myDims[0] == 3 && myDims[1] == 3)
   {
     // For the Boolean operation on solids we need to check first
@@ -800,11 +833,16 @@ void BOPAlgo_BOP::BuildShape()
   }
 
   // Build the result using splits of arguments.
-
-  BuildRC();
+  BuildRC(aPS.Next(2.));
   //
   if ((myOperation == BOPAlgo_FUSE) && (myDims[0] == 3)) {
-    BuildSolid();
+    BuildSolid(aPS.Next(8.));
+    return;
+  }
+
+  // Check for user break
+  if (UserBreak(aPS))
+  {
     return;
   }
   //
@@ -830,6 +868,11 @@ void BOPAlgo_BOP::BuildShape()
       CollectContainers(aS, aLSC);
     }
   }
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   // make containers
   TopTools_ListOfShape aLCRes;
   TopTools_MapOfShape aMInpFence;
@@ -909,6 +952,12 @@ void BOPAlgo_BOP::BuildShape()
   }
   //
   RemoveDuplicates(aLCRes);
+
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   //
   // add containers to result
   TopoDS_Compound aResult;
@@ -962,8 +1011,9 @@ void BOPAlgo_BOP::BuildShape()
 //function : BuildSolid
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BOP::BuildSolid()
+void BOPAlgo_BOP::BuildSolid(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS(theRange, NULL, 10.);
   // Containers
   TopTools_ListOfShape aLSC;
   //
@@ -991,6 +1041,11 @@ void BOPAlgo_BOP::BuildSolid()
       CollectContainers(aSA, aLSC);
     }
   }
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   //
   // Find solids in input arguments sharing faces with other solids
   TopTools_MapOfShape aMTSols;
@@ -1050,6 +1105,11 @@ void BOPAlgo_BOP::BuildSolid()
       }
     }
   }
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   //
   TopTools_IndexedDataMapOfShapeListOfShape aMEF;
   // Fill the list of faces to build the result solids
@@ -1072,7 +1132,7 @@ void BOPAlgo_BOP::BuildSolid()
     aBS.SetContext(myContext);
     aBS.SetShapes(aSFS);
     aBS.SetAvoidInternalShapes (Standard_True);
-    aBS.Perform();
+    aBS.Perform(aPS.Next(8.));
     if (aBS.HasErrors()) {
       AddError (new BOPAlgo_AlertSolidBuilderFailed); // SolidBuilder failed
       return;
@@ -1110,6 +1170,7 @@ void BOPAlgo_BOP::BuildSolid()
   TopoDS_Shape aResult;
   BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aResult);
   //
+
   aIt.Initialize(aRC);
   if (!aIt.More()) {
     // no solids in the result
@@ -1152,6 +1213,11 @@ void BOPAlgo_BOP::BuildSolid()
     }
   }
   //
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   // build connexity blocks from new solids
   TopTools_ListOfShape aLCBS;
   BOPTools_AlgoTools::MakeConnexityBlocks(aRC, TopAbs_FACE, TopAbs_SOLID, aLCBS);
index ee9f97ddacfbb6a917f45afd7bc071b1317401b3..5e1c49243544f5f89c895999739e6462468cb1a3 100644 (file)
@@ -92,15 +92,16 @@ protected:
   
   //! Performs calculations using prepared Filler
   //! object <thePF>
-  Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange) Standard_OVERRIDE;
-    
+  Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF,
+                                                 const Message_ProgressRange& theRange) Standard_OVERRIDE;
+
   Standard_EXPORT virtual void BuildResult (const TopAbs_ShapeEnum theType) Standard_OVERRIDE;
   
-  Standard_EXPORT void BuildShape();
+  Standard_EXPORT void BuildShape(const Message_ProgressRange& theRange);
   
-  Standard_EXPORT void BuildRC();
+  Standard_EXPORT void BuildRC(const Message_ProgressRange& theRange);
   
-  Standard_EXPORT void BuildSolid();
+  Standard_EXPORT void BuildSolid(const Message_ProgressRange& theRange);
   
   //! Treatment of the cases with empty shapes.<br>
   //! It returns TRUE if there is nothing to do, i.e.
@@ -113,6 +114,18 @@ protected:
   //! for building the result shape.
   Standard_EXPORT virtual Standard_Boolean CheckArgsForOpenSolid();
 
+protected:
+
+  //! Extend list of operations to be supported by the Progress Indicator
+  enum BOPAlgo_PIOperation
+  {
+    PIOperation_BuildShape = BOPAlgo_ToolsProvider::BOPAlgo_PIOperation::PIOperation_Last,
+    PIOperation_Last
+  };
+
+  //! Fill PI steps
+  Standard_EXPORT virtual void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
 protected:
 
   BOPAlgo_Operation myOperation;
index 9ea9085d12cd8f9e2453df3812237d052f68f156..8196cfd2f1100ab942fab7e519b86c3eb72b70bc 100644 (file)
@@ -36,7 +36,6 @@
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <TopTools_MapOfOrientedShape.hxx>
 
-
 //=======================================================================
 //function : 
 //purpose  : 
@@ -195,7 +194,7 @@ void BOPAlgo_Builder::Perform(const Message_ProgressRange& theRange)
   //
   pPF->SetArguments(myArguments);
   pPF->SetRunParallel(myRunParallel);
-  Message_ProgressScope aPS(theRange, "BOPAlgo_Builder::Perform()", 10);
+  Message_ProgressScope aPS(theRange, "Performing General Fuse operation", 10);
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
@@ -222,8 +221,7 @@ void BOPAlgo_Builder::PerformWithFiller(const BOPAlgo_PaveFiller& theFiller, con
   myFuzzyValue = theFiller.FuzzyValue();
   myGlue = theFiller.Glue();
   myUseOBB = theFiller.UseOBB();
-  Message_ProgressScope aPS(theRange, NULL, 1);
-  PerformInternal(theFiller, aPS.Next());
+  PerformInternal(theFiller, theRange);
 }
 //=======================================================================
 //function : PerformInternal
@@ -244,81 +242,90 @@ void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller, const
 }
 
 //=======================================================================
-//function : AnalyzeProgress
+//function : getNbShapes
 //purpose  : 
 //=======================================================================
-NCollection_Array1<Standard_Real> BOPAlgo_Builder::AnalyzeProgress()
+BOPAlgo_Builder::NbShapes BOPAlgo_Builder::getNbShapes() const
 {
-  Standard_Integer aSize = 8;
-  NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
-  for (Standard_Integer i = 0; i < aSize; i++)
-  {
-    aSteps(i) = 0;
-  }
-
-  Standard_Real aPart = 100.;
-  Standard_Integer aNbV = myDS->ShapesSD().Size();
-  Standard_Integer aNbE = 0;
-  Standard_Integer aNbW = 0;
-  Standard_Integer aNbF = 0;
-  Standard_Integer aNbSh = 0;
-  Standard_Integer aNbS = 0;
-  Standard_Integer aNbCS = 0;
-  Standard_Integer aNbC = 0;
-  for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); i++)
+  NbShapes aCounter;
+  aCounter.NbVertices() = myDS->ShapesSD().Size();
+  for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); ++i)
   {
     const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i); 
     switch (aSI.ShapeType())
     {
-    case TopAbs_EDGE:
-      aNbE++;
-      break;
-    case TopAbs_WIRE:
-      aNbW++;
-      break;
-    case TopAbs_FACE:
-      aNbF++;
-      break;
-    case TopAbs_SHELL:
-      aNbSh++;
-      break;
-    case TopAbs_SOLID:
-      aNbS++;
-      break;
-    case TopAbs_COMPSOLID:
-      aNbCS++;
-      break;
-    case TopAbs_COMPOUND:
-      aNbC++;
-      break;
-    default:
-      break;
+      case TopAbs_EDGE:
+      {
+        if (myDS->HasPaveBlocks(i))
+        {
+          aCounter.NbEdges()++;
+        }
+        break;
+      }
+      case TopAbs_WIRE:
+        aCounter.NbWires()++;
+        break;
+      case TopAbs_FACE:
+      {
+        if (myDS->HasFaceInfo(i))
+        {
+          aCounter.NbFaces()++;
+        }
+        break;
+      }
+      case TopAbs_SHELL:
+        aCounter.NbShells()++;
+        break;
+      case TopAbs_SOLID:
+        aCounter.NbSolids()++;
+        break;
+      case TopAbs_COMPSOLID:
+        aCounter.NbCompsolids()++;
+        break;
+      case TopAbs_COMPOUND:
+        aCounter.NbCompounds()++;
+        break;
+      default: break;
     }
   }
+  return aCounter;
+}
 
-  aNbE = 5 * aNbE;
-  aNbW = 10 * aNbW;
-  aNbF = 20 * aNbF;
-  aNbSh = 10 * aNbSh;
-  aNbS = 10 * aNbS;
-  aNbCS = 5 * aNbCS;
-  aNbC = 5 * aNbC;
-  Standard_Real aSum = aNbV + aNbE + aNbW + aNbF + aNbSh + aNbS + aNbCS + aNbC;
-  if (aSum == 0)
+//=======================================================================
+// function: fillPIConstants
+// purpose: 
+//=======================================================================
+void BOPAlgo_Builder::fillPIConstants (const Standard_Real theWhole,
+                                       BOPAlgo_PISteps& theSteps) const
+{
+  // Fill in the constants:
+  if (myFillHistory)
   {
-    return aSteps;
+    // for FillHistroty, which takes about 5% of the whole operation
+    theSteps.SetStep(PIOperation_FillHistory, 5. * theWhole / 100.);
   }
-  
-  aSteps(0) = aPart * aNbV / aSum;
-  aSteps(1) = aPart * aNbE / aSum;
-  aSteps(2) = aPart * aNbW / aSum;
-  aSteps(3) = aPart * aNbF / aSum;
-  aSteps(4) = aPart * aNbSh / aSum;
-  aSteps(5) = aPart * aNbS / aSum;
-  aSteps(6) = aPart * aNbCS / aSum;
-  aSteps(7) = aPart * aNbC / aSum;
-
-  return aSteps;
+
+  // and for PostTreat, which takes about 3% of the whole operation 
+  theSteps.SetStep(PIOperation_PostTreat, 3. * theWhole / 100.);
+}
+
+//=======================================================================
+// function: fillPISteps
+// purpose: 
+//=======================================================================
+void BOPAlgo_Builder::fillPISteps (BOPAlgo_PISteps& theSteps) const
+{
+  // Compute the rest of the operations - all depend on the number of sub-shapes of certain type
+  NbShapes aNbShapes = getNbShapes();
+
+  theSteps.SetStep(PIOperation_TreatVertices, aNbShapes.NbVertices());
+  theSteps.SetStep(PIOperation_TreatEdges, aNbShapes.NbEdges());
+  theSteps.SetStep(PIOperation_TreatWires, aNbShapes.NbWires());
+  theSteps.SetStep(PIOperation_TreatFaces, 20 * aNbShapes.NbFaces());
+  theSteps.SetStep(PIOperation_TreatShells, aNbShapes.NbShells());
+  theSteps.SetStep(PIOperation_TreatSolids, 50 * aNbShapes.NbSolids());
+  theSteps.SetStep(PIOperation_TreatCompsolids, aNbShapes.NbCompsolids());
+  theSteps.SetStep(PIOperation_TreatCompounds, aNbShapes.NbCompounds());
 }
 
 //=======================================================================
@@ -333,7 +340,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
   myFuzzyValue = myPaveFiller->FuzzyValue();
   myNonDestructive = myPaveFiller->NonDestructive();
   //
-  Message_ProgressScope aPS(theRange, "PerformInternal", 100);
+  Message_ProgressScope aPS(theRange, "Building the result of General Fuse operation", 100);
   // 1. CheckData
   CheckData();
   if (HasErrors()) {
@@ -346,10 +353,11 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
     return;
   }
   //
-  NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
+  BOPAlgo_PISteps aSteps(PIOperation_Last);
+  analyzeProgress(100., aSteps);
   // 3. Fill Images
   // 3.1 Vertice
-  FillImagesVertices(aPS.Next(aSteps(0)));
+  FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
   if (HasErrors()) {
     return;
   }
@@ -359,7 +367,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
     return;
   }
   // 3.2 Edges
-  FillImagesEdges(aPS.Next(aSteps(1)));
+  FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
   if (HasErrors()) {
     return;
   }
@@ -370,7 +378,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
   }
   //
   // 3.3 Wires
-  FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps(2)));
+  FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps.GetStep(PIOperation_TreatWires)));
   if (HasErrors()) {
     return;
   }
@@ -381,7 +389,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
   }
   
   // 3.4 Faces
-  FillImagesFaces(aPS.Next(aSteps(3)));
+  FillImagesFaces(aPS.Next(aSteps.GetStep(PIOperation_TreatFaces)));
   if (HasErrors()) {
     return;
   }
@@ -391,7 +399,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
     return;
   }
   // 3.5 Shells
-  FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(4)));
+  FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps.GetStep(PIOperation_TreatShells)));
   if (HasErrors()) {
     return;
   }
@@ -401,7 +409,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
     return;
   }
   // 3.6 Solids
-  FillImagesSolids(aPS.Next(aSteps(5)));
+  FillImagesSolids(aPS.Next(aSteps.GetStep(PIOperation_TreatSolids)));
   if (HasErrors()) {
     return;
   }
@@ -411,7 +419,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
     return;
   }
   // 3.7 CompSolids
-  FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(aSteps(6)));
+  FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(aSteps.GetStep(PIOperation_TreatCompsolids)));
   if (HasErrors()) {
     return;
   }
@@ -422,7 +430,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
   }
   
   // 3.8 Compounds
-  FillImagesCompounds(aPS.Next(aSteps(7)));
+  FillImagesCompounds(aPS.Next(aSteps.GetStep(PIOperation_TreatCompounds)));
   if (HasErrors()) {
     return;
   }
@@ -432,19 +440,21 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
     return;
   }
   //
-  // 4.History
-  PrepareHistory();
-  //
+  // 4 History
+  PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
+  if (HasErrors()) {
+    return;
+  }
   //
   // 5 Post-treatment 
-  PostTreat();
-  
+  PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
 }
+
 //=======================================================================
 //function : PostTreat
 //purpose  : 
 //=======================================================================
-void BOPAlgo_Builder::PostTreat()
+void BOPAlgo_Builder::PostTreat(const Message_ProgressRange& theRange)
 {
   Standard_Integer i, aNbS;
   TopAbs_ShapeEnum aType;
@@ -464,7 +474,9 @@ void BOPAlgo_Builder::PostTreat()
     }
   }
   //
+  Message_ProgressScope aPS(theRange, "Post treatment of result shape", 2);
   BOPTools_AlgoTools::CorrectTolerances(myShape, aMA, 0.05, myRunParallel);
+  aPS.Next().Close();
   BOPTools_AlgoTools::CorrectShapeTolerances(myShape, aMA, myRunParallel);
 }
 
@@ -827,5 +839,5 @@ void BOPAlgo_Builder::BuildBOP(const TopTools_ListOfShape& theObjects,
     aBB.Add(aResult, itLS.Value());
 
   myShape = aResult;
-  PrepareHistory();
+  PrepareHistory(Message_ProgressRange());
 }
index 759ff847123a4e18c1d7151f67a7370d1dbb1231..fc7fc593469eb8918aeb57fde0acb39733a103f1 100644 (file)
@@ -287,7 +287,7 @@ public: //! @name BOPs on open solids
 protected: //! @name History methods
 
   //! Prepare information for history support.
-  Standard_EXPORT void PrepareHistory();
+  Standard_EXPORT void PrepareHistory(const Message_ProgressRange& theRange);
 
   //! Prepare history information for the input shapes taking into account possible
   //! operation-specific modifications.
@@ -313,9 +313,6 @@ protected: //! @name History methods
   //! obtaining Generated elements differently.
   Standard_EXPORT virtual const TopTools_ListOfShape& LocGenerated(const TopoDS_Shape& theS);
 
-  //! AnalyzeProgress
-  Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
 public: //! @name Images/Origins
 
   //! Returns the map of images.
@@ -337,6 +334,70 @@ public: //! @name Images/Origins
     return myShapesSD;
   }
 
+protected://! @name Analyze progress of the operation
+
+  //! List of operations to be supported by the Progress Indicator
+  enum BOPAlgo_PIOperation
+  {
+    PIOperation_TreatVertices = 0,
+    PIOperation_TreatEdges,
+    PIOperation_TreatWires,
+    PIOperation_TreatFaces,
+    PIOperation_TreatShells,
+    PIOperation_TreatSolids,
+    PIOperation_TreatCompsolids,
+    PIOperation_TreatCompounds,
+    PIOperation_FillHistory,
+    PIOperation_PostTreat,
+    PIOperation_Last
+  };
+
+
+  //! Auxiliary structure to get information about number of shapes
+  //! of each type participated in operation.
+  class NbShapes
+  {
+  public:
+    NbShapes()
+    {
+      for (Standard_Integer i = 0; i < 8; ++i)
+      {
+        myNbShapesArr[i] = 0;
+      }
+    }
+
+    Standard_Integer NbVertices()   const { return myNbShapesArr[0]; }
+    Standard_Integer NbEdges()      const { return myNbShapesArr[1]; }
+    Standard_Integer NbWires()      const { return myNbShapesArr[2]; }
+    Standard_Integer NbFaces()      const { return myNbShapesArr[3]; }
+    Standard_Integer NbShells()     const { return myNbShapesArr[4]; }
+    Standard_Integer NbSolids()     const { return myNbShapesArr[5]; }
+    Standard_Integer NbCompsolids() const { return myNbShapesArr[6]; }
+    Standard_Integer NbCompounds()  const { return myNbShapesArr[7]; }
+
+    Standard_Integer& NbVertices()   { return myNbShapesArr[0]; }
+    Standard_Integer& NbEdges()      { return myNbShapesArr[1]; }
+    Standard_Integer& NbWires()      { return myNbShapesArr[2]; }
+    Standard_Integer& NbFaces()      { return myNbShapesArr[3]; }
+    Standard_Integer& NbShells()     { return myNbShapesArr[4]; }
+    Standard_Integer& NbSolids()     { return myNbShapesArr[5]; }
+    Standard_Integer& NbCompsolids() { return myNbShapesArr[6]; }
+    Standard_Integer& NbCompounds()  { return myNbShapesArr[7]; }
+
+  private:
+    Standard_Integer myNbShapesArr[8];
+  };
+
+protected:
+
+  //! Compute number of shapes of certain type participating in operation
+  Standard_EXPORT NbShapes getNbShapes() const;
+
+  //! Filling steps for constant operations
+  Standard_EXPORT void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
+  //! Filling steps for all other operations
+  Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
 
 protected: //! @name Methods for building the result
 
@@ -400,15 +461,15 @@ protected: //! @name Fill Images of FACES
 
   //! Builds the splits of faces using the information from the
   //! intersection stage stored in Data Structure.
-  Standard_EXPORT virtual void BuildSplitFaces();
+  Standard_EXPORT virtual void BuildSplitFaces(const Message_ProgressRange& theRange);
 
   //! Looks for the same domain faces among the splits of the faces.
   //! Updates the map of images with SD faces.
-  Standard_EXPORT void FillSameDomainFaces();
+  Standard_EXPORT void FillSameDomainFaces(const Message_ProgressRange& theRange);
 
   //! Classifies the alone vertices on faces relatively its splits
   //! and adds them as INTERNAL into the splits.
-  Standard_EXPORT void FillInternalVertices();
+  Standard_EXPORT void FillInternalVertices(const Message_ProgressRange& theRange);
 
 
 protected: //! @name Fill Images of SOLIDS
@@ -428,15 +489,17 @@ protected: //! @name Fill Images of SOLIDS
                                         TopTools_ListOfShape& theLIF);
 
   //! Finds faces located inside each solid.
-  Standard_EXPORT virtual void FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids);
+  Standard_EXPORT virtual void FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids,
+                                             const Message_ProgressRange& theRange);
 
   //! Builds the splits of the solids using their draft versions
   //! and faces located inside.
-  Standard_EXPORT void BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids);
+  Standard_EXPORT void BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids,
+                                        const Message_ProgressRange& theRange);
 
   //! Classifies the vertices and edges from the arguments relatively
   //! splits of solids and makes them INTERNAL for solids.
-  Standard_EXPORT void FillInternalShapes();
+  Standard_EXPORT void FillInternalShapes(const Message_ProgressRange& theRange);
 
 
 protected: //! @name Fill Images of COMPOUNDS
@@ -453,8 +516,7 @@ protected: //! @name Post treatment
   //! Post treatment of the result of the operation.
   //! The method checks validity of the sub-shapes of the result
   //! and updates the tolerances to make them valid.
-  Standard_EXPORT virtual void PostTreat();
-
+  Standard_EXPORT virtual void PostTreat(const Message_ProgressRange& theRange);
 
 protected: //! @name Fields
 
index ae818a50a88580409f39e280e3c0f188d624c0b5..5f12f43cb65aa665e68ff46abdca84c21c70663f 100644 (file)
@@ -80,13 +80,13 @@ protected:
   
   Standard_EXPORT BOPAlgo_BuilderArea(const Handle(NCollection_BaseAllocator)& theAllocator);
   
-  virtual void PerformShapesToAvoid() = 0;
+  virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange) = 0;
   
-  virtual void PerformLoops() = 0;
+  virtual void PerformLoops(const Message_ProgressRange& theRange) = 0;
   
-  virtual void PerformAreas() = 0;
+  virtual void PerformAreas(const Message_ProgressRange& theRange) = 0;
   
-  virtual void PerformInternalShapes() = 0;
+  virtual void PerformInternalShapes(const Message_ProgressRange& theRange) = 0;
 
 
   Handle(IntTools_Context) myContext;
index 942a66a5bbfa742aeaa54feecf11e5ef526d5aee..31123e0a1a0d2c632a99175fdfceb1da3f29f7d7 100644 (file)
@@ -141,8 +141,10 @@ void BOPAlgo_BuilderFace::CheckData()
 //function : Perform
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderFace::Perform(const Message_ProgressRange& /*theRange*/)
+void BOPAlgo_BuilderFace::Perform(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS (theRange, "Building face", 100);
+
   GetReport()->Clear();
   //
   CheckData();
@@ -150,31 +152,28 @@ void BOPAlgo_BuilderFace::Perform(const Message_ProgressRange& /*theRange*/)
     return;
   }
   //
-  PerformShapesToAvoid();
+  PerformShapesToAvoid (aPS.Next(1));
   if (HasErrors()) {
     return;
   }
   //
-  PerformLoops();
+  PerformLoops (aPS.Next(10));
   if (HasErrors()) {
     return;
   }
   //
-  PerformAreas();
+  PerformAreas (aPS.Next(80));
   if (HasErrors()) {
     return;
   }
   //
-  PerformInternalShapes();
-  if (HasErrors()) {
-    return;
-  }
+  PerformInternalShapes(aPS.Next(9));
 }
 //=======================================================================
 //function :PerformShapesToAvoid
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderFace::PerformShapesToAvoid()
+void BOPAlgo_BuilderFace::PerformShapesToAvoid(const Message_ProgressRange& theRange)
 {
   Standard_Boolean bFound;
   Standard_Integer i, iCnt, aNbV, aNbE;
@@ -183,8 +182,15 @@ void BOPAlgo_BuilderFace::PerformShapesToAvoid()
   //
   myShapesToAvoid.Clear();
   //
+  Message_ProgressScope aPS(theRange, NULL, 1);
+  //
   iCnt=0;
   for(;;) {
+    if (UserBreak(aPS))
+    {
+      return;
+    }
+
     ++iCnt;
     bFound=Standard_False;
     //
@@ -239,15 +245,13 @@ void BOPAlgo_BuilderFace::PerformShapesToAvoid()
     if (!bFound) {
       break;
     }
-    //
-  }//while (1) 
-  //printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt);
+  }
 }  
 //=======================================================================
 //function : PerformLoops
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderFace::PerformLoops()
+void BOPAlgo_BuilderFace::PerformLoops(const Message_ProgressRange& theRange)
 {
   Standard_Boolean bFlag;
   Standard_Integer i, aNbEA;
@@ -259,6 +263,8 @@ void BOPAlgo_BuilderFace::PerformLoops()
   BOPAlgo_WireEdgeSet aWES(myAllocator);
   BOPAlgo_WireSplitter aWSp(myAllocator);
   //
+  Message_ProgressScope aMainScope(theRange, "Making wires", 10);
+  //
   // 1. 
   myLoops.Clear();
   aWES.SetFace(myFace);
@@ -274,7 +280,7 @@ void BOPAlgo_BuilderFace::PerformLoops()
   aWSp.SetWES(aWES);
   aWSp.SetRunParallel(myRunParallel);
   aWSp.SetContext(myContext);
-  aWSp.Perform();
+  aWSp.Perform(aMainScope.Next(9));
   if (aWSp.HasErrors()) {
     return;
   }
@@ -298,6 +304,9 @@ void BOPAlgo_BuilderFace::PerformLoops()
       aMEP.Add(aE);
     }
   }
+  if (UserBreak (aMainScope)) {
+    return;
+  }
   // 
   // b. collect all edges that are to avoid
   aNbEA = myShapesToAvoid.Extent();
@@ -315,16 +324,19 @@ void BOPAlgo_BuilderFace::PerformLoops()
     }
   }
   //
+  if (UserBreak (aMainScope)) {
+    return;
+  }
   // 2. Internal Wires
   myLoopsInternal.Clear();
   //
   aNbEA = myShapesToAvoid.Extent();
   for (i = 1; i <= aNbEA; ++i) {
     const TopoDS_Shape& aEE = myShapesToAvoid(i);
-    TopExp::MapShapesAndAncestors(aEE, 
-                                    TopAbs_VERTEX, 
-                                    TopAbs_EDGE, 
-                                    aVEMap);
+    TopExp::MapShapesAndAncestors(aEE,
+                                  TopAbs_VERTEX,
+                                  TopAbs_EDGE,
+                                  aVEMap);
   }
   //
   bFlag=Standard_True;
@@ -334,6 +346,9 @@ void BOPAlgo_BuilderFace::PerformLoops()
       continue;
     }
     //
+    if (UserBreak (aMainScope)) {
+      return;
+    }
     // make new wire
     TopoDS_Wire aW;
     aBB.MakeWire(aW);
@@ -367,7 +382,7 @@ void BOPAlgo_BuilderFace::PerformLoops()
 //function : PerformAreas
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderFace::PerformAreas()
+void BOPAlgo_BuilderFace::PerformAreas(const Message_ProgressRange& theRange)
 {
   myAreas.Clear();
   BRep_Builder aBB;
@@ -378,6 +393,8 @@ void BOPAlgo_BuilderFace::PerformAreas()
   // Get tolerance of myFace
   Standard_Real aTol = BRep_Tool::Tolerance(myFace);
 
+  Message_ProgressScope aMainScope (theRange, NULL, 10);
+
   // Check if there are no loops at all
   if (myLoops.IsEmpty())
   {
@@ -402,9 +419,15 @@ void BOPAlgo_BuilderFace::PerformAreas()
   TopTools_IndexedMapOfShape aMHE;
 
   // Analyze the new wires - classify them to be the holes and growths
+  Message_ProgressScope aPSClass(aMainScope.Next(5), "Making faces", myLoops.Size());
   TopTools_ListIteratorOfListOfShape aItLL(myLoops);
-  for (; aItLL.More(); aItLL.Next())
+  for (; aItLL.More(); aItLL.Next(), aPSClass.Next())
   {
+    if (UserBreak(aPSClass))
+    {
+      return;
+    }
+
     const TopoDS_Shape& aWire = aItLL.Value();
 
     TopoDS_Face aFace;
@@ -463,9 +486,14 @@ void BOPAlgo_BuilderFace::PerformAreas()
   BOPTools_Box2dTreeSelector aSelector;
   aSelector.SetBVHSet (&aBoxTree);
 
+  Message_ProgressScope aPSHoles(aMainScope.Next(4), "Adding holes", aNewFaces.Extent());
   TopTools_ListIteratorOfListOfShape aItLS(aNewFaces);
-  for (; aItLS.More(); aItLS.Next())
+  for (; aItLS.More(); aItLS.Next(), aPSHoles.Next())
   {
+    if (UserBreak (aPSHoles))
+    {
+      return;
+    }
     const TopoDS_Face& aFace = TopoDS::Face(aItLS.Value());
 
     // Build box
@@ -542,9 +570,15 @@ void BOPAlgo_BuilderFace::PerformAreas()
   }
 
   // Add Holes to Faces and add them to myAreas
+  Message_ProgressScope aPSU (aMainScope.Next(), NULL, aNewFaces.Size());
   aItLS.Initialize(aNewFaces);
-  for ( ; aItLS.More(); aItLS.Next())
+  for ( ; aItLS.More(); aItLS.Next(), aPSU.Next())
   {
+    if (UserBreak (aPSU))
+    {
+      return;
+    }
+
     TopoDS_Face& aFace = *(TopoDS_Face*)&aItLS.Value();
     const TopTools_ListOfShape* pLHoles = aFaceHolesMap.Seek(aFace);
     if (pLHoles)
@@ -571,7 +605,7 @@ void BOPAlgo_BuilderFace::PerformAreas()
 //function : PerformInternalShapes
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderFace::PerformInternalShapes()
+void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& theRange)
 {
   if (myAvoidInternalShapes)
     // User-defined option to avoid internal edges
@@ -588,10 +622,17 @@ void BOPAlgo_BuilderFace::PerformInternalShapes()
   // Map of edges to classify
   TopTools_IndexedMapOfShape anEdgesMap;
 
+  // Main progress scope
+  Message_ProgressScope aMainScope (theRange, "Adding internal shapes", 3);
+
   // Fill the tree and the map
   TopTools_ListIteratorOfListOfShape itLE(myLoopsInternal);
   for (; itLE.More(); itLE.Next())
   {
+    if (UserBreak (aMainScope))
+    {
+      return;
+    }
     TopoDS_Iterator itE(itLE.Value());
     for (; itE.More(); itE.Next())
     {
@@ -610,13 +651,20 @@ void BOPAlgo_BuilderFace::PerformInternalShapes()
   // Build BVH
   aBoxTree.Build();
 
+  aMainScope.Next().Close();
+
   // Fence map
   TColStd_MapOfInteger aMEDone;
 
   // Classify edges relatively faces
+  Message_ProgressScope aPSClass(aMainScope.Next(), NULL, myAreas.Size());
   TopTools_ListIteratorOfListOfShape itLF(myAreas);
-  for (; itLF.More(); itLF.Next())
+  for (; itLF.More(); itLF.Next(), aPSClass.Next())
   {
+    if (UserBreak(aPSClass))
+    {
+      return;
+    }
     TopoDS_Face& aF = *(TopoDS_Face*)&itLF.Value();
 
     // Build box
index 2bc29661517802c760115d2b70a868e1d24fd16b..4823d587cf26906ae2dd0fbb78c8fc21aa44e0b9 100644 (file)
@@ -63,40 +63,27 @@ protected:
   //! Collect the edges that
   //! a) are internal
   //! b) are the same and have different orientation
-  Standard_EXPORT virtual void PerformShapesToAvoid() Standard_OVERRIDE;
+  Standard_EXPORT virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange) Standard_OVERRIDE;
   
   //! Build draft wires
   //! a)myLoops - draft wires that consist of
   //! boundary edges
   //! b)myLoopsInternal - draft wires that contains
   //! inner edges
-  Standard_EXPORT virtual void PerformLoops() Standard_OVERRIDE;
+  Standard_EXPORT virtual void PerformLoops(const Message_ProgressRange& theRange) Standard_OVERRIDE;
   
   //! Build draft faces that contains boundary edges
-  Standard_EXPORT virtual void PerformAreas() Standard_OVERRIDE;
+  Standard_EXPORT virtual void PerformAreas(const Message_ProgressRange& theRange) Standard_OVERRIDE;
   
   //! Build finalized faces with internals
-  Standard_EXPORT virtual void PerformInternalShapes() Standard_OVERRIDE;
+  Standard_EXPORT virtual void PerformInternalShapes(const Message_ProgressRange& theRange) Standard_OVERRIDE;
   
   Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
 
+protected:
 
   TopoDS_Face myFace;
   TopAbs_Orientation myOrientation;
-
-
-private:
-
-
-
-
-
 };
 
-
-
-
-
-
-
 #endif // _BOPAlgo_BuilderFace_HeaderFile
index 9fcdd4fa7ce55324c1b79ae6aeee317e26736d85..7409bab1826263c8d6278b76082df95498340ab4 100644 (file)
@@ -106,8 +106,10 @@ BOPAlgo_BuilderSolid::~BOPAlgo_BuilderSolid()
 //function : Perform
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderSolid::Perform(const Message_ProgressRange& /*theRange*/)
+void BOPAlgo_BuilderSolid::Perform(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS (theRange, "Building solids", 100);  
+
   GetReport()->Clear();
   //
   if (myShapes.IsEmpty())
@@ -130,31 +132,28 @@ void BOPAlgo_BuilderSolid::Perform(const Message_ProgressRange& /*theRange*/)
     aBB.Add(aC, aF);
   }
   //
-  PerformShapesToAvoid();
+  PerformShapesToAvoid (aPS.Next(1));
   if (HasErrors()) {
     return;
   }
   //
-  PerformLoops();
+  PerformLoops (aPS.Next(10));
   if (HasErrors()) {
     return;
   }
   //
-  PerformAreas();
+  PerformAreas (aPS.Next(80));
   if (HasErrors()) {
     return;
   }
   //
-  PerformInternalShapes();
-  if (HasErrors()) {
-    return;
-  }
+  PerformInternalShapes (aPS.Next(9));
 }
 //=======================================================================
 //function :PerformShapesToAvoid
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderSolid::PerformShapesToAvoid()
+void BOPAlgo_BuilderSolid::PerformShapesToAvoid(const Message_ProgressRange& theRange)
 {
   Standard_Boolean bFound;
   Standard_Integer i, iCnt, aNbE, aNbF;
@@ -164,8 +163,13 @@ void BOPAlgo_BuilderSolid::PerformShapesToAvoid()
   //
   myShapesToAvoid.Clear();
   //
+  Message_ProgressScope aPS(theRange, NULL, 1);
+  //
   iCnt=0;
   for(;;) {
+    if (UserBreak(aPS)) {
+      return;
+    }
     ++iCnt;
     bFound=Standard_False;
     //
@@ -234,7 +238,7 @@ void BOPAlgo_BuilderSolid::PerformShapesToAvoid()
 //function : PerformLoops
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderSolid::PerformLoops()
+void BOPAlgo_BuilderSolid::PerformLoops(const Message_ProgressRange& theRange)
 {
   Standard_Integer i, aNbSh;
   TopTools_ListIteratorOfListOfShape aIt;
@@ -247,7 +251,9 @@ void BOPAlgo_BuilderSolid::PerformLoops()
     NCollection_BaseAllocator::CommonBaseAllocator();
   BOPAlgo_ShellSplitter aSSp(aAlr);
   //
-  // 1. Shells Usual
+  Message_ProgressScope aMainScope (theRange, "Building shells", 10); 
+
+  // 1. Shells Usual 
   aIt.Initialize (myShapes);
   for (; aIt.More(); aIt.Next()) {
     const TopoDS_Face& aF=*((TopoDS_Face*)&aIt.Value());
@@ -267,9 +273,10 @@ void BOPAlgo_BuilderSolid::PerformLoops()
   }
   //
   aSSp.SetRunParallel(myRunParallel);
-  aSSp.Perform();
+  aSSp.Perform(aMainScope.Next(9));
   if (aSSp.HasErrors()) {
     // add warning status
+    if (aMainScope.More())
     {
       TopoDS_Compound aFacesSp;
       BRep_Builder().MakeCompound(aFacesSp);
@@ -306,6 +313,9 @@ void BOPAlgo_BuilderSolid::PerformLoops()
       aMP.Add(aF);
     }
   }
+  if (UserBreak (aMainScope)) {
+    return;
+  }
   // 
   // b. collect all edges that are to avoid
   aNbSh = myShapesToAvoid.Extent();
@@ -325,6 +335,9 @@ void BOPAlgo_BuilderSolid::PerformLoops()
     }
   }
   //=================================================
+  if (UserBreak (aMainScope)) {
+    return;
+  }
   //
   // 3.Internal Shells
   myLoopsInternal.Clear();
@@ -341,6 +354,9 @@ void BOPAlgo_BuilderSolid::PerformLoops()
   }
   //
   for (i = 1; i <= aNbSh; ++i) {
+    if (UserBreak(aMainScope)) {
+      return;
+    }
     const TopoDS_Shape& aFF = myShapesToAvoid(i);
     if (!AddedFacesMap.Add(aFF)) {
       continue;
@@ -377,7 +393,7 @@ void BOPAlgo_BuilderSolid::PerformLoops()
 //function : PerformAreas
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderSolid::PerformAreas()
+void BOPAlgo_BuilderSolid::PerformAreas(const Message_ProgressRange& theRange)
 {
   myAreas.Clear();
   BRep_Builder aBB;
@@ -389,10 +405,17 @@ void BOPAlgo_BuilderSolid::PerformAreas()
   // If the analyzed shell contains any of the hole faces, it is considered as growth.
   TopTools_IndexedMapOfShape aMHF;
 
+  Message_ProgressScope aMainScope(theRange, "Building solids", 10);
+
   // Analyze the shells
+  Message_ProgressScope aPSClass(aMainScope.Next(5), "Classify solids", myLoops.Size());
   TopTools_ListIteratorOfListOfShape aItLL(myLoops);
-  for (; aItLL.More(); aItLL.Next())
+  for (; aItLL.More(); aItLL.Next(), aPSClass.Next())
   {
+    if (UserBreak (aPSClass))
+    {
+      return;
+    }
     const TopoDS_Shape& aShell = aItLL.Value();
 
     Standard_Boolean bIsGrowth = IsGrowthShell(aShell, aMHF);
@@ -456,9 +479,14 @@ void BOPAlgo_BuilderSolid::PerformAreas()
   // Find outer growth shell that is most close to each hole shell
   TopTools_IndexedDataMapOfShapeShape aHoleSolidMap;
 
+  Message_ProgressScope aPSH(aMainScope.Next(4), "Adding holes", aNewSolids.Size());
   TopTools_ListIteratorOfListOfShape aItLS(aNewSolids);
-  for (; aItLS.More(); aItLS.Next())
+  for (; aItLS.More(); aItLS.Next(), aPSH.Next())
   {
+    if (UserBreak (aPSH))
+    {
+      return;
+    }
     const TopoDS_Shape& aSolid = aItLS.Value();
 
     // Build box
@@ -514,9 +542,14 @@ void BOPAlgo_BuilderSolid::PerformAreas()
   }
 
   // Add Holes to Solids and add them to myAreas
+  Message_ProgressScope aPSU (aMainScope.Next(), NULL, aNewSolids.Size());
   aItLS.Initialize(aNewSolids);
-  for ( ; aItLS.More(); aItLS.Next())
+  for ( ; aItLS.More(); aItLS.Next(), aPSU.Next())
   {
+    if (UserBreak (aPSU))
+    {
+      return;
+    }
     TopoDS_Solid& aSolid = *(TopoDS_Solid*)&aItLS.Value();
     const TopTools_ListOfShape* pLHoles = aSolidHolesMap.Seek(aSolid);
     if (pLHoles)
@@ -561,7 +594,7 @@ void BOPAlgo_BuilderSolid::PerformAreas()
 //function : PerformInternalShapes
 //purpose  : 
 //=======================================================================
-void BOPAlgo_BuilderSolid::PerformInternalShapes()
+void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& theRange)
 {
   if (myAvoidInternalShapes)
     // user-defined option to avoid internal parts is in force
@@ -571,6 +604,8 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes()
     // no internal parts
     return;
 
+  Message_ProgressScope aMainScope (theRange, "Adding internal shapes", 2);
+
   // Get all faces to classify
   TopTools_IndexedMapOfShape aMFs;
   TopTools_ListIteratorOfListOfShape aItLS(myLoopsInternal);
@@ -602,6 +637,11 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes()
     return;
   }
 
+  if (UserBreak (aMainScope))
+  {
+    return;
+  }
+
   // Classify faces relatively solids
 
   // Prepare list of faces to classify
@@ -614,15 +654,27 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes()
   TopTools_IndexedDataMapOfShapeListOfShape aMSLF;
 
   // Perform classification
-  BOPAlgo_Tools::ClassifyFaces(aLFaces, myAreas, myRunParallel, myContext, aMSLF, myBoxes);
+  BOPAlgo_Tools::ClassifyFaces(aLFaces,
+                               myAreas,
+                               myRunParallel,
+                               myContext,
+                               aMSLF,
+                               myBoxes,
+                               TopTools_DataMapOfShapeListOfShape(),
+                               aMainScope.Next());
 
   // Update Solids by internal Faces
 
   TopTools_MapOfShape aMFDone;
 
   Standard_Integer aNbS = aMSLF.Extent();
-  for (i = 1; i <= aNbS; ++i)
+  Message_ProgressScope aPSLoop(aMainScope.Next(), NULL, aNbS);
+  for (i = 1; i <= aNbS; ++i, aPSLoop.Next())
   {
+    if (UserBreak (aPSLoop))
+    {
+      return;
+    }
     const TopoDS_Shape& aSolid = aMSLF.FindKey(i);
     TopoDS_Shape *pSolid = (TopoDS_Shape*)&aSolid;
 
index 787c806cfbdc7bd9702045307710d3092d3232f0..1a8e3cea8413282ca9e3d1a3d05851ba18f7e569 100644 (file)
@@ -114,23 +114,23 @@ protected: //! @name Protected methods performing the operation
   //! - that are alone but given twice with different orientation.
   //! These faces will be put into the map *myShapesToAvoid* and will be
   //! avoided in shells construction, but will be classified later on.
-  Standard_EXPORT virtual void PerformShapesToAvoid() Standard_OVERRIDE;
+  Standard_EXPORT virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange) Standard_OVERRIDE;
 
   //! Build all possible closed shells from the given faces.
   //! The method fills the following maps:
   //! - myLoops - Created closed shells;
   //! - myLoopsInternal - The shells created from unused faces.
-  Standard_EXPORT virtual void PerformLoops() Standard_OVERRIDE;
+  Standard_EXPORT virtual void PerformLoops(const Message_ProgressRange& theRange) Standard_OVERRIDE;
 
   //! Classifies the created shells on the Holes and Growths.
   //! Creates the solids from the Growths shells.
   //! Puts the Hole shells into the closest Growths solids.
-  Standard_EXPORT virtual void PerformAreas() Standard_OVERRIDE;
+  Standard_EXPORT virtual void PerformAreas(const Message_ProgressRange& theRange) Standard_OVERRIDE;
 
   //! Classifies the unused faces relatively the created solids.
   //! Puts the classified faces into the closest solids as internal shells.
   //! Warns the user about unclassified faces if any.
-  Standard_EXPORT virtual void PerformInternalShapes() Standard_OVERRIDE;
+  Standard_EXPORT virtual void PerformInternalShapes(const Message_ProgressRange& theRange) Standard_OVERRIDE;
 
 private:
 
index ddb4b3052b60911f50221f5231a7d69a61e19b8f..47df33a24841dfc7e614a2809b221dcd644bdc67 100644 (file)
@@ -40,9 +40,9 @@
 //=======================================================================
 void BOPAlgo_Builder::FillImagesVertices(const Message_ProgressRange& theRange)
 {
-  Message_ProgressScope aPS(theRange, "Filling splits of vertices", 1);
+  Message_ProgressScope aPS(theRange, "Filling splits of vertices", myDS->ShapesSD().Size());
   TColStd_DataMapIteratorOfDataMapOfIntegerInteger aIt(myDS->ShapesSD());
-  for (; aIt.More(); aIt.Next())
+  for (; aIt.More(); aIt.Next(), aPS.Next())
   {
     if (UserBreak(aPS))
     {
@@ -71,8 +71,8 @@ void BOPAlgo_Builder::FillImagesVertices(const Message_ProgressRange& theRange)
   void BOPAlgo_Builder::FillImagesEdges(const Message_ProgressRange& theRange)
 {
   Standard_Integer i, aNbS = myDS->NbSourceShapes();
-  Message_ProgressScope aPS(theRange, "Filling splits of edges", 1);
-  for (i = 0; i < aNbS; ++i) {
+  Message_ProgressScope aPS(theRange, "Filling splits of edges", aNbS);
+  for (i = 0; i < aNbS; ++i, aPS.Next()) {
     if (UserBreak(aPS))
     {
       return;
@@ -165,7 +165,7 @@ void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
   TopTools_MapOfShape aMFP(100, myAllocator);
   //
   aNbS=myDS->NbSourceShapes();
-  Message_ProgressScope aPS(theRange, "Filling images containers", 1);
+  Message_ProgressScope aPS(theRange, "Building splits of containers", 1);
   for (i=0; i<aNbS; ++i) {
     if (UserBreak(aPS))
     {
@@ -188,7 +188,7 @@ void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
   TopTools_MapOfShape aMFP(100, myAllocator);
   //
   aNbS=myDS->NbSourceShapes();
-  Message_ProgressScope aPS(theRange, "Filling images compounds", aNbS);
+  Message_ProgressScope aPS(theRange, "Building splits of compounds", aNbS);
   for (i=0; i<aNbS; ++i, aPS.Next()) {
     if (UserBreak(aPS))
     {
index 5a0396e5de7f5b7d465e486425cdf47517440db3..9cfdec12c6ffe137d2d5bec95c02f420e80e841b 100644 (file)
@@ -69,13 +69,13 @@ static
 //class    : BOPAlgo_PairOfShapeBoolean
 //purpose  : 
 //=======================================================================
-class BOPAlgo_PairOfShapeBoolean : public BOPAlgo_Algo {
+class BOPAlgo_PairOfShapeBoolean : public BOPAlgo_ParallelAlgo {
 
  public:
   DEFINE_STANDARD_ALLOC
 
   BOPAlgo_PairOfShapeBoolean() : 
-    BOPAlgo_Algo(),
+    BOPAlgo_ParallelAlgo(),
     myFlag(Standard_False) {
   }
   //
@@ -103,7 +103,12 @@ class BOPAlgo_PairOfShapeBoolean : public BOPAlgo_Algo {
   }
   //
   virtual void Perform() {
-    //  
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
+    if (UserBreak(aPS))
+    {
+      return;
+    }
+
     const TopoDS_Face& aFj=*((TopoDS_Face*)&myShape1);
     const TopoDS_Face& aFk=*((TopoDS_Face*)&myShape2);
     myFlag=BOPTools_AlgoTools::AreFacesSameDomain(aFj, aFk, myContext, myFuzzyValue);
@@ -119,21 +124,50 @@ class BOPAlgo_PairOfShapeBoolean : public BOPAlgo_Algo {
 typedef NCollection_Vector<BOPAlgo_PairOfShapeBoolean> BOPAlgo_VectorOfPairOfShapeBoolean;
 
 //=======================================================================
-// BuilderFace
-//
-typedef NCollection_Vector<BOPAlgo_BuilderFace> BOPAlgo_VectorOfBuilderFace;
+//class   : BOPAlgo_SplitFace
+//purpose : Auxiliary class to extend BOPAlgo_BuilderSolid with progress support
+//=======================================================================
+class BOPAlgo_SplitFace : public BOPAlgo_BuilderFace
+{
+public:
+  //! Sets progress range
+  void SetProgressRange(const Message_ProgressRange& theRange)
+  {
+    myRange = theRange;
+  }
+
+  // New perform method, using own progress range
+  void Perform()
+  {
+    Message_ProgressScope aPS(myRange, NULL, 1);
+    if (!aPS.More())
+    {
+      return;
+    }
+    BOPAlgo_BuilderFace::Perform(aPS.Next());
+  }
+
+private:
+  //! Disable the range enabled method
+  virtual void Perform(const Message_ProgressRange& /*theRange*/) {};
+
+private:
+  TopoDS_Solid mySolid; //!< Solid to split
+  Message_ProgressRange myRange;
+};
+typedef NCollection_Vector<BOPAlgo_SplitFace> BOPAlgo_VectorOfBuilderFace;
 
 //=======================================================================
 //class    : BOPAlgo_VFI
 //purpose  : 
 //=======================================================================
-class BOPAlgo_VFI : public BOPAlgo_Algo {
+class BOPAlgo_VFI : public BOPAlgo_ParallelAlgo {
 
  public:
   DEFINE_STANDARD_ALLOC
   
   BOPAlgo_VFI() :
-    BOPAlgo_Algo(),
+    BOPAlgo_ParallelAlgo(),
     myIsInternal(Standard_False) {
   }
   //
@@ -169,6 +203,12 @@ class BOPAlgo_VFI : public BOPAlgo_Algo {
   }
   //
   virtual void Perform() {
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
+    if (UserBreak(aPS))
+    {
+      return;
+    }
+
     Standard_Real aT1, aT2, dummy;
     //
     Standard_Integer iFlag =
@@ -191,16 +231,24 @@ typedef NCollection_Vector<BOPAlgo_VFI> BOPAlgo_VectorOfVFI;
 //=======================================================================
 void BOPAlgo_Builder::FillImagesFaces(const Message_ProgressRange& theRange)
 {
-  Message_ProgressScope aPS(theRange, "Building splits of faces", 1);
-  BuildSplitFaces();
-  FillSameDomainFaces();
-  FillInternalVertices();
+  Message_ProgressScope aPS(theRange, "Building spligs of faces", 10);
+  BuildSplitFaces(aPS.Next(9));
+  if (HasErrors())
+  {
+    return;
+  }
+  FillSameDomainFaces(aPS.Next(0.5));
+  if (HasErrors())
+  {
+    return;
+  }
+  FillInternalVertices(aPS.Next(0.5));
 }
 //=======================================================================
 //function : BuildSplitFaces
 //purpose  : 
 //=======================================================================
-void BOPAlgo_Builder::BuildSplitFaces()
+void BOPAlgo_Builder::BuildSplitFaces(const Message_ProgressRange& theRange)
 {
   Standard_Boolean bHasFaceInfo, bIsClosed, bIsDegenerated, bToReverse;
   Standard_Integer i, j, k, aNbS, aNbPBIn, aNbPBOn, aNbPBSc, aNbAV, nSp;
@@ -221,6 +269,7 @@ void BOPAlgo_Builder::BuildSplitFaces()
   TopTools_ListOfShape aLE(aAllocator);
   TopTools_MapOfShape aMDE(100, aAllocator);
   //
+  Message_ProgressScope aPSOuter(theRange, NULL, 10);
   // Build temporary map of faces images to avoid rebuilding
   // of the faces without any IN or section edges
   NCollection_IndexedDataMap<Standard_Integer, TopTools_ListOfShape> aFacesIm;
@@ -232,6 +281,10 @@ void BOPAlgo_Builder::BuildSplitFaces()
     if (aSI.ShapeType()!=TopAbs_FACE) {
       continue;
     }
+    if (UserBreak(aPSOuter))
+    {
+      return;
+    }
     //
     const TopoDS_Face& aF=(*(TopoDS_Face*)(&aSI.Shape()));
     Standard_Boolean isUClosed = Standard_False,
@@ -445,18 +498,31 @@ void BOPAlgo_Builder::BuildSplitFaces()
       BRepLib::BuildPCurveForEdgesOnPlane(aLE, aFF);
     }
     // 3 Build split faces
-    BOPAlgo_BuilderFace& aBF=aVBF.Appended();
+    BOPAlgo_SplitFace& aBF=aVBF.Appended();
     aBF.SetFace(aF);
     aBF.SetShapes(aLE);
     aBF.SetRunParallel(myRunParallel);
     //
   }// for (i=0; i<aNbS; ++i) {
+
+  // close preparation task
+  aPSOuter.Next().Close();
   //
+  Standard_Integer aNbBF = aVBF.Length();
+  // Set progress range for each task to be run in parallel
+  Message_ProgressScope aPSParallel(aPSOuter.Next(9), "Splitting faces", aNbBF);
+  for (Standard_Integer iF = 0; iF < aNbBF; iF++)
+  {
+    BOPAlgo_SplitFace& aBF = aVBF.ChangeValue(iF);
+    aBF.SetProgressRange(aPSParallel.Next());
+  }
   //===================================================
   BOPTools_Parallel::Perform (myRunParallel, aVBF);
   //===================================================
-  //
-  Standard_Integer aNbBF = aVBF.Length();
+  if (UserBreak(aPSOuter))
+  {
+    return;
+  }
   for (k = 0; k < aNbBF; ++k)
   {
     BOPAlgo_BuilderFace& aBF = aVBF(k);
@@ -511,7 +577,7 @@ static void AddEdgeSet(const TopoDS_Shape& theS,
 //function : FillSameDomainFaces
 //purpose  : 
 //=======================================================================
-void BOPAlgo_Builder::FillSameDomainFaces()
+void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange)
 {
   // It is necessary to analyze all Face/Face intersections
   // and find all faces with equal sets of edges
@@ -520,6 +586,8 @@ void BOPAlgo_Builder::FillSameDomainFaces()
   if (!aNbFFs)
     return;
 
+  Message_ProgressScope aPSOuter(theRange, NULL, 10);
+
   Handle(NCollection_BaseAllocator) aAllocator = new NCollection_IncAllocator;
 
   // Vector to store the indices of faces for future sorting
@@ -532,6 +600,10 @@ void BOPAlgo_Builder::FillSameDomainFaces()
   // Fill the vector with indices of faces
   for (Standard_Integer i = 0; i < aNbFFs; ++i)
   {
+    if (UserBreak(aPSOuter))
+    {
+      return;
+    }
     const BOPDS_InterfFF& aFF = aFFs(i);
     // get indices
     Standard_Integer nF[2];
@@ -563,6 +635,10 @@ void BOPAlgo_Builder::FillSameDomainFaces()
   Standard_Integer aNbF = aFIVec.Length();
   for (Standard_Integer i = 0; i < aNbF; ++i)
   {
+    if (UserBreak(aPSOuter))
+    {
+      return;
+    }
     const Standard_Integer nF = aFIVec(i);
     const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(nF);
     const TopoDS_Shape& aF = aSI.Shape();
@@ -609,6 +685,10 @@ void BOPAlgo_Builder::FillSameDomainFaces()
   Standard_Integer aNbSets = anESetFaces.Extent();
   for (Standard_Integer i = 1; i <= aNbSets; ++i)
   {
+    if (UserBreak(aPSOuter))
+    {
+      return;
+    }
     const TopTools_ListOfShape& aLF = anESetFaces(i);
     if (aLF.Extent() < 2)
       continue;
@@ -639,10 +719,22 @@ void BOPAlgo_Builder::FillSameDomainFaces()
     }
   }
 
+  aPSOuter.Next().Close();
+
+  // Set progress range for each task to be run in parallel
+  Message_ProgressScope aPSParallel(aPSOuter.Next(3), "Checking SD faces", aVPSB.Size());
+  for (Standard_Integer iPSB = 0; iPSB < aVPSB.Size(); ++iPSB)
+  {
+    aVPSB.ChangeValue(iPSB).SetProgressRange(aPSParallel.Next());
+  }
   //================================================================
   // Perform analysis
   BOPTools_Parallel::Perform (myRunParallel, aVPSB, myContext);
   //================================================================
+  if (UserBreak(aPSOuter))
+  {
+    return;
+  }
 
   NCollection_List<TopTools_ListOfShape> aMBlocks(aAllocator);
   // Fill map with SD faces to make the blocks
@@ -749,8 +841,10 @@ void BOPAlgo_Builder::FillSameDomainFaces()
 // function: FillImagesFaces1
 // purpose: 
 //=======================================================================
-void BOPAlgo_Builder::FillInternalVertices()
+void BOPAlgo_Builder::FillInternalVertices(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
   // Vector of pairs of Vertex/Face for classification of the vertices
   // relatively faces, and adding them as internal into the faces
   BOPAlgo_VectorOfVFI aVVFI;
@@ -762,6 +856,11 @@ void BOPAlgo_Builder::FillInternalVertices()
     if (aSI.ShapeType() != TopAbs_FACE)
       continue;
 
+    if (UserBreak(aPSOuter))
+    {
+      return;
+    }
+
     const TopoDS_Shape& aF = aSI.Shape();
     const TopTools_ListOfShape* pLFIm = myImages.Seek(aF);
     if (!pLFIm)
@@ -791,10 +890,20 @@ void BOPAlgo_Builder::FillInternalVertices()
     }
   }
 
+  // Set progress range for each task to be run in parallel
+  Message_ProgressScope aPSParallel(aPSOuter.Next(), "Looking for internal shapes", aVVFI.Size());
+  for (Standard_Integer iVFI = 0; iVFI< aVVFI.Size(); ++iVFI)
+  {
+    aVVFI.ChangeValue(iVFI).SetProgressRange(aPSParallel.Next());
+  }
   // Perform classification
   //================================================================
   BOPTools_Parallel::Perform (myRunParallel, aVVFI, myContext);
   //================================================================
+  if (UserBreak(aPSOuter))
+  {
+    return;
+  }
 
   Standard_Integer aNbVFI = aVVFI.Length();
   for (Standard_Integer i = 0; i < aNbVFI; ++i)
index e01da97c8d0f7eeb074f6732ed4320c11a4fffeb..92da3eef0667f2cd7a9c3e561b6b06d9937bb992 100644 (file)
@@ -75,43 +75,45 @@ static
 //=======================================================================
 void BOPAlgo_Builder::FillImagesSolids(const Message_ProgressRange& theRange)
 {
-  Message_ProgressScope aPS(theRange, "Filling images solids", 1);
-  Standard_Boolean bHasSolids;
-  Standard_Integer i, aNbS;
-  //
-  bHasSolids=Standard_False;
-  aNbS=myDS->NbSourceShapes();
-  for (i=0; i<aNbS; ++i) {
-    if (UserBreak(aPS))
+  Standard_Integer i = 0, aNbS = myDS->NbSourceShapes();
+  for (i = 0; i < aNbS; ++i) {
+    const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
+    if (aSI.ShapeType() == TopAbs_SOLID)
     {
-      return;
-    }
-    const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
-    if (aSI.ShapeType()==TopAbs_SOLID) {
-      bHasSolids=!bHasSolids;
       break;
     }
   }
-  //
-  if (!bHasSolids) {
+  if (i >= aNbS) {
     return;
   }
 
+  Message_ProgressScope aPS(theRange, "Building splits of solids", 10);
   // Draft solids
   TopTools_DataMapOfShapeShape aDraftSolids;
   // Find all IN faces for all IN faces
-  FillIn3DParts(aDraftSolids);
+  FillIn3DParts(aDraftSolids, aPS.Next(4));
+  if (HasErrors())
+  {
+    return;
+  }
   // Build split of the solids
-  BuildSplitSolids(aDraftSolids);
+  BuildSplitSolids(aDraftSolids, aPS.Next(5));
+  if (HasErrors())
+  {
+    return;
+  }
   // Fill solids with internal parts
-  FillInternalShapes();
+  FillInternalShapes(aPS.Next());
 }
 //=======================================================================
 //function : FillIn3DParts
 //purpose  : 
 //=======================================================================
-void BOPAlgo_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids)
+void BOPAlgo_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids,
+                                    const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS(theRange, NULL, 2);
+
   Handle(NCollection_BaseAllocator) anAlloc = new NCollection_IncAllocator;
 
   // Find all faces that are IN solids
@@ -132,6 +134,11 @@ void BOPAlgo_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids
     if (aSI.ShapeType() != TopAbs_FACE)
       continue;
 
+    if (UserBreak(aPS))
+    {
+      return;
+    }
+
     const TopoDS_Shape& aS = aSI.Shape();
     const TopTools_ListOfShape* pLSIm = myImages.Seek(aS);
 
@@ -165,8 +172,13 @@ void BOPAlgo_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids
   {
     BOPDS_ShapeInfo& aSI = myDS->ChangeShapeInfo(i);
     if (aSI.ShapeType() != TopAbs_SOLID)
+    {
       continue;
-
+    }
+    if (UserBreak(aPS))
+    {
+      return;
+    }
     const TopoDS_Shape& aS = aSI.Shape();
     const TopoDS_Solid& aSolid = (*(TopoDS_Solid*)(&aS));
     //
@@ -191,12 +203,17 @@ void BOPAlgo_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids
   TopTools_IndexedDataMapOfShapeListOfShape anInParts;
 
   BOPAlgo_Tools::ClassifyFaces(aLFaces, aLSolids, myRunParallel,
-                               myContext, anInParts, aShapeBoxMap, aSolidsIF);
+                               myContext, anInParts, aShapeBoxMap,
+                               aSolidsIF, aPS.Next());
 
   // Analyze the results of classification
   Standard_Integer aNbSol = aDraftSolid.Extent();
   for (i = 1; i <= aNbSol; ++i)
   {
+    if (UserBreak(aPS))
+    {
+      return;
+    }
     const TopoDS_Solid& aSolid = TopoDS::Solid(aDraftSolid.FindKey(i));
     const TopoDS_Solid& aSDraft = TopoDS::Solid(aDraftSolid(i));
     const TopTools_ListOfShape& aLInFaces = anInParts.FindFromKey(aSDraft);
@@ -340,8 +357,30 @@ public:
   //! Returns the solid
   const TopoDS_Solid& Solid() const { return mySolid; }
 
+  //! Sets progress range
+  void SetProgressRange(const Message_ProgressRange& theRange)
+  {
+    myRange = theRange;
+  }
+
+  // New perform method, using own progress range
+  void Perform()
+  {
+    Message_ProgressScope aPS(myRange, NULL, 1);
+    if (!aPS.More())
+    {
+      return;
+    }
+    BOPAlgo_BuilderSolid::Perform(aPS.Next());
+  }
+
+private:
+  //! Disable the range enabled method
+  virtual void Perform(const Message_ProgressRange&/* theRange*/) {}
+
 private:
   TopoDS_Solid mySolid; //!< Solid to split
+  Message_ProgressRange myRange;
 };
 
 // Vector of Solid Builders
@@ -351,7 +390,8 @@ typedef NCollection_Vector<BOPAlgo_SplitSolid> BOPAlgo_VectorOfBuilderSolid;
 //function : BuildSplitSolids
 //purpose  : 
 //=======================================================================
-void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids)
+void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids,
+                                       const Message_ProgressRange& theRange)
 {
   Standard_Boolean bFlagSD;
   Standard_Integer i, aNbS;
@@ -366,6 +406,7 @@ void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSol
   BOPTools_MapOfSet aMST(100, aAlr0);
   BOPAlgo_VectorOfBuilderSolid aVBS;
   //
+  Message_ProgressScope aPSOuter (theRange, NULL, 10);
   // 0. Find same domain solids for non-interfered solids
   aNbS=myDS->NbSourceShapes();
   for (i=0; i<aNbS; ++i) {
@@ -374,6 +415,10 @@ void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSol
     if (aSI.ShapeType()!=TopAbs_SOLID) {
       continue;
     }
+    if (UserBreak(aPSOuter))
+    {
+      return;
+    }
     //
     const TopoDS_Shape& aS=aSI.Shape();
     if (!aMFence.Add(aS)) {
@@ -442,10 +487,21 @@ void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSol
   Standard_Integer k, aNbBS;
   //
   aNbBS=aVBS.Length();
+  // Set progress range for each task to be run in parallel
+  Message_ProgressScope aPSParallel(aPSOuter.Next(9), "Splitting solids", aNbBS);
+  for (Standard_Integer iS = 0; iS < aNbBS; iS++)
+  {
+    BOPAlgo_SplitSolid& aSplitSolid = aVBS.ChangeValue(iS);
+    aSplitSolid.SetProgressRange(aPSParallel.Next());
+  }
   //
   //===================================================
   BOPTools_Parallel::Perform (myRunParallel, aVBS);
   //===================================================
+  if (UserBreak(aPSOuter))
+  {
+    return;
+  }
   //
   for (k = 0; k < aNbBS; ++k)
   {
@@ -522,7 +578,7 @@ void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSol
 //function :FillInternalShapes 
 //purpose  : 
 //=======================================================================
-void BOPAlgo_Builder::FillInternalShapes()
+void BOPAlgo_Builder::FillInternalShapes(const Message_ProgressRange& theRange)
 {
   Standard_Integer i, j,  aNbS, aNbSI, aNbSx;
   TopAbs_ShapeEnum aType;
@@ -544,6 +600,8 @@ void BOPAlgo_Builder::FillInternalShapes()
   TopTools_ListOfShape aLArgs(aAllocator);
   TopTools_ListOfShape aLSC(aAllocator);
   TopTools_ListOfShape aLSI(aAllocator);
+
+  Message_ProgressScope aPS(theRange, NULL, 10);
   //
   // 1. Shapes to process
   //
@@ -597,7 +655,11 @@ void BOPAlgo_Builder::FillInternalShapes()
       }
     }
   }
-  
+  if (UserBreak(aPS))
+  {
+    return;
+  }
+
   aNbSI=aMSI.Extent();
   //
   // 2. Internal vertices, edges from source solids
@@ -611,6 +673,10 @@ void BOPAlgo_Builder::FillInternalShapes()
     if (aSI.ShapeType()!=TopAbs_SOLID) {
       continue;
     }
+    if (UserBreak(aPS))
+    {
+      return;
+    }
     //
     const TopoDS_Shape& aS=aSI.Shape();
     //
@@ -683,8 +749,11 @@ void BOPAlgo_Builder::FillInternalShapes()
   //
   // 5 Settle internal vertices and edges into solids
   aMx.Clear();
+
+  Message_ProgressScope aPSLoop(aPS.Next(), "Looking for internal shapes", aLSd.Size());
+
   aIt.Initialize(aLSd);
-  for (; aIt.More(); aIt.Next()) {
+  for (; aIt.More(); aIt.Next(), aPSLoop.Next()) {
     TopoDS_Solid aSd=TopoDS::Solid(aIt.Value());
     //
     aIt1.Initialize(aLSI);
index d592493aafa80bbf932931c78106823fc1359719..ee92e3f85fbffa62c4008257ff597155810cb753 100644 (file)
@@ -146,7 +146,7 @@ const TopTools_ListOfShape* BOPAlgo_Builder::LocModified(const TopoDS_Shape& the
 //function : PrepareHistory
 //purpose  : 
 //=======================================================================
-void BOPAlgo_Builder::PrepareHistory()
+void BOPAlgo_Builder::PrepareHistory(const Message_ProgressRange& theRange)
 {
   if (!HasHistory())
     return;
@@ -166,8 +166,13 @@ void BOPAlgo_Builder::PrepareHistory()
   // - Shapes that have no trace in the result shape. Add them as Deleted
   //   during the operation.
   Standard_Integer aNbS = myDS->NbSourceShapes();
-  for (Standard_Integer i = 0; i < aNbS; ++i)
+  Message_ProgressScope aPS(theRange, "Preparing history information", aNbS);
+  for (Standard_Integer i = 0; i < aNbS; ++i, aPS.Next())
   {
+    if (UserBreak(aPS))
+    {
+      return;
+    }
     const TopoDS_Shape& aS = myDS->Shape(i);
 
     // Check if History information is available for this kind of shape.
index d54f3497edebcfdf526ceebe582c7c72238a686b..e9645238e4c5b3f6fdcd7a635123a1b1c886c0bb 100644 (file)
@@ -109,7 +109,7 @@ void BOPAlgo_CellsBuilder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller,
   Standard_Boolean isHistory = HasHistory();
   SetToFillHistory(Standard_False);
   // Perform splitting of the arguments
-  Message_ProgressScope aPS(theRange, "Performing cells operation", 1);
+  Message_ProgressScope aPS(theRange, "Performing MakeCells operation", 1);
   BOPAlgo_Builder::PerformInternal1(theFiller, aPS.Next());
   if (HasErrors()) {
     return;
@@ -297,7 +297,7 @@ void BOPAlgo_CellsBuilder::AddToResult(const TopTools_ListOfShape& theLSToTake,
   //
   if (!theUpdate) {
     if (bChanged) {
-      PrepareHistory();
+      PrepareHistory(Message_ProgressRange());
     }
   }
   else {
@@ -330,7 +330,7 @@ void BOPAlgo_CellsBuilder::AddAllToResult(const Standard_Integer theMaterial,
   }
   //
   if (!theUpdate) {
-    PrepareHistory();
+    PrepareHistory(Message_ProgressRange());
   }
   else {
     RemoveInternalBoundaries();
@@ -420,7 +420,7 @@ void BOPAlgo_CellsBuilder::RemoveFromResult(const TopTools_ListOfShape& theLSToT
   if (bChanged) {
     myShape = aResult;
     //
-    PrepareHistory();
+    PrepareHistory(Message_ProgressRange());
   }
 }
 
@@ -439,7 +439,7 @@ void BOPAlgo_CellsBuilder::RemoveAllFromResult()
   myShapeMaterial.Clear();
   myMapModified.Clear();
   //
-  PrepareHistory();
+  PrepareHistory(Message_ProgressRange());
 }
 
 //=======================================================================
@@ -599,7 +599,7 @@ void BOPAlgo_CellsBuilder::RemoveInternalBoundaries()
     //
     myShape = aResult;
     //
-    PrepareHistory();
+    PrepareHistory(Message_ProgressRange());
   }
 }
 
index b6b64f4854c3d12ca1a81a7d045fde43bd7174c1..a1d0a4920f451968511664132234078df74e63ea 100644 (file)
 //=======================================================================
 class BOPAlgo_FaceSelfIntersect : 
   public IntTools_FaceFace,
-  public BOPAlgo_Algo {
+  public BOPAlgo_ParallelAlgo {
 
  public:
   DEFINE_STANDARD_ALLOC
 
   BOPAlgo_FaceSelfIntersect() : 
     IntTools_FaceFace(),  
-    BOPAlgo_Algo(),
+    BOPAlgo_ParallelAlgo(),
     myIF(-1), myTolF(1.e-7) {
   }
   //
@@ -88,8 +88,8 @@ class BOPAlgo_FaceSelfIntersect :
     return myTolF;
   }
   //
-  virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange()) {
-    Message_ProgressScope aPS(theRange, NULL, 1);
+  virtual void Perform() {
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
     if (UserBreak(aPS))
     {
       return;
@@ -178,29 +178,33 @@ void BOPAlgo_CheckerSI::Perform(const Message_ProgressRange& theRange)
       return;
     }
     //
-    Message_ProgressScope aPS(theRange, NULL, 1);
+    Message_ProgressScope aPS(theRange, "Checking shape on self-intersection", 10);
     // Perform intersection of sub shapes
-    BOPAlgo_PaveFiller::Perform(aPS.Next());
+    BOPAlgo_PaveFiller::Perform(aPS.Next(8));
     if (UserBreak(aPS))
     {
       return;
     }
     //
-    CheckFaceSelfIntersection();
+    CheckFaceSelfIntersection(aPS.Next());
     
+    Message_ProgressScope aPSZZ(aPS.Next(), NULL, 4);
     // Perform intersection with solids
     if (!HasErrors())
-      PerformVZ();
+      PerformVZ(aPSZZ.Next());
     //
     if (!HasErrors())
-      PerformEZ();
+      PerformEZ(aPSZZ.Next());
     //
     if (!HasErrors())
-      PerformFZ();
+      PerformFZ(aPSZZ.Next());
     //
     if (!HasErrors())
-      PerformZZ();
+      PerformZZ(aPSZZ.Next());
     //
+    if (HasErrors())
+      return;
+
     // Treat the intersection results
     PostTreat();
   }
@@ -393,7 +397,7 @@ void BOPAlgo_CheckerSI::PostTreat()
 //function : CheckFaceSelfIntersection
 //purpose  : 
 //=======================================================================
-void BOPAlgo_CheckerSI::CheckFaceSelfIntersection()
+void BOPAlgo_CheckerSI::CheckFaceSelfIntersection(const Message_ProgressRange& theRange)
 {
   if (myLevelOfCheck < 5)
     return;
@@ -407,6 +411,8 @@ void BOPAlgo_CheckerSI::CheckFaceSelfIntersection()
   BOPAlgo_VectorOfFaceSelfIntersect aVFace;
   
   Standard_Integer aNbS=myDS->NbSourceShapes();
+
+  Message_ProgressScope aPSOuter(theRange, NULL, 1);
   
   //
   for (Standard_Integer i = 0; i < aNbS; i++)
@@ -444,9 +450,18 @@ void BOPAlgo_CheckerSI::CheckFaceSelfIntersection()
   }
   
   Standard_Integer aNbFace = aVFace.Length();
+  Message_ProgressScope aPSParallel(aPSOuter.Next(), "Checking surface on self-intersection", aNbFace);
+  for (Standard_Integer iF = 0; iF < aVFace.Size(); ++iF)
+  {
+    aVFace.ChangeValue(iF).SetProgressRange(aPSParallel.Next());
+  }
   //======================================================
   BOPTools_Parallel::Perform (myRunParallel, aVFace);
   //======================================================
+  if (UserBreak(aPSOuter))
+  {
+    return;
+  }
   //
   for (Standard_Integer k = 0; k < aNbFace; k++)
   {
index 3e8701149f88387d0bf8e3876f5d55eae6577fba..31dd03118a277ac39df060c32c75e34b528a9cd0 100644 (file)
@@ -69,24 +69,24 @@ protected:
   //! Treats the intersection results
   Standard_EXPORT void PostTreat();
 
-  Standard_EXPORT void CheckFaceSelfIntersection();
+  Standard_EXPORT void CheckFaceSelfIntersection(const Message_ProgressRange& theRange);
 
   //! Methods for intersection with solids
 
   //! Vertex/Solid intersection
-  Standard_EXPORT virtual void PerformVZ();
+  Standard_EXPORT virtual void PerformVZ(const Message_ProgressRange& theRange);
 
   //! Edge/Solid intersection
-  Standard_EXPORT virtual void PerformEZ();
+  Standard_EXPORT virtual void PerformEZ(const Message_ProgressRange& theRange);
 
   //! Face/Solid intersection
-  Standard_EXPORT virtual void PerformFZ();
+  Standard_EXPORT virtual void PerformFZ(const Message_ProgressRange& theRange);
 
   //! Solid/Solid intersection
-  Standard_EXPORT virtual void PerformZZ();
+  Standard_EXPORT virtual void PerformZZ(const Message_ProgressRange& theRange);
 
   //! Used for intersection of edges and faces with solids
-  Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS);
+  Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS, const Message_ProgressRange& theRange);
 
   Standard_Integer myLevelOfCheck;
 
index dc9b8c6f90eeae58ed7bb43071fdaca9a726f4d0..05db010e0eb608a6e5bd35cf0647e5ad35a7d69a 100644 (file)
 //class    : BOPAlgo_VertexSolid
 //purpose  : 
 //=======================================================================
-class BOPAlgo_VertexSolid  {
+class BOPAlgo_VertexSolid : public BOPAlgo_ParallelAlgo  {
  public:
   DEFINE_STANDARD_ALLOC
   
-  BOPAlgo_VertexSolid()
-    : myIV(-1), myIZ(-1), myState(TopAbs_UNKNOWN) {
+  BOPAlgo_VertexSolid() :
+    BOPAlgo_ParallelAlgo(),
+    myIV(-1), myIZ(-1), myState(TopAbs_UNKNOWN) {
   };
   //
   virtual ~BOPAlgo_VertexSolid(){
@@ -92,7 +93,13 @@ class BOPAlgo_VertexSolid  {
     return myState;
   };
   //
-  void Perform() {
+  virtual void Perform() {
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
+    if (UserBreak(aPS))
+    {
+      return;
+    }
+
     Standard_Real aTol;
     gp_Pnt aPV;
     //
@@ -122,11 +129,12 @@ typedef NCollection_Vector<BOPAlgo_VertexSolid> BOPAlgo_VectorOfVertexSolid;
 //class    : BOPAlgo_ShapeSolid
 //purpose  : 
 //=======================================================================
-class BOPAlgo_ShapeSolid  {
+class BOPAlgo_ShapeSolid: public BOPAlgo_ParallelAlgo  {
  public:
   DEFINE_STANDARD_ALLOC
 
   BOPAlgo_ShapeSolid() : 
+    BOPAlgo_ParallelAlgo(),
     myIE(-1), 
     myIZ(-1), 
     myHasInterf(Standard_False), 
@@ -157,6 +165,12 @@ class BOPAlgo_ShapeSolid  {
   };
   //
   virtual void Perform() {
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
+    if (UserBreak(aPS))
+    {
+      return;
+    }
+
     Standard_Boolean bHasInterf;
     //
     myHasInterf=Standard_False;
@@ -193,6 +207,12 @@ class BOPAlgo_SolidSolid : public  BOPAlgo_ShapeSolid {
   };
   //
   virtual void Perform() {
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
+    if (UserBreak(aPS))
+    {
+      return;
+    }
+
     Standard_Boolean bFlag;
     //
     bFlag=Standard_False;
@@ -211,8 +231,10 @@ typedef NCollection_Vector<BOPAlgo_SolidSolid> BOPAlgo_VectorOfSolidSolid;
 //function : PerformVZ
 //purpose  : 
 //=======================================================================
-void BOPAlgo_CheckerSI::PerformVZ()
+void BOPAlgo_CheckerSI::PerformVZ(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
   Standard_Integer iSize, nV, nZ, k, aNbVVS;
   TopAbs_State aState;
   BOPDS_MapOfPair aMPK;
@@ -229,6 +251,10 @@ void BOPAlgo_CheckerSI::PerformVZ()
   BOPAlgo_VectorOfVertexSolid aVVS;
   //
   for (; myIterator->More(); myIterator->Next()) {
+    if (UserBreak(aPSOuter))
+    {
+      return;
+    }
     myIterator->Value(nV, nZ);
     //
     if (myDS->HasInterfShapeSubShapes(nV, nZ)) {
@@ -254,9 +280,19 @@ void BOPAlgo_CheckerSI::PerformVZ()
   }
   //
   aNbVVS=aVVS.Length();
+
+  Message_ProgressScope aPSParallel(aPSOuter.Next(), "Performing Vertex-Solid intersection", aNbVVS);
+  for (Standard_Integer iVS = 0; iVS < aNbVVS; ++iVS)
+  {
+    aVVS.ChangeValue(iVS).SetProgressRange(aPSParallel.Next());
+  }
   //=============================================================
   BOPTools_Parallel::Perform (myRunParallel, aVVS, myContext);
   //=============================================================
+  if (UserBreak(aPSOuter))
+  {
+    return;
+  }
   for (k=0; k < aNbVVS; ++k) {
     const BOPAlgo_VertexSolid& aVertexSolid=aVVS(k);
     aState=aVertexSolid.State();
@@ -274,24 +310,26 @@ void BOPAlgo_CheckerSI::PerformVZ()
 //function : PerformEZ
 //purpose  : 
 //=======================================================================
-void BOPAlgo_CheckerSI::PerformEZ()
+void BOPAlgo_CheckerSI::PerformEZ(const Message_ProgressRange& theRange)
 { 
-  PerformSZ(TopAbs_EDGE);
+  PerformSZ(TopAbs_EDGE, theRange);
 }
 //=======================================================================
 //function : PerformFZ
 //purpose  : 
 //=======================================================================
-void BOPAlgo_CheckerSI::PerformFZ()
+void BOPAlgo_CheckerSI::PerformFZ(const Message_ProgressRange& theRange)
 { 
-  PerformSZ(TopAbs_FACE);
+  PerformSZ(TopAbs_FACE, theRange);
 }
 //=======================================================================
 //function : PerformZZ
 //purpose  : 
 //=======================================================================
-void BOPAlgo_CheckerSI::PerformZZ()
+void BOPAlgo_CheckerSI::PerformZZ(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
   Standard_Boolean bHasInterf;
   Standard_Integer iSize, nZ1, nZ, k, aNbSolidSolid;
   //
@@ -312,9 +350,19 @@ void BOPAlgo_CheckerSI::PerformZZ()
   }
   //
   aNbSolidSolid=aVSolidSolid.Length();
+
+  Message_ProgressScope aPSParallel(aPSOuter.Next(), "Performing Solid-Solid intersection", aNbSolidSolid);
+  for (Standard_Integer iSS = 0; iSS < aNbSolidSolid; ++iSS)
+  {
+    aVSolidSolid.ChangeValue(iSS).SetProgressRange(aPSParallel.Next());
+  }
   //======================================================
   BOPTools_Parallel::Perform (myRunParallel, aVSolidSolid);
   //======================================================
+  if (UserBreak(aPSOuter))
+  {
+    return;
+  }
   //
   BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ();
   //
@@ -337,12 +385,14 @@ void BOPAlgo_CheckerSI::PerformZZ()
 //function : PerformSZ
 //purpose  : 
 //=======================================================================
-void BOPAlgo_CheckerSI::PerformSZ(const TopAbs_ShapeEnum aTS)
+void BOPAlgo_CheckerSI::PerformSZ(const TopAbs_ShapeEnum theTS, const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
   Standard_Boolean bHasInterf;
   Standard_Integer iSize, nS, nZ, k, aNbShapeSolid;
   //
-  myIterator->Initialize(aTS, TopAbs_SOLID);
+  myIterator->Initialize(theTS, TopAbs_SOLID);
   iSize=myIterator->ExpectedLength();
   if (!iSize) {
     return; 
@@ -351,6 +401,10 @@ void BOPAlgo_CheckerSI::PerformSZ(const TopAbs_ShapeEnum aTS)
   BOPAlgo_VectorOfShapeSolid aVShapeSolid;
   //
   for (; myIterator->More(); myIterator->Next()) {
+    if (UserBreak(aPSOuter))
+    {
+      return;
+    }
     myIterator->Value(nS, nZ);
     //
     BOPAlgo_ShapeSolid& aShapeSolid=aVShapeSolid.Appended();
@@ -359,14 +413,27 @@ void BOPAlgo_CheckerSI::PerformSZ(const TopAbs_ShapeEnum aTS)
   }
   //
   aNbShapeSolid=aVShapeSolid.Length();
+
+  Message_ProgressScope aPSParallel(aPSOuter.Next(),
+                                    theTS == TopAbs_EDGE ? "Performing Edge-Solid intersection" :
+                                                           "Performing Face-Solid intersection",
+                                    aNbShapeSolid);
+  for (Standard_Integer iSS = 0; iSS < aNbShapeSolid; ++iSS)
+  {
+    aVShapeSolid.ChangeValue(iSS).SetProgressRange(aPSParallel.Next());
+  }
   //======================================================
   BOPTools_Parallel::Perform (myRunParallel, aVShapeSolid);
   //======================================================
+  if (UserBreak(aPSOuter))
+  {
+    return;
+  }
   //
   BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ();
   BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ();
   //
-  if (aTS==TopAbs_EDGE) {
+  if (theTS==TopAbs_EDGE) {
     aEZs.SetIncrement(iSize);
   }
   else {//if (aTS==TopAbs_FACE)
@@ -379,7 +446,7 @@ void BOPAlgo_CheckerSI::PerformSZ(const TopAbs_ShapeEnum aTS)
     if (bHasInterf) {
       aShapeSolid.Indices(nS, nZ);
       //
-      if (aTS==TopAbs_EDGE) {
+      if (theTS==TopAbs_EDGE) {
         BOPDS_InterfEZ& aEZ=aEZs.Appended();
         aEZ.SetIndices(nS, nZ);
       }
index 97618d4a161f2143116eeede229e73863ee68066..dec0aae83693cac20f66de0584219fccc3985f5d 100644 (file)
@@ -50,6 +50,10 @@ void BOPAlgo_MakerVolume::CheckData()
 //=======================================================================
 void BOPAlgo_MakerVolume::Perform(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS(theRange, "Performing MakeVolume operation", 10);
+  Standard_Real anInterPart = myIntersect ? 9 : 0.5;
+  Standard_Real aBuildPart = 10. - anInterPart;
+
   GetReport()->Clear();
   //
   if (myEntryPoint == 1) {
@@ -90,15 +94,14 @@ void BOPAlgo_MakerVolume::Perform(const Message_ProgressRange& theRange)
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
   pPF->SetUseOBB(myUseOBB);
-  Message_ProgressScope aPS(theRange, "MakerVolume", 10);
-  pPF->Perform(aPS.Next(9));
+  pPF->Perform(aPS.Next(anInterPart));
   if (HasErrors())
   {
     return;
   }
   //
   myEntryPoint = 1;
-  PerformInternal(*pPF, aPS.Next(1));
+  PerformInternal(*pPF, aPS.Next(aBuildPart));
 }
 
 //=======================================================================
@@ -108,6 +111,7 @@ void BOPAlgo_MakerVolume::Perform(const Message_ProgressRange& theRange)
 void BOPAlgo_MakerVolume::PerformInternal1
   (const BOPAlgo_PaveFiller& theFiller, const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS(theRange, "Building volumes", 100);
   myPaveFiller = (BOPAlgo_PaveFiller*)&theFiller;
   myDS = myPaveFiller->PDS();
   myContext = myPaveFiller->Context();
@@ -124,28 +128,28 @@ void BOPAlgo_MakerVolume::PerformInternal1
     return;
   }
   //
+  BOPAlgo_PISteps aSteps(PIOperation_Last);
+  analyzeProgress(100., aSteps);
+
   // 3. Fill Images
-  // 3.1. Vertice
   if (myIntersect) {
-    Message_ProgressScope aPS(theRange, "PerformInternal", 100);
-    NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
-
-    FillImagesVertices(aPS.Next(aSteps(0)));
+    // 3.1. Vertices
+    FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
     if (HasErrors()) {
       return;
     }
     // 3.2. Edges
-    FillImagesEdges(aPS.Next(aSteps(1)));
+    FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
     if (HasErrors()) {
       return;
     }
     // 3.3. Wires
-    FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps(2)));
+    FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps.GetStep(PIOperation_TreatWires)));
     if (HasErrors()) {
       return;
     }
     // 3.4. Faces
-    FillImagesFaces(aPS.Next(aSteps(3)));
+    FillImagesFaces(aPS.Next(aSteps.GetStep(PIOperation_TreatFaces)));
     if (HasErrors()) {
       return;
     }
@@ -164,7 +168,7 @@ void BOPAlgo_MakerVolume::PerformInternal1
   MakeBox(aBoxFaces);
   //
   // 6. Make volumes
-  BuildSolids(aLSR);
+  BuildSolids(aLSR, aPS.Next(aSteps.GetStep(PIOperation_BuildSolids)));
   if (HasErrors()) {
     return;
   }
@@ -179,65 +183,30 @@ void BOPAlgo_MakerVolume::PerformInternal1
   BuildShape(aLSR);
   //
   // 10. History
-  PrepareHistory();
+  PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
+  if (HasErrors()) {
+    return;
+  }
   //
   // 11. Post-treatment 
-  PostTreat();  
+  PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
 }
 
 //=======================================================================
-//function : AnalyzeProgress
+//function : fillPISteps
 //purpose  : 
 //=======================================================================
-NCollection_Array1<Standard_Real> BOPAlgo_MakerVolume::AnalyzeProgress()
+void BOPAlgo_MakerVolume::fillPISteps(BOPAlgo_PISteps& theSteps) const
 {
-  Standard_Integer aSize = 4;
-  NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
-  for (Standard_Integer i = 0; i < aSize; i++)
+  NbShapes aNbShapes = getNbShapes();
+  if (myIntersect)
   {
-    aSteps(i) = 0;
+    theSteps.SetStep(PIOperation_TreatVertices, aNbShapes.NbVertices());
+    theSteps.SetStep(PIOperation_TreatEdges, aNbShapes.NbEdges());
+    theSteps.SetStep(PIOperation_TreatWires, aNbShapes.NbWires());
+    theSteps.SetStep(PIOperation_TreatFaces, 50 * aNbShapes.NbFaces());
   }
-
-  Standard_Real aPart = 100.;
-  Standard_Integer aNbV = myDS->ShapesSD().Size();
-  Standard_Integer aNbE = 0;
-  Standard_Integer aNbW = 0;
-  Standard_Integer aNbF = 0;
-
-  for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); i++)
-  {
-    const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
-    switch (aSI.ShapeType())
-    {
-    case TopAbs_EDGE:
-      aNbE++;
-      break;
-    case TopAbs_WIRE:
-      aNbW++;
-      break;
-    case TopAbs_FACE:
-      aNbF++;
-      break;
-    default:
-      break;
-    }
-  }
-
-  aNbE = 5 * aNbE;
-  aNbW = 10 * aNbW;
-  aNbF = 20 * aNbF;
-  Standard_Real aSum = aNbV + aNbE + aNbW + aNbF;
-  if (aSum == 0)
-  {
-    return aSteps;
-  }
-
-  aSteps(0) = aPart * aNbV / aSum;
-  aSteps(1) = aPart * aNbE / aSum;
-  aSteps(2) = aPart * aNbW / aSum;
-  aSteps(3) = aPart * aNbF / aSum;
-
-  return aSteps;
+  theSteps.SetStep(PIOperation_BuildSolids, 50 * aNbShapes.NbFaces());
 }
 
 //=======================================================================
@@ -308,15 +277,15 @@ void BOPAlgo_MakerVolume::MakeBox(TopTools_MapOfShape& theBoxFaces)
 //function : BuildSolids
 //purpose  : 
 //=======================================================================
-void BOPAlgo_MakerVolume::BuildSolids(TopTools_ListOfShape& theLSR)
+void BOPAlgo_MakerVolume::BuildSolids(TopTools_ListOfShape& theLSR,
+                                      const Message_ProgressRange& theRange)
 {
-  //
   BOPAlgo_BuilderSolid aBS;
   //
   aBS.SetShapes(myFaces);
   aBS.SetRunParallel(myRunParallel);
   aBS.SetAvoidInternalShapes(myAvoidInternalShapes);
-  aBS.Perform();
+  aBS.Perform(theRange);
   if (aBS.HasErrors())
   {
     AddError (new BOPAlgo_AlertSolidBuilderFailed); // SolidBuilder failed
index faff5c8800653824b71e579cace97abd71efba7e..5d116869dd269e9f30a3a89d61110b4969e412a4 100644 (file)
@@ -113,8 +113,6 @@ public:
 
   DEFINE_STANDARD_ALLOC
 
-  
-
   //! Empty constructor.
   BOPAlgo_MakerVolume();
   virtual ~BOPAlgo_MakerVolume();
@@ -158,9 +156,6 @@ protected:
   //! Checks the data.
   Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
 
-  //! Analyze progress steps
-  Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
   //! Performs the operation.
   Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
 
@@ -171,7 +166,8 @@ protected:
   Standard_EXPORT void MakeBox (TopTools_MapOfShape& theBoxFaces);
 
   //! Builds solids.
-  Standard_EXPORT void BuildSolids (TopTools_ListOfShape& theLSR);
+  Standard_EXPORT void BuildSolids (TopTools_ListOfShape& theLSR,
+                                    const Message_ProgressRange& theRange);
 
   //! Removes the covering box.
   Standard_EXPORT void RemoveBox (TopTools_ListOfShape& theLSR, const TopTools_MapOfShape& theBoxFaces);
@@ -182,6 +178,25 @@ protected:
   //! Builds the result.
   Standard_EXPORT void BuildShape (const TopTools_ListOfShape& theLSR);
 
+protected:
+  //! List of operations to be supported by the Progress Indicator.
+  //! Enumeration is going to contain some extra operations from base class,
+  //! which are not going to be used here. So, the array of steps will also
+  //! contain some extra zero values. This is the only extra resource that is
+  //! going to be used, but it allows us not to override the methods that use
+  //! the values of the enumeration of base class.
+  //! Starting the enumeration from the middle of enumeration of base class is
+  //! not a good idea as the values in enumeration may be swapped.
+  enum BOPAlgo_PIOperation
+  {
+    PIOperation_BuildSolids = BOPAlgo_Builder::PIOperation_Last,
+    PIOperation_Last
+  };
+
+  //! Analyze progress steps
+  Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
+protected:
 
   Standard_Boolean myIntersect;
   Bnd_Box myBBox;
index f3b9bc74b5cbe40a029216860d4fc0624c11f3e9..1ad5a147ed772f186c6e751625087c8120643a99 100644 (file)
 #include <TopoDS_Vertex.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 
+namespace
+{
+  //=======================================================================
+  //function : BOPAlgo_PIOperation
+  //purpose  : List of operations to be supported by the Progress Indicator
+  //=======================================================================
+  enum BOPAlgo_PIOperation
+  {
+    PIOperation_Prepare = 0,
+    PIOperation_PerformVV,
+    PIOperation_PerformVE,
+    PIOperation_PerformEE,
+    PIOperation_PerformVF,
+    PIOperation_PerformEF,
+    PIOperation_RepeatIntersection,
+    PIOperation_ForceInterfEE,
+    PIOperation_ForceInterfEF,
+    PIOperation_PerformFF,
+    PIOperation_MakeSplitEdges,
+    PIOperation_MakeBlocks,
+    PIOperation_MakePCurves,
+    PIOperation_ProcessDE,
+    PIOperation_Last
+  };
+}
+
 //=======================================================================
 //function : 
 //purpose  : 
 //=======================================================================
 BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
-:
+  :
   BOPAlgo_Algo()
 {
   myDS = NULL;
@@ -52,13 +78,13 @@ BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
 //purpose  : 
 //=======================================================================
 BOPAlgo_PaveFiller::BOPAlgo_PaveFiller
-  (const Handle(NCollection_BaseAllocator)& theAllocator)
-:
-  BOPAlgo_Algo(theAllocator),
-  myFPBDone(1, theAllocator),
-  myIncreasedSS(1, theAllocator),
-  myVertsToAvoidExtension(1, theAllocator),
-  myDistances(1, theAllocator)
+(const Handle (NCollection_BaseAllocator)& theAllocator)
+  :
+  BOPAlgo_Algo (theAllocator),
+  myFPBDone (1, theAllocator),
+  myIncreasedSS (1, theAllocator),
+  myVertsToAvoidExtension (1, theAllocator),
+  myDistances (1, theAllocator)
 {
   myDS = NULL;
   myIterator = NULL;
@@ -79,15 +105,15 @@ BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller()
 //function : SetNonDestructive
 //purpose  : 
 //=======================================================================
-void BOPAlgo_PaveFiller::SetNonDestructive(const Standard_Boolean bFlag)
+void BOPAlgo_PaveFiller::SetNonDestructive (const Standard_Boolean bFlag)
 {
-  myNonDestructive=bFlag;
+  myNonDestructive = bFlag;
 }
 //=======================================================================
 //function : NonDestructive
 //purpose  : 
 //=======================================================================
-Standard_Boolean BOPAlgo_PaveFiller::NonDestructive()const 
+Standard_Boolean BOPAlgo_PaveFiller::NonDestructive() const
 {
   return myNonDestructive;
 }
@@ -95,15 +121,15 @@ Standard_Boolean BOPAlgo_PaveFiller::NonDestructive()const
 //function : SetGlue
 //purpose  : 
 //=======================================================================
-void BOPAlgo_PaveFiller::SetGlue(const BOPAlgo_GlueEnum theGlue)
+void BOPAlgo_PaveFiller::SetGlue (const BOPAlgo_GlueEnum theGlue)
 {
-  myGlue=theGlue;
+  myGlue = theGlue;
 }
 //=======================================================================
 //function : Glue
 //purpose  : 
 //=======================================================================
-BOPAlgo_GlueEnum BOPAlgo_PaveFiller::Glue() const 
+BOPAlgo_GlueEnum BOPAlgo_PaveFiller::Glue() const
 {
   return myGlue;
 }
@@ -111,15 +137,15 @@ BOPAlgo_GlueEnum BOPAlgo_PaveFiller::Glue() const
 //function : SetIsPrimary
 //purpose  : 
 //=======================================================================
-void BOPAlgo_PaveFiller::SetIsPrimary(const Standard_Boolean bFlag)
+void BOPAlgo_PaveFiller::SetIsPrimary (const Standard_Boolean bFlag)
 {
-  myIsPrimary=bFlag;
+  myIsPrimary = bFlag;
 }
 //=======================================================================
 //function : IsPrimary
 //purpose  : 
 //=======================================================================
-Standard_Boolean BOPAlgo_PaveFiller::IsPrimary()const 
+Standard_Boolean BOPAlgo_PaveFiller::IsPrimary() const
 {
   return myIsPrimary;
 }
@@ -132,11 +158,11 @@ void BOPAlgo_PaveFiller::Clear()
   BOPAlgo_Algo::Clear();
   if (myIterator) {
     delete myIterator;
-    myIterator=NULL;
+    myIterator = NULL;
   }
   if (myDS) {
     delete myDS;
-    myDS=NULL;
+    myDS = NULL;
   }
   myIncreasedSS.Clear();
 }
@@ -160,7 +186,7 @@ BOPDS_PDS BOPAlgo_PaveFiller::PDS()
 //function : Context
 //purpose  : 
 //=======================================================================
-const Handle(IntTools_Context)& BOPAlgo_PaveFiller::Context()
+const Handle (IntTools_Context)& BOPAlgo_PaveFiller::Context()
 {
   return myContext;
 }
@@ -169,7 +195,7 @@ const Handle(IntTools_Context)& BOPAlgo_PaveFiller::Context()
 //purpose  : 
 //=======================================================================
 void BOPAlgo_PaveFiller::SetSectionAttribute
-  (const BOPAlgo_SectionAttribute& theSecAttr)
+(const BOPAlgo_SectionAttribute& theSecAttr)
 {
   mySectionAttribute = theSecAttr;
 }
@@ -177,15 +203,15 @@ void BOPAlgo_PaveFiller::SetSectionAttribute
 // function: Init
 // purpose: 
 //=======================================================================
-void BOPAlgo_PaveFiller::Init(const Message_ProgressRange& theRange)
+void BOPAlgo_PaveFiller::Init (const Message_ProgressRange& theRange)
 {
   if (!myArguments.Extent()) {
     AddError (new BOPAlgo_AlertTooFewArguments);
     return;
   }
   //
-  Message_ProgressScope aPS(theRange, "Init", myArguments.Size());
-  TopTools_ListIteratorOfListOfShape aIt(myArguments);
+  Message_ProgressScope aPS (theRange, "Initialization of Intersection algorithm", 1);
+  TopTools_ListIteratorOfListOfShape aIt (myArguments);
   for (; aIt.More(); aIt.Next(), aPS.Next()) {
     if (aIt.Value().IsNull()) {
       AddError (new BOPAlgo_AlertNullInputShapes);
@@ -197,228 +223,132 @@ void BOPAlgo_PaveFiller::Init(const Message_ProgressRange& theRange)
   Clear();
   //
   // 1.myDS 
-  myDS=new BOPDS_DS(myAllocator);
-  myDS->SetArguments(myArguments);
-  myDS->Init(myFuzzyValue);
+  myDS = new BOPDS_DS (myAllocator);
+  myDS->SetArguments (myArguments);
+  myDS->Init (myFuzzyValue);
   //
   // 2 myContext
-  myContext=new IntTools_Context;
+  myContext = new IntTools_Context;
   //
   // 3.myIterator 
-  myIterator=new BOPDS_Iterator(myAllocator);
-  myIterator->SetRunParallel(myRunParallel);
-  myIterator->SetDS(myDS);
-  myIterator->Prepare(myContext, myUseOBB, myFuzzyValue);
+  myIterator = new BOPDS_Iterator (myAllocator);
+  myIterator->SetRunParallel (myRunParallel);
+  myIterator->SetDS (myDS);
+  myIterator->Prepare (myContext, myUseOBB, myFuzzyValue);
   //
   // 4 NonDestructive flag
   SetNonDestructive();
 }
 
-NCollection_Array1<Standard_Real> BOPAlgo_PaveFiller::AnalyzeProgress()
-{
-  Standard_Integer aSize = 13;
-  NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
-  for (Standard_Integer i = 0; i < aSize; i++)
-  {
-    aSteps(i) = 0;
-  }
-
-  Standard_Real aPart = 95.;
-
-  myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
-  Standard_Real aPerformVVSize = myIterator->ExpectedLength();
-
-  myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
-  Standard_Real aPerformVESize = myIterator->ExpectedLength();
-
-  myIterator->Initialize(TopAbs_EDGE, TopAbs_EDGE);
-  Standard_Real aPerformEESize = myIterator->ExpectedLength();
-
-  myIterator->Initialize(TopAbs_VERTEX, TopAbs_FACE);
-  Standard_Real aPerformVFSize = myIterator->ExpectedLength();
-
-  myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE);
-  Standard_Real aPerformEFSize = myIterator->ExpectedLength();
-
-  myIterator->Initialize(TopAbs_FACE, TopAbs_FACE);
-  Standard_Real aPerformFFSize = myIterator->ExpectedLength();
-
-  Standard_Real aStep1 = aPerformVVSize;
-  Standard_Real aStep2 = 2 * aPerformVESize;
-  Standard_Real aStep3 = 5 * aPerformEESize;
-  Standard_Real aStep4 = 5 * aPerformVFSize;
-  Standard_Real aStep5 = 10 * aPerformEFSize;
-  Standard_Real aStep6 = 0.1 * (aStep1 + aStep2 + aStep4);
-  Standard_Real aStep7 = 2 * aPerformEESize;
-  Standard_Real aStep8 = 2 * aPerformEFSize;
-  Standard_Real aStep9 = 30 * aPerformFFSize;
-  Standard_Real aStep10 = 0.2 * aStep3;
-  Standard_Real aStep11 = 0.2 * aStep9;
-  Standard_Real aStep12 = 0.2 * aStep3;
-
-  Standard_Real aSum = aStep1 + aStep2 + aStep3 + aStep4 + aStep5 + aStep6 +
-    aStep7 + aStep8 + aStep9 + aStep10 + aStep11 + aStep12;
-
-  if (!myNonDestructive)
-  {
-    aPart -= 5;
-    // step for init
-    aSteps(0) = 5;
-  }
-  if (!myIsPrimary)
-  {
-    aSum -= aStep8;
-    aStep8 = 0;
-  }
-  if (myGlue != BOPAlgo_GlueOff)
-  {
-    aSum -= aStep8;
-    aStep11 = 0;
-  }
-  if (myAvoidBuildPCurve)
-  {
-    aSum -= aStep12;
-    aStep12 = 0;
-  }
-
-  if (aSum == 0)
-  {
-    aSteps(0) = 95.;
-    return aSteps;
-  }
-  // step for PerformVV()
-  aSteps(1) = aPart * aStep1 / aSum;
-  // step for PerformVE()
-  aSteps(2) = aPart * aStep2 / aSum;
-  // step for PerformEE()
-  aSteps(3) = aPart * aStep3 / aSum;
-  // step for PerformVF()
-  aSteps(4) = aPart * aStep4 / aSum;
-  // step for PerformEF()
-  aSteps(5) = aPart * aStep5 / aSum;
-  // step for RepeatIntersection()
-  aSteps(6) = aPart * aStep6 / aSum;
-  // step for ForceInterfEE()
-  aSteps(7) = aPart * aStep7 / aSum;
-  // step for ForceInterfEF()
-  aSteps(8) = aPart * aStep8 / aSum;
-  // step for PerformFF()
-  aSteps(9) = aPart * aStep9 / aSum;
-  // step for MakeSplitEdges()
-  aSteps(10) = aPart * aStep10 / aSum;
-  // step for MakeBloks()
-  aSteps(11) = aPart * aStep11 / aSum;
-  // step for MakePCurves()
-  aSteps(12) = aPart * aStep12 / aSum;
-
-  return aSteps;
-}
-
 //=======================================================================
 // function: Perform
 // purpose: 
 //=======================================================================
-void BOPAlgo_PaveFiller::Perform(const Message_ProgressRange& theRange)
+void BOPAlgo_PaveFiller::Perform (const Message_ProgressRange& theRange)
 {
   try {
     OCC_CATCH_SIGNALS
       //
-    PerformInternal(theRange);
+      PerformInternal (theRange);
   }
   //
   catch (Standard_Failure const&) {
     AddError (new BOPAlgo_AlertIntersectionFailed);
-  } 
+  }
 }
+
 //=======================================================================
 // function: PerformInternal
 // purpose: 
 //=======================================================================
-void BOPAlgo_PaveFiller::PerformInternal(const Message_ProgressRange& theRange)
+void BOPAlgo_PaveFiller::PerformInternal (const Message_ProgressRange& theRange)
 {
-  Message_ProgressScope aPS(theRange, "Performing intersections of shapes", 100);
+  Message_ProgressScope aPS (theRange, "Performing intersection of shapes", 100);
 
-  Init(aPS.Next(5));
+  Init (aPS.Next (5));
   if (HasErrors()) {
-    return; 
+    return;
   }
-  NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
+
+  // Compute steps of the PI
+  BOPAlgo_PISteps aSteps (PIOperation_Last);
+  analyzeProgress (95, aSteps);
   //
-  Prepare(aPS.Next(aSteps[0]));
+  Prepare (aPS.Next (aSteps.GetStep (PIOperation_Prepare)));
   if (HasErrors()) {
-    return; 
+    return;
   }
   // 00
-  PerformVV(aPS.Next(aSteps[1]));
+  PerformVV (aPS.Next (aSteps.GetStep (PIOperation_PerformVV)));
   if (HasErrors()) {
-    return; 
+    return;
   }
   // 01
-  PerformVE(aPS.Next(aSteps[2]));
+  PerformVE (aPS.Next (aSteps.GetStep (PIOperation_PerformVE)));
   if (HasErrors()) {
-    return; 
+    return;
   }
   //
   UpdatePaveBlocksWithSDVertices();
   // 11
-  PerformEE(aPS.Next(aSteps[3]));
+  PerformEE (aPS.Next (aSteps.GetStep (PIOperation_PerformEE)));
   if (HasErrors()) {
-    return; 
+    return;
   }
   UpdatePaveBlocksWithSDVertices();
   // 02
-  PerformVF(aPS.Next(aSteps[4]));
+  PerformVF (aPS.Next (aSteps.GetStep (PIOperation_PerformVF)));
   if (HasErrors()) {
-    return; 
+    return;
   }
   UpdatePaveBlocksWithSDVertices();
   // 12
-  PerformEF(aPS.Next(aSteps[5]));
+  PerformEF (aPS.Next (aSteps.GetStep (PIOperation_PerformEF)));
   if (HasErrors()) {
-    return; 
+    return;
   }
   UpdatePaveBlocksWithSDVertices();
   UpdateInterfsWithSDVertices();
 
   // Repeat Intersection with increased vertices
-  RepeatIntersection(aPS.Next(aSteps[6]));
+  RepeatIntersection (aPS.Next (aSteps.GetStep (PIOperation_RepeatIntersection)));
   if (HasErrors())
     return;
   // Force intersection of edges after increase
   // of the tolerance values of their vertices
-  ForceInterfEE(aPS.Next(aSteps[7]));
+  ForceInterfEE (aPS.Next (aSteps.GetStep (PIOperation_ForceInterfEE)));
   if (HasErrors())
   {
     return;
   }
   // Force Edge/Face intersection after increase
   // of the tolerance values of their vertices
-  ForceInterfEF(aPS.Next(aSteps[8]));
+  ForceInterfEF (aPS.Next (aSteps.GetStep (PIOperation_ForceInterfEF)));
   if (HasErrors())
   {
     return;
   }
   //
   // 22
-  PerformFF(aPS.Next(aSteps[9]));
+  PerformFF (aPS.Next (aSteps.GetStep (PIOperation_PerformFF)));
   if (HasErrors()) {
-    return; 
+    return;
   }
   //
   UpdateBlocksWithSharedVertices();
   //
   myDS->RefineFaceInfoIn();
   //
-  MakeSplitEdges(aPS.Next(aSteps[10]));
+  MakeSplitEdges (aPS.Next (aSteps.GetStep (PIOperation_MakeSplitEdges)));
   if (HasErrors()) {
     return;
   }
   //
   UpdatePaveBlocksWithSDVertices();
   //
-  MakeBlocks(aPS.Next(aSteps[11]));
+  MakeBlocks (aPS.Next (aSteps.GetStep (PIOperation_MakeBlocks)));
   if (HasErrors()) {
-    return; 
+    return;
   }
   //
   CheckSelfInterference();
@@ -429,14 +359,14 @@ void BOPAlgo_PaveFiller::PerformInternal(const Message_ProgressRange& theRange)
   //
   RemoveMicroEdges();
   //
-  MakePCurves(aPS.Next(aSteps[12]));
+  MakePCurves (aPS.Next (aSteps.GetStep (PIOperation_MakePCurves)));
   if (HasErrors()) {
-    return; 
+    return;
   }
   //
-  ProcessDE();
+  ProcessDE (aPS.Next (aSteps.GetStep (PIOperation_ProcessDE)));
   if (HasErrors()) {
-    return; 
+    return;
   }
 }
 
@@ -444,59 +374,118 @@ void BOPAlgo_PaveFiller::PerformInternal(const Message_ProgressRange& theRange)
 // function: RepeatIntersection
 // purpose: 
 //=======================================================================
-void BOPAlgo_PaveFiller::RepeatIntersection(const Message_ProgressRange& theRange)
+void BOPAlgo_PaveFiller::RepeatIntersection (const Message_ProgressRange& theRange)
 {
   // Find all vertices with increased tolerance
   TColStd_MapOfInteger anExtraInterfMap;
   const Standard_Integer aNbS = myDS->NbSourceShapes();
-  Message_ProgressScope aPS(theRange, "Repeat intersection", 3);
+  Message_ProgressScope aPS (theRange, "Repeat intersection", 3);
   for (Standard_Integer i = 0; i < aNbS; ++i)
   {
-    if (UserBreak(aPS))
+    if (UserBreak (aPS))
     {
       return;
     }
-    const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
+    const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo (i);
     if (aSI.ShapeType() != TopAbs_VERTEX)
       continue;
     // Check if the tolerance of the original vertex has been increased
-    if (myIncreasedSS.Contains(i))
+    if (myIncreasedSS.Contains (i))
     {
-      anExtraInterfMap.Add(i);
+      anExtraInterfMap.Add (i);
       continue;
     }
 
     // Check if the vertex created a new vertex with greater tolerance
     Standard_Integer nVSD;
-    if (!myDS->HasShapeSD(i, nVSD))
+    if (!myDS->HasShapeSD (i, nVSD))
       continue;
 
-    if (myIncreasedSS.Contains(nVSD))
-      anExtraInterfMap.Add(i);
+    if (myIncreasedSS.Contains (nVSD))
+      anExtraInterfMap.Add (i);
   }
 
   if (anExtraInterfMap.IsEmpty())
     return;
 
   // Update iterator of pairs of shapes with interfering boxes
-  myIterator->IntersectExt(anExtraInterfMap);
+  myIterator->IntersectExt (anExtraInterfMap);
 
   // Perform intersections with vertices
 
-  PerformVV(aPS.Next());
+  PerformVV (aPS.Next());
   if (HasErrors())
     return;
   UpdatePaveBlocksWithSDVertices();
 
-  PerformVE(aPS.Next());
+  PerformVE (aPS.Next());
   if (HasErrors())
     return;
   UpdatePaveBlocksWithSDVertices();
 
-  PerformVF(aPS.Next());
+  PerformVF (aPS.Next());
   if (HasErrors())
     return;
 
   UpdatePaveBlocksWithSDVertices();
   UpdateInterfsWithSDVertices();
 }
+
+
+//=======================================================================
+// function: fillPISteps
+// purpose: 
+//=======================================================================
+void BOPAlgo_PaveFiller::fillPIConstants (const Standard_Real theWhole,
+                                          BOPAlgo_PISteps& theSteps) const
+{
+  if (!myNonDestructive)
+  {
+    theSteps.SetStep (PIOperation_Prepare, 1 * theWhole / 100.);
+  }
+}
+
+//=======================================================================
+// function: fillPISteps
+// purpose: 
+//=======================================================================
+void BOPAlgo_PaveFiller::fillPISteps (BOPAlgo_PISteps& theSteps) const
+{
+  // Get number of all intersecting pairs
+  Standard_Integer aVVSize = 0, aVESize = 0, aEESize = 0, aVFSize = 0, aEFSize = 0, aFFSize = 0;
+
+  myIterator->Initialize (TopAbs_VERTEX, TopAbs_VERTEX);
+  aVVSize = myIterator->ExpectedLength();
+
+  myIterator->Initialize (TopAbs_VERTEX, TopAbs_EDGE);
+  aVESize = myIterator->ExpectedLength();
+
+  myIterator->Initialize (TopAbs_EDGE, TopAbs_EDGE);
+  aEESize = myIterator->ExpectedLength();
+
+  myIterator->Initialize (TopAbs_VERTEX, TopAbs_FACE);
+  aVFSize = myIterator->ExpectedLength();
+
+  if (myGlue != BOPAlgo_GlueFull)
+  {
+    myIterator->Initialize (TopAbs_EDGE, TopAbs_FACE);
+    aEFSize = myIterator->ExpectedLength();
+  }
+
+  myIterator->Initialize (TopAbs_FACE, TopAbs_FACE);
+  aFFSize = myIterator->ExpectedLength();
+
+  theSteps.SetStep (PIOperation_PerformVV, aVVSize);
+  theSteps.SetStep (PIOperation_PerformVE, 2 * aVESize);
+  theSteps.SetStep (PIOperation_PerformEE, 5 * aEESize);
+  theSteps.SetStep (PIOperation_PerformVF, 5 * aVFSize);
+  theSteps.SetStep (PIOperation_PerformEF, 10 * aEFSize);
+  theSteps.SetStep (PIOperation_RepeatIntersection, 0.2 * (aVVSize + aVESize + aVFSize));
+  theSteps.SetStep (PIOperation_ForceInterfEE, 2 * aEESize);
+  theSteps.SetStep (PIOperation_ForceInterfEF, 2 * aEFSize);
+  theSteps.SetStep (PIOperation_PerformFF, (myGlue == BOPAlgo_GlueFull ? 1 : 30) * aFFSize);
+  theSteps.SetStep (PIOperation_MakeSplitEdges, aEESize);
+  theSteps.SetStep (PIOperation_MakeBlocks, (myGlue == BOPAlgo_GlueFull ? 0 : 5) * aFFSize);
+  theSteps.SetStep (PIOperation_MakePCurves, myAvoidBuildPCurve ? 0 : 0.2 * (aEESize + aEFSize));
+  theSteps.SetStep (PIOperation_ProcessDE, 0.1 * aEESize);
+}
index c2d55ff4e5c924b3c66ec0562232ee31b8ccba30..5906e8182593ada062431021d90e409b921ecaaf 100644 (file)
@@ -232,8 +232,6 @@ protected:
   Standard_EXPORT void SplitPaveBlocks(const TColStd_MapOfInteger& theMEdges,
                                        const Standard_Boolean theAddInterfs);
 
-  Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
   Standard_EXPORT virtual void PerformVF(const Message_ProgressRange& theRange);
   
   Standard_EXPORT virtual void PerformEE(const Message_ProgressRange& theRange);
@@ -256,7 +254,7 @@ protected:
   Standard_EXPORT Standard_Integer MakeSDVertices(const TColStd_ListOfInteger& theVertIndices,
                                                   const Standard_Boolean theAddInterfs = 1);
   
-  Standard_EXPORT void ProcessDE();
+  Standard_EXPORT void ProcessDE(const Message_ProgressRange& theRange);
   
   Standard_EXPORT void FillShrunkData (Handle(BOPDS_PaveBlock)& thePB);
   
@@ -345,7 +343,8 @@ protected:
                                     TColStd_DataMapOfIntegerInteger& theDMNewSD,
                                     const BOPDS_IndexedMapOfPaveBlock& theMicroPB,
                                     const TopTools_IndexedMapOfShape& theVertsOnRejectedPB,
-                                    const Handle(NCollection_BaseAllocator)& theAllocator);
+                                    const Handle(NCollection_BaseAllocator)& theAllocator,
+                                    const Message_ProgressRange& theRange);
   
   Standard_EXPORT void FindPaveBlocks (const Standard_Integer theV,
                                        const Standard_Integer theF,
@@ -636,6 +635,13 @@ protected:
     {}
   };
 
+protected: //! Analyzing Progress steps
+
+  //! Filling steps for constant operations
+  Standard_EXPORT void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+  //! Filling steps for all other operations
+  Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
 protected: //! Fields
 
   TopTools_ListOfShape myArguments;
index 8587ca63fd5f70556aa6806b9e0bb4a4a8e83e37..65f15f879b7e920fbfde234ee23c83c729afed02 100644 (file)
@@ -51,7 +51,7 @@ void BOPAlgo_PaveFiller::PerformVV(const Message_ProgressRange& theRange)
   //
   myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX);
   aSize=myIterator->ExpectedLength();
-  Message_ProgressScope aPS(theRange, "PerformVV", 1);
+  Message_ProgressScope aPS(theRange, NULL, 2.);
   if (!aSize) {
     return; 
   }
@@ -66,7 +66,9 @@ void BOPAlgo_PaveFiller::PerformVV(const Message_ProgressRange& theRange)
   NCollection_List<TColStd_ListOfInteger> aMBlocks(aAllocator);
   //
   // 1. Map V/LV
-  for (; myIterator->More(); myIterator->Next()) {
+  // Split progress range on intersection stage and making blocks. Display only intersection stage.
+  Message_ProgressScope aPSLoop(aPS.Next(1.), "Performing Vertex-Vertex intersection", aSize);
+  for (; myIterator->More(); myIterator->Next(), aPSLoop.Next()) {
     if (UserBreak(aPS))
     {
       return;
index dd8040749a4b1de09507de0c16ba483932601b5a..b82966efdb7f5f7085112805def3b7bb96075e58 100644 (file)
 //class    : BOPAlgo_VertexEdge
 //purpose  : 
 //=======================================================================
-class BOPAlgo_VertexEdge : public BOPAlgo_Algo {
+class BOPAlgo_VertexEdge : public BOPAlgo_ParallelAlgo {
 
  public:
   DEFINE_STANDARD_ALLOC
 
   BOPAlgo_VertexEdge() : 
-    BOPAlgo_Algo(),
+    BOPAlgo_ParallelAlgo(),
     myIV(-1), myIE(-1), myFlag(-1), myT(-1.), myTolVNew(-1.) {
   };
   //
@@ -109,13 +109,9 @@ class BOPAlgo_VertexEdge : public BOPAlgo_Algo {
   const Handle(BOPDS_PaveBlock)& PaveBlock() const {
     return myPB;
   }
-  void SetRange(const Message_ProgressRange& theRange)
-  {
-    myRange = theRange;
-  }
   //
   virtual void Perform() {
-    Message_ProgressScope aPS(myRange, NULL, 1);
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
     if (UserBreak(aPS))
     {
       return;
@@ -142,8 +138,6 @@ class BOPAlgo_VertexEdge : public BOPAlgo_Algo {
   TopoDS_Edge myE;
   Handle(IntTools_Context) myContext;
   Handle(BOPDS_PaveBlock) myPB;
-private:
-  Message_ProgressRange myRange;
 };
 //=======================================================================
 typedef NCollection_Vector<BOPAlgo_VertexEdge> BOPAlgo_VectorOfVertexEdge;
@@ -158,6 +152,7 @@ void BOPAlgo_PaveFiller::PerformVE(const Message_ProgressRange& theRange)
   //
   myIterator->Initialize(TopAbs_VERTEX, TopAbs_EDGE);
   Message_ProgressScope aPS(theRange, NULL, 1);
+
   Standard_Integer iSize = myIterator->ExpectedLength();
   if (!iSize) {
     return; 
@@ -237,7 +232,7 @@ void BOPAlgo_PaveFiller::IntersectVE
   // intersection of the same SD vertex with edge
   NCollection_DataMap<BOPDS_Pair, TColStd_ListOfInteger, BOPDS_PairMapHasher> aDMVSD;
   //
-  Message_ProgressScope aPSOuter(theRange, "Intersecting vertices with edges", 1);
+  Message_ProgressScope aPSOuter(theRange, NULL, 10);
   for (i = 1; i <= aNbVE; ++i) {
     if (UserBreak(aPSOuter))
     {
@@ -290,11 +285,11 @@ void BOPAlgo_PaveFiller::IntersectVE
   //
   aNbVE = aVVE.Length();
 
-  Message_ProgressScope aPS(aPSOuter.Next(), "Intersecting vertices with edges", aNbVE);
+  Message_ProgressScope aPS(aPSOuter.Next(9), "Performing Vertex-Edge intersection", aNbVE);
   for (i = 0; i < aVVE.Length(); i++)
   {
     BOPAlgo_VertexEdge& aVESolver = aVVE.ChangeValue(i);
-    aVESolver.SetRange(aPS.Next());
+    aVESolver.SetProgressRange(aPS.Next());
   }
   // Perform intersection
   //=============================================================
index 1cefdbf7f69833d703d664a682caae5e149e96c2..9eb030eeb6dfc0b12fce018019f07f7da7fe0fc3 100644 (file)
@@ -60,7 +60,7 @@
 //=======================================================================
 class BOPAlgo_EdgeEdge : 
   public IntTools_EdgeEdge,
-  public BOPAlgo_Algo {
+  public BOPAlgo_ParallelAlgo {
  
  public:
 
@@ -68,7 +68,7 @@ class BOPAlgo_EdgeEdge :
   //
   BOPAlgo_EdgeEdge(): 
     IntTools_EdgeEdge(),
-    BOPAlgo_Algo() {
+    BOPAlgo_ParallelAlgo() {
   };
   //
   virtual ~BOPAlgo_EdgeEdge(){
@@ -101,13 +101,8 @@ class BOPAlgo_EdgeEdge :
     IntTools_EdgeEdge::SetFuzzyValue(theFuzz);
   }
   //
-  void SetRange(const Message_ProgressRange& theRange)
-  {
-    myRange = theRange;
-  }
-  //
   virtual void Perform() {
-    Message_ProgressScope aPS(myRange, NULL, 1);
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
     if (UserBreak(aPS))
     {
       return;
@@ -155,8 +150,6 @@ class BOPAlgo_EdgeEdge :
   Handle(BOPDS_PaveBlock) myPB2;
   Bnd_Box myBox1;
   Bnd_Box myBox2;
-private:
-  Message_ProgressRange myRange;
 };
 //
 //=======================================================================
@@ -172,7 +165,7 @@ void BOPAlgo_PaveFiller::PerformEE(const Message_ProgressRange& theRange)
   //
   myIterator->Initialize(TopAbs_EDGE, TopAbs_EDGE);
   Standard_Integer iSize = myIterator->ExpectedLength();
-  Message_ProgressScope aPSOuter(theRange, NULL, 100);
+  Message_ProgressScope aPSOuter(theRange, NULL, 10);
   if (!iSize) {
     return; 
   }
@@ -283,11 +276,11 @@ void BOPAlgo_PaveFiller::PerformEE(const Message_ProgressRange& theRange)
   //
   aNbEdgeEdge=aVEdgeEdge.Length();
 
-  Message_ProgressScope aPS(aPSOuter.Next(90), "Edge-edge perform", aNbEdgeEdge);
+  Message_ProgressScope aPS(aPSOuter.Next(9), "Performing Edge-edge intersection", aNbEdgeEdge);
   for (k = 0; k < aNbEdgeEdge; k++)
   {
     BOPAlgo_EdgeEdge& anEdgeEdge = aVEdgeEdge.ChangeValue(k);
-    anEdgeEdge.SetRange(aPS.Next());
+    anEdgeEdge.SetProgressRange(aPS.Next());
   }
   //======================================================
   BOPTools_Parallel::Perform (myRunParallel, aVEdgeEdge);
@@ -558,7 +551,7 @@ void BOPAlgo_PaveFiller::PerformEE(const Message_ProgressRange& theRange)
   // Update vertices of common blocks with real CB tolerances
   UpdateVerticesOfCB();
 
-  PerformNewVertices(aMVCPB, aAllocator, aPSOuter.Next(10));
+  PerformNewVertices(aMVCPB, aAllocator, aPSOuter.Next());
   if (HasErrors())
   {
     return;
@@ -610,7 +603,7 @@ void BOPAlgo_PaveFiller::PerformNewVertices
     // 4. Compute Extra Paves and split Pave blocks by the Extra paves
   Message_ProgressScope aPS(theRange, NULL, 2);
   Standard_Integer i, aNb = aImages.Extent();
-  Message_ProgressScope aPS1(aPS.Next(), "Performing new vertices", aNb + aNbV);
+  Message_ProgressScope aPS1(aPS.Next(), NULL, aNb + aNbV);
   for (i = 1; i <= aNb; ++i, aPS1.Next()) {
     if (UserBreak(aPS))
     {
@@ -965,7 +958,7 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange)
   // those pairs of pave blocks with the same bounding vertices.
 
   Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
-  Message_ProgressScope aPSOuter(theRange, NULL, 1);
+  Message_ProgressScope aPSOuter(theRange, NULL, 10);
   // Initialize pave blocks for all vertices which participated in intersections
   const Standard_Integer aNbS = myDS->NbSourceShapes();
   for (Standard_Integer i = 0; i < aNbS; ++i)
@@ -1163,15 +1156,18 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange)
   if (!aNbPairs)
     return;
 
+  // close preparation step
+  aPSOuter.Next(0.7).Close();
+
   aPBMap.Clear();
   aMPBFence.Clear();
   anAlloc->Reset();
 
-  Message_ProgressScope aPS(aPSOuter.Next(), "Intersection edge-edge", aNbPairs);
+  Message_ProgressScope aPS(aPSOuter.Next(9), "Checking for coinciding edges", aNbPairs);
   for (Standard_Integer i = 0; i < aNbPairs; i++)
   {
     BOPAlgo_EdgeEdge& anEdgeEdge = aVEdgeEdge.ChangeValue(i);
-    anEdgeEdge.SetRange(aPS.Next());
+    anEdgeEdge.SetProgressRange(aPS.Next());
   }
 
   // Perform intersection of the found pairs
index 984204b75b6e5eaa85bd9458a992b88c6bc74238..0eca3667a7f7f686ba15f8dd1cb927762390270e 100644 (file)
 //class    : BOPAlgo_VertexFace
 //purpose  : 
 //=======================================================================
-class BOPAlgo_VertexFace : public BOPAlgo_Algo {
+class BOPAlgo_VertexFace : public BOPAlgo_ParallelAlgo {
  public:
   DEFINE_STANDARD_ALLOC
 
   BOPAlgo_VertexFace() : 
-    BOPAlgo_Algo(),
+    BOPAlgo_ParallelAlgo(),
     myIV(-1), myIF(-1),
     myFlag(-1), myT1(-1.),  myT2(-1.), myTolVNew(-1.) {
   }
@@ -106,13 +106,8 @@ class BOPAlgo_VertexFace : public BOPAlgo_Algo {
     return myContext;
   }
   //
-  void SetRange(const Message_ProgressRange& theRange)
-  {
-    myRange = theRange;
-  }
-  //
   virtual void Perform() {
-    Message_ProgressScope aPS(myRange, NULL, 1);
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
     if (UserBreak(aPS))
     {
       return;
@@ -139,8 +134,6 @@ class BOPAlgo_VertexFace : public BOPAlgo_Algo {
   TopoDS_Vertex myV;
   TopoDS_Face myF;
   Handle(IntTools_Context) myContext;
-private:
-  Message_ProgressRange myRange;
 };
 //=======================================================================
 typedef NCollection_Vector<BOPAlgo_VertexFace> BOPAlgo_VectorOfVertexFace;
@@ -156,7 +149,7 @@ void BOPAlgo_PaveFiller::PerformVF(const Message_ProgressRange& theRange)
   //
   Standard_Integer nV, nF;
   //
-  Message_ProgressScope aPSOuter(theRange, NULL, 1);
+  Message_ProgressScope aPSOuter(theRange, NULL, 10);
   if (myGlue == BOPAlgo_GlueFull) {
     // there is no need to intersect vertices with faces in this mode
     // just initialize FaceInfo for all faces
@@ -236,11 +229,11 @@ void BOPAlgo_PaveFiller::PerformVF(const Message_ProgressRange& theRange)
   }//for (; myIterator->More(); myIterator->Next()) {
   //
   aNbVF=aVVF.Length();
-  Message_ProgressScope aPS(aPSOuter.Next(), "Vertex-face perform", aNbVF);
+  Message_ProgressScope aPS(aPSOuter.Next(9), "Performing Vertex-Face intersection", aNbVF);
   for (k = 0; k < aNbVF; k++)
   {
     BOPAlgo_VertexFace& aVertexFace = aVVF.ChangeValue(k);
-    aVertexFace.SetRange(aPS.Next());
+    aVertexFace.SetProgressRange(aPS.Next());
   }
   //================================================================
   BOPTools_Parallel::Perform (myRunParallel, aVVF, myContext);
index abda6a57b091262031979ac638d0de01ec14b948..77b8c718dfa9113ea6ad9ee7cccd4cd6f72976d0 100644 (file)
 //=======================================================================
 class BOPAlgo_EdgeFace : 
   public IntTools_EdgeFace,
-  public BOPAlgo_Algo {
+  public BOPAlgo_ParallelAlgo {
  
  public:
   DEFINE_STANDARD_ALLOC
   
   BOPAlgo_EdgeFace() : 
     IntTools_EdgeFace(), 
-    BOPAlgo_Algo(),
+    BOPAlgo_ParallelAlgo(),
     myIE(-1), myIF(-1) {
   };
   //
@@ -112,13 +112,8 @@ class BOPAlgo_EdgeFace :
     myBox2 = theBox2;
   }
   //
-  void SetProgress (const Message_ProgressRange& theRange)
-  {
-    myRange = theRange;
-  }
-  //
   virtual void Perform() {
-    Message_ProgressScope aPS(myRange, NULL, 1);
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
     if (UserBreak(aPS))
     {
       return;
@@ -167,9 +162,6 @@ class BOPAlgo_EdgeFace :
   Handle(BOPDS_PaveBlock) myPB;
   Bnd_Box myBox1;
   Bnd_Box myBox2;
-  
-private:
-  Message_ProgressRange myRange;
 };
 //
 //=======================================================================
@@ -184,7 +176,7 @@ void BOPAlgo_PaveFiller::PerformEF(const Message_ProgressRange& theRange)
   FillShrunkData(TopAbs_EDGE, TopAbs_FACE);
   //
   myIterator->Initialize(TopAbs_EDGE, TopAbs_FACE);
-  Message_ProgressScope aPSOuter(theRange, "Intersecting edges with faces", 100);
+  Message_ProgressScope aPSOuter(theRange, NULL, 10);
   Standard_Integer iSize = myIterator->ExpectedLength();
   if (!iSize) {
     return; 
@@ -309,11 +301,11 @@ void BOPAlgo_PaveFiller::PerformEF(const Message_ProgressRange& theRange)
   }//for (; myIterator->More(); myIterator->Next()) {
   //
   aNbEdgeFace=aVEdgeFace.Length();
-  Message_ProgressScope aPS(aPSOuter.Next(90), "Edge-face perform", aNbEdgeFace);
+  Message_ProgressScope aPS(aPSOuter.Next(9), "Performing Edge-Face intersection", aNbEdgeFace);
   for (Standard_Integer index = 0; index < aNbEdgeFace; index++)
   {
     BOPAlgo_EdgeFace& aEdgeFace = aVEdgeFace.ChangeValue(index);
-    aEdgeFace.SetProgress(aPS.Next());
+    aEdgeFace.SetProgressRange(aPS.Next());
   }
   //=================================================================
   BOPTools_Parallel::Perform (myRunParallel, aVEdgeFace, myContext);
@@ -560,7 +552,7 @@ void BOPAlgo_PaveFiller::PerformEF(const Message_ProgressRange& theRange)
   //=========================================
   BOPAlgo_Tools::PerformCommonBlocks(aMPBLI, aAllocator, myDS, myContext);
   UpdateVerticesOfCB();
-  PerformNewVertices(aMVCPB, aAllocator, aPSOuter.Next(10), Standard_False);
+  PerformNewVertices(aMVCPB, aAllocator, aPSOuter.Next(1), Standard_False);
   if (HasErrors())
   {
     return;
@@ -830,7 +822,8 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
                                        const Message_ProgressRange& theRange,
                                        const Standard_Boolean theAddInterf)
 {
-  Message_ProgressScope aPSOuter(theRange, NULL, 1);
+  // Split progress on preparation, intersection and post-treatment stages
+  Message_ProgressScope aPSOuter(theRange, NULL, 10);
   if (theMPB.IsEmpty())
     return;
   // Fill the tree with bounding boxes of the pave blocks
@@ -1074,16 +1067,21 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
 
   Standard_Integer aNbEFs = aVEdgeFace.Length();
   if (!aNbEFs)
+  {
     return;
+  }
+
+  // close preparation step
+  aPSOuter.Next(0.7).Close();
 
   aPBMap.Clear();
   anAlloc->Reset();
 
-  Message_ProgressScope aPS(aPSOuter.Next(), "Checking for coinciding edges and faces", aNbEFs);
+  Message_ProgressScope aPS(aPSOuter.Next(9), "Checking for edges coinciding with faces", aNbEFs);
   for (Standard_Integer i = 0; i < aNbEFs; i++)
   {
     BOPAlgo_EdgeFace& aEdgeFace = aVEdgeFace.ChangeValue(i);
-    aEdgeFace.SetProgress(aPS.Next());
+    aEdgeFace.SetProgressRange(aPS.Next());
   }
   // Perform intersection of the found pairs
   BOPTools_Parallel::Perform (myRunParallel, aVEdgeFace, myContext);
index 6b755f6b85ed907957f3e45d46cf8ac226f30eca..46e4fa1d42f083677c1c1a0ec7bf91bf7800d724 100644 (file)
@@ -92,14 +92,14 @@ static Standard_Real ToleranceFF(const BRepAdaptor_Surface& aBAS1,
 //=======================================================================
 class BOPAlgo_FaceFace : 
   public IntTools_FaceFace,
-  public BOPAlgo_Algo {
+  public BOPAlgo_ParallelAlgo {
 
  public:
   DEFINE_STANDARD_ALLOC
 
   BOPAlgo_FaceFace() : 
     IntTools_FaceFace(),  
-    BOPAlgo_Algo(),
+    BOPAlgo_ParallelAlgo(),
     myIF1(-1), myIF2(-1), myTolFF(1.e-7) {
   }
   //
@@ -150,15 +150,10 @@ class BOPAlgo_FaceFace :
     IntTools_FaceFace::SetFuzzyValue(theFuzz);
   }
   //
-  void SetProgress(const Message_ProgressRange& theRange)
-  {
-    myRange = theRange;
-  }
-  //
   const gp_Trsf& Trsf() const { return myTrsf; }
   //
   virtual void Perform() {
-    Message_ProgressScope aPS(myRange, NULL, 1);
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
     if (UserBreak(aPS))
     {
       return;
@@ -230,9 +225,6 @@ class BOPAlgo_FaceFace :
   Bnd_Box myBox1;
   Bnd_Box myBox2;
   gp_Trsf myTrsf;
-
-  private:
-    Message_ProgressRange myRange;
 };
 //
 //=======================================================================
@@ -337,11 +329,11 @@ void BOPAlgo_PaveFiller::PerformFF(const Message_ProgressRange& theRange)
   }//for (; myIterator->More(); myIterator->Next()) {
   //
   Standard_Integer k, aNbFaceFace = aVFaceFace.Length();;
-  Message_ProgressScope aPS(aPSOuter.Next(), "Intersecting faces", aNbFaceFace);
+  Message_ProgressScope aPS(aPSOuter.Next(), "Performing Face-Face intersection", aNbFaceFace);
   for (k = 0; k < aVFaceFace.Size(); k++)
   {
     BOPAlgo_FaceFace& aFaceFace = aVFaceFace.ChangeValue(k);
-    aFaceFace.SetProgress(aPS.Next());
+    aFaceFace.SetProgressRange(aPS.Next());
   }
   //======================================================
   // Perform intersection
@@ -461,14 +453,14 @@ static void UpdateSavedTolerance(const BOPDS_PDS& theDS,
 //=======================================================================
 void BOPAlgo_PaveFiller::MakeBlocks(const Message_ProgressRange& theRange)
 {
-  Message_ProgressScope aPSOuter(theRange, NULL, 2);
+  Message_ProgressScope aPSOuter(theRange, NULL, 4);
   if (myGlue != BOPAlgo_GlueOff) {
     return;
   }
   //
   BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
   Standard_Integer aNbFF = aFFs.Length();
-  Message_ProgressScope aPS(aPSOuter.Next(), "Making blocks", aNbFF);
+  Message_ProgressScope aPS(aPSOuter.Next(), "Building section edges", aNbFF);
   if (!aNbFF) {
     return;
   }
@@ -817,7 +809,7 @@ void BOPAlgo_PaveFiller::MakeBlocks(const Message_ProgressRange& theRange)
 
   // post treatment
   MakeSDVerticesFF(aDMVLV, aDMNewSD);
-  PostTreatFF(aMSCPB, aDMExEdges, aDMNewSD, aMicroPB, aVertsOnRejectedPB, aAllocator);
+  PostTreatFF(aMSCPB, aDMExEdges, aDMNewSD, aMicroPB, aVertsOnRejectedPB, aAllocator, aPSOuter.Next(2));
   if (HasErrors()) {
     return;
   }
@@ -878,7 +870,8 @@ void BOPAlgo_PaveFiller::PostTreatFF
      TColStd_DataMapOfIntegerInteger& aDMNewSD,
      const BOPDS_IndexedMapOfPaveBlock& theMicroPB,
      const TopTools_IndexedMapOfShape& theVertsOnRejectedPB,
-     const Handle(NCollection_BaseAllocator)& theAllocator)
+     const Handle(NCollection_BaseAllocator)& theAllocator,
+     const Message_ProgressRange& theRange)
 {
   Standard_Integer aNbS = theMSCPB.Extent();
   if (!aNbS) {
@@ -1059,10 +1052,12 @@ void BOPAlgo_PaveFiller::PostTreatFF
     }
   }
   //
+  Message_ProgressScope aPS(theRange, "Intersection of section edges", 1);
+
   // 2 Fuse shapes
   aPF.SetRunParallel(myRunParallel);
   aPF.SetArguments(aLS);
-  aPF.Perform();
+  aPF.Perform(aPS.Next());
   if (aPF.HasErrors()) {
     AddError (new BOPAlgo_AlertPostTreatFF);
     return;
index 2400febd33b207e359b08b5a6732c5b0f5f5f29f..1ba29aae8a6f64b2739befe7c9509dac12b5e385 100644 (file)
@@ -74,13 +74,13 @@ static void UpdateVertices(const TopoDS_Edge& aE,
 //class    : BOPAlgo_SplitEdge
 //purpose  : 
 //=======================================================================
-class BOPAlgo_SplitEdge : public BOPAlgo_Algo  {
+class BOPAlgo_SplitEdge : public BOPAlgo_ParallelAlgo  {
  
  public:
   DEFINE_STANDARD_ALLOC
 
   BOPAlgo_SplitEdge() :
-    BOPAlgo_Algo() {
+    BOPAlgo_ParallelAlgo() {
     myT1=0.;
     myT2=0.;
     myTol = 0.;
@@ -138,13 +138,8 @@ class BOPAlgo_SplitEdge : public BOPAlgo_Algo  {
     myContext = aContext;
   }
   //
-  void SetRange(const Message_ProgressRange& theRange)
-  {
-    myRange = theRange;
-  }
-  //
   virtual void Perform () {
-    Message_ProgressScope aPS(myRange, NULL, 1);
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
     if (UserBreak(aPS))
     {
       return;
@@ -175,8 +170,6 @@ class BOPAlgo_SplitEdge : public BOPAlgo_Algo  {
   //
   BOPDS_PDS   myDS;
   Handle(IntTools_Context) myContext;
-private:
-  Message_ProgressRange myRange;
 };
 //
 //=======================================================================
@@ -186,13 +179,13 @@ typedef NCollection_Vector<BOPAlgo_SplitEdge> BOPAlgo_VectorOfSplitEdge;
 //class    : BOPAlgo_MPC
 //purpose  : 
 //=======================================================================
-class BOPAlgo_MPC : public BOPAlgo_Algo  {
+class BOPAlgo_MPC : public BOPAlgo_ParallelAlgo  {
  
  public:
   DEFINE_STANDARD_ALLOC
 
   BOPAlgo_MPC() : 
-    BOPAlgo_Algo(),
+    BOPAlgo_ParallelAlgo(),
     myFlag(Standard_False) {
   };
   //
@@ -243,13 +236,8 @@ class BOPAlgo_MPC : public BOPAlgo_Algo  {
     return myContext;
   }
   //
-  void SetRange(const Message_ProgressRange& theRange)
-  {
-    myRange = theRange;
-  }
-  //
   virtual void Perform() {
-    Message_ProgressScope aPS(myRange, NULL, 1);
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
     if (UserBreak(aPS))
     {
       return;
@@ -339,8 +327,6 @@ class BOPAlgo_MPC : public BOPAlgo_Algo  {
   Standard_Real myNewTol;
   //
   Handle(IntTools_Context) myContext;
- private:
-   Message_ProgressRange myRange;
 };
 //
 //=======================================================================
@@ -527,11 +513,11 @@ void BOPAlgo_PaveFiller::MakeSplitEdges(const Message_ProgressRange& theRange)
   }  // for (i=0; i<aNbPBP; ++i) {      
   //
   aNbVBSE=aVBSE.Length();
-  Message_ProgressScope aPS(aPSOuter.Next(), "MakeSplitEdges", aNbVBSE);
+  Message_ProgressScope aPS(aPSOuter.Next(), "Splitting edges", aNbVBSE);
   for (k = 0; k < aNbVBSE; k++)
   {
     BOPAlgo_SplitEdge& aBSE = aVBSE.ChangeValue(k);
-    aBSE.SetRange(aPS.Next());
+    aBSE.SetProgressRange(aPS.Next());
   }
   //======================================================
   BOPTools_Parallel::Perform (myRunParallel, aVBSE, myContext);
@@ -776,7 +762,7 @@ void BOPAlgo_PaveFiller::MakePCurves(const Message_ProgressRange& theRange)
   for (i = 0; i < aVMPC.Length(); i++)
   {
     BOPAlgo_MPC& aMPC = aVMPC.ChangeValue(i);
-    aMPC.SetRange(aPS.Next());
+    aMPC.SetProgressRange(aPS.Next());
   }
   //======================================================
   BOPTools_Parallel::Perform (myRunParallel, aVMPC, myContext);
index 69619a00439161438f16f5deff1bbf27c32ea801..1a2ab61bbbacbc1dadf396157b314a17ed25d288 100644 (file)
@@ -62,8 +62,10 @@ static
 //function : ProcessDE
 //purpose  : 
 //=======================================================================
-void BOPAlgo_PaveFiller::ProcessDE()
+void BOPAlgo_PaveFiller::ProcessDE(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPSOuter(theRange, NULL, 1);
+
   Standard_Integer nF, aNb, nE, nV, nVSD, aNbPB;
   Handle(NCollection_BaseAllocator) aAllocator;
   Handle(BOPDS_PaveBlock) aPBD;
@@ -78,6 +80,10 @@ void BOPAlgo_PaveFiller::ProcessDE()
   //
   aNb=myDS->NbSourceShapes();
   for (nE=0; nE<aNb; ++nE) {
+    if (UserBreak(aPSOuter))
+    {
+      return;
+    }
     const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
     if (aSIE.ShapeType()==TopAbs_EDGE) {
       if (aSIE.HasFlag(nF)) {
@@ -89,7 +95,7 @@ void BOPAlgo_PaveFiller::ProcessDE()
         //nV,nE,nF
         //
         if (aSIF.ShapeType() == TopAbs_FACE) {
-          // 1. Find PaveBlocks that are go through nV for nF
+          // 1. Find PaveBlocks that go through nV for nF
           FindPaveBlocks(nV, nF, aLPBOut);
           aNbPB=aLPBOut.Extent();
           if (aNbPB) {
index 1a5e060e2487fdf4ab7c531d87ec874587603bd7..f792974d4c5d266679f82e69c08300bd20dc6b0e 100644 (file)
@@ -85,54 +85,35 @@ void BOPAlgo_Section::CheckData()
 }
 
 //=======================================================================
-//function : AnalyzeProgress
-//purpose  
+// function: fillPIConstants
+// purpose
 //=======================================================================
-NCollection_Array1<Standard_Real> BOPAlgo_Section::AnalyzeProgress()
+void BOPAlgo_Section::fillPIConstants (const Standard_Real theWhole,
+                                       BOPAlgo_PISteps& theSteps) const
 {
-  Standard_Integer aSize = 3;
-  NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
-  for (Standard_Integer i = 0; i < aSize; i++)
-  {
-    aSteps(i) = 0;
-  }
-
-  Standard_Real aPart = 100.;
-  Standard_Integer aNbV = myDS->ShapesSD().Size();
-  Standard_Integer aNbE = 0;
-  Standard_Integer aNbF = 0;
-  for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); i++)
-  {
-    const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
-    switch (aSI.ShapeType())
-    {
-    case TopAbs_EDGE:
-      aNbE++;
-      break;
-    case TopAbs_FACE:
-      aNbF++;
-      break;
-    default:
-      break;
-    }
-  }
-
-  aNbE = 5 * aNbE;
-  aNbF = 20 * aNbF;
-
-  Standard_Real aSum = aNbV + aNbE + aNbF;
-  if (aSum == 0)
+  // Fill in the constants:
+  if (myFillHistory)
   {
-    return aSteps;
+    // for FillHistroty, which takes about 10% of the whole operation
+    theSteps.SetStep(PIOperation_FillHistory, 10. * theWhole / 100.);
   }
 
-  aSteps(0) = aPart * aNbV / aSum;
-  aSteps(1) = aPart * aNbE / aSum;
-  aSteps(2) = aPart * aNbF / aSum;
-
-  return aSteps;
+  // and for PostTreat, which takes about 5% of the whole operation 
+  theSteps.SetStep(PIOperation_PostTreat, 5. * theWhole / 100.);
 }
 
+//=======================================================================
+// function: fillPISteps
+// purpose: 
+//=======================================================================
+void BOPAlgo_Section::fillPISteps (BOPAlgo_PISteps& theSteps) const
+{
+  // Compute the rest of the operations - all depend on the number of sub-shapes of certain type
+  NbShapes aNbShapes = getNbShapes();
+  theSteps.SetStep(PIOperation_TreatVertices, aNbShapes.NbVertices());
+  theSteps.SetStep(PIOperation_TreatEdges, aNbShapes.NbEdges());
+  theSteps.SetStep(PIOperation_BuildSection, aNbShapes.NbEdges() + aNbShapes.NbFaces());
+}
 //=======================================================================
 //function : PerformInternal1
 //purpose  : 
@@ -140,6 +121,7 @@ NCollection_Array1<Standard_Real> BOPAlgo_Section::AnalyzeProgress()
 void BOPAlgo_Section::PerformInternal1
   (const BOPAlgo_PaveFiller& theFiller, const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS(theRange, "Building result of SECTION operation", 100);
   myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
   myDS=myPaveFiller->PDS();
   myContext=myPaveFiller->Context();
@@ -156,11 +138,11 @@ void BOPAlgo_Section::PerformInternal1
     return;
   }
   //
-  Message_ProgressScope aPS(theRange, "Building result of SECTION operation", 100);
-  NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
+  BOPAlgo_PISteps aSteps (PIOperation_Last);
+  analyzeProgress(100., aSteps);
   // 3. Fill Images
   // 3.1 Vertices
-  FillImagesVertices(aPS.Next(aSteps(0)));
+  FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
   if (HasErrors()) {
     return;
   }
@@ -170,7 +152,7 @@ void BOPAlgo_Section::PerformInternal1
     return;
   }
   // 3.2 Edges
-  FillImagesEdges(aPS.Next(aSteps(1)));
+  FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
   if (HasErrors()) {
     return;
   }
@@ -180,19 +162,17 @@ void BOPAlgo_Section::PerformInternal1
     return;
   }
   // 4. Section
-  BuildSection(aPS.Next(aSteps(2)));
-  //
+  BuildSection(aPS.Next(aSteps.GetStep(PIOperation_BuildSection)));
   if (HasErrors()) {
     return;
   }
   // 5.History
-  PrepareHistory();
-  //
+  PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
   if (HasErrors()) {
     return;
   } 
   // 6. Post-treatment
-  PostTreat();
+  PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
 }
 //=======================================================================
 //function : BuildSection
@@ -200,7 +180,7 @@ void BOPAlgo_Section::PerformInternal1
 //=======================================================================
 void BOPAlgo_Section::BuildSection(const Message_ProgressRange& theRange)
 {
-  Message_ProgressScope aPS(theRange, "BuildSection", 1);
+  Message_ProgressScope aPS(theRange, "Building the result of Section operation", 1);
   Standard_Integer i, aNbMS, aNbLE;
   Standard_Integer j,  nE, nV, aNb, aNbF, aNbPBSc;
   TopoDS_Shape aRC, aRC1;
index 89117ccbc7213ff4c2ef870cbf2e5feb476fa13a..fde4a020a1189d0df1d206e29249a76ae0cd4be7 100644 (file)
@@ -55,13 +55,29 @@ protected:
   //! Combine the result of section operation
   Standard_EXPORT virtual void BuildSection(const Message_ProgressRange& theRange);
 
-  //! AnalyzeProgress
-  Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-
   //! Performs calculations using prepared Filler object <thePF>
   Standard_EXPORT virtual void PerformInternal1(const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange) Standard_OVERRIDE;
 
-private:
+protected:
+
+  //! List of operations to be supported by the Progress Indicator.
+  //! Override the whole enumeration here since the constant operations are also
+  //! going to be overridden.
+  enum BOPAlgo_PIOperation
+  {
+    PIOperation_TreatVertices = 0,
+    PIOperation_TreatEdges,
+    PIOperation_BuildSection,
+    PIOperation_FillHistory,
+    PIOperation_PostTreat,
+    PIOperation_Last
+  };
+
+  //! Filling steps for constant operations
+  Standard_EXPORT void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
+  //! Filling steps for all other operations
+  Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
 
 };
 
index 033d441246f8948caf579e856754a3021737b4d9..107a86a4b57bdb03413bc609407f6c5a281d371f 100644 (file)
@@ -64,11 +64,22 @@ class BOPAlgo_CBK {
     return *myPCB;
   }
   //
+  void SetProgressRange(const Message_ProgressRange& theRange)
+  {
+    myProgressRange = theRange;
+  }
+  //
   void Perform() {
+    Message_ProgressScope aPS(myProgressRange, NULL, 1);
+    if (!aPS.More())
+    {
+      return;
+    }
     BOPAlgo_ShellSplitter::SplitBlock(*myPCB);
   }
  protected:
   BOPTools_ConnexityBlock *myPCB;
+  Message_ProgressRange myProgressRange;
 };
 //=======================================================================
 typedef NCollection_Vector<BOPAlgo_CBK> BOPAlgo_VectorOfCBK;
@@ -133,14 +144,19 @@ const TopTools_ListOfShape& BOPAlgo_ShellSplitter::Shells()const
 //function : Perform
 //purpose  : 
 //=======================================================================
-void BOPAlgo_ShellSplitter::Perform(const Message_ProgressRange& /*theRange*/)
+void BOPAlgo_ShellSplitter::Perform(const Message_ProgressRange& theRange)
 {
   GetReport()->Clear();
+  Message_ProgressScope aPS(theRange, "Building shells", 1);
   //
   BOPTools_AlgoTools::MakeConnexityBlocks
     (myStartShapes, TopAbs_EDGE, TopAbs_FACE, myLCB);
-  //
-  MakeShells();
+  if (UserBreak (aPS))
+  {
+    return;
+  }
+
+  MakeShells(aPS.Next());
 }
 
 //=======================================================================
@@ -535,7 +551,7 @@ void RefineShell(TopoDS_Shell& theShell,
 //function : MakeShells
 //purpose  : 
 //=======================================================================
-void BOPAlgo_ShellSplitter::MakeShells()
+void BOPAlgo_ShellSplitter::MakeShells(const Message_ProgressRange& theRange)
 {
   Standard_Boolean bIsRegular;
   Standard_Integer aNbVCBK, k;
@@ -543,10 +559,15 @@ void BOPAlgo_ShellSplitter::MakeShells()
   TopTools_ListIteratorOfListOfShape aIt;
   BOPAlgo_VectorOfCBK aVCBK;
   //
+  Message_ProgressScope aPSOuter(theRange, NULL, 1);
   myShells.Clear();
   //
   aItCB.Initialize(myLCB);
   for (; aItCB.More(); aItCB.Next()) {
+    if (UserBreak (aPSOuter))
+    {
+      return;
+    }
     BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue();
     bIsRegular=aCB.IsRegular();
     if (bIsRegular) {
@@ -564,6 +585,11 @@ void BOPAlgo_ShellSplitter::MakeShells()
   }
   //
   aNbVCBK=aVCBK.Length();
+  Message_ProgressScope aPSParallel(aPSOuter.Next(), NULL, aNbVCBK);
+  for (Standard_Integer iS = 0; iS < aNbVCBK; ++iS)
+  {
+    aVCBK.ChangeValue(iS).SetProgressRange(aPSParallel.Next());
+  }
   //===================================================
   BOPTools_Parallel::Perform (myRunParallel, aVCBK);
   //===================================================
index 8f2d42cb5c463cb0c003477281165ef9210b280d..71a341f1d776e92ded42c5c72731e81af21d45f5 100644 (file)
@@ -61,7 +61,7 @@ Standard_EXPORT virtual ~BOPAlgo_ShellSplitter();
 
 protected:
 
-  Standard_EXPORT void MakeShells();
+  Standard_EXPORT void MakeShells(const Message_ProgressRange& theRange);
 
 
   TopTools_ListOfShape myStartShapes;
index 88088f2175e82be7207fee6e6c1e3e74de8f4710..735b83eda14a3f3081e714981ffa085d6d1f04f1 100644 (file)
@@ -95,7 +95,7 @@ void BOPAlgo_Splitter::Perform(const Message_ProgressRange& theRange)
   pPF->SetGlue(myGlue);
   pPF->SetUseOBB(myUseOBB);
   //
-  Message_ProgressScope aPS(theRange, "BOPAlgo_Splitter", 10);
+  Message_ProgressScope aPS(theRange, "Performing Split operation", 10);
   pPF->Perform(aPS.Next(9));
   if (HasErrors())
   {
index 4f4e292ad6b048f87d375db593be72a01bc0c59c..8bc5b551d9f5d4b83df9e318adc6670046386603 100644 (file)
@@ -1143,7 +1143,7 @@ typedef NCollection_Vector<BOPAlgo_ShapeBox> BOPAlgo_VectorOfShapeBox;
 //class : BOPAlgo_FillIn3DParts
 //purpose : Auxiliary class for faces classification in parallel mode
 //=======================================================================
-class BOPAlgo_FillIn3DParts : public BOPAlgo_Algo
+class BOPAlgo_FillIn3DParts : public BOPAlgo_ParallelAlgo
 {
 public:
   DEFINE_STANDARD_ALLOC
@@ -1219,7 +1219,7 @@ public:
   }
 
   //! Performs the classification
-  virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange());
+  virtual void Perform();
 
   //! Returns the faces classified as IN for solid
   const TopTools_ListOfShape& InFaces() const
@@ -1260,10 +1260,10 @@ private:
 //function : BOPAlgo_FillIn3DParts::Perform
 //purpose  : 
 //=======================================================================
-void BOPAlgo_FillIn3DParts::Perform(const Message_ProgressRange& theRange)
+void BOPAlgo_FillIn3DParts::Perform()
 {
-  Message_ProgressScope aPS(theRange, NULL, 1);
-  if (UserBreak(aPS))
+  Message_ProgressScope aPSOuter(myProgressRange, NULL, 2);
+  if (UserBreak(aPSOuter))
   {
     return;
   }
@@ -1338,6 +1338,8 @@ void BOPAlgo_FillIn3DParts::Perform(const Message_ProgressRange& theRange)
       MapEdgesAndFaces(aVShapeBox(aIVec(k)).Shape(), aMEFP, anAlloc);
   }
 
+  aPSOuter.Next().Close();
+
   // Map of Edge-Face connection, necessary for solid classification.
   // It will be filled when first classification is performed.
   TopTools_IndexedDataMapOfShapeListOfShape aMEFDS(1, anAlloc);
@@ -1345,8 +1347,13 @@ void BOPAlgo_FillIn3DParts::Perform(const Message_ProgressRange& theRange)
   // Fence map to avoid processing of the same faces twice
   TopTools_MapOfShape aMFDone(1, anAlloc);
 
-  for (k = 0; k < aNbFP; ++k)
+  Message_ProgressScope aPSLoop (aPSOuter.Next(), NULL, aNbFP);
+  for (k = 0; k < aNbFP; ++k, aPSLoop.Next())
   {
+    if (UserBreak (aPSLoop))
+    {
+      return;
+    }
     Standard_Integer nFP = aIVec(k);
     const TopoDS_Face& aFP = (*(TopoDS_Face*)&aVShapeBox(nFP).Shape());
     if (!aMFDone.Add(aFP))
@@ -1495,16 +1502,24 @@ void BOPAlgo_Tools::ClassifyFaces(const TopTools_ListOfShape& theFaces,
                                   Handle(IntTools_Context)& theContext,
                                   TopTools_IndexedDataMapOfShapeListOfShape& theInParts,
                                   const TopTools_DataMapOfShapeBox& theShapeBoxMap,
-                                  const TopTools_DataMapOfShapeListOfShape& theSolidsIF)
+                                  const TopTools_DataMapOfShapeListOfShape& theSolidsIF,
+                                  const Message_ProgressRange& theRange)
 {
   Handle(NCollection_BaseAllocator) anAlloc = new NCollection_IncAllocator;
 
+  Message_ProgressScope aPSOuter(theRange, NULL, 10);
+
   // Fill the vector of shape box with faces and its bounding boxes
   BOPAlgo_VectorOfShapeBox aVSB(256, anAlloc);
 
   TopTools_ListIteratorOfListOfShape aItLF(theFaces);
   for (; aItLF.More(); aItLF.Next())
   {
+    if (!aPSOuter.More())
+    {
+      return;
+    }
+
     const TopoDS_Shape& aF = aItLF.Value();
     // Append face to the vector of shape box
     BOPAlgo_ShapeBox& aSB = aVSB.Appended();
@@ -1572,14 +1587,20 @@ void BOPAlgo_Tools::ClassifyFaces(const TopTools_ListOfShape& theFaces,
     aFIP.SetShapeBoxVector(aVSB);
   }
 
+  // Close preparation task
+  aPSOuter.Next().Close();
+  // Set progress range for each task to be run in parallel
+  Standard_Integer aNbS = aVFIP.Length();
+  Message_ProgressScope aPSParallel(aPSOuter.Next(9), "Classification of faces relatively solids", aNbS);
+  for (Standard_Integer iFS = 0; iFS < aNbS; ++iFS)
+  {
+    aVFIP.ChangeValue(iFS).SetProgressRange(aPSParallel.Next());
+  }
   // Perform classification
   //================================================================
   BOPTools_Parallel::Perform (theRunParallel, aVFIP, theContext);
   //================================================================
-
   // Analyze the results and fill the resulting map
-
-  Standard_Integer aNbS = aVFIP.Length();
   for (Standard_Integer i = 0; i < aNbS; ++i)
   {
     BOPAlgo_FillIn3DParts& aFIP = aVFIP(i);
index b91d3420fb76ca857c7f6c6ff6f3659b9a974ecc..f6aaee2c257e23d0a4fd3b9b96a7bee3e60eadd1 100644 (file)
@@ -31,6 +31,7 @@
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <Standard_Integer.hxx>
+#include <Message_ProgressRange.hxx>
 
 class BOPDS_PaveBlock;
 class BOPDS_CommonBlock;
@@ -184,7 +185,8 @@ public:
                                             Handle(IntTools_Context)& theContext,
                                             TopTools_IndexedDataMapOfShapeListOfShape& theInParts,
                                             const TopTools_DataMapOfShapeBox& theShapeBoxMap = TopTools_DataMapOfShapeBox(),
-                                            const TopTools_DataMapOfShapeListOfShape& theSolidsIF = TopTools_DataMapOfShapeListOfShape());
+                                            const TopTools_DataMapOfShapeListOfShape& theSolidsIF = TopTools_DataMapOfShapeListOfShape(),
+                                            const Message_ProgressRange& theRange = Message_ProgressRange());
 
   //! Classifies the given parts relatively the given solids and
   //! fills the solids with the parts classified as INTERNAL.
index b6f2d2b20519a7700b8d4b8c4ef18c7a6464232f..0653cf4b055202384778f2db4eb8023c29bab201 100644 (file)
@@ -109,9 +109,10 @@ void BOPAlgo_WireSplitter::CheckData()
 //function : Perform
 //purpose  : 
 //=======================================================================
-void BOPAlgo_WireSplitter::Perform(const Message_ProgressRange& /*theRange*/)
+void BOPAlgo_WireSplitter::Perform(const Message_ProgressRange& theRange)
 {
   GetReport()->Clear();
+  Message_ProgressScope aPS(theRange, "Building wires", 1);
   //
   CheckData();
   if (HasErrors()) {
@@ -125,8 +126,12 @@ void BOPAlgo_WireSplitter::Perform(const Message_ProgressRange& /*theRange*/)
   //
   BOPTools_AlgoTools::MakeConnexityBlocks
     (myWES->StartElements(), TopAbs_VERTEX, TopAbs_EDGE, myLCB);
+  if (UserBreak (aPS))
+  {
+    return;
+  }
 
-  MakeWires();
+  MakeWires(aPS.Next());
 }
 
 /////////////////////////////////////////////////////////////////////////
@@ -158,8 +163,17 @@ public:
   const Handle(IntTools_Context)& Context()const {
     return myContext;
   }
+  //
+  void SetProgressRange(const Message_ProgressRange& theRange) {
+    myRange = theRange;
+  }
 
   void Perform() {
+    Message_ProgressScope aPS (myRange, NULL, 1);
+    if (!aPS.More())
+    {
+      return;
+    }
     BOPAlgo_WireSplitter::SplitBlock(myFace, myCB, myContext);
   }
 
@@ -167,6 +181,7 @@ protected:
   TopoDS_Face myFace;
   BOPTools_ConnexityBlock myCB;
   Handle(IntTools_Context) myContext;
+  Message_ProgressRange myRange;
 };
 
 typedef NCollection_Vector<BOPAlgo_WS_ConnexityBlock> BOPAlgo_VectorOfConnexityBlock;
@@ -175,7 +190,7 @@ typedef NCollection_Vector<BOPAlgo_WS_ConnexityBlock> BOPAlgo_VectorOfConnexityB
 //function : MakeWires
 //purpose  : 
 //=======================================================================
-void BOPAlgo_WireSplitter::MakeWires()
+void BOPAlgo_WireSplitter::MakeWires(const Message_ProgressRange& theRange)
 {
   Standard_Boolean bIsRegular;
   Standard_Integer aNbVCB, k;
@@ -184,10 +199,17 @@ void BOPAlgo_WireSplitter::MakeWires()
   TopTools_ListIteratorOfListOfShape aIt;
   BOPAlgo_VectorOfConnexityBlock aVCB;
   //
+  Message_ProgressScope aPSOuter(theRange, NULL, 1);
+  //
   const TopoDS_Face& aF=myWES->Face();
   //
   aItCB.Initialize(myLCB);
   for (; aItCB.More(); aItCB.Next()) {
+    if (UserBreak (aPSOuter))
+    {
+      return;
+    }
+
     BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue();
     bIsRegular=aCB.IsRegular();
     if (bIsRegular) {
@@ -201,10 +223,15 @@ void BOPAlgo_WireSplitter::MakeWires()
       aWSCB.SetConnexityBlock(aCB);
     }
   }
+  aNbVCB=aVCB.Length();
+  Message_ProgressScope aPSParallel(aPSOuter.Next(), NULL, aNbVCB);
+  for (Standard_Integer iW = 0; iW < aNbVCB; ++iW)
+  {
+    aVCB.ChangeValue(iW).SetProgressRange(aPSParallel.Next());
+  }
   //===================================================
   BOPTools_Parallel::Perform (myRunParallel, aVCB, myContext);
   //===================================================
-  aNbVCB=aVCB.Length();
   for (k=0; k<aNbVCB; ++k) {
     const BOPAlgo_WS_ConnexityBlock& aCB=aVCB(k);
     const TopTools_ListOfShape& aLW=aCB.ConnexityBlock().Loops();
index 5820ad3a93586071ee00751c9e4908e103e049c1..68408a1827a196a1ec241d9cfbeeed8f59accdd2 100644 (file)
@@ -70,7 +70,7 @@ protected:
 
   Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
   
-  Standard_EXPORT void MakeWires();
+  Standard_EXPORT void MakeWires(const Message_ProgressRange& theRange);
 
   BOPAlgo_PWireEdgeSet myWES;
   BOPTools_ListOfConnexityBlock myLCB;
index f9e66de4868493b7c45ce327256a91676b6f8b26..a9ee0eed152b4c23824919fc39cf4dcf92e2d525 100644 (file)
@@ -487,10 +487,8 @@ Standard_Integer bsmt (Draw_Interpretor& di,
                        const char** a,
                        const BOPAlgo_Operation aOp)
 {
-  Standard_Boolean bRunParallel, bNonDestructive;
   TopoDS_Shape aS1, aS2;
   TopTools_ListOfShape aLC;
-  Standard_Real aTol;
   //
   if (n != 4) {
     di << " use bx r s1 s2\n";
@@ -506,49 +504,30 @@ Standard_Integer bsmt (Draw_Interpretor& di,
   }
   aLC.Append(aS1);
   aLC.Append(aS2);
-  // 
-  aTol=BOPTest_Objects::FuzzyValue();
-  bRunParallel = BOPTest_Objects::RunParallel();
-  bNonDestructive = BOPTest_Objects::NonDestructive();
-  BOPAlgo_GlueEnum aGlue = BOPTest_Objects::Glue();
   //
   Handle(NCollection_BaseAllocator)aAL=
     NCollection_BaseAllocator::CommonBaseAllocator();
   //
-  //---------------------------------------------------------------
-  BOPAlgo_PaveFiller aPF(aAL);
-  //
-  aPF.SetArguments(aLC);
-  aPF.SetFuzzyValue(aTol); 
-  aPF.SetRunParallel(bRunParallel);
-  aPF.SetNonDestructive(bNonDestructive);
-  aPF.SetGlue(aGlue);
-  aPF.SetUseOBB(BOPTest_Objects::UseOBB());
-  //
-  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
-  Message_ProgressScope aPS(aProgress->Start(), "BOP", 10);
-  aPF.Perform(aPS.Next(9));
-  BOPTest::ReportAlerts(aPF.GetReport());
-  if (aPF.HasErrors()) {
-    return 0;
-  }
-  //
-  //---------------------------------------------------------------
   BOPAlgo_BOP aBOP(aAL);
-  //
   aBOP.AddArgument(aS1);
   aBOP.AddTool(aS2);
   aBOP.SetOperation(aOp);
-  aBOP.SetRunParallel(bRunParallel);
+  // set options
+  aBOP.SetGlue(BOPTest_Objects::Glue());
+  aBOP.SetFuzzyValue(BOPTest_Objects::FuzzyValue());
+  aBOP.SetNonDestructive(BOPTest_Objects::NonDestructive());
+  aBOP.SetRunParallel(BOPTest_Objects::RunParallel());
+  aBOP.SetUseOBB(BOPTest_Objects::UseOBB());
   aBOP.SetCheckInverted(BOPTest_Objects::CheckInverted());
   aBOP.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
   //
-  aBOP.PerformWithFiller(aPF, aPS.Next(1));
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
+  aBOP.Perform(aProgress->Start());
   BOPTest::ReportAlerts(aBOP.GetReport());
 
   // Store the history of Boolean operation into the session
   if (BRepTest_Objects::IsHistoryNeeded())
-    BRepTest_Objects::SetHistory(aPF.Arguments(), aBOP);
+    BRepTest_Objects::SetHistory(aBOP.PDS()->Arguments(), aBOP);
 
   if (aBOP.HasErrors()) {
     return 0;
index 0f18c76bbb3c66c0d2bb46ebf881ab9218b2fda2..13ad4f919b8462b3ca08d758e4e6ecc59f1a4617 100644 (file)
@@ -212,11 +212,12 @@ Standard_Integer bbuild(Draw_Interpretor& di,
   aBuilder.SetCheckInverted(BOPTest_Objects::CheckInverted());
   aBuilder.SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
   //
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
   //
   OSD_Timer aTimer;
   aTimer.Start();
   //
-  aBuilder.PerformWithFiller(aPF); 
+  aBuilder.PerformWithFiller(aPF, aProgress->Start()); 
   BOPTest::ReportAlerts(aBuilder.GetReport());
 
   // Set history of GF operation into the session
@@ -329,10 +330,12 @@ Standard_Integer bbop(Draw_Interpretor& di,
   pBuilder->SetCheckInverted(BOPTest_Objects::CheckInverted());
   pBuilder->SetToFillHistory(BRepTest_Objects::IsHistoryNeeded());
   //
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
+  //
   OSD_Timer aTimer;
   aTimer.Start();
   //
-  pBuilder->PerformWithFiller(aPF);
+  pBuilder->PerformWithFiller(aPF, aProgress->Start());
   BOPTest::ReportAlerts(pBuilder->GetReport());
 
   // Set history of Boolean operation into the session
index 3789c5b202d912a4b682abfbfd2a45383caa3b17..845b4f4e20dd1648e6625e8a079f02030fa6b67b 100644 (file)
@@ -167,7 +167,27 @@ void BRepAlgoAPI_BooleanOperation::Build(const Message_ProgressRange& theRange)
     }
   }
 
-  Message_ProgressScope aPS(theRange, NULL, myIsIntersectionNeeded ? 100 : 30);
+  TCollection_AsciiString aPSName;
+  switch (myOperation)
+  {
+    case BOPAlgo_COMMON:
+      aPSName = "Performing COMMON operation";
+      break;
+    case BOPAlgo_FUSE:
+      aPSName = "Performing FUSE operation";
+      break;
+    case BOPAlgo_CUT:
+    case BOPAlgo_CUT21:
+      aPSName = "Performing CUT operation";
+      break;
+    case BOPAlgo_SECTION:
+      aPSName = "Performing SECTION operation";
+      break;
+    default:
+      return;
+  }
+
+  Message_ProgressScope aPS(theRange, aPSName, myIsIntersectionNeeded ? 100 : 30);
   // If necessary perform intersection of the argument shapes
   if (myIsIntersectionNeeded)
   {
index b87c69720ea0a6ced5828de588fe0ea84d1c9e01..d89a00906478939d21400e0b456eabb16e3399d1 100644 (file)
@@ -150,8 +150,7 @@ void BRepAlgoAPI_BuilderAlgo::BuildResult(const Message_ProgressRange& theRange)
   myBuilder->SetCheckInverted(myCheckInverted);
   myBuilder->SetToFillHistory(myFillHistory);
   // Perform building of the result with pre-calculated intersections
-  Message_ProgressScope aPS(theRange, NULL, 1);
-  myBuilder->PerformWithFiller(*myDSFiller, aPS.Next());
+  myBuilder->PerformWithFiller(*myDSFiller, theRange);
   // Merge the warnings of the Building part
   GetReport()->Merge(myBuilder->GetReport());
   // Check for the errors
index 72002a40492b6e217bac535ea65670c2694848fe..3c7d4da21a81fe5972eb65c6a60d3b76431427ce 100644 (file)
@@ -98,7 +98,7 @@ void BRepAlgoAPI_Check::Perform(const Message_ProgressRange& theRange)
   anAnalyzer.SetRunParallel(myRunParallel);
   anAnalyzer.SetFuzzyValue(myFuzzyValue);
   // Perform the check
-  Message_ProgressScope aPS(theRange, "Performing CHECK operation", 1);
+  Message_ProgressScope aPS(theRange, "Checking shapes", 1);
   anAnalyzer.Perform(aPS.Next());
   if (UserBreak(aPS))
   {
index 12f7f53b0a2f6bd4f92e1d93518ca33ea50b5fc7..5060b99596f33dbdd3e1ea48a9877848171dd13a 100644 (file)
@@ -52,10 +52,11 @@ BRepAlgoAPI_Common::~BRepAlgoAPI_Common()
 //purpose  : 
 //=======================================================================
 BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1, 
-                                       const TopoDS_Shape& S2)
+                                       const TopoDS_Shape& S2,
+                                       const Message_ProgressRange& theRange)
 : BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_COMMON)
 {
-  Build();
+  Build(theRange);
 }
 //=======================================================================
 //function : BRepAlgoAPI_Common
@@ -63,10 +64,11 @@ BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1,
 //=======================================================================
 BRepAlgoAPI_Common::BRepAlgoAPI_Common(const TopoDS_Shape& S1, 
                                        const TopoDS_Shape& S2,
-                                       const BOPAlgo_PaveFiller& aDSF)
+                                       const BOPAlgo_PaveFiller& aDSF,
+                                       const Message_ProgressRange& theRange)
 : BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOPAlgo_COMMON)
 {
-  Build();
+  Build(theRange);
 }
 
 
index 401593cd1b0a0ecdcc8a8fcdc7194d5ebba502b5..a3151a2df81c2a8eeb3ec0d08a56f0d67ee6b1d8 100644 (file)
@@ -49,7 +49,9 @@ Standard_EXPORT virtual ~BRepAlgoAPI_Common();
   //! <S2>  -tool
   //! <anOperation> - the type of the operation
   //! Obsolete
-  Standard_EXPORT BRepAlgoAPI_Common(const TopoDS_Shape& S1, const TopoDS_Shape& S2);
+  Standard_EXPORT BRepAlgoAPI_Common(const TopoDS_Shape& S1,
+                                     const TopoDS_Shape& S2,
+                                     const Message_ProgressRange& theRange = Message_ProgressRange());
   
   //! Constructor with two shapes
   //! <S1>  -argument
@@ -57,7 +59,10 @@ Standard_EXPORT virtual ~BRepAlgoAPI_Common();
   //! <anOperation> - the type of the operation
   //! <PF> - PaveFiller object that is carried out
   //! Obsolete
-  Standard_EXPORT BRepAlgoAPI_Common(const TopoDS_Shape& S1, const TopoDS_Shape& S2, const BOPAlgo_PaveFiller& PF);
+  Standard_EXPORT BRepAlgoAPI_Common(const TopoDS_Shape& S1,
+                                     const TopoDS_Shape& S2,
+                                     const BOPAlgo_PaveFiller& PF,
+                                     const Message_ProgressRange& theRange = Message_ProgressRange());
 
 
 
index ae4dc2603a0a733dcb83fff29d1b1ec0c9b6f41e..89defaf635595cdacd07ee7f5ea35964a2cb89f4 100644 (file)
@@ -57,8 +57,7 @@ BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1,
 :
   BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_CUT)
 {
-  Message_ProgressScope aPS(theRange, "Performing CUT operation", 1);
-  Build(aPS.Next());
+  Build(theRange);
 }
 //=======================================================================
 //function : BRepAlgoAPI_Cut
@@ -73,6 +72,5 @@ BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1,
   BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, 
                                (bFWD) ? BOPAlgo_CUT : BOPAlgo_CUT21)
 {
-  Message_ProgressScope aPS(theRange, "Performing CUT operation", 1);
-  Build(aPS.Next());
+  Build(theRange);
 }
index b7e47da9798f37da23bad48cdd1000db7fd905a0..cd3689b91596ca2a86d47c4c82d6e32c41421ca2 100644 (file)
@@ -57,8 +57,7 @@ BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,
 : 
   BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_FUSE)
 {
-  Message_ProgressScope aPS(theRange, "Performing FUSE operation", 1);
-  Build(aPS.Next());
+  Build(theRange);
 }
 //=======================================================================
 //function : BRepAlgoAPI_Fuse
@@ -71,6 +70,5 @@ BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,
 : 
   BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOPAlgo_FUSE)
 {
-  Message_ProgressScope aPS(theRange, "Performing FUSE operation", 1);
-  Build(aPS.Next());
+  Build(theRange);
 }
index b5a1d325d21f38eae5e048317e17d073fcfd0622..1125e6d71976bcfb0b868a64309c6deda495024b 100644 (file)
@@ -273,8 +273,7 @@ void BRepAlgoAPI_Section::SetAttributes()
 //=======================================================================
 void BRepAlgoAPI_Section::Build(const Message_ProgressRange& theRange) 
 {
-  Message_ProgressScope aPS(theRange, "Performing SECTION operation", 1);
-  BRepAlgoAPI_BooleanOperation::Build(aPS.Next());
+  BRepAlgoAPI_BooleanOperation::Build(theRange);
 }
 //=======================================================================
 //function : HasAncestorFaceOn1
index 5d8cfe296970bc7e4536a0e412244a2e6e62ccb3..24c641209bc3c35332d0e2911ce2b4db9eebb367 100644 (file)
 }
 
 //=======================================================================
-//function : AnalyzeProgress
+//function : PerformResult
 //purpose  : 
 //=======================================================================
-NCollection_Array1<Standard_Real> BRepFeat_Builder::AnalyzeProgress()
+  void BRepFeat_Builder::PerformResult(const Message_ProgressRange& theRange)
 {
-  Standard_Integer aSize = 3;
-  NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
-  for (Standard_Integer i = 0; i < aSize; i++)
+  myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
+  if (myShapes.IsEmpty())
   {
-    aSteps(i) = 0;
+    BuildShape(theRange);
+    return;
   }
-
-  Standard_Real aPart = 100.;
-  Standard_Integer aNbSh = 0;
-  Standard_Integer aNbS = 0;
-  Standard_Integer aNbC = 0;
-  for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); i++)
+  
+  Standard_Real aWhole = 100.;
+  Message_ProgressScope aPS(theRange, "BRepFeat_Builder", aWhole);
+  Standard_Real aBSPart = 15;
+  aWhole -= aBSPart;
+
+  // Compute PI steps 
+  const Standard_Integer aSize = 4;
+  NCollection_Array1<Standard_Real> aSteps(0, aSize - 1);
   {
-    const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
-    switch (aSI.ShapeType())
+    for (Standard_Integer i = 0; i < aSize; ++i)
+      aSteps(i) = 0.;
+
+    NbShapes aNbShapes = getNbShapes();
+    Standard_Real aTreatFaces = 5 * aNbShapes.NbFaces();
+    Standard_Real aTreatShells = aNbShapes.NbShells();
+    Standard_Real aTreatSolids = 20 * aNbShapes.NbSolids();
+    Standard_Real aTreatCompounds = aNbShapes.NbCompounds();
+
+    Standard_Real aSum = aTreatFaces + aTreatShells + aTreatSolids + aTreatCompounds;
+    if (aSum > 0)
     {
-    case TopAbs_SHELL:
-      aNbSh++;
-      break;
-    case TopAbs_SOLID:
-      aNbS++;
-      break;
-    case TopAbs_COMPOUND:
-      aNbC++;
-      break;
-    default:
-      break;
+      aSteps(0) = aTreatFaces * aWhole / aSum;
+      aSteps(1) = aTreatShells * aWhole / aSum;
+      aSteps(2) = aTreatSolids * aWhole / aSum;
+      aSteps(3) = aTreatCompounds * aWhole / aSum;
     }
   }
-
-  aNbSh = 10 * aNbSh;
-  aNbS = 10 * aNbS;
-  aNbC = 5 * aNbC;
-  Standard_Real aSum = aNbSh + aNbS + aNbC;
-  if (aSum == 0)
-  {
-    return aSteps;
+  //
+  Prepare();
+  //
+  RebuildFaces();
+  aPS.Next(aSteps(0));
+  //
+  FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(1)));
+  if (HasErrors()) {
+    return;
   }
-
-  aSteps(0) = aPart * aNbSh / aSum;
-  aSteps(1) = aPart * aNbS / aSum;
-  aSteps(2) = aPart * aNbC / aSum;
-
-  return aSteps;
-}
-
-//=======================================================================
-//function : PerformResult
-//purpose  : 
-//=======================================================================
-  void BRepFeat_Builder::PerformResult(const Message_ProgressRange& theRange)
-{
-  myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
   //
-  if (!myShapes.IsEmpty()) {
-    Message_ProgressScope aPS(theRange, "BRepFeat_Builder", 100);
-    //
-    NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
-    Prepare(); 
-    //
-    RebuildFaces();
-    //
-    FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(0)));
-    if (HasErrors()) {
-      return;
-    }
-    //
-    FillImagesSolids(aPS.Next(aSteps(1)));
-    if (HasErrors()) {
-      return;
-    }
-    //
-    CheckSolidImages();
-    //
-    BuildResult(TopAbs_SOLID);
-    if (HasErrors()) {
-      return;
-    }
-    // 
-    FillImagesCompounds(aPS.Next(aSteps(2)));
-    if (HasErrors()) {
-      return;
-    }
-    //
-    BuildResult(TopAbs_COMPOUND);
-    if (HasErrors()) {
-      return;
-    }
+  FillImagesSolids(aPS.Next(aSteps(2)));
+  if (HasErrors()) {
+    return;
+  }
+  //
+  CheckSolidImages();
+  //
+  BuildResult(TopAbs_SOLID);
+  if (HasErrors()) {
+    return;
+  }
+  // 
+  FillImagesCompounds(aPS.Next(aSteps(3)));
+  if (HasErrors()) {
+    return;
+  }
+  //
+  BuildResult(TopAbs_COMPOUND);
+  if (HasErrors()) {
+    return;
   }
   //
-  BuildShape();
+  BuildShape(aPS.Next(aBSPart));
 }
 
 //=======================================================================
@@ -786,11 +763,12 @@ NCollection_Array1<Standard_Real> BRepFeat_Builder::AnalyzeProgress()
 //function : FillIn3DParts
 //purpose  : 
 //=======================================================================
-  void BRepFeat_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids)
+  void BRepFeat_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids,
+                                       const Message_ProgressRange& theRange)
 {
   GetReport()->Clear();
 
-  BOPAlgo_Builder::FillIn3DParts(theDraftSolids);
+  BOPAlgo_Builder::FillIn3DParts(theDraftSolids, theRange);
 
   // Clear the IN parts of the solids from the removed faces
   TopTools_DataMapOfShapeListOfShape::Iterator itM(myInParts);
index c46c6615d9c71b5f22d0af352d5321878ab9c486..b0f261683249efca35f84a22bcbb7a0bdd24bebc 100644 (file)
@@ -112,14 +112,12 @@ Standard_EXPORT virtual ~BRepFeat_Builder();
 
 protected:
 
-  //! AnalyzeProgress
-  Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-  
   //! Prepares builder of local operation.
   Standard_EXPORT virtual void Prepare() Standard_OVERRIDE;
   
   //! Function is redefined to avoid the usage of removed faces.
-  Standard_EXPORT virtual void FillIn3DParts (TopTools_DataMapOfShapeShape& theDraftSolids) Standard_OVERRIDE;
+  Standard_EXPORT virtual void FillIn3DParts (TopTools_DataMapOfShapeShape& theDraftSolids,
+                                              const Message_ProgressRange& theRange) Standard_OVERRIDE;
 
   //! Avoid the check for open solids and always use the splits
   //! of solids for building the result shape.