mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +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:
@@ -35,8 +35,7 @@
|
||||
#include <ShapeBuild_ReShape.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
|
||||
#include <Message_ProgressIndicator.hxx>
|
||||
#include <Message_ProgressSentry.hxx>
|
||||
#include <Message_ProgressScope.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ApplyModifier
|
||||
@@ -47,7 +46,7 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
|
||||
const Handle(BRepTools_Modification) &M,
|
||||
TopTools_DataMapOfShapeShape &context,
|
||||
BRepTools_Modifier& MD,
|
||||
const Handle(Message_ProgressIndicator) & aProgress,
|
||||
const Message_ProgressRange& theProgress,
|
||||
const Handle(ShapeBuild_ReShape) & aReShape)
|
||||
{
|
||||
// protect against INTERNAL/EXTERNAL shapes
|
||||
@@ -61,16 +60,17 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
|
||||
B.MakeCompound ( C );
|
||||
|
||||
Standard_Integer aShapeCount = SF.NbChildren();
|
||||
Message_ProgressSentry aPSentry(aProgress, "Applying Modifier For Solids", 0, aShapeCount, 1);
|
||||
for ( TopoDS_Iterator it(SF); it.More() && aPSentry.More(); it.Next(), aPSentry.Next() ) {
|
||||
Message_ProgressScope aPS(theProgress, "Applying Modifier For Solids", aShapeCount);
|
||||
for ( TopoDS_Iterator it(SF); it.More() && aPS.More(); it.Next()) {
|
||||
TopoDS_Shape shape = it.Value();
|
||||
TopLoc_Location L = shape.Location(), nullLoc;
|
||||
shape.Location ( nullLoc );
|
||||
TopoDS_Shape res;
|
||||
Message_ProgressRange aRange = aPS.Next();
|
||||
if ( context.IsBound ( shape ) )
|
||||
res = context.Find ( shape ).Oriented ( shape.Orientation() );
|
||||
else
|
||||
res = ApplyModifier ( shape, M, context ,MD, aProgress);
|
||||
res = ApplyModifier ( shape, M, context ,MD, aRange);
|
||||
|
||||
if ( ! res.IsSame ( shape ) ) {
|
||||
context.Bind ( shape, res );
|
||||
@@ -80,7 +80,7 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
|
||||
B.Add ( C, res );
|
||||
}
|
||||
|
||||
if ( !aPSentry.More() )
|
||||
if ( !aPS.More() )
|
||||
{
|
||||
// Was cancelled
|
||||
return S;
|
||||
@@ -91,12 +91,12 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
|
||||
return C.Oriented ( S.Orientation() );
|
||||
}
|
||||
|
||||
Message_ProgressSentry aPSentry(aProgress, "Modify the Shape", 0, 1, 1);
|
||||
Message_ProgressScope aPS(theProgress, "Modify the Shape", 1);
|
||||
// Modify the shape
|
||||
MD.Init(SF);
|
||||
MD.Perform(M, aProgress);
|
||||
MD.Perform(M, aPS.Next());
|
||||
|
||||
if ( !aPSentry.More() || !MD.IsDone() ) return S;
|
||||
if ( !aPS.More() || !MD.IsDone() ) return S;
|
||||
if ( !aReShape.IsNull() )
|
||||
{
|
||||
for(TopoDS_Iterator theIterator(SF,Standard_False);theIterator.More();theIterator.Next())
|
||||
|
@@ -26,10 +26,11 @@
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Message_ProgressRange.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class BRepTools_Modification;
|
||||
class BRepTools_Modifier;
|
||||
class Message_ProgressIndicator;
|
||||
class ShapeBuild_ReShape;
|
||||
class ShapeCustom_RestrictionParameters;
|
||||
class ShapeCustom_Surface;
|
||||
@@ -66,7 +67,11 @@ public:
|
||||
|
||||
|
||||
//! Applies modifier to shape and checks sharing in the case assemblies.
|
||||
Standard_EXPORT static TopoDS_Shape ApplyModifier (const TopoDS_Shape& S, const Handle(BRepTools_Modification)& M, TopTools_DataMapOfShapeShape& context, BRepTools_Modifier& MD, const Handle(Message_ProgressIndicator)& aProgress = NULL, const Handle(ShapeBuild_ReShape)& aReShape = NULL);
|
||||
Standard_EXPORT static TopoDS_Shape ApplyModifier
|
||||
(const TopoDS_Shape& S, const Handle(BRepTools_Modification)& M,
|
||||
TopTools_DataMapOfShapeShape& context, BRepTools_Modifier& MD,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange(),
|
||||
const Handle(ShapeBuild_ReShape)& aReShape = NULL);
|
||||
|
||||
//! Returns a new shape without indirect surfaces.
|
||||
Standard_EXPORT static TopoDS_Shape DirectFaces (const TopoDS_Shape& S);
|
||||
|
Reference in New Issue
Block a user