1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0025113: Mesh - Progress indication and user break functionality for BRepMesh component

Added Progress Indicator to BRep_Mesh
This commit is contained in:
emv 2020-07-10 14:19:31 +03:00 committed by bugmaster
parent 99ca2eec6b
commit ce97cd9708
33 changed files with 266 additions and 84 deletions

View File

@ -46,7 +46,8 @@ BRepMesh_BaseMeshAlgo::~BRepMesh_BaseMeshAlgo()
//======================================================================= //=======================================================================
void BRepMesh_BaseMeshAlgo::Perform( void BRepMesh_BaseMeshAlgo::Perform(
const IMeshData::IFaceHandle& theDFace, const IMeshData::IFaceHandle& theDFace,
const IMeshTools_Parameters& theParameters) const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange)
{ {
try try
{ {
@ -61,7 +62,11 @@ void BRepMesh_BaseMeshAlgo::Perform(
if (initDataStructure()) if (initDataStructure())
{ {
generateMesh(); if (!theRange.More())
{
return;
}
generateMesh(theRange);
commitSurfaceTriangulation(); commitSurfaceTriangulation();
} }
} }

View File

@ -42,7 +42,8 @@ public:
//! Performs processing of the given face. //! Performs processing of the given face.
Standard_EXPORT virtual void Perform( Standard_EXPORT virtual void Perform(
const IMeshData::IFaceHandle& theDFace, const IMeshData::IFaceHandle& theDFace,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE; const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_BaseMeshAlgo, IMeshTools_MeshAlgo) DEFINE_STANDARD_RTTI_INLINE(BRepMesh_BaseMeshAlgo, IMeshTools_MeshAlgo)
@ -103,7 +104,7 @@ protected:
Standard_EXPORT virtual Standard_Boolean initDataStructure(); Standard_EXPORT virtual Standard_Boolean initDataStructure();
//! Generates mesh for the contour stored in data structure. //! Generates mesh for the contour stored in data structure.
Standard_EXPORT virtual void generateMesh() = 0; Standard_EXPORT virtual void generateMesh(const Message_ProgressRange& theRange) = 0;
private: private:

View File

@ -52,7 +52,8 @@ protected:
//! Perfroms processing of generated mesh. //! Perfroms processing of generated mesh.
//! By default does nothing. //! By default does nothing.
//! Expected to be called from method generateMesh() in successor classes. //! Expected to be called from method generateMesh() in successor classes.
virtual void postProcessMesh (BRepMesh_Delaun& /*theMesher*/) virtual void postProcessMesh (BRepMesh_Delaun& /*theMesher*/,
const Message_ProgressRange& /*theRange*/)
{ {
} }
}; };

View File

@ -370,7 +370,7 @@ void BRepMesh_Delaun::compute(IMeshData::VectorOfInteger& theVertexIndexes)
createTriangles( theVertexIndexes( anVertexIdx ), aLoopEdges ); createTriangles( theVertexIndexes( anVertexIdx ), aLoopEdges );
// Add other nodes to the mesh // Add other nodes to the mesh
createTrianglesOnNewVertices( theVertexIndexes ); createTrianglesOnNewVertices (theVertexIndexes, Message_ProgressRange());
} }
// Destruction of triangles containing a top of the super triangle // Destruction of triangles containing a top of the super triangle
@ -523,7 +523,8 @@ void BRepMesh_Delaun::createTriangles(const Standard_Integer theVertexI
//purpose : Creation of triangles from the new nodes //purpose : Creation of triangles from the new nodes
//======================================================================= //=======================================================================
void BRepMesh_Delaun::createTrianglesOnNewVertices( void BRepMesh_Delaun::createTrianglesOnNewVertices(
IMeshData::VectorOfInteger& theVertexIndexes) IMeshData::VectorOfInteger& theVertexIndexes,
const Message_ProgressRange& theRange)
{ {
Handle(NCollection_IncAllocator) aAllocator = Handle(NCollection_IncAllocator) aAllocator =
new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE); new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE);
@ -537,8 +538,13 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
Standard_Integer anIndex = theVertexIndexes.Lower(); Standard_Integer anIndex = theVertexIndexes.Lower();
Standard_Integer anUpper = theVertexIndexes.Upper(); Standard_Integer anUpper = theVertexIndexes.Upper();
for( ; anIndex <= anUpper; ++anIndex ) Message_ProgressScope aPS(theRange, "Create triangles on new vertices", anUpper);
for (; anIndex <= anUpper; ++anIndex, aPS.Next())
{ {
if (!aPS.More())
{
return;
}
aAllocator->Reset(Standard_False); aAllocator->Reset(Standard_False);
IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator); IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator);
@ -2207,13 +2213,14 @@ void BRepMesh_Delaun::RemoveVertex( const BRepMesh_Vertex& theVertex )
//function : AddVertices //function : AddVertices
//purpose : Adds some vertices in the triangulation. //purpose : Adds some vertices in the triangulation.
//======================================================================= //=======================================================================
void BRepMesh_Delaun::AddVertices(IMeshData::VectorOfInteger& theVertices) void BRepMesh_Delaun::AddVertices(IMeshData::VectorOfInteger& theVertices,
const Message_ProgressRange& theRange)
{ {
ComparatorOfIndexedVertexOfDelaun aCmp(myMeshData); ComparatorOfIndexedVertexOfDelaun aCmp(myMeshData);
std::make_heap(theVertices.begin(), theVertices.end(), aCmp); std::make_heap(theVertices.begin(), theVertices.end(), aCmp);
std::sort_heap(theVertices.begin(), theVertices.end(), aCmp); std::sort_heap(theVertices.begin(), theVertices.end(), aCmp);
createTrianglesOnNewVertices(theVertices); createTrianglesOnNewVertices(theVertices, theRange);
} }
//======================================================================= //=======================================================================

View File

@ -29,6 +29,7 @@
#include <TColStd_Array1OfInteger.hxx> #include <TColStd_Array1OfInteger.hxx>
#include <TColStd_SequenceOfInteger.hxx> #include <TColStd_SequenceOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <Message_ProgressRange.hxx>
class Bnd_B2d; class Bnd_B2d;
class Bnd_Box2d; class Bnd_Box2d;
@ -75,7 +76,8 @@ public:
Standard_EXPORT void RemoveVertex (const BRepMesh_Vertex& theVertex); Standard_EXPORT void RemoveVertex (const BRepMesh_Vertex& theVertex);
//! Adds some vertices into the triangulation. //! Adds some vertices into the triangulation.
Standard_EXPORT void AddVertices (IMeshData::VectorOfInteger& theVerticesIndices); Standard_EXPORT void AddVertices (IMeshData::VectorOfInteger& theVerticesIndices,
const Message_ProgressRange& theRange = Message_ProgressRange());
//! Modify mesh to use the edge. //! Modify mesh to use the edge.
//! @return True if done //! @return True if done
@ -284,7 +286,8 @@ private:
IMeshData::SequenceOfBndB2d& thePolyBoxes); IMeshData::SequenceOfBndB2d& thePolyBoxes);
//! Creates the triangles on new nodes. //! Creates the triangles on new nodes.
void createTrianglesOnNewVertices (IMeshData::VectorOfInteger& theVertexIndices); void createTrianglesOnNewVertices (IMeshData::VectorOfInteger& theVertexIndices,
const Message_ProgressRange& theRange);
//! Cleanup mesh from the free triangles. //! Cleanup mesh from the free triangles.
void cleanupMesh(); void cleanupMesh();

