From f0f985bcd61ecc27d54c99fa7d7791ebc1e130c7 Mon Sep 17 00:00:00 2001 From: akaftasev Date: Tue, 27 Apr 2021 16:19:28 +0300 Subject: [PATCH] Added AnalyzeProgress to BRepFeat_Builder --- src/BOPAlgo/BOPAlgo_BOP.hxx | 5 +-- src/BOPAlgo/BOPAlgo_Builder.cxx | 6 +-- src/BRepFeat/BRepFeat_Builder.cxx | 64 ++++++++++++++++++++++++++++--- src/BRepFeat/BRepFeat_Builder.hxx | 2 + 4 files changed, 62 insertions(+), 15 deletions(-) diff --git a/src/BOPAlgo/BOPAlgo_BOP.hxx b/src/BOPAlgo/BOPAlgo_BOP.hxx index af4494871c..ee9f97ddac 100644 --- a/src/BOPAlgo/BOPAlgo_BOP.hxx +++ b/src/BOPAlgo/BOPAlgo_BOP.hxx @@ -93,10 +93,7 @@ protected: //! Performs calculations using prepared Filler //! object Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange) Standard_OVERRIDE; - - //! AnalyzeProgress - Standard_EXPORT NCollection_Array1 AnalyzeProgress() Standard_OVERRIDE; - + Standard_EXPORT virtual void BuildResult (const TopAbs_ShapeEnum theType) Standard_OVERRIDE; Standard_EXPORT void BuildShape(); diff --git a/src/BOPAlgo/BOPAlgo_Builder.cxx b/src/BOPAlgo/BOPAlgo_Builder.cxx index 0d372783c6..9ea9085d12 100644 --- a/src/BOPAlgo/BOPAlgo_Builder.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder.cxx @@ -317,11 +317,7 @@ NCollection_Array1 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; } diff --git a/src/BRepFeat/BRepFeat_Builder.cxx b/src/BRepFeat/BRepFeat_Builder.cxx index 6bf049b3f3..5d8cfe2969 100644 --- a/src/BRepFeat/BRepFeat_Builder.cxx +++ b/src/BRepFeat/BRepFeat_Builder.cxx @@ -209,6 +209,58 @@ } } +//======================================================================= +//function : AnalyzeProgress +//purpose : +//======================================================================= +NCollection_Array1 BRepFeat_Builder::AnalyzeProgress() +{ + Standard_Integer aSize = 3; + NCollection_Array1 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 : @@ -217,20 +269,20 @@ { 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 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; } @@ -242,7 +294,7 @@ return; } // - FillImagesCompounds(aPS.Next(40)); + FillImagesCompounds(aPS.Next(aSteps(2))); if (HasErrors()) { return; } @@ -253,7 +305,7 @@ } } // - BuildShape(aPSOuter.Next()); + BuildShape(); } //======================================================================= diff --git a/src/BRepFeat/BRepFeat_Builder.hxx b/src/BRepFeat/BRepFeat_Builder.hxx index 9807e582c8..c46c6615d9 100644 --- a/src/BRepFeat/BRepFeat_Builder.hxx +++ b/src/BRepFeat/BRepFeat_Builder.hxx @@ -112,6 +112,8 @@ Standard_EXPORT virtual ~BRepFeat_Builder(); protected: + //! AnalyzeProgress + Standard_EXPORT NCollection_Array1 AnalyzeProgress() Standard_OVERRIDE; //! Prepares builder of local operation. Standard_EXPORT virtual void Prepare() Standard_OVERRIDE; -- 2.39.5