]> OCCT Git - occt-copy.git/commitdiff
Added AnalyzeProgress to BOPAlgo_MakerVolume
authorakaftasev <akaftasev@opencascade.com>
Tue, 27 Apr 2021 13:47:56 +0000 (16:47 +0300)
committerakaftasev <akaftasev@opencascade.com>
Tue, 27 Apr 2021 13:47:56 +0000 (16:47 +0300)
src/BOPAlgo/BOPAlgo_MakerVolume.cxx
src/BOPAlgo/BOPAlgo_MakerVolume.hxx

index e2237324748fdc460e665d53b7e789f99cf4481c..97618d4a161f2143116eeede229e73863ee68066 100644 (file)
@@ -128,30 +128,28 @@ void BOPAlgo_MakerVolume::PerformInternal1
   // 3.1. Vertice
   if (myIntersect) {
     Message_ProgressScope aPS(theRange, "PerformInternal", 100);
-    FillImagesVertices(aPS.Next(15));         // 15
+    NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
+
+    FillImagesVertices(aPS.Next(aSteps(0)));
     if (HasErrors()) {
       return;
     }
     // 3.2. Edges
-    FillImagesEdges(aPS.Next(15));            // 30
+    FillImagesEdges(aPS.Next(aSteps(1)));
     if (HasErrors()) {
       return;
     }
     // 3.3. Wires
-    FillImagesContainers(TopAbs_WIRE, aPS.Next(20));    // 50
+    FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps(2)));
     if (HasErrors()) {
       return;
     }
     // 3.4. Faces
-    FillImagesFaces(aPS.Next(50));            // 100
+    FillImagesFaces(aPS.Next(aSteps(3)));
     if (HasErrors()) {
       return;
     }
   }
-  else
-  {
-    Message_ProgressScope aPS(theRange, NULL, 1);
-  }
   //
   // 4. Collect faces
   CollectFaces();
@@ -187,6 +185,61 @@ void BOPAlgo_MakerVolume::PerformInternal1
   PostTreat();  
 }
 
+//=======================================================================
+//function : AnalyzeProgress
+//purpose  : 
+//=======================================================================
+NCollection_Array1<Standard_Real> BOPAlgo_MakerVolume::AnalyzeProgress()
+{
+  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)
+  {
+    return aSteps;
+  }
+
+  aSteps(0) = aPart * aNbV / aSum;
+  aSteps(1) = aPart * aNbE / aSum;
+  aSteps(2) = aPart * aNbW / aSum;
+  aSteps(3) = aPart * aNbF / aSum;
+
+  return aSteps;
+}
+
 //=======================================================================
 //function : CollectFaces
 //purpose  : 
index 6763df030ce09ae6ca699660af458dc47ba5d133..faff5c8800653824b71e579cace97abd71efba7e 100644 (file)
@@ -158,6 +158,9 @@ 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;