View File

@ -37,7 +37,7 @@ BRepMesh_DelaunayBaseMeshAlgo::~BRepMesh_DelaunayBaseMeshAlgo()
//function : generateMesh //function : generateMesh
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_DelaunayBaseMeshAlgo::generateMesh() void BRepMesh_DelaunayBaseMeshAlgo::generateMesh(const Message_ProgressRange& theRange)
{ {
const Handle(BRepMesh_DataStructureOfDelaun)& aStructure = getStructure(); const Handle(BRepMesh_DataStructureOfDelaun)& aStructure = getStructure();
const Handle(VectorOfPnt)& aNodesMap = getNodesMap(); const Handle(VectorOfPnt)& aNodesMap = getNodesMap();
@ -53,5 +53,9 @@ void BRepMesh_DelaunayBaseMeshAlgo::generateMesh()
BRepMesh_MeshTool aCleaner(aStructure); BRepMesh_MeshTool aCleaner(aStructure);
aCleaner.EraseFreeLinks(); aCleaner.EraseFreeLinks();
postProcessMesh(aMesher); if (!theRange.More())
{
return;
}
postProcessMesh(aMesher, theRange);
} }

View File

@ -40,7 +40,7 @@ public:
protected: protected:
//! Generates mesh for the contour stored in data structure. //! Generates mesh for the contour stored in data structure.
Standard_EXPORT virtual void generateMesh() Standard_OVERRIDE; Standard_EXPORT virtual void generateMesh (const Message_ProgressRange& theRange) Standard_OVERRIDE;
}; };
#endif #endif

View File

