From 16d9a485f86ea35d1bca3a29d6bd32cdd968421c Mon Sep 17 00:00:00 2001 From: akaftasev Date: Tue, 27 Apr 2021 16:47:56 +0300 Subject: [PATCH] Added AnalyzeProgress to BOPAlgo_MakerVolume --- src/BOPAlgo/BOPAlgo_MakerVolume.cxx | 69 +++++++++++++++++++++++++---- src/BOPAlgo/BOPAlgo_MakerVolume.hxx | 3 ++ 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/src/BOPAlgo/BOPAlgo_MakerVolume.cxx b/src/BOPAlgo/BOPAlgo_MakerVolume.cxx index e223732474..97618d4a16 100644 --- a/src/BOPAlgo/BOPAlgo_MakerVolume.cxx +++ b/src/BOPAlgo/BOPAlgo_MakerVolume.cxx @@ -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 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 BOPAlgo_MakerVolume::AnalyzeProgress() +{ + Standard_Integer aSize = 4; + NCollection_Array1 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 : diff --git a/src/BOPAlgo/BOPAlgo_MakerVolume.hxx b/src/BOPAlgo/BOPAlgo_MakerVolume.hxx index 6763df030c..faff5c8800 100644 --- a/src/BOPAlgo/BOPAlgo_MakerVolume.hxx +++ b/src/BOPAlgo/BOPAlgo_MakerVolume.hxx @@ -158,6 +158,9 @@ protected: //! Checks the data. Standard_EXPORT virtual void CheckData() Standard_OVERRIDE; + //! Analyze progress steps + Standard_EXPORT NCollection_Array1 AnalyzeProgress() Standard_OVERRIDE; + //! Performs the operation. Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; -- 2.39.5