From 2167fa40660dedbac1c2c38a80cc26041c26f67a Mon Sep 17 00:00:00 2001 From: akaftasev Date: Thu, 6 May 2021 12:24:39 +0300 Subject: [PATCH] Updating BOPAlgo_Section Added AnalyzeProgress --- src/BOPAlgo/BOPAlgo_BOP.cxx | 2 +- src/BOPAlgo/BOPAlgo_Section.cxx | 83 ++++++++++++++++++++++----------- src/BOPAlgo/BOPAlgo_Section.hxx | 3 ++ 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/src/BOPAlgo/BOPAlgo_BOP.cxx b/src/BOPAlgo/BOPAlgo_BOP.cxx index c573a9b6f2..733df41a00 100644 --- a/src/BOPAlgo/BOPAlgo_BOP.cxx +++ b/src/BOPAlgo/BOPAlgo_BOP.cxx @@ -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, "BOPAlgo_BOP::Perform()", 10); + Message_ProgressScope aPS(theRange, "Performing result of BOP operation", 10); pPF->SetFuzzyValue(myFuzzyValue); pPF->SetNonDestructive(myNonDestructive); diff --git a/src/BOPAlgo/BOPAlgo_Section.cxx b/src/BOPAlgo/BOPAlgo_Section.cxx index 3a4838396d..1a5e060e24 100644 --- a/src/BOPAlgo/BOPAlgo_Section.cxx +++ b/src/BOPAlgo/BOPAlgo_Section.cxx @@ -83,6 +83,56 @@ void BOPAlgo_Section::CheckData() // CheckFiller(); } + +//======================================================================= +//function : AnalyzeProgress +//purpose : +//======================================================================= +NCollection_Array1 BOPAlgo_Section::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 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; +} + //======================================================================= //function : PerformInternal1 //purpose : @@ -106,10 +156,11 @@ void BOPAlgo_Section::PerformInternal1 return; } // - Message_ProgressScope aPS(theRange, "PerformInternal", 100); + Message_ProgressScope aPS(theRange, "Building result of SECTION operation", 100); + NCollection_Array1 aSteps = AnalyzeProgress(); // 3. Fill Images // 3.1 Vertices - FillImagesVertices(aPS.Next(30)); // 30 + FillImagesVertices(aPS.Next(aSteps(0))); if (HasErrors()) { return; } @@ -119,7 +170,7 @@ void BOPAlgo_Section::PerformInternal1 return; } // 3.2 Edges - FillImagesEdges(aPS.Next(35)); // 65 + FillImagesEdges(aPS.Next(aSteps(1))); if (HasErrors()) { return; } @@ -129,7 +180,7 @@ void BOPAlgo_Section::PerformInternal1 return; } // 4. Section - BuildSection(aPS.Next(35)); // 100 + BuildSection(aPS.Next(aSteps(2))); // if (HasErrors()) { return; @@ -187,10 +238,6 @@ void BOPAlgo_Section::BuildSection(const Message_ProgressRange& theRange) const TColStd_MapOfInteger& aMVSc=aFI.VerticesSc(); aItMI.Initialize(aMVSc); for(; aItMI.More(); aItMI.Next()) { - if (UserBreak(aPS)) - { - return; - } nV=aItMI.Key(); const TopoDS_Shape& aV=myDS->Shape(nV); aBB.Add(aRC1, aV); @@ -200,10 +247,6 @@ void BOPAlgo_Section::BuildSection(const Message_ProgressRange& theRange) const TColStd_MapOfInteger& aMI=aFI.VerticesIn(); aItMI.Initialize(aMI); for(; aItMI.More(); aItMI.Next()) { - if (UserBreak(aPS)) - { - return; - } nV=aItMI.Key(); if (nV<0) { continue; @@ -219,10 +262,6 @@ void BOPAlgo_Section::BuildSection(const Message_ProgressRange& theRange) // aNbPBSc=aMPBSc.Extent(); for (j=1; j<=aNbPBSc; ++j) { - if (UserBreak(aPS)) - { - return; - } const Handle(BOPDS_PaveBlock)& aPB=aMPBSc(j); nE=aPB->Edge(); const TopoDS_Shape& aE=myDS->Shape(nE); @@ -242,10 +281,6 @@ void BOPAlgo_Section::BuildSection(const Message_ProgressRange& theRange) const BOPDS_ListOfPaveBlock& aLPB=aPBP(i); aItPB.Initialize(aLPB); for (; aItPB.More(); aItPB.Next()) { - if (UserBreak(aPS)) - { - return; - } const Handle(BOPDS_PaveBlock)& aPB=aItPB.Value(); Handle(BOPDS_CommonBlock) aCB=myDS->CommonBlock(aPB); if (!aCB.IsNull()) { @@ -310,10 +345,6 @@ void BOPAlgo_Section::BuildSection(const Message_ProgressRange& theRange) const TopTools_ListOfShape& aLSIm=myImages.Find(aS); aItIm.Initialize(aLSIm); for (; aItIm.More(); aItIm.Next()) { - if (UserBreak(aPS)) - { - return; - } const TopoDS_Shape& aSIm=aItIm.Value(); TopExp::MapShapes(aSIm, TopAbs_VERTEX, aMS); TopExp::MapShapes(aSIm, TopAbs_EDGE , aMS); @@ -327,10 +358,6 @@ void BOPAlgo_Section::BuildSection(const Message_ProgressRange& theRange) // aNbMS=aMS.Extent(); for (i=1; i<=aNbMS; ++i) { - if (UserBreak(aPS)) - { - return; - } const TopoDS_Shape& aS=aMS(i); if (aMSI.Contains(aS)) { Standard_Integer& iCnt=aMSI.ChangeFromKey(aS); diff --git a/src/BOPAlgo/BOPAlgo_Section.hxx b/src/BOPAlgo/BOPAlgo_Section.hxx index ac7cd1f958..89117ccbc7 100644 --- a/src/BOPAlgo/BOPAlgo_Section.hxx +++ b/src/BOPAlgo/BOPAlgo_Section.hxx @@ -55,6 +55,9 @@ protected: //! Combine the result of section operation Standard_EXPORT virtual void BuildSection(const Message_ProgressRange& theRange); + //! AnalyzeProgress + Standard_EXPORT NCollection_Array1 AnalyzeProgress() Standard_OVERRIDE; + //! Performs calculations using prepared Filler object Standard_EXPORT virtual void PerformInternal1(const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange) Standard_OVERRIDE; -- 2.39.5