@ -47,21 +47,32 @@ public:
protected: protected:
//! Perfroms processing of generated mesh. Generates surface nodes and inserts them into structure. //! Perfroms processing of generated mesh. Generates surface nodes and inserts them into structure.
virtual void postProcessMesh(BRepMesh_Delaun& theMesher) Standard_OVERRIDE virtual void postProcessMesh (BRepMesh_Delaun& theMesher,
const Message_ProgressRange& theRange) Standard_OVERRIDE
{ {
Message_ProgressScope aPS(theRange, "Post process mesh", 2);
// Insert surface nodes. // Insert surface nodes.
DelaunayInsertionBaseClass::postProcessMesh(theMesher); DelaunayInsertionBaseClass::postProcessMesh (theMesher, aPS.Next());
if (!aPS.More())
{
return;
}
if (this->getParameters().ControlSurfaceDeflection && if (this->getParameters().ControlSurfaceDeflection &&
this->getStructure()->ElementsOfDomain().Extent() > 0) this->getStructure()->ElementsOfDomain().Extent() > 0)
{ {
optimizeMesh(theMesher); optimizeMesh(theMesher, aPS.Next());
}
else
{
aPS.Next();
} }
} }
//! Checks deviation of a mesh from geometrical surface. //! Checks deviation of a mesh from geometrical surface.
//! Inserts additional nodes in case of huge deviation. //! Inserts additional nodes in case of huge deviation.
virtual void optimizeMesh(BRepMesh_Delaun& theMesher) virtual void optimizeMesh (BRepMesh_Delaun& theMesher,
const Message_ProgressRange& theRange)
{ {
Handle(NCollection_IncAllocator) aTmpAlloc = Handle(NCollection_IncAllocator) aTmpAlloc =
new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE); new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE);
@ -72,8 +83,13 @@ protected:
const Standard_Integer aIterationsNb = 11; const Standard_Integer aIterationsNb = 11;
Standard_Boolean isInserted = Standard_True; Standard_Boolean isInserted = Standard_True;
Message_ProgressScope aPS(theRange, "Iteration", aIterationsNb);
for (Standard_Integer aPass = 1; aPass <= aIterationsNb && isInserted && !myIsAllDegenerated; ++aPass) for (Standard_Integer aPass = 1; aPass <= aIterationsNb && isInserted && !myIsAllDegenerated; ++aPass)
{ {
if (!aPS.More())
{
return;
}
// Reset stop condition // Reset stop condition
myMaxSqDeflection = -1.; myMaxSqDeflection = -1.;
myIsAllDegenerated = Standard_True; myIsAllDegenerated = Standard_True;
@ -83,7 +99,6 @@ protected:
{ {
break; break;
} }
// Iterate on current triangles // Iterate on current triangles
IMeshData::IteratorOfMapOfInteger aTriangleIt(this->getStructure()->ElementsOfDomain()); IMeshData::IteratorOfMapOfInteger aTriangleIt(this->getStructure()->ElementsOfDomain());
for (; aTriangleIt.More(); aTriangleIt.Next()) for (; aTriangleIt.More(); aTriangleIt.Next())
@ -92,7 +107,7 @@ protected:
splitTriangleGeometry(aTriangle); splitTriangleGeometry(aTriangle);
} }
isInserted = this->insertNodes(myControlNodes, theMesher); isInserted = this->insertNodes(myControlNodes, theMesher, aPS.Next());
} }
myCouplesMap.Nullify(); myCouplesMap.Nullify();

View File

@ -85,23 +85,29 @@ protected:
} }
//! Perfroms processing of generated mesh. Generates surface nodes and inserts them into structure. //! Perfroms processing of generated mesh. Generates surface nodes and inserts them into structure.
virtual void postProcessMesh(BRepMesh_Delaun& theMesher) Standard_OVERRIDE virtual void postProcessMesh (BRepMesh_Delaun& theMesher,
const Message_ProgressRange& theRange) Standard_OVERRIDE
{ {
InsertionBaseClass::postProcessMesh(theMesher); if (!theRange.More())
{
return;
}
InsertionBaseClass::postProcessMesh (theMesher, Message_ProgressRange()); // shouldn't be range passed here?
if (!myIsPreProcessSurfaceNodes) if (!myIsPreProcessSurfaceNodes)
{ {
const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes = const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters()); this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
insertNodes(aSurfaceNodes, theMesher); insertNodes(aSurfaceNodes, theMesher, theRange);
} }
} }
//! Inserts nodes into mesh. //! Inserts nodes into mesh.
Standard_Boolean insertNodes( Standard_Boolean insertNodes(
const Handle(IMeshData::ListOfPnt2d)& theNodes, const Handle(IMeshData::ListOfPnt2d)& theNodes,
BRepMesh_Delaun& theMesher) BRepMesh_Delaun& theMesher,
const Message_ProgressRange& theRange)
{ {
if (theNodes.IsNull() || theNodes->IsEmpty()) if (theNodes.IsNull() || theNodes->IsEmpty())
{ {
@ -120,7 +126,11 @@ protected:
} }
} }
theMesher.AddVertices(aVertexIndexes); theMesher.AddVertices (aVertexIndexes, theRange);
if (!theRange.More())
{
return Standard_False;
}
return !aVertexIndexes.IsEmpty(); return !aVertexIndexes.IsEmpty();
} }

View File

@ -18,6 +18,7 @@
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <Standard_Transient.hxx> #include <Standard_Transient.hxx>
#include <Message_ProgressRange.hxx>
//! This is a common interface for meshing algorithms //! This is a common interface for meshing algorithms
//! instantiated by Mesh Factory and implemented by plugins. //! instantiated by Mesh Factory and implemented by plugins.
@ -46,7 +47,7 @@ public:
} }
//! Compute triangulation for set shape. //! Compute triangulation for set shape.
virtual void Perform() = 0; virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange()) = 0;
DEFINE_STANDARD_RTTIEXT(BRepMesh_DiscretRoot,Standard_Transient) DEFINE_STANDARD_RTTIEXT(BRepMesh_DiscretRoot,Standard_Transient)

View File

