]> OCCT Git - occt-copy.git/commitdiff
Updating BOPAlgo_Section
authorakaftasev <akaftasev@opencascade.com>
Thu, 6 May 2021 09:24:39 +0000 (12:24 +0300)
committerakaftasev <akaftasev@opencascade.com>
Thu, 6 May 2021 09:32:33 +0000 (12:32 +0300)
Added AnalyzeProgress

src/BOPAlgo/BOPAlgo_BOP.cxx
src/BOPAlgo/BOPAlgo_Section.cxx
src/BOPAlgo/BOPAlgo_Section.hxx

index c573a9b6f200c534da69d571db194083fc241525..733df41a0040b171a98d7d33aa35b25b02495f9f 100644 (file)
@@ -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);
index 3a4838396dbc5186742232cb1f6d504c2d0726ed..1a5e060e2487fdf4ab7c531d87ec874587603bd7 100644 (file)
@@ -83,6 +83,56 @@ void BOPAlgo_Section::CheckData()
   //
   CheckFiller();
 }
+
+//=======================================================================
+//function : AnalyzeProgress
+//purpose  : 
+//=======================================================================
+NCollection_Array1<Standard_Real> BOPAlgo_Section::AnalyzeProgress()
+{
+  Standard_Integer aSize = 3;
+  NCollection_Array1<Standard_Real> 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<Standard_Real> 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);
index ac7cd1f9586b719f5c7740fcb1e39c20de7c20bc..89117ccbc7213ff4c2ef870cbf2e5feb476fa13a 100644 (file)
@@ -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<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
+
   //! Performs calculations using prepared Filler object <thePF>
   Standard_EXPORT virtual void PerformInternal1(const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange) Standard_OVERRIDE;