]> OCCT Git - occt-copy.git/commitdiff
Provide BOPAlgo_ParallelAlgo which has myRange in its field to be used in parallel... CR21264_1_draft
authoremv <emv@opencascade.com>
Fri, 2 Jul 2021 14:03:54 +0000 (17:03 +0300)
committeremv <emv@opencascade.com>
Fri, 2 Jul 2021 14:08:23 +0000 (17:08 +0300)
Provide suitable way of keeping the progress steps of operations.

24 files changed:
src/BOPAlgo/BOPAlgo_Algo.cxx
src/BOPAlgo/BOPAlgo_Algo.hxx
src/BOPAlgo/BOPAlgo_BOP.cxx
src/BOPAlgo/BOPAlgo_BOP.hxx
src/BOPAlgo/BOPAlgo_Builder.cxx
src/BOPAlgo/BOPAlgo_Builder.hxx
src/BOPAlgo/BOPAlgo_Builder_2.cxx
src/BOPAlgo/BOPAlgo_Builder_4.cxx
src/BOPAlgo/BOPAlgo_CellsBuilder.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_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/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 733df41a0040b171a98d7d33aa35b25b02495f9f..e0066ccf8a67c8f03481ba43b22fcdee67f47955 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", 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,16 +541,16 @@ 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)));
   //
   // 6 Post-treatment 
-  PostTreat();
+  PostTreat(aPS.Next(aSteps.GetStep(PIOperation_PostTreat)));
 }
 //=======================================================================
 //function : BuildRC
@@ -773,8 +786,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
@@ -799,12 +814,24 @@ void BOPAlgo_BOP::BuildShape()
     }
   }
 
-  // Build the result using splits of arguments.
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
 
+  // Build the result using splits of arguments.
   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 +857,12 @@ 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 +942,13 @@ void BOPAlgo_BOP::BuildShape()
   }
   //
   RemoveDuplicates(aLCRes);
+
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
+  aPS.Next(5.);
   //
   // add containers to result
   TopoDS_Compound aResult;
@@ -936,6 +976,12 @@ void BOPAlgo_BOP::BuildShape()
     }
   }
 
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
+
   // put non-container shapes in the result
   aItLS.Initialize(aLSNonCont);
   for (; aItLS.More(); aItLS.Next())
@@ -962,8 +1008,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 +1038,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;
@@ -1004,6 +1056,11 @@ void BOPAlgo_BOP::BuildSolid()
       }
     }
   }
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   //
   // Possibly untouched solids - to be added to results as is
   TopTools_IndexedMapOfShape aMUSols;
@@ -1022,6 +1079,12 @@ void BOPAlgo_BOP::BuildSolid()
     //
     MapFacesToBuildSolids(aSx, aMFS);
   } // for (; aIt.More(); aIt.Next()) {
+
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   //
   // Process possibly untouched solids.
   // Really untouched solids will be added into result as is.
@@ -1050,6 +1113,12 @@ 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
@@ -1064,6 +1133,13 @@ void BOPAlgo_BOP::BuildSolid()
     }
   }
   //
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
+  aPS.Next(1.);
+  //
   TopoDS_Shape aRC;
   BOPTools_AlgoTools::MakeContainer(TopAbs_COMPOUND, aRC);
   if (aSFS.Extent()) {
@@ -1072,7 +1148,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 +1186,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
@@ -1131,6 +1208,11 @@ void BOPAlgo_BOP::BuildSolid()
     return;
   }
   //
+  // Check for user break
+  if (UserBreak(aPS))
+  {
+    return;
+  }
   // get splits of faces of the Compsolid arguments
   TopTools_MapOfShape aMFCs;
   aItLS.Initialize(aLSC);