@ -85,8 +85,10 @@ Handle(IMeshTools_CurveTessellator) BRepMesh_EdgeDiscret::CreateEdgeTessellation
//======================================================================= //=======================================================================
Standard_Boolean BRepMesh_EdgeDiscret::performInternal ( Standard_Boolean BRepMesh_EdgeDiscret::performInternal (
const Handle (IMeshData_Model)& theModel, const Handle (IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange)
{ {
(void )theRange;
myModel = theModel; myModel = theModel;
myParameters = theParameters; myParameters = theParameters;

View File

@ -75,7 +75,8 @@ protected:
//! Performs processing of edges of the given model. //! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal ( Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle (IMeshData_Model)& theModel, const Handle (IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE; const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange) Standard_OVERRIDE;
private: private:

View File

@ -39,13 +39,46 @@ BRepMesh_FaceDiscret::~BRepMesh_FaceDiscret()
{ {
} }
//! Auxiliary functor for parallel processing of Faces.
class BRepMesh_FaceDiscret::FaceListFunctor
{
public:
FaceListFunctor (BRepMesh_FaceDiscret* theAlgo,
const Message_ProgressRange& theRange)
: myAlgo (theAlgo),
myScope (theRange, "Face Discret", theAlgo->myModel->FacesNb())
{
myRanges.reserve (theAlgo->myModel->FacesNb());
for (Standard_Integer aFaceIter = 0; aFaceIter < theAlgo->myModel->FacesNb(); ++aFaceIter)
{
myRanges.push_back (myScope.Next());
}
}
void operator() (const Standard_Integer theFaceIndex) const
{
if (!myScope.More())
{
return;
}
Message_ProgressScope aFaceScope(myRanges[theFaceIndex], NULL, 1);
myAlgo->process(theFaceIndex, aFaceScope.Next());
}
private:
mutable BRepMesh_FaceDiscret* myAlgo;
Message_ProgressScope myScope;
std::vector<Message_ProgressRange> myRanges;
};
//======================================================================= //=======================================================================
// Function: Perform // Function: Perform
// Purpose : // Purpose :
//======================================================================= //=======================================================================
Standard_Boolean BRepMesh_FaceDiscret::performInternal( Standard_Boolean BRepMesh_FaceDiscret::performInternal(
const Handle(IMeshData_Model)& theModel, const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange)
{ {
myModel = theModel; myModel = theModel;
myParameters = theParameters; myParameters = theParameters;
@ -54,7 +87,12 @@ Standard_Boolean BRepMesh_FaceDiscret::performInternal(
return Standard_False; return Standard_False;
} }
OSD_Parallel::For(0, myModel->FacesNb(), *this, !(myParameters.InParallel && myModel->FacesNb() > 1)); FaceListFunctor aFunctor(this, theRange);
OSD_Parallel::For(0, myModel->FacesNb(), aFunctor, !(myParameters.InParallel && myModel->FacesNb() > 1));
if (!theRange.More())
{
return Standard_False;
}
myModel.Nullify(); // Do not hold link to model. myModel.Nullify(); // Do not hold link to model.
return Standard_True; return Standard_True;
@ -64,7 +102,8 @@ Standard_Boolean BRepMesh_FaceDiscret::performInternal(
// Function: process // Function: process
// Purpose : // Purpose :
//======================================================================= //=======================================================================
void BRepMesh_FaceDiscret::process(const Standard_Integer theFaceIndex) const void BRepMesh_FaceDiscret::process(const Standard_Integer theFaceIndex,
const Message_ProgressRange& theRange) const
{ {
const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex); const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex);
if (aDFace->IsSet(IMeshData_Failure) || if (aDFace->IsSet(IMeshData_Failure) ||
@ -86,7 +125,12 @@ void BRepMesh_FaceDiscret::process(const Standard_Integer theFaceIndex) const
return; return;
} }
aMeshingAlgo->Perform(aDFace, myParameters); if (!theRange.More())
{
aDFace->SetStatus (IMeshData_UserBreak);
return;
}
aMeshingAlgo->Perform(aDFace, myParameters, theRange);
} }
catch (Standard_Failure const&) catch (Standard_Failure const&)
{ {

View File

@ -20,6 +20,7 @@
#include <IMeshTools_Parameters.hxx> #include <IMeshTools_Parameters.hxx>
#include <IMeshData_Types.hxx> #include <IMeshData_Types.hxx>
#include <IMeshTools_MeshAlgoFactory.hxx> #include <IMeshTools_MeshAlgoFactory.hxx>
#include <NCollection_Array1.hxx>
//! Class implements functionality starting triangulation of model's faces. //! Class implements functionality starting triangulation of model's faces.
//! Each face is processed separately and can be executed in parallel mode. //! Each face is processed separately and can be executed in parallel mode.
@ -36,11 +37,6 @@ public:
//! Destructor. //! Destructor.
Standard_EXPORT virtual ~BRepMesh_FaceDiscret(); Standard_EXPORT virtual ~BRepMesh_FaceDiscret();
//! Functor API to discretize the given edge.
inline void operator() (const Standard_Integer theFaceIndex) const {
process(theFaceIndex);
}
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_FaceDiscret, IMeshTools_ModelAlgo) DEFINE_STANDARD_RTTI_INLINE(BRepMesh_FaceDiscret, IMeshTools_ModelAlgo)
protected: protected:
@ -48,12 +44,17 @@ protected:
//! Performs processing of faces of the given model. //! Performs processing of faces of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal ( Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle(IMeshData_Model)& theModel, const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE; const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange) Standard_OVERRIDE;
private: private:
//! Checks existing discretization of the face and updates data model. //! Checks existing discretization of the face and updates data model.
void process(const Standard_Integer theFaceIndex) const; void process (const Standard_Integer theFaceIndex,
const Message_ProgressRange& theRange) const;
private:
class FaceListFunctor;
private: private:

View File

@ -66,11 +66,12 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape& theSh
//======================================================================= //=======================================================================
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(
const TopoDS_Shape& theShape, const TopoDS_Shape& theShape,
const IMeshTools_Parameters& theParameters) const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange)
: myParameters(theParameters) : myParameters(theParameters)
{ {
myShape = theShape; myShape = theShape;
Perform(); Perform(theRange);
} }
//======================================================================= //=======================================================================
@ -85,17 +86,17 @@ BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
//function : Perform //function : Perform
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_IncrementalMesh::Perform() void BRepMesh_IncrementalMesh::Perform(const Message_ProgressRange& theRange)
{ {
Handle(BRepMesh_Context) aContext = new BRepMesh_Context; Handle(BRepMesh_Context) aContext = new BRepMesh_Context;
Perform (aContext); Perform (aContext, theRange);
} }
//======================================================================= //=======================================================================
//function : Perform //function : Perform
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theContext) void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theContext, const Message_ProgressRange& theRange)
{ {
initParameters(); initParameters();
@ -103,9 +104,14 @@ void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theCont
theContext->ChangeParameters() = myParameters; theContext->ChangeParameters() = myParameters;
theContext->ChangeParameters().CleanModel = Standard_False; theContext->ChangeParameters().CleanModel = Standard_False;
Message_ProgressScope aPS(theRange, "Perform incmesh", 10);
IMeshTools_MeshBuilder aIncMesh(theContext); IMeshTools_MeshBuilder aIncMesh(theContext);
aIncMesh.Perform(); aIncMesh.Perform(aPS.Next(9));
if (!aPS.More())
{
myStatus = IMeshData_UserBreak;
return;
}
myStatus = IMeshData_NoError; myStatus = IMeshData_NoError;
const Handle(IMeshData_Model)& aModel = theContext->GetModel(); const Handle(IMeshData_Model)& aModel = theContext->GetModel();
if (!aModel.IsNull()) if (!aModel.IsNull())
@ -122,7 +128,7 @@ void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theCont
} }
} }
} }
aPS.Next(1);
setDone(); setDone();
} }

