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

@@ -32,7 +32,7 @@
#include <Geom_Surface.hxx>
#include <Interface_Static.hxx>
#include <Message_Messenger.hxx>
#include <Message_ProgressSentry.hxx>
#include <Message_ProgressScope.hxx>
#include <Precision.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <Standard_ErrorHandler.hxx>
@@ -110,67 +110,6 @@ StepToTopoDS_Builder::StepToTopoDS_Builder()
done = Standard_False;
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor with a ManifoldSolidBrep
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_ManifoldSolidBrep)& aManifoldSolid,
const Handle(Transfer_TransientProcess)& TP)
{
Init(aManifoldSolid, TP);
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor woth a BrepWithVoids
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_BrepWithVoids)& aBRepWithVoids,
const Handle(Transfer_TransientProcess)& TP)
{
Init(aBRepWithVoids, TP);
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor with a FacetedBrep
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_FacetedBrep)& aFB,
const Handle(Transfer_TransientProcess)& TP)
{
Init(aFB, TP);
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor with a FacetedBrepAndBrepWithVoids
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_FacetedBrepAndBrepWithVoids)& aFBABWV,
const Handle(Transfer_TransientProcess)& TP)
{
Init(aFBABWV, TP);
}
// ============================================================================
// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
// Purpose : Constructor with a ShellBasedSurfaceModel
// ============================================================================
StepToTopoDS_Builder::StepToTopoDS_Builder
(const Handle(StepShape_ShellBasedSurfaceModel)& aSBSM,
const Handle(Transfer_TransientProcess)& TP,
StepToTopoDS_NMTool& NMTool)
{
Init(aSBSM, TP, NMTool);
}
// ============================================================================
// Method : Init
// Purpose : Init with a ManifoldSolidBrep
@@ -178,7 +117,8 @@ StepToTopoDS_Builder::StepToTopoDS_Builder
void StepToTopoDS_Builder::Init
(const Handle(StepShape_ManifoldSolidBrep)& aManifoldSolid,
const Handle(Transfer_TransientProcess)& TP)
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress)
{
Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo();
// Initialisation of the Tool
@@ -198,7 +138,7 @@ void StepToTopoDS_Builder::Init
myTranShell.SetMaxTol(MaxTol());
// Non-manifold topology is not referenced by ManifoldSolidBrep (ssv; 14.11.2010)
StepToTopoDS_NMTool dummyNMTool;
myTranShell.Init(aShell, myTool, dummyNMTool);
myTranShell.Init(aShell, myTool, dummyNMTool, theProgress);
if (myTranShell.IsDone()) {
TopoDS_Shape Sh = myTranShell.Value();
@@ -245,7 +185,8 @@ void StepToTopoDS_Builder::Init
void StepToTopoDS_Builder::Init
(const Handle(StepShape_BrepWithVoids)& aBRepWithVoids,
const Handle(Transfer_TransientProcess)& TP)
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress)
{
Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo();
// Initialisation of the Tool
@@ -263,7 +204,7 @@ void StepToTopoDS_Builder::Init
BRep_Builder B;
B.MakeSolid(S);
Message_ProgressSentry PS ( TP->GetProgress(), "Shell", 0, Nb+1, 1 );
Message_ProgressScope PS (theProgress, "Shell", Nb+1);
StepToTopoDS_TranslateShell myTranShell;
@@ -274,9 +215,7 @@ void StepToTopoDS_Builder::Init
aCShell = Handle(StepShape_ClosedShell)::DownCast(aBRepWithVoids->Outer());
// Non-manifold topology is not referenced by BrepWithVoids (ssv; 14.11.2010)
StepToTopoDS_NMTool dummyNMTool;
myTranShell.Init(aCShell, myTool, dummyNMTool);
PS.Next();
myTranShell.Init(aCShell, myTool, dummyNMTool, PS.Next());
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
@@ -297,10 +236,10 @@ void StepToTopoDS_Builder::Init
// Voids
for (Standard_Integer i=1; i<=Nb && PS.More(); i++, PS.Next()) {
for (Standard_Integer i=1; i<=Nb && PS.More(); i++) {
aCShell = aBRepWithVoids->VoidsValue(i);
myTranShell.Init(aCShell, myTool, dummyNMTool);
myTranShell.Init(aCShell, myTool, dummyNMTool, PS.Next());
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
Sh.Closed(Standard_True);
@@ -346,7 +285,8 @@ void StepToTopoDS_Builder::Init
// ============================================================================
void StepToTopoDS_Builder::Init(const Handle(StepShape_FacetedBrep)& aFB,
const Handle(Transfer_TransientProcess)& TP)
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress)
{
// Initialisation of the Tool
@@ -366,7 +306,7 @@ void StepToTopoDS_Builder::Init(const Handle(StepShape_FacetedBrep)& aFB,
myTranShell.SetMaxTol(MaxTol());
// Non-manifold topology is not referenced by FacetedBrep (ss; 14.11.2010)
StepToTopoDS_NMTool dummyNMTool;
myTranShell.Init(aCShell, myTool, dummyNMTool);
myTranShell.Init(aCShell, myTool, dummyNMTool, theProgress);
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
@@ -397,7 +337,8 @@ void StepToTopoDS_Builder::Init(const Handle(StepShape_FacetedBrep)& aFB,
void StepToTopoDS_Builder::Init
(const Handle(StepShape_FacetedBrepAndBrepWithVoids)& aFBABWV,
const Handle(Transfer_TransientProcess)& TP)
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress)
{
// Initialisation of the Tool
@@ -412,12 +353,14 @@ void StepToTopoDS_Builder::Init
aCShell = Handle(StepShape_ClosedShell)::DownCast(aFBABWV->Outer());
TopoDS_Shape Sh;
Message_ProgressScope aPSRoot(theProgress, NULL, 2);
StepToTopoDS_TranslateShell myTranShell;
myTranShell.SetPrecision(Precision()); //gka
myTranShell.SetMaxTol(MaxTol());
// Non-manifold topology is not referenced by FacetedBrepAndBrepWithVoids (ss; 14.11.2010)
StepToTopoDS_NMTool dummyNMTool;
myTranShell.Init(aCShell, myTool, dummyNMTool);
myTranShell.Init(aCShell, myTool, dummyNMTool, aPSRoot.Next());
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
@@ -429,9 +372,10 @@ void StepToTopoDS_Builder::Init
B.Add(S,Sh);
Standard_Integer Nb, i;
Nb = aFBABWV->NbVoids();
for ( i=1; i<=Nb; i++ ) {
Message_ProgressScope aPS (aPSRoot.Next(), NULL, Nb);
for ( i=1; i<=Nb && aPS.More(); i++) {
aCShell = aFBABWV->VoidsValue(i);
myTranShell.Init(aCShell, myTool, dummyNMTool);
myTranShell.Init(aCShell, myTool, dummyNMTool, aPS.Next());
if (myTranShell.IsDone()) {
Sh = myTranShell.Value();
Sh.Closed(Standard_True);
@@ -463,7 +407,8 @@ void StepToTopoDS_Builder::Init
void StepToTopoDS_Builder::Init
(const Handle(StepShape_ShellBasedSurfaceModel)& aSBSM,
const Handle(Transfer_TransientProcess)& TP,
StepToTopoDS_NMTool& NMTool)
StepToTopoDS_NMTool& NMTool,
const Message_ProgressRange& theProgress)
{
Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo();
// Initialisation of the Tool
@@ -490,13 +435,15 @@ void StepToTopoDS_Builder::Init
myTranShell.SetPrecision(Precision());
myTranShell.SetMaxTol(MaxTol());
Message_ProgressSentry PS ( TP->GetProgress(), "Shell", 0, Nb, 1 );
for (Standard_Integer i = 1; i <= Nb && PS.More(); i++, PS.Next()) {
Message_ProgressScope PS ( theProgress, "Shell", Nb);
for (Standard_Integer i = 1; i <= Nb && PS.More(); i++)
{
Message_ProgressRange aRange = PS.Next();
aShell = aSBSM->SbsmBoundaryValue(i);
aOpenShell = aShell.OpenShell();
aClosedShell = aShell.ClosedShell();
if (!aOpenShell.IsNull()) {
myTranShell.Init(aOpenShell, myTool, NMTool);
myTranShell.Init(aOpenShell, myTool, NMTool, aRange);
if (myTranShell.IsDone()) {
Shl = TopoDS::Shell(myTranShell.Value());
Shl.Closed(Standard_False);
@@ -508,7 +455,7 @@ void StepToTopoDS_Builder::Init
}
}
else if (!aClosedShell.IsNull()) {
myTranShell.Init(aClosedShell, myTool, NMTool);
myTranShell.Init(aClosedShell, myTool, NMTool, aRange);
if (myTranShell.IsDone()) {
Shl = TopoDS::Shell(myTranShell.Value());
Shl.Closed(Standard_True);
@@ -710,7 +657,8 @@ void StepToTopoDS_Builder::Init
(const Handle(StepShape_GeometricSet)& GCS,
const Handle(Transfer_TransientProcess)& TP,
const Handle(Transfer_ActorOfTransientProcess)& RA,
const Standard_Boolean isManifold)
const Standard_Boolean isManifold,
const Message_ProgressRange& theProgress)
{
// Start Mapping
TopoDS_Compound S;
@@ -721,7 +669,10 @@ void StepToTopoDS_Builder::Init
Standard_Real preci = Precision(); //gka
Standard_Real maxtol = MaxTol();
Standard_Integer nbElem = GCS->NbElements();
for (i = 1; i <= nbElem ; i++) {
Message_ProgressScope aPS(theProgress, NULL, nbElem);
for (i = 1; i <= nbElem && aPS.More(); i++)
{
Message_ProgressRange aRange = aPS.Next();
StepShape_GeometricSetSelect aGSS = GCS->ElementsValue(i);
Handle(Standard_Transient) ent = aGSS.Value();
@@ -834,7 +785,7 @@ void StepToTopoDS_Builder::Init
Handle(STEPControl_ActorRead) anActor = Handle(STEPControl_ActorRead)::DownCast(RA);
Handle(Transfer_Binder) binder;
if( !anActor.IsNull())
binder = anActor->TransferShape(GRI, TP, isManifold);
binder = anActor->TransferShape(GRI, TP, isManifold, Standard_False, aRange);
if (!binder.IsNull())
{
res = TransferBRep::ShapeResult(binder);

View File

@@ -25,6 +25,8 @@
#include <TopoDS_Shape.hxx>
#include <StepToTopoDS_Root.hxx>
#include <Standard_Boolean.hxx>
#include <Message_ProgressRange.hxx>
class StdFail_NotDone;
class StepShape_ManifoldSolidBrep;
class Transfer_TransientProcess;
@@ -50,33 +52,38 @@ public:
Standard_EXPORT StepToTopoDS_Builder();
Standard_EXPORT StepToTopoDS_Builder(const Handle(StepShape_ManifoldSolidBrep)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_ManifoldSolidBrep)& S,
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT StepToTopoDS_Builder(const Handle(StepShape_BrepWithVoids)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_BrepWithVoids)& S,
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT StepToTopoDS_Builder(const Handle(StepShape_FacetedBrep)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_FacetedBrep)& S,
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT StepToTopoDS_Builder(const Handle(StepShape_FacetedBrepAndBrepWithVoids)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_FacetedBrepAndBrepWithVoids)& S,
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT StepToTopoDS_Builder(const Handle(StepShape_ShellBasedSurfaceModel)& S, const Handle(Transfer_TransientProcess)& TP, StepToTopoDS_NMTool& NMTool);
Standard_EXPORT void Init (const Handle(StepShape_ShellBasedSurfaceModel)& S,
const Handle(Transfer_TransientProcess)& TP,
StepToTopoDS_NMTool& NMTool,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT StepToTopoDS_Builder(const Handle(StepShape_GeometricSet)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_EdgeBasedWireframeModel)& S,
const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_ManifoldSolidBrep)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_FaceBasedSurfaceModel)& S,
const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_BrepWithVoids)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_FacetedBrep)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_FacetedBrepAndBrepWithVoids)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_ShellBasedSurfaceModel)& S, const Handle(Transfer_TransientProcess)& TP, StepToTopoDS_NMTool& NMTool);
Standard_EXPORT void Init (const Handle(StepShape_EdgeBasedWireframeModel)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_FaceBasedSurfaceModel)& S, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT void Init (const Handle(StepShape_GeometricSet)& S, const Handle(Transfer_TransientProcess)& TP, const Handle(Transfer_ActorOfTransientProcess)& RA = NULL, const Standard_Boolean isManifold = Standard_False);
Standard_EXPORT void Init (const Handle(StepShape_GeometricSet)& S,
const Handle(Transfer_TransientProcess)& TP,
const Handle(Transfer_ActorOfTransientProcess)& RA = NULL,
const Standard_Boolean isManifold = Standard_False,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT const TopoDS_Shape& Value() const;

View File

@@ -116,7 +116,8 @@ Standard_Boolean StepToTopoDS_MakeTransformed::Transform
TopoDS_Shape StepToTopoDS_MakeTransformed::TranslateMappedItem
(const Handle(StepRepr_MappedItem)& mapit,
const Handle(Transfer_TransientProcess)& TP)
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress)
{
TopoDS_Shape theResult;
@@ -142,7 +143,7 @@ TopoDS_Shape StepToTopoDS_MakeTransformed::TranslateMappedItem
// La Shape, et la mise en position
Handle(StepRepr_Representation) maprep = mapit->MappingSource()->MappedRepresentation();
Handle(Transfer_Binder) binder = TP->Find(maprep);
if (binder.IsNull()) binder = TP->Transferring(maprep);
if (binder.IsNull()) binder = TP->Transferring(maprep, theProgress);
Handle(TransferBRep_ShapeBinder) shbinder =
Handle(TransferBRep_ShapeBinder)::DownCast(binder);
if (shbinder.IsNull()) TP->AddWarning(mapit,"No Shape Produced");

View File

@@ -24,6 +24,8 @@
#include <gp_Trsf.hxx>
#include <StepToTopoDS_Root.hxx>
#include <Standard_Boolean.hxx>
#include <Message_ProgressRange.hxx>
class StepGeom_Axis2Placement3d;
class StepGeom_CartesianTransformationOperator3d;
class gp_Trsf;
@@ -31,7 +33,6 @@ class TopoDS_Shape;
class StepRepr_MappedItem;
class Transfer_TransientProcess;
//! Produces instances by Transformation of a basic item
class StepToTopoDS_MakeTransformed : public StepToTopoDS_Root
{
@@ -68,7 +69,9 @@ public:
//! Hence, the transformation from MappingOrigin and MappingTarget
//! is computed, the MappedRepr. is converted to a Shape, then
//! transformed as an instance of this Shape
Standard_EXPORT TopoDS_Shape TranslateMappedItem (const Handle(StepRepr_MappedItem)& mapit, const Handle(Transfer_TransientProcess)& TP);
Standard_EXPORT TopoDS_Shape TranslateMappedItem (const Handle(StepRepr_MappedItem)& mapit,
const Handle(Transfer_TransientProcess)& TP,
const Message_ProgressRange& theProgress = Message_ProgressRange());

View File

@@ -17,8 +17,7 @@
//: gka 09.04.99: S4136: improving tolerance management
#include <BRep_Builder.hxx>
#include <Message_ProgressIndicator.hxx>
#include <Message_ProgressSentry.hxx>
#include <Message_ProgressScope.hxx>
#include <StdFail_NotDone.hxx>
#include <StepShape_ConnectedFaceSet.hxx>
#include <StepShape_FaceSurface.hxx>
@@ -42,24 +41,16 @@ StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
done = Standard_False;
}
// ============================================================================
// Method : StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell()
// Purpose : Constructor with a ConnectedFaceSet and a Tool
// ============================================================================
StepToTopoDS_TranslateShell::StepToTopoDS_TranslateShell
(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& T, StepToTopoDS_NMTool& NMTool)
{
Init(CFS, T, NMTool);
}
// ============================================================================
// Method : Init
// Purpose : Init with a ConnectedFaceSet and a Tool
// ============================================================================
void StepToTopoDS_TranslateShell::Init
(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& aTool, StepToTopoDS_NMTool& NMTool)
(const Handle(StepShape_ConnectedFaceSet)& CFS,
StepToTopoDS_Tool& aTool,
StepToTopoDS_NMTool& NMTool,
const Message_ProgressRange& theProgress)
{
//bug15697
if(CFS.IsNull())
@@ -81,7 +72,7 @@ void StepToTopoDS_TranslateShell::Init
myTranFace.SetPrecision(Precision()); //gka
myTranFace.SetMaxTol(MaxTol());
Message_ProgressSentry PS ( TP->GetProgress(), "Face", 0, NbFc, 1 );
Message_ProgressScope PS ( theProgress, "Face", NbFc);
for (Standard_Integer i = 1; i <= NbFc && PS.More(); i++, PS.Next()) {
#ifdef OCCT_DEBUG
std::cout << "Processing Face : " << i << std::endl;

View File

@@ -24,6 +24,8 @@
#include <StepToTopoDS_TranslateShellError.hxx>
#include <TopoDS_Shape.hxx>
#include <StepToTopoDS_Root.hxx>
#include <Message_ProgressRange.hxx>
class StdFail_NotDone;
class StepShape_ConnectedFaceSet;
class StepToTopoDS_Tool;
@@ -41,9 +43,10 @@ public:
Standard_EXPORT StepToTopoDS_TranslateShell();
Standard_EXPORT StepToTopoDS_TranslateShell(const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& T, StepToTopoDS_NMTool& NMTool);
Standard_EXPORT void Init (const Handle(StepShape_ConnectedFaceSet)& CFS, StepToTopoDS_Tool& T, StepToTopoDS_NMTool& NMTool);
Standard_EXPORT void Init (const Handle(StepShape_ConnectedFaceSet)& CFS,
StepToTopoDS_Tool& T,
StepToTopoDS_NMTool& NMTool,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT const TopoDS_Shape& Value() const;