@@ -1152,6 +1234,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..9be5baa42a57060def96fe4dba4601667b66db5d 100644 (file)
@@ -66,6 +66,14 @@ class BOPAlgo_PaveFiller;
 //!
 class BOPAlgo_BOP  : public BOPAlgo_ToolsProvider
 {
+public:
+  //! Extend list of operations to be supported by the Progress Indicator
+  enum BOPAlgo_PIOperation
+  {
+    PIOperation_BuildShape = BOPAlgo_Builder::PIOperation_Last,
+    PIOperation_Last
+  };
+
 public:
 
   DEFINE_STANDARD_ALLOC
@@ -92,15 +100,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 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 +122,9 @@ protected:
   //! for building the result shape.
   Standard_EXPORT virtual Standard_Boolean CheckArgsForOpenSolid();
 
+  //! Fill PI steps
+  Standard_EXPORT virtual void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
 protected:
 
   BOPAlgo_Operation myOperation;
index 9ea9085d12cd8f9e2453df3812237d052f68f156..c25d878c345655b8085b412b9b67427e72cb4088 100644 (file)
@@ -36,7 +36,6 @@
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <TopTools_MapOfOrientedShape.hxx>
 
-
 //=======================================================================
 //function : 
 //purpose  : 
@@ -244,81 +243,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 +341,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 +354,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 +368,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 +379,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 +390,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 +400,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 +410,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 +420,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 +431,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;
   }
@@ -433,18 +442,18 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons
   }
   //
   // 4.History
-  PrepareHistory();
+  PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
   //
   //
   // 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 +473,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();
   BOPTools_AlgoTools::CorrectShapeTolerances(myShape, aMA, myRunParallel);
 }
 
@@ -827,5 +838,5 @@ void BOPAlgo_Builder::BuildBOP(const TopTools_ListOfShape& theObjects,
     aBB.Add(aResult, itLS.Value());
 
   myShape = aResult;
-  PrepareHistory();
+  PrepareHistory(Message_ProgressRange());
 }
index 759ff847123a4e18c1d7151f67a7370d1dbb1231..33acf6a7a100c27a5b3a1c88d724b789ecafc47a 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;
   }
 
+public: //! @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
 
@@ -453,8 +514,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 5a0396e5de7f5b7d465e486425cdf47517440db3..7b6ff5d25951502961b7eb8f45a2c3630f80f773 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) {
   }
   //
@@ -127,13 +127,13 @@ typedef NCollection_Vector<BOPAlgo_BuilderFace> 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) {
   }
   //
index d592493aafa80bbf932931c78106823fc1359719..e4f92ba517224660c03cf50d7c90ad7805289bde 100644 (file)
@@ -146,11 +146,13 @@ 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;
 
+  Message_ProgressScope aPS(theRange, "Filling history information", 1);
+
   // Initializing history tool
   myHistory = new BRepTools_History;
 
index d54f3497edebcfdf526ceebe582c7c72238a686b..a69554f32691b313d5d9382a6ff8bfb7432bd43d 100644 (file)
@@ -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 97618d4a161f2143116eeede229e73863ee68066..253660fe0cdcd83d7acd54deb9cd48039ee8b1ba 100644 (file)
@@ -50,6 +50,10 @@ void BOPAlgo_MakerVolume::CheckData()
 //=======================================================================
 void BOPAlgo_MakerVolume::Perform(const Message_ProgressRange& theRange)
 {
+  Message_ProgressScope aPS(theRange, "MakerVolume", 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 the volume", 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,27 @@ void BOPAlgo_MakerVolume::PerformInternal1
   BuildShape(aLSR);
   //
   // 10. History
-  PrepareHistory();
+  PrepareHistory(aPS.Next(aSteps.GetStep(PIOperation_FillHistory)));
   //
   // 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++)
-  {
-    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;
-
-  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)
+  NbShapes aNbShapes = getNbShapes();
+  if (myIntersect)
   {
-    return aSteps;
+    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());
   }
-
-  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 +274,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..115bcea8614e7ced8f0ba6dae0cdb90bfb148435 100644 (file)
@@ -110,10 +110,23 @@ class BOPAlgo_PaveFiller;
 class BOPAlgo_MakerVolume  : public BOPAlgo_Builder
 {
 public:
+  //! 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
+  };
 
-  DEFINE_STANDARD_ALLOC
+public:
 
-  
+  DEFINE_STANDARD_ALLOC
 
   //! Empty constructor.
   BOPAlgo_MakerVolume();
@@ -158,9 +171,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 +181,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 +193,12 @@ protected:
   //! Builds the result.
   Standard_EXPORT void BuildShape (const TopTools_ListOfShape& theLSR);
 
+protected:
+
+  //! Analyze progress steps
+  Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
+
+protected:
 
   Standard_Boolean myIntersect;
   Bnd_Box myBBox;
index f3b9bc74b5cbe40a029216860d4fc0624c11f3e9..b6db998a45aca01b0d020c56247299fea8654616 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, "Init", myArguments.Size());
+  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 intersections 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..99d3d7e9d0cc294144a0424d40e7aeaac7118824 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);
   