View File

@ -50,13 +50,15 @@ public: //! @name mesher API
//! @param theShape shape to be meshed. //! @param theShape shape to be meshed.
//! @param theParameters - parameters of meshing //! @param theParameters - parameters of meshing
Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape, Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape,
const IMeshTools_Parameters& theParameters); const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange = Message_ProgressRange());
//! Performs meshing ot the shape. //! Performs meshing ot the shape.
Standard_EXPORT virtual void Perform() Standard_OVERRIDE; Standard_EXPORT virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
//! Performs meshing using custom context; //! Performs meshing using custom context;
Standard_EXPORT void Perform(const Handle(IMeshTools_Context)& theContext); Standard_EXPORT void Perform(const Handle(IMeshTools_Context)& theContext,
const Message_ProgressRange& theRange = Message_ProgressRange());
public: //! @name accessing to parameters. public: //! @name accessing to parameters.

View File

@ -117,8 +117,10 @@ BRepMesh_ModelHealer::~BRepMesh_ModelHealer()
//======================================================================= //=======================================================================
Standard_Boolean BRepMesh_ModelHealer::performInternal( Standard_Boolean BRepMesh_ModelHealer::performInternal(
const Handle(IMeshData_Model)& theModel, const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange)
{ {
(void )theRange;
myModel = theModel; myModel = theModel;
myParameters = theParameters; myParameters = theParameters;
if (myModel.IsNull()) if (myModel.IsNull())

View File

@ -61,7 +61,8 @@ protected:
//! Performs processing of edges of the given model. //! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal ( Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle(IMeshData_Model)& theModel, const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE; const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange) Standard_OVERRIDE;
private: private:

View File

@ -179,8 +179,10 @@ BRepMesh_ModelPostProcessor::~BRepMesh_ModelPostProcessor()
//======================================================================= //=======================================================================
Standard_Boolean BRepMesh_ModelPostProcessor::performInternal( Standard_Boolean BRepMesh_ModelPostProcessor::performInternal(
const Handle(IMeshData_Model)& theModel, const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& /*theParameters*/) const IMeshTools_Parameters& /*theParameters*/,
const Message_ProgressRange& theRange)
{ {
(void )theRange;
if (theModel.IsNull()) if (theModel.IsNull())
{ {
return Standard_False; return Standard_False;

View File

@ -39,7 +39,8 @@ protected:
//! Performs processing of edges of the given model. //! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal ( Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle(IMeshData_Model)& theModel, const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE; const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange) Standard_OVERRIDE;
}; };
#endif #endif

View File

@ -250,8 +250,10 @@ BRepMesh_ModelPreProcessor::~BRepMesh_ModelPreProcessor()
//======================================================================= //=======================================================================
Standard_Boolean BRepMesh_ModelPreProcessor::performInternal( Standard_Boolean BRepMesh_ModelPreProcessor::performInternal(
const Handle(IMeshData_Model)& theModel, const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange)
{ {
(void )theRange;
if (theModel.IsNull()) if (theModel.IsNull())
{ {
return Standard_False; return Standard_False;

View File

@ -40,7 +40,8 @@ protected:
//! Performs processing of edges of the given model. //! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal ( Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle(IMeshData_Model)& theModel, const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE; const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange) Standard_OVERRIDE;
}; };
#endif #endif

View File

@ -47,11 +47,16 @@ public:
//! Performs processing of the given face. //! Performs processing of the given face.
virtual void Perform( virtual void Perform(
const IMeshData::IFaceHandle& theDFace, const IMeshData::IFaceHandle& theDFace,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange) Standard_OVERRIDE
{ {
myRangeSplitter.Reset(theDFace, theParameters); myRangeSplitter.Reset(theDFace, theParameters);
myClassifier = new BRepMesh_Classifier; myClassifier = new BRepMesh_Classifier;
BaseAlgo::Perform(theDFace, theParameters); if (!theRange.More())
{
return;
}
BaseAlgo::Perform(theDFace, theParameters, theRange);
myClassifier.Nullify(); myClassifier.Nullify();
} }

View File

@ -23,6 +23,7 @@
#include <Draw_Drawable3D.hxx> #include <Draw_Drawable3D.hxx>
#include <Draw_Grid.hxx> #include <Draw_Grid.hxx>
#include <Draw_Number.hxx> #include <Draw_Number.hxx>
#include <Message.hxx>
#include <Draw_ProgressIndicator.hxx> #include <Draw_ProgressIndicator.hxx>
#include <Draw_SequenceOfDrawable3D.hxx> #include <Draw_SequenceOfDrawable3D.hxx>
#include <Message.hxx> #include <Message.hxx>

View File

@ -19,15 +19,16 @@
//! Enumerates statuses used to notify state of discrete model. //! Enumerates statuses used to notify state of discrete model.
enum IMeshData_Status enum IMeshData_Status
{ {
IMeshData_NoError = 0x0, //!< Mesh generation is successful. IMeshData_NoError = 0x0, //!< Mesh generation is successful.
IMeshData_OpenWire = 0x1, //!< Notifies open wire problem, which can potentially lead to incorrect results. IMeshData_OpenWire = 0x1, //!< Notifies open wire problem, which can potentially lead to incorrect results.
IMeshData_SelfIntersectingWire = 0x2, //!< Notifies self-intersections on discretized wire, which can potentially lead to incorrect results. IMeshData_SelfIntersectingWire = 0x2, //!< Notifies self-intersections on discretized wire, which can potentially lead to incorrect results.
IMeshData_Failure = 0x4, //!< Failed to generate mesh for some faces. IMeshData_Failure = 0x4, //!< Failed to generate mesh for some faces.
IMeshData_ReMesh = 0x8, //!< Deflection of some edges has been decreased due to interference of discrete model. IMeshData_ReMesh = 0x8, //!< Deflection of some edges has been decreased due to interference of discrete model.
IMeshData_UnorientedWire = 0x10, //!< Notifies bad orientation of a wire, which can potentially lead to incorrect results. IMeshData_UnorientedWire = 0x10, //!< Notifies bad orientation of a wire, which can potentially lead to incorrect results.
IMeshData_TooFewPoints = 0x20, //!< Discrete model contains too few boundary points to generate mesh. IMeshData_TooFewPoints = 0x20, //!< Discrete model contains too few boundary points to generate mesh.
IMeshData_Outdated = 0x40, //!< Existing triangulation of some faces corresponds to greater deflection than specified by parameter. IMeshData_Outdated = 0x40, //!< Existing triangulation of some faces corresponds to greater deflection than specified by parameter.
IMeshData_Reused = 0x80 //!< Existing triangulation of some faces is reused as far as it fits specified deflection. IMeshData_Reused = 0x80, //!< Existing triangulation of some faces is reused as far as it fits specified deflection.
IMeshData_UserBreak = 0x160 //!< User break
}; };
#endif #endif

View File

@ -22,6 +22,7 @@
#include <IMeshData_Model.hxx> #include <IMeshData_Model.hxx>
#include <IMeshTools_Parameters.hxx> #include <IMeshTools_Parameters.hxx>
#include <IMeshTools_ModelAlgo.hxx> #include <IMeshTools_ModelAlgo.hxx>
#include <Message_ProgressRange.hxx>
//! Interface class representing context of BRepMesh algorithm. //! Interface class representing context of BRepMesh algorithm.
//! Intended to cache discrete model and instances of tools for //! Intended to cache discrete model and instances of tools for
@ -64,7 +65,7 @@ public:
} }
// Discretize edges of a model. // Discretize edges of a model.
return myEdgeDiscret->Perform(myModel, myParameters); return myEdgeDiscret->Perform(myModel, myParameters, Message_ProgressRange());
} }
//! Performs healing of discrete model built by DiscretizeEdges() method //! Performs healing of discrete model built by DiscretizeEdges() method
@ -79,7 +80,7 @@ public:
return myModelHealer.IsNull() ? return myModelHealer.IsNull() ?
Standard_True : Standard_True :
myModelHealer->Perform(myModel, myParameters); myModelHealer->Perform (myModel, myParameters, Message_ProgressRange());
} }
//! Performs pre-processing of discrete model using assigned algorithm. //! Performs pre-processing of discrete model using assigned algorithm.
@ -94,12 +95,12 @@ public:
return myPreProcessor.IsNull() ? return myPreProcessor.IsNull() ?
Standard_True : Standard_True :
myPreProcessor->Perform(myModel, myParameters); myPreProcessor->Perform (myModel, myParameters, Message_ProgressRange());
} }
//! Performs meshing of faces of discrete model using assigned meshing algorithm. //! Performs meshing of faces of discrete model using assigned meshing algorithm.
//! @return True on success, False elsewhere. //! @return True on success, False elsewhere.
Standard_EXPORT virtual Standard_Boolean DiscretizeFaces() virtual Standard_Boolean DiscretizeFaces (const Message_ProgressRange& theRange)
{ {
if (myModel.IsNull() || myFaceDiscret.IsNull()) if (myModel.IsNull() || myFaceDiscret.IsNull())
{ {
@ -107,7 +108,7 @@ public:
} }
// Discretize faces of a model. // Discretize faces of a model.
return myFaceDiscret->Perform(myModel, myParameters); return myFaceDiscret->Perform (myModel, myParameters, theRange);
} }
//! Performs post-processing of discrete model using assigned algorithm. //! Performs post-processing of discrete model using assigned algorithm.
@ -121,7 +122,7 @@ public:
return myPostProcessor.IsNull() ? return myPostProcessor.IsNull() ?
Standard_True : Standard_True :
myPostProcessor->Perform(myModel, myParameters); myPostProcessor->Perform(myModel, myParameters, Message_ProgressRange());
} }
//! Cleans temporary context data. //! Cleans temporary context data.

