1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0025748: Parallel version of progress indicator

Progress indication mechanism is refactored to support incrementing progress within multithreaded algorithms.

The class Message_ProgressIndicator is only an interface to the user application.
It accumulates the progress provided by progress scopes.
The counter is protected by mutex for thread-safety.

The new class Message_ProgressScope replacing Message_ProgressSentry should be used to advance the progress.
The scopes are nested to each other to reflect the nested nature of operations.
The new class Message_ProgressRange should be used to pass the progress to sub-scopes.

All OCCT algorithms involving progress indication have been updated to new API.

Improvements in Draw_ProgressIndicator:
- Separate console mode has been added in order to make possible to put the progress into std::cout instead
  or in addition to the draw interpreter, instead of trigger option "-tclOutput".
- Treatment of Ctrl-Break signal has been added.
  Now any operation can be aborted by Ctrl-C or Ctrl-Break keystroke.

Added new test case 'perf fclasses progr_par' for testing of parallel work of the progress.
This commit is contained in:
msv
2020-07-10 14:19:31 +03:00
committed by abv
parent 99289bed0a
commit 7e785937b3
271 changed files with 3701 additions and 3149 deletions

View File

@@ -54,7 +54,8 @@ Standard_Boolean IGESControl_ActorWrite::Recognize
Handle(Transfer_Binder) IGESControl_ActorWrite::Transfer
(const Handle(Transfer_Finder)& start,
const Handle(Transfer_FinderProcess)& FP)
const Handle(Transfer_FinderProcess)& FP,
const Message_ProgressRange& theProgress)
{
XSAlgo::AlgoContainer()->PrepareForTransfer();
@@ -74,14 +75,14 @@ Handle(Transfer_Binder) IGESControl_ActorWrite::Transfer
shape = XSAlgo::AlgoContainer()->ProcessShape( shape, Tol, maxTol,
"write.iges.resource.name",
"write.iges.sequence", info,
FP->GetProgress() );
theProgress );
// modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___
BRepToIGES_BREntity BR0; BR0.SetModel(modl); BR0.SetTransferProcess(FP);
BRepToIGESBRep_Entity BR1; BR1.SetModel(modl); BR1.SetTransferProcess(FP);
if (themodetrans == 0) ent = BR0.TransferShape(shape);
if (themodetrans == 1) ent = BR1.TransferShape(shape);
if (themodetrans == 0) ent = BR0.TransferShape(shape, theProgress);
if (themodetrans == 1) ent = BR1.TransferShape(shape, theProgress);
// modified by NIZHNY-EAP Tue Aug 29 11:37:18 2000 ___BEGIN___
XSAlgo::AlgoContainer()->MergeTransferInfo(FP, info);
// modified by NIZHNY-EAP Tue Aug 29 11:37:25 2000 ___END___

View File

