]> OCCT Git - occt-copy.git/commitdiff
Update indication in BOPAlgo_Builder
authorakaftasev <akaftasev@opencascade.com>
Thu, 15 Apr 2021 09:52:05 +0000 (12:52 +0300)
committerakaftasev <akaftasev@opencascade.com>
Thu, 15 Apr 2021 09:52:05 +0000 (12:52 +0300)
src/BOPAlgo/BOPAlgo_Builder.cxx
src/BOPAlgo/BOPAlgo_Builder.hxx
src/BOPAlgo/BOPAlgo_Builder_1.cxx
src/BOPAlgo/BOPAlgo_Builder_2.cxx
src/BOPAlgo/BOPAlgo_Builder_3.cxx
src/BOPAlgo/BOPAlgo_PaveFiller.cxx

index 156a7ad38e058da3e6785181b2273318e7c2b579..0d372783c626b68d931cbd47e5fab31c78ef1d6d 100644 (file)
@@ -242,6 +242,89 @@ void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller, const
     AddError (new BOPAlgo_AlertBuilderFailed);
   }
 }
+
+//=======================================================================
+//function : AnalyzeProgress
+//purpose  : 
+//=======================================================================
+NCollection_Array1<Standard_Real> BOPAlgo_Builder::AnalyzeProgress()
+{
+  Standard_Integer aSize = 8;
+  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 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<Standard_Real> 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;
   }
index 78cfa8b6e0ed4e8546c07ffece6e7aaf41c861e6..759ff847123a4e18c1d7151f67a7370d1dbb1231 100644 (file)
@@ -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<Standard_Real> AnalyzeProgress() Standard_OVERRIDE;
+
 public: //! @name Images/Origins
 
   //! Returns the map of images.
index fce80e4cd4e6ea3f1aa4db67eef1350d85cdc828..ddb4b3052b60911f50221f5231a7d69a61e19b8f 100644 (file)
@@ -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; i<aNbS; ++i, aPS.Next()) {
+  Message_ProgressScope aPS(theRange, "Filling images containers", 1);
+  for (i=0; i<aNbS; ++i) {
     if (UserBreak(aPS))
     {
       return;
@@ -192,7 +188,7 @@ void BOPAlgo_Builder::BuildResult(const TopAbs_ShapeEnum theType)
   TopTools_MapOfShape aMFP(100, myAllocator);
   //
   aNbS=myDS->NbSourceShapes();
-  Message_ProgressScope aPS(theRange, "FillImagesCompounds", aNbS);
+  Message_ProgressScope aPS(theRange, "Filling images compounds", aNbS);
   for (i=0; i<aNbS; ++i, aPS.Next()) {
     if (UserBreak(aPS))
     {
index ec9e7be05e0fc430f53a6e2841002538ebe2bce8..302825e736cab5059aa0b1b16bf8584ee96fd04c 100644 (file)
@@ -191,17 +191,9 @@ typedef NCollection_Vector<BOPAlgo_VFI> 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();
 }
 //=======================================================================
index 6a5cc2a692a241696390b47df2dab664c3a09c8b..e01da97c8d0f7eeb074f6732ed4320c11a4fffeb 100644 (file)
@@ -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();
 }
index baa25725a89e68c9f5fda70f23568f0dd2fb6309..84d39467f930e588fe526de3583124b3194d93ad 100644 (file)
@@ -229,7 +229,7 @@ NCollection_Array1<Standard_Real> 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();