View File

@ -19,6 +19,7 @@
#include <Standard_Transient.hxx> #include <Standard_Transient.hxx>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <IMeshData_Types.hxx> #include <IMeshData_Types.hxx>
#include <Message_ProgressRange.hxx>
struct IMeshTools_Parameters; struct IMeshTools_Parameters;
@ -35,7 +36,8 @@ public:
//! Performs processing of the given face. //! Performs processing of the given face.
Standard_EXPORT virtual void Perform( Standard_EXPORT virtual void Perform(
const IMeshData::IFaceHandle& theDFace, const IMeshData::IFaceHandle& theDFace,
const IMeshTools_Parameters& theParameters) = 0; const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange) = 0;
DEFINE_STANDARD_RTTI_INLINE(IMeshTools_MeshAlgo, Standard_Transient) DEFINE_STANDARD_RTTI_INLINE(IMeshTools_MeshAlgo, Standard_Transient)

View File

@ -47,7 +47,7 @@ IMeshTools_MeshBuilder::~IMeshTools_MeshBuilder ()
// Function: Perform // Function: Perform
// Purpose : // Purpose :
//======================================================================= //=======================================================================
void IMeshTools_MeshBuilder::Perform () void IMeshTools_MeshBuilder::Perform (const Message_ProgressRange& theRange)
{ {
ClearStatus (); ClearStatus ();
@ -58,6 +58,8 @@ void IMeshTools_MeshBuilder::Perform ()
return; return;
} }
Message_ProgressScope aPS(theRange, "Mesh Perform", 10);
if (aContext->BuildModel ()) if (aContext->BuildModel ())
{ {
if (aContext->DiscretizeEdges ()) if (aContext->DiscretizeEdges ())
@ -66,7 +68,7 @@ void IMeshTools_MeshBuilder::Perform ()
{ {
if (aContext->PreProcessModel()) if (aContext->PreProcessModel())
{ {
if (aContext->DiscretizeFaces()) if (aContext->DiscretizeFaces(aPS.Next(9)))
{ {
if (aContext->PostProcessModel()) if (aContext->PostProcessModel())
{ {
@ -79,6 +81,12 @@ void IMeshTools_MeshBuilder::Perform ()
} }
else else
{ {
if (!aPS.More())
{
SetStatus(Message_Fail8);
aContext->Clean();
return;
}
SetStatus(Message_Fail6); SetStatus(Message_Fail6);
} }
} }
@ -113,6 +121,6 @@ void IMeshTools_MeshBuilder::Perform ()
Message_Warn1 : Message_Fail2); Message_Warn1 : Message_Fail2);
} }
} }
aPS.Next(1);
aContext->Clean (); aContext->Clean ();
} }

