From: Zhuravlev Kirill Date: Wed, 26 May 2021 14:32:32 +0000 (+0300) Subject: Process indication added in the following classes: BOPAlgo_BuilderFace and BOPAlgo_Bu... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=81ee5bcbcae4d33359d868f21f8923faa004065e;p=occt-copy.git Process indication added in the following classes: BOPAlgo_BuilderFace and BOPAlgo_BuilderSolid bbop of Draw modified: indicator displayed Indication in PerformanceAreas() may be incorrect due to the lack of tests --- diff --git a/src/BOPAlgo/BOPAlgo_Builder.hxx b/src/BOPAlgo/BOPAlgo_Builder.hxx index d20ca1beb3..5f71f7b90b 100644 --- a/src/BOPAlgo/BOPAlgo_Builder.hxx +++ b/src/BOPAlgo/BOPAlgo_Builder.hxx @@ -397,7 +397,7 @@ protected: //! @name Fill Images of FACES //! Builds the splits of faces using the information from the //! intersection stage stored in Data Structure. - Standard_EXPORT virtual void BuildSplitFaces(); + Standard_EXPORT virtual void BuildSplitFaces(const Message_ProgressRange& theRange = Message_ProgressRange()); //! Looks for the same domain faces among the splits of the faces. //! Updates the map of images with SD faces. @@ -429,7 +429,7 @@ protected: //! @name Fill Images of SOLIDS //! Builds the splits of the solids using their draft versions //! and faces located inside. - Standard_EXPORT void BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids); + Standard_EXPORT void BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids, const Message_ProgressRange& theRange = Message_ProgressRange()); //! Classifies the vertices and edges from the arguments relatively //! splits of solids and makes them INTERNAL for solids. @@ -439,7 +439,7 @@ protected: //! @name Fill Images of SOLIDS protected: //! @name Fill Images of COMPOUNDS //! Fills the images of compounds. - Standard_EXPORT void FillImagesCompounds(const Message_ProgressRange& theRange); + Standard_EXPORT void FillImagesCompounds(const Message_ProgressRange& theRange = Message_ProgressRange()); //! Builds the image of the given compound. Standard_EXPORT void FillImagesCompound (const TopoDS_Shape& theS, diff --git a/src/BOPAlgo/BOPAlgo_BuilderArea.hxx b/src/BOPAlgo/BOPAlgo_BuilderArea.hxx index ae818a50a8..fbb28e0711 100644 --- a/src/BOPAlgo/BOPAlgo_BuilderArea.hxx +++ b/src/BOPAlgo/BOPAlgo_BuilderArea.hxx @@ -80,13 +80,13 @@ protected: Standard_EXPORT BOPAlgo_BuilderArea(const Handle(NCollection_BaseAllocator)& theAllocator); - virtual void PerformShapesToAvoid() = 0; + virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange = Message_ProgressRange()) = 0; - virtual void PerformLoops() = 0; + virtual void PerformLoops(const Message_ProgressRange& theRange = Message_ProgressRange()) = 0; - virtual void PerformAreas() = 0; + virtual void PerformAreas(const Message_ProgressRange& theRange = Message_ProgressRange()) = 0; - virtual void PerformInternalShapes() = 0; + virtual void PerformInternalShapes(const Message_ProgressRange& theRange = Message_ProgressRange()) = 0; Handle(IntTools_Context) myContext; diff --git a/src/BOPAlgo/BOPAlgo_BuilderFace.cxx b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx index f4ddc32c8d..a16c280d2f 100644 --- a/src/BOPAlgo/BOPAlgo_BuilderFace.cxx +++ b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx @@ -143,50 +143,34 @@ void BOPAlgo_BuilderFace::CheckData() //======================================================================= void BOPAlgo_BuilderFace::Perform(const Message_ProgressRange& theRange) { + + Message_ProgressScope aPS(theRange, "Perform", 100); + GetReport()->Clear(); // CheckData(); - if (HasErrors()) { - return; - } - // - if (!theRange.More()) - { - return; - } - // - PerformShapesToAvoid(); - if (HasErrors()) { - return; - } - // - if (!theRange.More()) - { + if (HasErrors() || !theRange.More()) { return; } // - PerformLoops(); - if (HasErrors()) { + PerformShapesToAvoid(aPS.Next(1)); //1% + if (HasErrors() || !theRange.More()) { return; } // - if (!theRange.More()) - { - return; - } // - PerformAreas(); - if (HasErrors()) { + PerformLoops(aPS.Next(9)); //9% + if (HasErrors() || !theRange.More()) { return; } // - if (!theRange.More()) - { + PerformAreas(aPS.Next(80)); //80% + if (HasErrors() || !theRange.More()) { return; } // - PerformInternalShapes(); - if (HasErrors()) { + PerformInternalShapes(aPS.Next(9)); //9% + if (HasErrors() || !theRange.More()) { return; } } @@ -194,7 +178,7 @@ void BOPAlgo_BuilderFace::Perform(const Message_ProgressRange& theRange) //function :PerformShapesToAvoid //purpose : //======================================================================= -void BOPAlgo_BuilderFace::PerformShapesToAvoid() +void BOPAlgo_BuilderFace::PerformShapesToAvoid(const Message_ProgressRange& theRange) { Standard_Boolean bFound; Standard_Integer i, iCnt, aNbV, aNbE; @@ -203,6 +187,8 @@ void BOPAlgo_BuilderFace::PerformShapesToAvoid() // myShapesToAvoid.Clear(); // + Message_ProgressScope theScope(theRange, "Perform Shapes to Avoid", 1); + // iCnt=0; for(;;) { ++iCnt; @@ -267,7 +253,7 @@ void BOPAlgo_BuilderFace::PerformShapesToAvoid() //function : PerformLoops //purpose : //======================================================================= -void BOPAlgo_BuilderFace::PerformLoops() +void BOPAlgo_BuilderFace::PerformLoops(const Message_ProgressRange& theRange) { Standard_Boolean bFlag; Standard_Integer i, aNbEA; @@ -279,12 +265,17 @@ void BOPAlgo_BuilderFace::PerformLoops() BOPAlgo_WireEdgeSet aWES(myAllocator); BOPAlgo_WireSplitter aWSp(myAllocator); // + Message_ProgressScope MainScope(theRange, "PerformLoops", 100); + // // 1. myLoops.Clear(); aWES.SetFace(myFace); // aIt.Initialize(myShapes); - for (; aIt.More(); aIt.Next()) { + Message_ProgressScope aPS(MainScope.Next(4), "Shells Usual", myShapes.Size()); + for (; aIt.More(); aIt.Next(), aPS.Next()) { + if (!aPS.More()) + return; const TopoDS_Shape& aE=aIt.Value(); if (!myShapesToAvoid.Contains(aE)) { aWES.AddStartElement(aE); @@ -294,7 +285,7 @@ void BOPAlgo_BuilderFace::PerformLoops() aWSp.SetWES(aWES); aWSp.SetRunParallel(myRunParallel); aWSp.SetContext(myContext); - aWSp.Perform(); + aWSp.Perform(MainScope.Next(90)); if (aWSp.HasErrors()) { return; } @@ -310,7 +301,10 @@ void BOPAlgo_BuilderFace::PerformLoops() // // a. collect all edges that are in loops aIt.Initialize (myLoops); - for (; aIt.More(); aIt.Next()) { + Message_ProgressScope aPT_PS(MainScope.Next(), "Post Treatment: collect all edges", myLoops.Size()); + for (; aIt.More(); aIt.Next(), aPT_PS.Next()) { + if (!aPT_PS.More()) + return; const TopoDS_Shape& aW=aIt.Value(); aItW.Initialize(aW); for (; aItW.More(); aItW.Next()) { @@ -328,7 +322,8 @@ void BOPAlgo_BuilderFace::PerformLoops() // // c. add all edges that are not processed to myShapesToAvoid aIt.Initialize (myShapes); - for (; aIt.More(); aIt.Next()) { + Message_ProgressScope aPT_PS1(MainScope.Next(), "Post Treatment: adding edges", myShapes.Size()); + for (; aIt.More(); aIt.Next(), aPT_PS1.Next()) { const TopoDS_Shape& aE=aIt.Value(); if (!aMEP.Contains(aE)) { myShapesToAvoid.Add(aE); @@ -387,7 +382,7 @@ void BOPAlgo_BuilderFace::PerformLoops() //function : PerformAreas //purpose : //======================================================================= -void BOPAlgo_BuilderFace::PerformAreas() +void BOPAlgo_BuilderFace::PerformAreas(const Message_ProgressRange& theRange) { myAreas.Clear(); BRep_Builder aBB; @@ -398,6 +393,8 @@ void BOPAlgo_BuilderFace::PerformAreas() // Get tolerance of myFace Standard_Real aTol = BRep_Tool::Tolerance(myFace); + Message_ProgressScope theMainPS(theRange, "PerformAreas", 10); + // Check if there are no loops at all if (myLoops.IsEmpty()) { @@ -423,7 +420,8 @@ void BOPAlgo_BuilderFace::PerformAreas() // Analyze the new wires - classify them to be the holes and growths TopTools_ListIteratorOfListOfShape aItLL(myLoops); - for (; aItLL.More(); aItLL.Next()) + Message_ProgressScope aPS(theMainPS.Next(4), "Analyze the shells", myLoops.Size()); + for (; aItLL.More(); aItLL.Next(), aPS.Next()) { const TopoDS_Shape& aWire = aItLL.Value(); @@ -464,7 +462,8 @@ void BOPAlgo_BuilderFace::PerformAreas() BOPTools_Box2dTree aBoxTree; Standard_Integer i, aNbH = aHoleFaces.Extent(); aBoxTree.SetSize (aNbH); - for (i = 1; i <= aNbH; ++i) + Message_ProgressScope aTPPS(theMainPS.Next(), "Prepare tree with the boxes of the hole faces", aNbH); + for (i = 1; i <= aNbH; ++i, aTPPS.Next()) { const TopoDS_Face& aHFace = TopoDS::Face(aHoleFaces(i)); // @@ -484,7 +483,8 @@ void BOPAlgo_BuilderFace::PerformAreas() aSelector.SetBVHSet (&aBoxTree); TopTools_ListIteratorOfListOfShape aItLS(aNewFaces); - for (; aItLS.More(); aItLS.Next()) + Message_ProgressScope aPS1(theMainPS.Next(), "Selector", aNewFaces.Size()); + for (; aItLS.More(); aItLS.Next(), aPS1.Next()) { const TopoDS_Face& aFace = TopoDS::Face(aItLS.Value()); @@ -526,7 +526,8 @@ void BOPAlgo_BuilderFace::PerformAreas() TopTools_IndexedDataMapOfShapeListOfShape aFaceHolesMap; aNbH = aHoleFaceMap.Extent(); - for (i = 1; i <= aNbH; ++i) + Message_ProgressScope aPS2(theMainPS.Next(), "Make the back map from faces to holes", aNbH); + for (i = 1; i <= aNbH; ++i, aPS2.Next()) { const TopoDS_Shape& aHole = aHoleFaceMap.FindKey(i); const TopoDS_Shape& aFace = aHoleFaceMap(i); @@ -563,6 +564,7 @@ void BOPAlgo_BuilderFace::PerformAreas() // Add Holes to Faces and add them to myAreas aItLS.Initialize(aNewFaces); + Message_ProgressScope aPS4(theMainPS.Next(), "Adding Holes to Faces", aNewFaces.Size()); for ( ; aItLS.More(); aItLS.Next()) { TopoDS_Face& aFace = *(TopoDS_Face*)&aItLS.Value(); @@ -591,7 +593,7 @@ void BOPAlgo_BuilderFace::PerformAreas() //function : PerformInternalShapes //purpose : //======================================================================= -void BOPAlgo_BuilderFace::PerformInternalShapes() +void BOPAlgo_BuilderFace::PerformInternalShapes(const Message_ProgressRange& theRange) { if (myAvoidInternalShapes) // User-defined option to avoid internal edges @@ -607,10 +609,14 @@ void BOPAlgo_BuilderFace::PerformInternalShapes() // Map of edges to classify TopTools_IndexedMapOfShape anEdgesMap; + + //Make main progress scope + Message_ProgressScope aPS(theRange, "PerformInternalShapes", 3); // Fill the tree and the map TopTools_ListIteratorOfListOfShape itLE(myLoopsInternal); - for (; itLE.More(); itLE.Next()) + Message_ProgressScope aFTPS(aPS.Next(), "Filling the tree and the map", myLoopsInternal.Size()); + for (; itLE.More(); itLE.Next(), aFTPS.Next()) { TopoDS_Iterator itE(itLE.Value()); for (; itE.More(); itE.Next()) @@ -635,7 +641,8 @@ void BOPAlgo_BuilderFace::PerformInternalShapes() // Classify edges relatively faces TopTools_ListIteratorOfListOfShape itLF(myAreas); - for (; itLF.More(); itLF.Next()) + Message_ProgressScope aCEPS(aPS.Next(), "Classify edges", myAreas.Size()); + for (; itLF.More(); itLF.Next(), aCEPS.Next()) { TopoDS_Face& aF = *(TopoDS_Face*)&itLF.Value(); @@ -700,7 +707,7 @@ void BOPAlgo_BuilderFace::PerformInternalShapes() // Make internal wires TopTools_ListOfShape aLSI; - MakeInternalWires(anEdgesUnUsed, aLSI); + MakeInternalWires(anEdgesUnUsed, aLSI/*, aPS.Next()*/); // Make compound TopoDS_Compound aWShape; @@ -717,6 +724,8 @@ void BOPAlgo_BuilderFace::PerformInternalShapes() BRep_Builder().Add(aWShape, aCE); } + aPS.Next(); + // Add warning AddWarning(new BOPAlgo_AlertFaceBuilderUnusedEdges(aWShape)); } diff --git a/src/BOPAlgo/BOPAlgo_BuilderFace.hxx b/src/BOPAlgo/BOPAlgo_BuilderFace.hxx index 2bc2966151..e888d1553a 100644 --- a/src/BOPAlgo/BOPAlgo_BuilderFace.hxx +++ b/src/BOPAlgo/BOPAlgo_BuilderFace.hxx @@ -63,20 +63,20 @@ protected: //! Collect the edges that //! a) are internal //! b) are the same and have different orientation - Standard_EXPORT virtual void PerformShapesToAvoid() Standard_OVERRIDE; + Standard_EXPORT virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; //! Build draft wires //! a)myLoops - draft wires that consist of //! boundary edges //! b)myLoopsInternal - draft wires that contains //! inner edges - Standard_EXPORT virtual void PerformLoops() Standard_OVERRIDE; + Standard_EXPORT virtual void PerformLoops(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; //! Build draft faces that contains boundary edges - Standard_EXPORT virtual void PerformAreas() Standard_OVERRIDE; + Standard_EXPORT virtual void PerformAreas(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; //! Build finalized faces with internals - Standard_EXPORT virtual void PerformInternalShapes() Standard_OVERRIDE; + Standard_EXPORT virtual void PerformInternalShapes(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; Standard_EXPORT virtual void CheckData() Standard_OVERRIDE; diff --git a/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx b/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx index f85bd2e053..5a5e3d5e3d 100644 --- a/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx +++ b/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx @@ -41,10 +41,6 @@ #include #include #include - -#include -#include - #include #include #include @@ -64,9 +60,6 @@ #include #include #include -//----------------------------------------------------------- -#include -//----------------------------------------------------------- // static @@ -115,103 +108,51 @@ BOPAlgo_BuilderSolid::~BOPAlgo_BuilderSolid() //======================================================================= void BOPAlgo_BuilderSolid::Perform(const Message_ProgressRange& theRange) { - //Message_ProgressRange aRootRange=theRange->Start(); - Message_ProgressScope aPS(theRange, "Perform Builder Solid", 100); - //Timer construction - //--------------------------------------------------------------------- - OSD_Timer DurationTimer; - //--------------------------------------------------------------------- - - DurationTimer.Start(); + Message_ProgressScope theScope(theRange, "Perform", 100); GetReport()->Clear(); // if (myShapes.IsEmpty()) return; - if (myContext.IsNull()) { myContext=new IntTools_Context; } - myBoxes.Clear(); - - DurationTimer.Stop(); - std::cout << "Prelim. duration: " << DurationTimer.ElapsedTime() << std::endl; - aPS.Next(1); - - + // TopoDS_Compound aC; BRep_Builder aBB; TopTools_ListIteratorOfListOfShape aIt; // - DurationTimer.Restart(); - aBB.MakeCompound(aC); - DurationTimer.Stop(); - std::cout << "MakeCompound duration: " << DurationTimer.ElapsedTime() << std::endl; - aPS.Next(1); - DurationTimer.Restart(); + aBB.MakeCompound(aC); aIt.Initialize(myShapes); - DurationTimer.Stop(); - std::cout << "Initialize duration: " << DurationTimer.ElapsedTime() << std::endl; - aPS.Next(1); - DurationTimer.Restart(); + for(; aIt.More(); aIt.Next()) { const TopoDS_Shape& aF=aIt.Value(); aBB.Add(aC, aF); } - DurationTimer.Stop(); - std::cout << "ItLoop duration: " << DurationTimer.ElapsedTime() << std::endl; - // if (!theRange.More()) { return; } // - DurationTimer.Restart(); - PerformShapesToAvoid(); - DurationTimer.Stop(); - std::cout << "PerformShapesToAvoid duration: " << DurationTimer.ElapsedTime() << std::endl; - if (HasErrors()) { - return; - } - // - if (!theRange.More()) - { + PerformShapesToAvoid(theScope.Next(1)); //1% + if (HasErrors() || !theRange.More()) { return; } - // - DurationTimer.Restart(); - PerformLoops(); - DurationTimer.Stop(); - std::cout << "PerformLoops duration: " << DurationTimer.ElapsedTime() << std::endl; - aPS.Next(97); - if (HasErrors()) { - return; - } - // - if (!theRange.More()) - { - return; - } - // - DurationTimer.Restart(); - PerformAreas(); - DurationTimer.Stop(); - std::cout << "PerformAreas duration: " << DurationTimer.ElapsedTime() << std::endl; - if (HasErrors()) { + // + PerformLoops(theScope.Next(9)); //9% + + if (HasErrors() || !theRange.More()) { return; } - // - if (!theRange.More()) - { + // + PerformAreas(theScope.Next(80)); //80% + if (HasErrors() || !theRange.More()) { return; } // - DurationTimer.Restart(); - PerformInternalShapes(); - DurationTimer.Stop(); - std::cout << "PerformInternalShapes duration: " << DurationTimer.ElapsedTime() << std::endl; - if (HasErrors()) { + PerformInternalShapes(theScope.Next(9)); //10% + if (HasErrors() || !theRange.More()) { return; } } @@ -219,7 +160,7 @@ void BOPAlgo_BuilderSolid::Perform(const Message_ProgressRange& theRange) //function :PerformShapesToAvoid //purpose : //======================================================================= -void BOPAlgo_BuilderSolid::PerformShapesToAvoid() +void BOPAlgo_BuilderSolid::PerformShapesToAvoid(const Message_ProgressRange& theRange) { Standard_Boolean bFound; Standard_Integer i, iCnt, aNbE, aNbF; @@ -229,6 +170,8 @@ void BOPAlgo_BuilderSolid::PerformShapesToAvoid() // myShapesToAvoid.Clear(); // + Message_ProgressScope theScope(theRange, "Perform Shapes to Avoid", 1); + // iCnt=0; for(;;) { ++iCnt; @@ -299,7 +242,7 @@ void BOPAlgo_BuilderSolid::PerformShapesToAvoid() //function : PerformLoops //purpose : //======================================================================= -void BOPAlgo_BuilderSolid::PerformLoops() +void BOPAlgo_BuilderSolid::PerformLoops(const Message_ProgressRange& theRange) { Standard_Integer i, aNbSh; TopTools_ListIteratorOfListOfShape aIt; @@ -307,17 +250,24 @@ void BOPAlgo_BuilderSolid::PerformLoops() Handle(NCollection_BaseAllocator) aAlr; // myLoops.Clear(); + // // aAlr= NCollection_BaseAllocator::CommonBaseAllocator(); BOPAlgo_ShellSplitter aSSp(aAlr); // - // 1. Shells Usual + // + Message_ProgressScope MainScope(theRange, "PerformLoops", 100); + + // 1. Shells Usual aIt.Initialize (myShapes); - for (; aIt.More(); aIt.Next()) { + Message_ProgressScope aPS(MainScope.Next(4), "Shells Usual", myShapes.Size()); + for (; aIt.More(); aIt.Next(), aPS.Next()) { + if (!aPS.More()) + return; const TopoDS_Face& aF=*((TopoDS_Face*)&aIt.Value()); if (myContext->IsInfiniteFace(aF)) { - TopoDS_Shell aSh; + TopoDS_Shell aSh; BRep_Builder aBB; // aBB.MakeShell(aSh); @@ -330,11 +280,14 @@ void BOPAlgo_BuilderSolid::PerformLoops() aSSp.AddStartElement(aF); } } - // + aSSp.SetRunParallel(myRunParallel); - aSSp.Perform(); + aSSp.Perform(MainScope.Next(90)); + if (!MainScope.More()) + return; + if (aSSp.HasErrors()) { - // add warning status + // add warning status { TopoDS_Compound aFacesSp; BRep_Builder().MakeCompound(aFacesSp); @@ -346,24 +299,26 @@ void BOPAlgo_BuilderSolid::PerformLoops() } return; } - // + const TopTools_ListOfShape& aLSh=aSSp.Shells(); aIt.Initialize (aLSh); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aSh=aIt.Value(); myLoops.Append(aSh); } - //================================================= // // 2. Post Treatment BRep_Builder aBB; TopTools_MapOfOrientedShape AddedFacesMap; TopTools_IndexedDataMapOfShapeListOfShape aEFMap; TopTools_MapOfOrientedShape aMP; - // + // a. collect all edges that are in loops aIt.Initialize (myLoops); - for (; aIt.More(); aIt.Next()) { + Message_ProgressScope aPT_PS(MainScope.Next(), "Post Treatment: collect all edges", myLoops.Size()); + for (; aIt.More(); aIt.Next(), aPT_PS.Next()) { + if (!aPT_PS.More()) + return; const TopoDS_Shape& aS=aIt.Value(); aItS.Initialize(aS); for (; aItS.More(); aItS.Next()) { @@ -379,17 +334,17 @@ void BOPAlgo_BuilderSolid::PerformLoops() aMP.Add(aF); } // - // c. add all edges that are not processed to myShapesToAvoid + // c. add all edges that are not processed to myShapesToAvoid aIt.Initialize (myShapes); - for (; aIt.More(); aIt.Next()) { + Message_ProgressScope aPT_PS1(MainScope.Next(), "Post Treatment: adding edges", myShapes.Size()); + for (; aIt.More(); aIt.Next(), aPT_PS1.Next()) { const TopoDS_Face& aF=*((TopoDS_Face*)&aIt.Value()); if (!myContext->IsInfiniteFace(aF)) { if (!aMP.Contains(aF)) { myShapesToAvoid.Add(aF); } } - } - //================================================= + } // // 3.Internal Shells myLoopsInternal.Clear(); @@ -398,13 +353,14 @@ void BOPAlgo_BuilderSolid::PerformLoops() AddedFacesMap.Clear(); // aNbSh = myShapesToAvoid.Extent(); + for (i = 1; i <= aNbSh; ++i) { const TopoDS_Shape& aFF = myShapesToAvoid(i); TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap); } - // + // for (i = 1; i <= aNbSh; ++i) { const TopoDS_Shape& aFF = myShapesToAvoid(i); if (!AddedFacesMap.Add(aFF)) { @@ -442,8 +398,9 @@ void BOPAlgo_BuilderSolid::PerformLoops() //function : PerformAreas //purpose : //======================================================================= -void BOPAlgo_BuilderSolid::PerformAreas() +void BOPAlgo_BuilderSolid:: PerformAreas(const Message_ProgressRange& theRange) { + myAreas.Clear(); BRep_Builder aBB; // The new solids @@ -454,12 +411,17 @@ void BOPAlgo_BuilderSolid::PerformAreas() // If the analyzed shell contains any of the hole faces, it is considered as growth. TopTools_IndexedMapOfShape aMHF; + Message_ProgressScope theMainPS(theRange, "PerformAreas", 10); + // Analyze the shells TopTools_ListIteratorOfListOfShape aItLL(myLoops); - for (; aItLL.More(); aItLL.Next()) + Message_ProgressScope aPS(theMainPS.Next(4), "Analyze the shells", myLoops.Size()); + for (; aItLL.More(); aItLL.Next(), aPS.Next()) { - const TopoDS_Shape& aShell = aItLL.Value(); + if (!aPS.More()) + return; + const TopoDS_Shape& aShell = aItLL.Value(); Standard_Boolean bIsGrowth = IsGrowthShell(aShell, aMHF); if (!bIsGrowth) { @@ -481,12 +443,13 @@ void BOPAlgo_BuilderSolid::PerformAreas() TopExp::MapShapes(aShell, TopAbs_FACE, aMHF); } } - + if (aHoleShells.IsEmpty()) { // No holes, stop the analysis TopTools_ListIteratorOfListOfShape aItLS(aNewSolids); - for (; aItLS.More(); aItLS.Next()) + Message_ProgressScope aSHPS(theMainPS.Next(), "SearchHoles", aNewSolids.Size()); + for (; aItLS.More(); aItLS.Next(), aSHPS.Next()) { const TopoDS_Shape& aSol = aItLS.Value(); myAreas.Append(aSol); @@ -497,14 +460,13 @@ void BOPAlgo_BuilderSolid::PerformAreas() } return; } - // Classify holes relatively solids - // Prepare tree with the boxes of the hole shells BOPTools_BoxTree aBBTree; Standard_Integer i, aNbH = aHoleShells.Extent(); + Message_ProgressScope aPS1(theMainPS.Next(), "Prepare tree with the boxes of the hole shells", aNbH); aBBTree.SetSize (aNbH); - for (i = 1; i <= aNbH; ++i) + for (i = 1; i <= aNbH; ++i, aPS.Next()) { const TopoDS_Shape& aHShell = aHoleShells(i); // @@ -520,8 +482,9 @@ void BOPAlgo_BuilderSolid::PerformAreas() // Find outer growth shell that is most close to each hole shell TopTools_IndexedDataMapOfShapeShape aHoleSolidMap; - TopTools_ListIteratorOfListOfShape aItLS(aNewSolids); + Message_ProgressScope aPS2(theMainPS.Next(), "Find outer growth shell that is most close to each hole shell", aNewSolids.Size()); + //50% for (; aItLS.More(); aItLS.Next()) { const TopoDS_Shape& aSolid = aItLS.Value(); @@ -539,7 +502,8 @@ void BOPAlgo_BuilderSolid::PerformAreas() const TColStd_ListOfInteger& aLI = aSelector.Indices(); TColStd_ListIteratorOfListOfInteger aItLI(aLI); - for (; aItLI.More(); aItLI.Next()) + Message_ProgressScope aPS21(aPS2.Next(), "Iteration", aLI.Size()); + for (; aItLI.More(); aItLI.Next(), aPS21.Next()) { Standard_Integer k = aItLI.Value(); const TopoDS_Shape& aHole = aHoleShells(k); @@ -562,12 +526,12 @@ void BOPAlgo_BuilderSolid::PerformAreas() } } } - + // Make the back map from solids to holes TopTools_IndexedDataMapOfShapeListOfShape aSolidHolesMap; - aNbH = aHoleSolidMap.Extent(); - for (i = 1; i <= aNbH; ++i) + Message_ProgressScope aPS3(theMainPS.Next(), "Make the back map from solids to holes", aNbH); + for (i = 1; i <= aNbH; ++i, aPS3.Next()) { const TopoDS_Shape& aHole = aHoleSolidMap.FindKey(i); const TopoDS_Shape& aSolid = aHoleSolidMap(i); @@ -580,7 +544,8 @@ void BOPAlgo_BuilderSolid::PerformAreas() // Add Holes to Solids and add them to myAreas aItLS.Initialize(aNewSolids); - for ( ; aItLS.More(); aItLS.Next()) + Message_ProgressScope aPS4(theMainPS.Next(), "Adding Holes to Solids", aNewSolids.Size()); + for ( ; aItLS.More(); aItLS.Next(), aPS4.Next()) { TopoDS_Solid& aSolid = *(TopoDS_Solid*)&aItLS.Value(); const TopTools_ListOfShape* pLHoles = aSolidHolesMap.Seek(aSolid); @@ -603,7 +568,8 @@ void BOPAlgo_BuilderSolid::PerformAreas() // Add holes that outside the solids to myAreas aNbH = aHoleShells.Extent(); - for (i = 1; i <= aNbH; ++i) + Message_ProgressScope aPS5(theMainPS.Next(), "Add holes that outside the solids to myAreas", aNbH); + for (i = 1; i <= aNbH; ++i, aPS5.Next()) { const TopoDS_Shape& aHole = aHoleShells(i); if (!aHoleSolidMap.Contains(aHole)) @@ -626,20 +592,22 @@ void BOPAlgo_BuilderSolid::PerformAreas() //function : PerformInternalShapes //purpose : //======================================================================= -void BOPAlgo_BuilderSolid::PerformInternalShapes() -{ +void BOPAlgo_BuilderSolid::PerformInternalShapes(const Message_ProgressRange& theRange) +{ if (myAvoidInternalShapes) - // user-defined option to avoid internal parts is in force - return; + // user-defined option to avoid internal parts is in force + return; if (myLoopsInternal.IsEmpty()) - // no internal parts - return; + // no internal parts + return; // Get all faces to classify TopTools_IndexedMapOfShape aMFs; TopTools_ListIteratorOfListOfShape aItLS(myLoopsInternal); - for (; aItLS.More(); aItLS.Next()) + Message_ProgressScope aMainPS(theRange, "PerformInternalShapes", 3); + Message_ProgressScope aSPrSc(aMainPS.Next(), "PerformInternalShapes", myLoopsInternal.Size()); + for (; aItLS.More(); aItLS.Next(), aSPrSc.Next()) { const TopoDS_Shape& aShell = aItLS.Value(); TopoDS_Iterator aIt(aShell); @@ -686,7 +654,8 @@ void BOPAlgo_BuilderSolid::PerformInternalShapes() TopTools_MapOfShape aMFDone; Standard_Integer aNbS = aMSLF.Extent(); - for (i = 1; i <= aNbS; ++i) + Message_ProgressScope aSPrSc1(aMainPS.Next(), "Update Solids by internal Faces", aNbS); + for (i = 1; i <= aNbS; ++i, aSPrSc1.Next()) { const TopoDS_Shape& aSolid = aMSLF.FindKey(i); TopoDS_Shape *pSolid = (TopoDS_Shape*)&aSolid; diff --git a/src/BOPAlgo/BOPAlgo_BuilderSolid.hxx b/src/BOPAlgo/BOPAlgo_BuilderSolid.hxx index 787c806cfb..b4dbb526ac 100644 --- a/src/BOPAlgo/BOPAlgo_BuilderSolid.hxx +++ b/src/BOPAlgo/BOPAlgo_BuilderSolid.hxx @@ -114,28 +114,28 @@ protected: //! @name Protected methods performing the operation //! - that are alone but given twice with different orientation. //! These faces will be put into the map *myShapesToAvoid* and will be //! avoided in shells construction, but will be classified later on. - Standard_EXPORT virtual void PerformShapesToAvoid() Standard_OVERRIDE; + Standard_EXPORT virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; //! Build all possible closed shells from the given faces. //! The method fills the following maps: //! - myLoops - Created closed shells; //! - myLoopsInternal - The shells created from unused faces. - Standard_EXPORT virtual void PerformLoops() Standard_OVERRIDE; + Standard_EXPORT virtual void PerformLoops(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; //! Classifies the created shells on the Holes and Growths. //! Creates the solids from the Growths shells. //! Puts the Hole shells into the closest Growths solids. - Standard_EXPORT virtual void PerformAreas() Standard_OVERRIDE; + Standard_EXPORT virtual void PerformAreas(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; //! Classifies the unused faces relatively the created solids. //! Puts the classified faces into the closest solids as internal shells. //! Warns the user about unclassified faces if any. - Standard_EXPORT virtual void PerformInternalShapes() Standard_OVERRIDE; + Standard_EXPORT virtual void PerformInternalShapes(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; private: TopTools_DataMapOfShapeBox myBoxes; // Boxes of the produced solids - + }; #endif // _BOPAlgo_BuilderSolid_HeaderFile diff --git a/src/BOPAlgo/BOPAlgo_Builder_2.cxx b/src/BOPAlgo/BOPAlgo_Builder_2.cxx index 3464b3de39..b0da72f3aa 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_2.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_2.cxx @@ -200,23 +200,15 @@ typedef NCollection_Vector BOPAlgo_VectorOfVFI; void BOPAlgo_Builder::FillImagesFaces(const Message_ProgressRange& theRange) { Message_ProgressScope aPS(theRange, "FillImagesFaces", 1); - BuildSplitFaces(); - if (!aPS.More()) - { - return; - } + BuildSplitFaces(aPS.Next()); FillSameDomainFaces(); - if (!aPS.More()) - { - return; - } FillInternalVertices(); } //======================================================================= //function : BuildSplitFaces //purpose : //======================================================================= -void BOPAlgo_Builder::BuildSplitFaces() +void BOPAlgo_Builder::BuildSplitFaces(const Message_ProgressRange& theRange) { Standard_Boolean bHasFaceInfo, bIsClosed, bIsDegenerated, bToReverse; Standard_Integer i, j, k, aNbS, aNbPBIn, aNbPBOn, aNbPBSc, aNbAV, nSp; @@ -473,11 +465,13 @@ void BOPAlgo_Builder::BuildSplitFaces() //=================================================== // Standard_Integer aNbBF = aVBF.Length(); + Message_ProgressScope aPS(theRange, "Builder Face", aNbBF); for (k = 0; k < aNbBF; ++k) { - BOPAlgo_BuilderFace& aBF = aVBF(k); + BOPAlgo_BuilderFace& aBF = aVBF(k); aFacesIm.Add(myDS->Index(aBF.Face()), aBF.Areas()); myReport->Merge(aBF.GetReport()); + aBF.Perform(aPS.Next()); } aNbBF = aFacesIm.Extent(); diff --git a/src/BOPAlgo/BOPAlgo_Builder_3.cxx b/src/BOPAlgo/BOPAlgo_Builder_3.cxx index 499317cc5c..7f47065078 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_3.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_3.cxx @@ -105,8 +105,9 @@ void BOPAlgo_Builder::FillImagesSolids(const Message_ProgressRange& theRange) { return; } + //std::cout << "FillImagesSolids:theRange = " << theRange.IsActive() << std::endl; // Build split of the solids - BuildSplitSolids(aDraftSolids); + BuildSplitSolids(aDraftSolids, aPS.Next()); if (!aPS.More()) { return; @@ -348,8 +349,19 @@ public: //! Returns the solid const TopoDS_Solid& Solid() const { return mySolid; } + void SetProgress(const Message_ProgressRange& theRange) + { + myRange = theRange; + } + + virtual void Perform(const Message_ProgressRange& /*theRange*/ = Message_ProgressRange()) + { + BOPAlgo_BuilderSolid::Perform(myRange); + } + private: TopoDS_Solid mySolid; //!< Solid to split + Message_ProgressRange myRange; }; // Vector of Solid Builders @@ -359,7 +371,7 @@ typedef NCollection_Vector BOPAlgo_VectorOfBuilderSolid; //function : BuildSplitSolids //purpose : //======================================================================= -void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids) +void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSolids, const Message_ProgressRange& theRange) { Standard_Boolean bFlagSD; Standard_Integer i, aNbS; @@ -376,6 +388,7 @@ void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSol // // 0. Find same domain solids for non-interfered solids aNbS=myDS->NbSourceShapes(); + for (i=0; iShapeInfo(i); // @@ -451,11 +464,17 @@ void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSol // aNbBS=aVBS.Length(); // + + Message_ProgressScope aPS(theRange, "Builder solid", aNbBS); + for (Standard_Integer index = 0; index < aNbBS; index++) { + BOPAlgo_SplitSolid& aSplitSolid = aVBS.ChangeValue(index); + aSplitSolid.SetProgress(aPS.Next()); + } //=================================================== BOPTools_Parallel::Perform (myRunParallel, aVBS); //=================================================== // - for (k = 0; k < aNbBS; ++k) + for (k = 0; k < aNbBS; ++k) { BOPAlgo_SplitSolid& aBS = aVBS(k); aSolidsIm.Add(aBS.Solid(), aBS.Areas()); diff --git a/src/BOPAlgo/BOPAlgo_CellsBuilder.cxx b/src/BOPAlgo/BOPAlgo_CellsBuilder.cxx index 1a4f7ee110..dca505d89b 100644 --- a/src/BOPAlgo/BOPAlgo_CellsBuilder.cxx +++ b/src/BOPAlgo/BOPAlgo_CellsBuilder.cxx @@ -109,7 +109,7 @@ void BOPAlgo_CellsBuilder::PerformInternal1(const BOPAlgo_PaveFiller& theFiller, Standard_Boolean isHistory = HasHistory(); SetToFillHistory(Standard_False); // Perform splitting of the arguments - Message_ProgressScope aPS(theRange, "BOPAlgo_CellsBuilder", 1); + Message_ProgressScope aPS(theRange, "BOPAlgo_CellsBuilder", 2); BOPAlgo_Builder::PerformInternal1(theFiller, aPS.Next()); if (HasErrors() || !aPS.More()) { return; diff --git a/src/BOPAlgo/BOPAlgo_ShellSplitter.cxx b/src/BOPAlgo/BOPAlgo_ShellSplitter.cxx index 033d441246..bf493ebf0b 100644 --- a/src/BOPAlgo/BOPAlgo_ShellSplitter.cxx +++ b/src/BOPAlgo/BOPAlgo_ShellSplitter.cxx @@ -64,11 +64,19 @@ class BOPAlgo_CBK { return *myPCB; } // + void SetProgress(const Message_ProgressRange& theRange) + { + myRange = theRange; + } + // void Perform() { BOPAlgo_ShellSplitter::SplitBlock(*myPCB); } protected: BOPTools_ConnexityBlock *myPCB; + + private: + Message_ProgressRange myRange; }; //======================================================================= typedef NCollection_Vector BOPAlgo_VectorOfCBK; @@ -133,14 +141,15 @@ const TopTools_ListOfShape& BOPAlgo_ShellSplitter::Shells()const //function : Perform //purpose : //======================================================================= -void BOPAlgo_ShellSplitter::Perform(const Message_ProgressRange& /*theRange*/) +void BOPAlgo_ShellSplitter::Perform(const Message_ProgressRange& theRange) { GetReport()->Clear(); + Message_ProgressScope aPS(theRange, "Perform", 1); // BOPTools_AlgoTools::MakeConnexityBlocks (myStartShapes, TopAbs_EDGE, TopAbs_FACE, myLCB); // - MakeShells(); + MakeShells(aPS.Next()); } //======================================================================= @@ -535,7 +544,7 @@ void RefineShell(TopoDS_Shell& theShell, //function : MakeShells //purpose : //======================================================================= -void BOPAlgo_ShellSplitter::MakeShells() +void BOPAlgo_ShellSplitter::MakeShells(const Message_ProgressRange& theRange) { Standard_Boolean bIsRegular; Standard_Integer aNbVCBK, k; @@ -546,7 +555,9 @@ void BOPAlgo_ShellSplitter::MakeShells() myShells.Clear(); // aItCB.Initialize(myLCB); - for (; aItCB.More(); aItCB.Next()) { + Message_ProgressScope aPSOuter(theRange, "Make shells", 10); + Message_ProgressScope aPS(aPSOuter.Next(1), "Iteration", myLCB.Size()); + for (; aItCB.More(); aItCB.Next(), aPS.Next()) { BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue(); bIsRegular=aCB.IsRegular(); if (bIsRegular) { @@ -564,10 +575,21 @@ void BOPAlgo_ShellSplitter::MakeShells() } // aNbVCBK=aVCBK.Length(); + + //Message_ProgressScope aPS(aPSOuter.Next(8), "MS", aNbVCBK); + //for (Standard_Integer index = 0; index < aNbVCBK; index++) { + //BOPAlgo_CBK& aUselessCBK = aVCBK.ChangeValue(index); + //aUselessCBK.SetProgress(aPS.Next()); + //} + //=================================================== BOPTools_Parallel::Perform (myRunParallel, aVCBK); //=================================================== - for (k=0; kClear(); + Message_ProgressScope aPS(theRange, "Perform", 1); // CheckData(); if (HasErrors()) { @@ -126,7 +127,7 @@ void BOPAlgo_WireSplitter::Perform(const Message_ProgressRange& /*theRange*/) BOPTools_AlgoTools::MakeConnexityBlocks (myWES->StartElements(), TopAbs_VERTEX, TopAbs_EDGE, myLCB); - MakeWires(); + MakeWires(aPS.Next()); } ///////////////////////////////////////////////////////////////////////// @@ -175,7 +176,7 @@ typedef NCollection_Vector BOPAlgo_VectorOfConnexityB //function : MakeWires //purpose : //======================================================================= -void BOPAlgo_WireSplitter::MakeWires() +void BOPAlgo_WireSplitter::MakeWires(const Message_ProgressRange& theRange) { Standard_Boolean bIsRegular; Standard_Integer aNbVCB, k; @@ -185,9 +186,11 @@ void BOPAlgo_WireSplitter::MakeWires() BOPAlgo_VectorOfConnexityBlock aVCB; // const TopoDS_Face& aF=myWES->Face(); + Message_ProgressScope aPSOuter(theRange, "Make shells", 10); // - aItCB.Initialize(myLCB); - for (; aItCB.More(); aItCB.Next()) { + aItCB.Initialize(myLCB); + Message_ProgressScope aPS(aPSOuter.Next(1), "Iteration", myLCB.Size()); + for (; aItCB.More(); aItCB.Next(), aPS.Next()) { BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue(); bIsRegular=aCB.IsRegular(); if (bIsRegular) { @@ -204,8 +207,11 @@ void BOPAlgo_WireSplitter::MakeWires() //=================================================== BOPTools_Parallel::Perform (myRunParallel, aVCB, myContext); //=================================================== + if (!aPSOuter.More()) + return; aNbVCB=aVCB.Length(); - for (k=0; kSetCheckInverted(BOPTest_Objects::CheckInverted()); pBuilder->SetToFillHistory(BRepTest_Objects::IsHistoryNeeded()); // + OSD_Timer aTimer; aTimer.Start(); + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1); // - pBuilder->PerformWithFiller(aPF); + pBuilder->PerformWithFiller(aPF, aProgress->Start()); + if (aProgress->UserBreak()) + { + di << "Error: User break"; + return 0; + } BOPTest::ReportAlerts(pBuilder->GetReport()); // Set history of Boolean operation into the session