0025748: Parallel version of progress indicator
[occt.git] / src / ShapeFix / ShapeFix_Solid.cxx
index cddd763..e04e1d7 100644 (file)
@@ -20,8 +20,7 @@
 #include <Geom_Surface.hxx>
 #include <gp_Pnt.hxx>
 #include <Message_Msg.hxx>
-#include <Message_ProgressIndicator.hxx>
-#include <Message_ProgressSentry.hxx>
+#include <Message_ProgressScope.hxx>
 #include <Precision.hxx>
 #include <ShapeAnalysis.hxx>
 #include <ShapeAnalysis_Curve.hxx>
@@ -386,7 +385,7 @@ static Standard_Boolean CreateSolids(const TopoDS_Shape theShape,TopTools_Indexe
 //purpose  : 
 //=======================================================================
 
-Standard_Boolean ShapeFix_Solid::Perform(const Handle(Message_ProgressIndicator)& theProgress) 
+Standard_Boolean ShapeFix_Solid::Perform(const Message_ProgressRange& theProgress) 
 {
 
   Standard_Boolean status = Standard_False;
@@ -403,20 +402,20 @@ Standard_Boolean ShapeFix_Solid::Perform(const Handle(Message_ProgressIndicator)
     aNbShells++;
 
   // Start progress scope (no need to check if progress exists -- it is safe)
-  Message_ProgressSentry aPSentry(theProgress, "Fixing solid stage", 0, 2, 1);
+  Message_ProgressScope aPS(theProgress, "Fixing solid stage", 2);
 
   if ( NeedFix(myFixShellMode) )
   {
     // Start progress scope (no need to check if progress exists -- it is safe)
-    Message_ProgressSentry aPSentryFixShell(theProgress, "Fixing shell", 0, aNbShells, 1);
+    Message_ProgressScope aPSFixShell(aPS.Next(), "Fixing shell", aNbShells);
 
     // Fix shell by shell using ShapeFix_Shell tool
-    for ( TopExp_Explorer aExpSh(S, TopAbs_SHELL); aExpSh.More() && aPSentryFixShell.More(); aExpSh.Next(), aPSentryFixShell.Next() )
+    for ( TopExp_Explorer aExpSh(S, TopAbs_SHELL); aExpSh.More() && aPSFixShell.More(); aExpSh.Next())
     { 
       TopoDS_Shape sh = aExpSh.Current();
 
       myFixShell->Init( TopoDS::Shell(sh) );
-      if ( myFixShell->Perform(theProgress) )
+      if (myFixShell->Perform (aPSFixShell.Next()))
       {
         status = Standard_True;
         myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
@@ -425,7 +424,7 @@ Standard_Boolean ShapeFix_Solid::Perform(const Handle(Message_ProgressIndicator)
     }
 
     // Halt algorithm in case of user's abort
-    if ( !aPSentryFixShell.More() )
+    if ( !aPSFixShell.More() )
       return Standard_False;
     }
   else 
@@ -433,9 +432,6 @@ Standard_Boolean ShapeFix_Solid::Perform(const Handle(Message_ProgressIndicator)
     NbShells = aNbShells;
   }
 
-  // Switch to the second stage
-  aPSentry.Next();
-
   if (!NeedFix(myFixShellOrientationMode))
   {
     myShape = Context()->Apply(myShape);
@@ -511,10 +507,9 @@ Standard_Boolean ShapeFix_Solid::Perform(const Handle(Message_ProgressIndicator)
         BRep_Builder aB;
         TopoDS_Compound aComp;
         aB.MakeCompound(aComp);
-        Message_ProgressSentry aPSentryCreatingSolid(theProgress, "Creating solid",
-                                        0, aMapSolids.Extent(), 1);
-        for(Standard_Integer i =1; (i <= aMapSolids.Extent()) && (aPSentryCreatingSolid.More());
-            i++, aPSentryCreatingSolid.Next())
+        Message_ProgressScope aPSCreatingSolid (aPS.Next(), "Creating solid", aMapSolids.Extent());
+        for(Standard_Integer i =1; (i <= aMapSolids.Extent()) && (aPSCreatingSolid.More());
+            i++, aPSCreatingSolid.Next())
         {
           TopoDS_Shape aResSh =aMapSolids.FindKey(i);
           if(aResShape.ShapeType() == TopAbs_SHELL && myCreateOpenSolidMode) {
@@ -530,7 +525,7 @@ Standard_Boolean ShapeFix_Solid::Perform(const Handle(Message_ProgressIndicator)
           aB.Add(aComp,aResSh);
           
         }
-        if ( !aPSentryCreatingSolid.More() )
+        if ( !aPSCreatingSolid.More() )
           return Standard_False; // aborted execution
         Context()->Replace(aResShape,aComp);
       }