View File

@ -19,6 +19,7 @@
#include <Message_Algorithm.hxx> #include <Message_Algorithm.hxx>
#include <IMeshTools_Context.hxx> #include <IMeshTools_Context.hxx>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <Message_ProgressRange.hxx>
//! Builds mesh for each face of shape without triangulation. //! Builds mesh for each face of shape without triangulation.
//! In case if some faces of shape have already been triangulated //! In case if some faces of shape have already been triangulated
@ -62,7 +63,7 @@ public:
} }
//! Performs meshing ot the shape using current context. //! Performs meshing ot the shape using current context.
Standard_EXPORT virtual void Perform (); Standard_EXPORT virtual void Perform (const Message_ProgressRange& theRange);
DEFINE_STANDARD_RTTI_INLINE(IMeshTools_MeshBuilder, Message_Algorithm) DEFINE_STANDARD_RTTI_INLINE(IMeshTools_MeshBuilder, Message_Algorithm)

View File

@ -20,6 +20,7 @@
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#include <Standard_Transient.hxx> #include <Standard_Transient.hxx>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <Message_ProgressRange.hxx>
class IMeshData_Model; class IMeshData_Model;
struct IMeshTools_Parameters; struct IMeshTools_Parameters;
@ -37,13 +38,14 @@ public:
//! Exceptions protected processing of the given model. //! Exceptions protected processing of the given model.
Standard_Boolean Perform ( Standard_Boolean Perform (
const Handle (IMeshData_Model)& theModel, const Handle (IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange)
{ {
try try
{ {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
return performInternal (theModel, theParameters); return performInternal (theModel, theParameters, theRange);
} }
catch (Standard_Failure const&) catch (Standard_Failure const&)
{ {
@ -63,7 +65,8 @@ protected:
//! Performs processing of the given model. //! Performs processing of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal ( Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle (IMeshData_Model)& theModel, const Handle (IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) = 0; const IMeshTools_Parameters& theParameters,
const Message_ProgressRange& theRange) = 0;
}; };
#endif #endif

View File

@ -32,11 +32,13 @@
#include <CSLib.hxx> #include <CSLib.hxx>
#include <DBRep.hxx> #include <DBRep.hxx>
#include <Draw_Appli.hxx> #include <Draw_Appli.hxx>
#include <Draw_ProgressIndicator.hxx>
#include <Draw_Segment2D.hxx> #include <Draw_Segment2D.hxx>
#include <DrawTrSurf.hxx> #include <DrawTrSurf.hxx>
#include <GeometryTest.hxx> #include <GeometryTest.hxx>
#include <IMeshData_Status.hxx> #include <IMeshData_Status.hxx>
#include <Message.hxx> #include <Message.hxx>
#include <Message_ProgressRange.hxx>
#include <Poly_Connect.hxx> #include <Poly_Connect.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx> #include <TopTools_MapIteratorOfMapOfShape.hxx>
@ -157,7 +159,8 @@ options:\n\
di << "Incremental Mesh, multi-threading " di << "Incremental Mesh, multi-threading "
<< (aMeshParams.InParallel ? "ON" : "OFF") << "\n"; << (aMeshParams.InParallel ? "ON" : "OFF") << "\n";
BRepMesh_IncrementalMesh aMesher (aShape, aMeshParams); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
BRepMesh_IncrementalMesh aMesher (aShape, aMeshParams, aProgress->Start());
di << "Meshing statuses: "; di << "Meshing statuses: ";
const Standard_Integer aStatus = aMesher.GetStatusFlags(); const Standard_Integer aStatus = aMesher.GetStatusFlags();
@ -168,7 +171,7 @@ options:\n\
else else
{ {
Standard_Integer i; Standard_Integer i;
for (i = 0; i < 8; i++) for (i = 0; i < 9; i++)
{ {
Standard_Integer aFlag = aStatus & (1 << i); Standard_Integer aFlag = aStatus & (1 << i);
if (aFlag) if (aFlag)
@ -199,6 +202,9 @@ options:\n\
case IMeshData_Reused: case IMeshData_Reused:
di << "Reused "; di << "Reused ";
break; break;
case IMeshData_UserBreak:
di << "User break";
break;
case IMeshData_NoError: case IMeshData_NoError:
default: default:
break; break;

View File

@ -0,0 +1,21 @@
puts "========="
puts "0025113: Progress indicator in mesh"
puts "========="
puts ""
restore [locate_data_file bug21134_r.brep] a
tclean a
XProgress +t
set output [incmesh a 0.005]
set ctr { "Perform incmesh" "Mesh Perform"
"Face Discret" "100%"
"Create triangles on new vertices" }
foreach data ${ctr} {
if ![regexp $data $output] {
puts "Error: Non parallel version incmesh command: Mismatch data on '$data'"
break;
}
}

View File

@ -0,0 +1,21 @@
puts "========="
puts "0025113: Progress indicator in mesh"
puts "========="
puts ""
restore [locate_data_file bug21134_r.brep] a
tclean a
XProgress +t
set output [incmesh a 0.005 -parallel]
set ctr { "Perform incmesh" "Mesh Perform"
"Face Discret" "100%"
"Create triangles on new vertices" }
foreach data ${ctr} {
if ![regexp $data $output] {
puts "Error: Parallel version incmesh command for: Mismatch data on '$data'"
break;
}
}