@@ -46,7 +46,10 @@ public:
//!
//! ModeTrans may be : 0 -> groups of Faces
//! or 1 -> BRep
Standard_EXPORT virtual Handle(Transfer_Binder) Transfer (const Handle(Transfer_Finder)& start, const Handle(Transfer_FinderProcess)& FP) Standard_OVERRIDE;
Standard_EXPORT virtual Handle(Transfer_Binder) Transfer
(const Handle(Transfer_Finder)& start,
const Handle(Transfer_FinderProcess)& FP,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;

View File

@@ -344,9 +344,10 @@ Handle(Transfer_ActorOfTransientProcess) IGESControl_Controller::ActorRead (cons
IFSelect_ReturnStatus IGESControl_Controller::TransferWriteShape (const TopoDS_Shape& shape,
const Handle(Transfer_FinderProcess)& FP,
const Handle(Interface_InterfaceModel)& model,
const Standard_Integer modetrans) const
const Standard_Integer modetrans,
const Message_ProgressRange& theProgress) const
{
return XSControl_Controller::TransferWriteShape (shape,FP,model,modetrans);
return XSControl_Controller::TransferWriteShape(shape, FP, model, modetrans, theProgress);
}
//=======================================================================

View File

@@ -62,7 +62,12 @@ public:
//! -2 bad model (requires an IGESModel)
//! modeshape : 0 groupe of face (version < 5.1)
//! 1 BREP-version 5.1 of IGES
Standard_EXPORT virtual IFSelect_ReturnStatus TransferWriteShape (const TopoDS_Shape& shape, const Handle(Transfer_FinderProcess)& FP, const Handle(Interface_InterfaceModel)& model, const Standard_Integer modetrans = 0) const Standard_OVERRIDE;
Standard_EXPORT virtual IFSelect_ReturnStatus TransferWriteShape
(const TopoDS_Shape& shape,
const Handle(Transfer_FinderProcess)& FP,
const Handle(Interface_InterfaceModel)& model,
const Standard_Integer modetrans = 0,
const Message_ProgressRange& theProgress = Message_ProgressRange()) const Standard_OVERRIDE;
//! Standard Initialisation. It creates a Controller for IGES and
//! records it to various names, available to select it later

View File

@@ -37,7 +37,7 @@
#include <IGESSelect_WorkLibrary.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Static.hxx>
#include <Message_ProgressIndicator.hxx>
#include <Message_ProgressScope.hxx>
#include <OSD_OpenFile.hxx>
#include <ShapeAnalysis_ShapeTolerance.hxx>
#include <Standard_Stream.hxx>
@@ -82,21 +82,14 @@ IGESControl_Writer::IGESControl_Writer
myEditor (model,IGESSelect_WorkLibrary::DefineProtocol()) ,
myWriteMode (modecr) , myIsComputed (Standard_False) { }
Standard_Boolean IGESControl_Writer::AddShape (const TopoDS_Shape& theShape)
Standard_Boolean IGESControl_Writer::AddShape (const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
if (theShape.IsNull()) return Standard_False;
// for progress indication
Handle(Message_ProgressIndicator) progress = myTP->GetProgress();
if ( ! progress.IsNull() ) {
Standard_Integer nbfaces=0;
for( TopExp_Explorer exp(theShape,TopAbs_FACE); exp.More(); exp.Next() )
nbfaces++;
progress->SetScale ( "Faces", 0, nbfaces, 1 );
}
XSAlgo::AlgoContainer()->PrepareForTransfer();
Message_ProgressScope aPS(theProgress, NULL, 2);
// modified by NIZHNY-EAP Tue Aug 29 11:16:54 2000 ___BEGIN___
Handle(Standard_Transient) info;
Standard_Real Tol = Interface_Static::RVal("write.precision.val");
@@ -104,11 +97,17 @@ Standard_Boolean IGESControl_Writer::AddShape (const TopoDS_Shape& theShape)
TopoDS_Shape Shape = XSAlgo::AlgoContainer()->ProcessShape( theShape, Tol, maxTol,
"write.iges.resource.name",
"write.iges.sequence", info,
progress );
aPS.Next());
if (!aPS.More())
return Standard_False;
// modified by NIZHNY-EAP Tue Aug 29 11:17:01 2000 ___END___
BRepToIGES_BREntity B0; B0.SetTransferProcess(myTP); B0.SetModel(myModel);
BRepToIGESBRep_Entity B1; B1.SetTransferProcess(myTP); B1.SetModel(myModel);
Handle(IGESData_IGESEntity) ent = myWriteMode? B1.TransferShape(Shape) : B0.TransferShape(Shape);
Handle(IGESData_IGESEntity) ent = myWriteMode?
B1.TransferShape (Shape, aPS.Next()) : B0.TransferShape(Shape, aPS.Next());
if (!aPS.More())
return Standard_False;
if(ent.IsNull())
return Standard_False;

View File

@@ -26,6 +26,8 @@
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
#include <Standard_OStream.hxx>
#include <Message_ProgressRange.hxx>
class Transfer_FinderProcess;
class IGESData_IGESModel;
class TopoDS_Shape;
@@ -85,7 +87,8 @@ public:
//! Translates a Shape to IGES Entities and adds them to the model
//! Returns True if done, False if Shape not suitable for IGES or null
Standard_EXPORT Standard_Boolean AddShape (const TopoDS_Shape& sh);
Standard_EXPORT Standard_Boolean AddShape (const TopoDS_Shape& sh,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Translates a Geometry (Surface or Curve) to IGES Entities and
//! adds them to the model