]> OCCT Git - occt-copy.git/commitdiff
Added AnalyzeProgress to BRepFeat_Builder
authorakaftasev <akaftasev@opencascade.com>
Tue, 27 Apr 2021 13:19:28 +0000 (16:19 +0300)
committerakaftasev <akaftasev@opencascade.com>
Tue, 27 Apr 2021 13:46:55 +0000 (16:46 +0300)
src/BOPAlgo/BOPAlgo_BOP.hxx
src/BOPAlgo/BOPAlgo_Builder.cxx
src/BRepFeat/BRepFeat_Builder.cxx
src/BRepFeat/BRepFeat_Builder.hxx

index af4494871cc8364e6000e08b02f7a4548e060439..ee9f97ddacfbb6a917f45afd7bc071b1317401b3 100644 (file)
@@ -93,10 +93,7 @@ protected:
   //! Performs calculations using prepared Filler
   //! object <thePF>
   Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange) Standard_OVERRIDE;
-  
-  //! AnalyzeProgress
-  Standard_EXPORT NCollection_Array1<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
-  
+    
   Standard_EXPORT virtual void BuildResult (const TopAbs_ShapeEnum theType) Standard_OVERRIDE;
   
   Standard_EXPORT void BuildShape();
index 0d372783c626b68d931cbd47e5fab31c78ef1d6d..9ea9085d12cd8f9e2453df3812237d052f68f156 100644 (file)
@@ -317,11 +317,7 @@ NCollection_Array1<Standard_Real> BOPAlgo_Builder::AnalyzeProgress()
   aSteps(5) = aPart * aNbS / aSum;
   aSteps(6) = aPart * aNbCS / aSum;
   aSteps(7) = aPart * aNbC / aSum;
-  Standard_Real a = 0;
-  for (Standard_Integer i = 0; i < aSize; i++)
-  {
-    a += aSteps(i);
-  }
+
   return aSteps;
 }
 
index 6bf049b3f32b8583a97e2912cf9b7097dffa56af..5d8cfe296970bc7e4536a0e412244a2e6e62ccb3 100644 (file)
   }
 }
 
+//=======================================================================
+//function : AnalyzeProgress
+//purpose  : 
+//=======================================================================
+NCollection_Array1<Standard_Real> BRepFeat_Builder::AnalyzeProgress()
+{
+  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 aNbSh = 0;
+  Standard_Integer aNbS = 0;
+  Standard_Integer aNbC = 0;
+  for (Standard_Integer i = 0; i < myDS->NbSourceShapes(); i++)
+  {
+    const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
+    switch (aSI.ShapeType())
+    {
+    case TopAbs_SHELL:
+      aNbSh++;
+      break;
+    case TopAbs_SOLID:
+      aNbS++;
+      break;
+    case TopAbs_COMPOUND:
+      aNbC++;
+      break;
+    default:
+      break;
+    }
+  }
+
+  aNbSh = 10 * aNbSh;
+  aNbS = 10 * aNbS;
+  aNbC = 5 * aNbC;
+  Standard_Real aSum = aNbSh + aNbS + aNbC;
+  if (aSum == 0)
+  {
+    return aSteps;
+  }
+
+  aSteps(0) = aPart * aNbSh / aSum;
+  aSteps(1) = aPart * aNbS / aSum;
+  aSteps(2) = aPart * aNbC / aSum;
+
+  return aSteps;
+}
+
 //=======================================================================
 //function : PerformResult
 //purpose  : 
 {
   myOperation = myFuse ? BOPAlgo_FUSE : BOPAlgo_CUT;
   //
-  Message_ProgressScope aPSOuter(theRange, NULL, 2);
   if (!myShapes.IsEmpty()) {
-    Message_ProgressScope aPS(aPSOuter.Next(), "BRepFeat_Builder", 100);
+    Message_ProgressScope aPS(theRange, "BRepFeat_Builder", 100);
     //
+    NCollection_Array1<Standard_Real> aSteps = AnalyzeProgress();
     Prepare(); 
     //
     RebuildFaces();
     //
-    FillImagesContainers(TopAbs_SHELL, aPS.Next(30));
+    FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(0)));
     if (HasErrors()) {
       return;
     }
     //
-    FillImagesSolids(aPS.Next(30));
+    FillImagesSolids(aPS.Next(aSteps(1)));
     if (HasErrors()) {
       return;
     }
       return;
     }
     // 
-    FillImagesCompounds(aPS.Next(40));
+    FillImagesCompounds(aPS.Next(aSteps(2)));
     if (HasErrors()) {
       return;
     }
     }
   }
   //
-  BuildShape(aPSOuter.Next());
+  BuildShape();
 }
 
 //=======================================================================
index 9807e582c8f84123dc222573c936e0c471078281..c46c6615d9c71b5f22d0af352d5321878ab9c486 100644 (file)
@@ -112,6 +112,8 @@ 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;