0025748: Parallel version of progress indicator
[occt.git] / src / TopoDSToStep / TopoDSToStep_Builder.cxx
index 850c1ba..f17e5df 100644 (file)
@@ -15,7 +15,7 @@
 // commercial license or contractual agreement.
 
 
-#include <Message_ProgressIndicator.hxx>
+#include <Message_ProgressScope.hxx>
 #include <StdFail_NotDone.hxx>
 #include <StepShape_ClosedShell.hxx>
 #include <StepShape_ConnectedFaceSet.hxx>
@@ -42,6 +42,7 @@
 // Purpose :
 // ============================================================================
 TopoDSToStep_Builder::TopoDSToStep_Builder()
+: myError(TopoDSToStep_BuilderOther)
 {
   done = Standard_False;
 }
@@ -53,10 +54,12 @@ TopoDSToStep_Builder::TopoDSToStep_Builder()
 
 TopoDSToStep_Builder::TopoDSToStep_Builder
 (const TopoDS_Shape& aShape,
- TopoDSToStep_Tool& aTool, const Handle(Transfer_FinderProcess)& FP)
+ TopoDSToStep_Tool& aTool,
+ const Handle(Transfer_FinderProcess)& FP,
+ const Message_ProgressRange& theProgress)
 {
   done = Standard_False;
-  Init(aShape, aTool, FP);
+  Init(aShape, aTool, FP, theProgress);
 }
 
 // ============================================================================
@@ -66,7 +69,8 @@ TopoDSToStep_Builder::TopoDSToStep_Builder
 
 void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
                                 TopoDSToStep_Tool& myTool,
-                                const Handle(Transfer_FinderProcess)& FP)
+                                const Handle(Transfer_FinderProcess)& FP,
+                                const Message_ProgressRange& theProgress)
 {
   
    if (myTool.IsBound(aShape)) {
@@ -76,8 +80,6 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
     return;
   }
 
-  Handle(Message_ProgressIndicator) progress = FP->GetProgress();
-
   switch (aShape.ShapeType()) 
     {      
     case TopAbs_SHELL: 
@@ -106,15 +108,19 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
 
 
 
-       TopExp_Explorer myExp(myShell, TopAbs_FACE);
+       TopExp_Explorer anExp;
 
        TopoDSToStep_MakeStepFace MkFace;
 
-       for (;myExp.More();myExp.Next()) {
-
-         const TopoDS_Face Face = TopoDS::Face(myExp.Current());
+        Standard_Integer nbshapes = 0;
+        for (anExp.Init(myShell, TopAbs_FACE); anExp.More(); anExp.Next())
+          nbshapes++;
+        Message_ProgressScope aPS(theProgress, NULL, nbshapes);
+        for (anExp.Init(myShell, TopAbs_FACE); anExp.More() && aPS.More(); anExp.Next(), aPS.Next())
+        {
+         const TopoDS_Face Face = TopoDS::Face(anExp.Current());
     
-    MkFace.Init(Face, myTool, FP);
+          MkFace.Init(Face, myTool, FP);
 
          if (MkFace.IsDone()) {
            FS = Handle(StepShape_FaceSurface)::DownCast(MkFace.Value());
@@ -123,13 +129,14 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
          }
          else {
            // MakeFace Error Handling : warning only
-//         cout << "Warning : one Face has not been mapped" << endl;
+//         std::cout << "Warning : one Face has not been mapped" << std::endl;
 //       Handle(TransferBRep_ShapeMapper) errShape =
 //         new TransferBRep_ShapeMapper(Face);
 //         FP->AddWarning(errShape, " a Face from a Shell has not been mapped");
          }
-    if (!progress.IsNull()) progress->Increment();
        }
+        if (!aPS.More())
+          return;
 
        Standard_Integer nbFaces = mySeq.Length();
        if ( nbFaces >= 1) {
@@ -189,7 +196,6 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
 //       FP->AddWarning(errShape, " the Face has not been mapped");
          done = Standard_False;
        }
-        if (!progress.IsNull()) progress->Increment();
        break;
       }
     default: break;