From cad010a68357c0fe13cf4d6ca9807c013a9626b5 Mon Sep 17 00:00:00 2001 From: akaftasev Date: Thu, 15 Apr 2021 12:52:05 +0300 Subject: [PATCH] Update indication in BOPAlgo_Builder --- src/BOPAlgo/BOPAlgo_Builder.cxx | 100 ++++++++++++++++++++++++++--- src/BOPAlgo/BOPAlgo_Builder.hxx | 3 + src/BOPAlgo/BOPAlgo_Builder_1.cxx | 18 ++---- src/BOPAlgo/BOPAlgo_Builder_2.cxx | 10 +-- src/BOPAlgo/BOPAlgo_Builder_3.cxx | 10 +-- src/BOPAlgo/BOPAlgo_PaveFiller.cxx | 2 +- 6 files changed, 105 insertions(+), 38 deletions(-) diff --git a/src/BOPAlgo/BOPAlgo_Builder.cxx b/src/BOPAlgo/BOPAlgo_Builder.cxx index 156a7ad38e..0d372783c6 100644 --- a/src/BOPAlgo/BOPAlgo_Builder.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder.cxx @@ -242,6 +242,89 @@ void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller, const AddError (new BOPAlgo_AlertBuilderFailed); } } + +//======================================================================= +//function : AnalyzeProgress +//purpose : +//======================================================================= +NCollection_Array1 BOPAlgo_Builder::AnalyzeProgress() +{ + Standard_Integer aSize = 8; + 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; + Standard_Integer aNbSh = 0; + Standard_Integer aNbS = 0; + Standard_Integer aNbCS = 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_EDGE: + aNbE++; + break; + case TopAbs_WIRE: + aNbW++; + break; + case TopAbs_FACE: + aNbF++; + break; + case TopAbs_SHELL: + aNbSh++; + break; + case TopAbs_SOLID: + aNbS++; + break; + case TopAbs_COMPSOLID: + aNbCS++; + break; + case TopAbs_COMPOUND: + aNbC++; + break; + default: + break; + } + } + + aNbE = 5 * aNbE; + aNbW = 10 * aNbW; + aNbF = 20 * aNbF; + aNbSh = 10 * aNbSh; + aNbS = 10 * aNbS; + aNbCS = 5 * aNbCS; + aNbC = 5 * aNbC; + Standard_Real aSum = aNbV + aNbE + aNbW + aNbF + aNbSh + aNbS + aNbCS + aNbC; + 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; + aSteps(4) = aPart * aNbSh / aSum; + 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; +} + //======================================================================= //function : PerformInternal1 //purpose : @@ -267,9 +350,10 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons return; } // + NCollection_Array1 aSteps = AnalyzeProgress(); // 3. Fill Images // 3.1 Vertice - FillImagesVertices(aPS.Next(10)); // 10 + FillImagesVertices(aPS.Next(aSteps(0))); if (HasErrors()) { return; } @@ -279,7 +363,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons return; } // 3.2 Edges - FillImagesEdges(aPS.Next(10)); // 20 + FillImagesEdges(aPS.Next(aSteps(1))); if (HasErrors()) { return; } @@ -290,7 +374,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons } // // 3.3 Wires - FillImagesContainers(TopAbs_WIRE, aPS.Next(10)); // 30 + FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps(2))); if (HasErrors()) { return; } @@ -301,7 +385,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons } // 3.4 Faces - FillImagesFaces(aPS.Next(30)); // 60 + FillImagesFaces(aPS.Next(aSteps(3))); if (HasErrors()) { return; } @@ -311,7 +395,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons return; } // 3.5 Shells - FillImagesContainers(TopAbs_SHELL, aPS.Next(10)); // 70 + FillImagesContainers(TopAbs_SHELL, aPS.Next(aSteps(4))); if (HasErrors()) { return; } @@ -321,7 +405,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons return; } // 3.6 Solids - FillImagesSolids(aPS.Next(10)); // 80 + FillImagesSolids(aPS.Next(aSteps(5))); if (HasErrors()) { return; } @@ -331,7 +415,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons return; } // 3.7 CompSolids - FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(10)); // 90 + FillImagesContainers(TopAbs_COMPSOLID, aPS.Next(aSteps(6))); if (HasErrors()) { return; } @@ -342,7 +426,7 @@ void BOPAlgo_Builder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, cons } // 3.8 Compounds - FillImagesCompounds(aPS.Next(10)); // 100 + FillImagesCompounds(aPS.Next(aSteps(7))); if (HasErrors()) { return; } diff --git a/src/BOPAlgo/BOPAlgo_Builder.hxx b/src/BOPAlgo/BOPAlgo_Builder.hxx index 78cfa8b6e0..759ff84712 100644 --- a/src/BOPAlgo/BOPAlgo_Builder.hxx +++ b/src/BOPAlgo/BOPAlgo_Builder.hxx @@ -313,6 +313,9 @@ protected: //! @name History methods //! obtaining Generated elements differently. Standard_EXPORT virtual const TopTools_ListOfShape& LocGenerated(const TopoDS_Shape& theS); + //! AnalyzeProgress + Standard_EXPORT NCollection_Array1 AnalyzeProgress() Standard_OVERRIDE; + public: //! @name Images/Origins //! Returns the map of images. diff --git a/src/BOPAlgo/BOPAlgo_Builder_1.cxx b/src/BOPAlgo/BOPAlgo_Builder_1.cxx index fce80e4cd4..ddb4b3052b 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_1.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_1.cxx @@ -40,9 +40,9 @@ //======================================================================= void BOPAlgo_Builder::FillImagesVertices(const Message_ProgressRange& theRange) { - Message_ProgressScope aPS(theRange, "FillImagesVertices", myDS->ShapesSD().Size()); + Message_ProgressScope aPS(theRange, "Filling splits of vertices", 1); TColStd_DataMapIteratorOfDataMapOfIntegerInteger aIt(myDS->ShapesSD()); - for (; aIt.More(); aIt.Next(), aPS.Next()) + for (; aIt.More(); aIt.Next()) { if (UserBreak(aPS)) { @@ -71,8 +71,8 @@ void BOPAlgo_Builder::FillImagesVertices(const Message_ProgressRange& theRange) void BOPAlgo_Builder::FillImagesEdges(const Message_ProgressRange& theRange) { Standard_Integer i, aNbS = myDS->NbSourceShapes(); - Message_ProgressScope aPS(theRange, "FillImagesEdges", aNbS); - for (i = 0; i < aNbS; ++i, aPS.Next()) { + Message_ProgressScope aPS(theRange, "Filling splits of edges", 1); + for (i = 0; i < aNbS; ++i) { if (UserBreak(aPS)) { return; @@ -97,10 +97,6 @@ void BOPAlgo_Builder::FillImagesVertices(const Message_ProgressRange& theRange) // BOPDS_ListIteratorOfListOfPaveBlock aItPB(aLPB); for (; aItPB.More(); aItPB.Next()) { - if (UserBreak(aPS)) - { - return; - } const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value(); Handle(BOPDS_PaveBlock) aPBR = myDS->RealPaveBlock(aPB); // @@ -169,8 +165,8 @@ void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType) TopTools_MapOfShape aMFP(100, myAllocator); // aNbS=myDS->NbSourceShapes(); - Message_ProgressScope aPS(theRange, "FillImagesContainers", aNbS); - for (i=0; iNbSourceShapes(); - Message_ProgressScope aPS(theRange, "FillImagesCompounds", aNbS); + Message_ProgressScope aPS(theRange, "Filling images compounds", aNbS); for (i=0; i BOPAlgo_VectorOfVFI; //======================================================================= void BOPAlgo_Builder::FillImagesFaces(const Message_ProgressRange& theRange) { - Message_ProgressScope aPS(theRange, "FillImagesFaces", 1); + Message_ProgressScope aPS(theRange, "Building splits of faces", 1); BuildSplitFaces(); - if (UserBreak(aPS)) - { - return; - } FillSameDomainFaces(); - if (UserBreak(aPS)) - { - return; - } FillInternalVertices(); } //======================================================================= diff --git a/src/BOPAlgo/BOPAlgo_Builder_3.cxx b/src/BOPAlgo/BOPAlgo_Builder_3.cxx index 6a5cc2a692..e01da97c8d 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_3.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_3.cxx @@ -75,7 +75,7 @@ static //======================================================================= void BOPAlgo_Builder::FillImagesSolids(const Message_ProgressRange& theRange) { - Message_ProgressScope aPS(theRange, "FillImagesSolid", 1); + Message_ProgressScope aPS(theRange, "Filling images solids", 1); Standard_Boolean bHasSolids; Standard_Integer i, aNbS; // @@ -101,16 +101,8 @@ void BOPAlgo_Builder::FillImagesSolids(const Message_ProgressRange& theRange) TopTools_DataMapOfShapeShape aDraftSolids; // Find all IN faces for all IN faces FillIn3DParts(aDraftSolids); - if (UserBreak(aPS)) - { - return; - } // Build split of the solids BuildSplitSolids(aDraftSolids); - if (UserBreak(aPS)) - { - return; - } // Fill solids with internal parts FillInternalShapes(); } diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx index baa25725a8..84d39467f9 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx @@ -229,7 +229,7 @@ NCollection_Array1 BOPAlgo_PaveFiller::AnalyzeProgress() aSteps(i) = 0; } - Standard_Integer aPart = 85; + Standard_Real aPart = 85.; myIterator->Initialize(TopAbs_VERTEX, TopAbs_VERTEX); Standard_Real aPerformVVSize = myIterator->ExpectedLength(); -- 2.39.5