@@ -636,6 +634,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 dd8040749a4b1de09507de0c16ba483932601b5a..7d8d299781de95248f563bb5350b60455e112126 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;
@@ -294,7 +288,7 @@ void BOPAlgo_PaveFiller::IntersectVE
   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..4819db0c6409cb3b007dd8b19f82a1d5ed27a99f 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;
 };
 //
 //=======================================================================
@@ -287,7 +280,7 @@ void BOPAlgo_PaveFiller::PerformEE(const Message_ProgressRange& theRange)
   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);
@@ -1171,7 +1164,7 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange)
   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..44bb3cf0ea07cf654be5c1d33ba5fae6a85f561a 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;
@@ -240,7 +233,7 @@ void BOPAlgo_PaveFiller::PerformVF(const Message_ProgressRange& theRange)
   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..9152260d1fac1d3b7c378e5b6793467236fe2a12 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;
 };
 //
 //=======================================================================
@@ -313,7 +305,7 @@ void BOPAlgo_PaveFiller::PerformEF(const Message_ProgressRange& theRange)
   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);
@@ -1083,7 +1075,7 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
   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..4c5a2145edae6afd7b3245023ea80c809fecf463 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;
 };
 //
 //=======================================================================
@@ -341,7 +333,7 @@ void BOPAlgo_PaveFiller::PerformFF(const Message_ProgressRange& theRange)
   for (k = 0; k < aVFaceFace.Size(); k++)
   {
     BOPAlgo_FaceFace& aFaceFace = aVFaceFace.ChangeValue(k);
-    aFaceFace.SetProgress(aPS.Next());
+    aFaceFace.SetProgressRange(aPS.Next());
   }
   //======================================================
   // Perform intersection
index 2400febd33b207e359b08b5a6732c5b0f5f5f29f..95de46a25bc6bd45afbd531f51e6e9f7338683ee 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;
 };
 //
 //=======================================================================
@@ -531,7 +517,7 @@ void BOPAlgo_PaveFiller::MakeSplitEdges(const Message_ProgressRange& theRange)
   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..8075b0f9006ce4ede2596d27a0f8c77ae24c3a47 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, "Processing of degenerated edges", 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)) {
index 1a5e060e2487fdf4ab7c531d87ec874587603bd7..f6181c50c1aec7d7f3ab2c60a0a687a7865955e0 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++)
+  // Fill in the constants:
+  if (myFillHistory)
   {
-    aSteps(i) = 0;
+    // for FillHistroty, which takes about 10% of the whole operation
+    theSteps.SetStep(PIOperation_FillHistory, 10. * theWhole / 100.);
   }
 
-  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)
-  {
-    return aSteps;
-  }
-
-  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,19 @@ 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
index 89117ccbc7213ff4c2ef870cbf2e5feb476fa13a..672d68396d7075e31451d0c4451d7a674799fa45 100644 (file)
@@ -36,6 +36,20 @@ class TopoDS_Shape;
 //! 4. edges that are Common Blocks
 class BOPAlgo_Section  : public BOPAlgo_Builder
 {
+public:
+  //! 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
+  };
+
 public:
 
   DEFINE_STANDARD_ALLOC
@@ -55,13 +69,16 @@ 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:
+
+  //! 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 5d8cfe296970bc7e4536a0e412244a2e6e62ccb3..8565b42e2948269019f2c25723a6013cbc6bcad5 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);
   }
-
-  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;
+  //
+  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));
 }
 
 //=======================================================================
index c46c6615d9c71b5f22d0af352d5321878ab9c486..54dc5c08111e06e0263e00a37e6a8782518f7a81 100644 (file)
@@ -112,9 +112,6 @@ 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;