]> OCCT Git - occt-copy.git/commitdiff
Added progress indicator to BRepMesh_IncrementalMesh [0025113 for OCCT 7.2.0]
authorakaftasev <akaftasev@opencascade.com>
Wed, 15 Jul 2020 14:23:32 +0000 (17:23 +0300)
committermsv <msv@opencascade.com>
Fri, 7 Aug 2020 11:50:01 +0000 (14:50 +0300)
16 files changed:
src/BRepMesh/BRepMesh_Delaun.cxx
src/BRepMesh/BRepMesh_Delaun.hxx
src/BRepMesh/BRepMesh_DiscretRoot.hxx
src/BRepMesh/BRepMesh_FaceSentry.hxx [new file with mode: 0644]
src/BRepMesh/BRepMesh_FastDiscret.cxx
src/BRepMesh/BRepMesh_FastDiscret.hxx
src/BRepMesh/BRepMesh_FastDiscretFace.cxx
src/BRepMesh/BRepMesh_FastDiscretFace.hxx
src/BRepMesh/BRepMesh_IncrementalMesh.cxx
src/BRepMesh/BRepMesh_IncrementalMesh.hxx
src/BRepMesh/BRepMesh_Status.hxx
src/BRepMesh/FILES
src/MeshTest/MeshTest.cxx
src/Message/Message_ProgressSentry.cxx
src/Message/Message_ProgressSentry.hxx
src/Message/Message_ProgressSentry.lxx

index 62ff759122532aaa76dadb6f5dc5cf42bbe872a6..72cf0bc9620d613dbf7feea1c654bd2d44820dcc 100644 (file)
@@ -304,6 +304,18 @@ void BRepMesh_Delaun::compute(BRepMesh::Array1OfInteger& theVertexIndexes)
 //=======================================================================
 void BRepMesh_Delaun::createTriangles(const Standard_Integer         theVertexIndex,  
                                       BRepMesh::MapOfIntegerInteger& thePoly)
+{
+  Message_ProgressSentry aSentry(NULL, "", 0, 100, 1);
+  createTriangles(theVertexIndex, thePoly, aSentry);
+}
+
+//=======================================================================
+//function : createTriangles
+//purpose  : Creates the triangles beetween the node and the polyline.
+//=======================================================================
+void BRepMesh_Delaun::createTriangles(const Standard_Integer         theVertexIndex,
+                                      BRepMesh::MapOfIntegerInteger& thePoly,
+                                      Message_ProgressSentry&        theProgressEntry)
 {
   BRepMesh::ListOfInteger aLoopEdges, anExternalEdges;
   const gp_XY& aVertexCoord = myMeshData->GetNode( theVertexIndex ).Coord();
@@ -311,6 +323,10 @@ void BRepMesh_Delaun::createTriangles(const Standard_Integer         theVertexIn
   BRepMesh::MapOfIntegerInteger::Iterator anEdges( thePoly );
   for ( ; anEdges.More(); anEdges.Next() )
   {
+    if (!theProgressEntry.More())
+    {
+      return;
+    }
     Standard_Integer     anEdgeId = anEdges.Key();
     const BRepMesh_Edge& anEdge   = GetEdge( anEdgeId );
 
@@ -408,6 +424,10 @@ void BRepMesh_Delaun::createTriangles(const Standard_Integer         theVertexIn
 
   while ( !aLoopEdges.IsEmpty() )
   {
+    if (!theProgressEntry.More())
+    {
+      return;
+    }
     const BRepMesh_Edge& anEdge = GetEdge( Abs( aLoopEdges.First() ) );
     if ( anEdge.Movability() != BRepMesh_Deleted )
     {
@@ -425,6 +445,18 @@ void BRepMesh_Delaun::createTriangles(const Standard_Integer         theVertexIn
 //=======================================================================
 void BRepMesh_Delaun::createTrianglesOnNewVertices(
   BRepMesh::Array1OfInteger& theVertexIndexes)
+{
+  Message_ProgressSentry aSentry(NULL, "", 0, 100, 1);
+  createTrianglesOnNewVertices(theVertexIndexes, aSentry);
+}
+
+//=======================================================================
+//function : createTrianglesOnNewVertices
+//purpose  : Creation of triangles from the new nodes
+//=======================================================================
+void BRepMesh_Delaun::createTrianglesOnNewVertices(
+  BRepMesh::Array1OfInteger& theVertexIndexes,
+  Message_ProgressSentry&    theProgressEntry)
 {
   Handle(NCollection_IncAllocator) aAllocator =
     new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE);
@@ -440,6 +472,10 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
   Standard_Integer anUpper = theVertexIndexes.Upper();
   for( ; anIndex <= anUpper; ++anIndex ) 
   {
+    if (!theProgressEntry.More())
+    {
+      return;
+    }
     aAllocator->Reset(Standard_False);
     BRepMesh::MapOfIntegerInteger aLoopEdges(10, aAllocator);
     
@@ -483,6 +519,10 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
       isModify = Standard_True;    
       while ( isModify && !aCirclesList.IsEmpty() )
       {
+        if (!theProgressEntry.More())
+        {
+          return;
+        }
         isModify = Standard_False;
         BRepMesh::ListOfInteger::Iterator aCircleIt1( aCirclesList );
         for ( ; aCircleIt1.More(); aCircleIt1.Next() )
@@ -503,14 +543,24 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
         }
       }
 
+      if (!theProgressEntry.More())
+      {
+        return;
+      }
       // Creation of triangles with the current node and free edges
       // and removal of these edges from the list of free edges
-      createTriangles( aVertexIdx, aLoopEdges );
+      createTriangles( aVertexIdx, aLoopEdges, theProgressEntry );
     }
   }
-
-  insertInternalEdges();
-
+  if (!theProgressEntry.More())
+  {
+    return;
+  }
+  insertInternalEdges(theProgressEntry);
+  if (!theProgressEntry.More())
+  {
+    return;
+  }
   // Adjustment of meshes to boundary edges
   frontierAdjust();
 }
@@ -520,6 +570,16 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
 //purpose  : 
 //=======================================================================
 void BRepMesh_Delaun::insertInternalEdges()
+{
+  Message_ProgressSentry aSentry(NULL, "", 0, 100, 1);
+  insertInternalEdges(aSentry);
+}
+
+//=======================================================================
+//function : insertInternalEdges
+//purpose  : 
+//=======================================================================
+void BRepMesh_Delaun::insertInternalEdges(Message_ProgressSentry& theProgressEntry)
 {
   BRepMesh::HMapOfInteger anInternalEdges = InternalEdges();
 
@@ -530,6 +590,10 @@ void BRepMesh_Delaun::insertInternalEdges()
   BRepMesh::MapOfInteger::Iterator anInernalEdgesIt( *anInternalEdges );
   for ( ; anInernalEdgesIt.More(); anInernalEdgesIt.Next() )
   {
+    if (!theProgressEntry.More())
+    {
+      return;
+    }
     const Standard_Integer aLinkIndex = anInernalEdgesIt.Key();
     const BRepMesh_PairOfIndex& aPair = myMeshData->ElementsConnectedTo(aLinkIndex);
 
@@ -2099,7 +2163,8 @@ void BRepMesh_Delaun::RemoveVertex( const BRepMesh_Vertex& theVertex )
 //function : AddVertices
 //purpose  : Adds some vertices in the triangulation.
 //=======================================================================
-void BRepMesh_Delaun::AddVertices(BRepMesh::Array1OfVertexOfDelaun& theVertices)
+void BRepMesh_Delaun::AddVertices(BRepMesh::Array1OfVertexOfDelaun& theVertices,
+                                  Message_ProgressSentry&           theProgressEntry)
 {
   std::make_heap(theVertices.begin(), theVertices.end(), ComparatorOfVertexOfDelaun());
   std::sort_heap(theVertices.begin(), theVertices.end(), ComparatorOfVertexOfDelaun());
@@ -2111,7 +2176,7 @@ void BRepMesh_Delaun::AddVertices(BRepMesh::Array1OfVertexOfDelaun& theVertices)
   for ( Standard_Integer i = aLower; i <= anUpper; ++i )     
     aVertexIndexes(i) = myMeshData->AddNode( theVertices(i) );
 
-  createTrianglesOnNewVertices( aVertexIndexes );
+  createTrianglesOnNewVertices( aVertexIndexes, theProgressEntry );
 }
 
 //=======================================================================
index e8fcba595e5a975fa2c4b92627460fc861fc1691..33f564780b62bf1aea361da572af96be8f59da58 100755 (executable)
@@ -29,6 +29,7 @@
 #include <TColStd_Array1OfInteger.hxx>
 #include <TColStd_SequenceOfInteger.hxx>
 #include <TColStd_MapOfInteger.hxx>
+#include <Message_ProgressSentry.hxx>
 
 class Bnd_B2d;
 class Bnd_Box2d;
@@ -59,7 +60,8 @@ public:
   Standard_EXPORT void RemoveVertex (const BRepMesh_Vertex& theVertex);
 
   //! Adds some vertices into the triangulation.
-  Standard_EXPORT void AddVertices (BRepMesh::Array1OfVertexOfDelaun& theVertices);
+  Standard_EXPORT void AddVertices (BRepMesh::Array1OfVertexOfDelaun& theVertices, 
+                                    Message_ProgressSentry&           theProgressEntry);
 
   //! Modify mesh to use the edge.
   //! @return True if done
@@ -221,6 +223,9 @@ private:
   //! Creates the triangles beetween the given node and the given polyline.
   void createTriangles (const Standard_Integer         theVertexIndex,
                         BRepMesh::MapOfIntegerInteger& thePoly);
+  void createTriangles (const Standard_Integer         theVertexIndex,
+                        BRepMesh::MapOfIntegerInteger& thePoly,
+                        Message_ProgressSentry&        theProgressEntry);
 
   //! Add a triangle based on the given oriented edges into mesh
   void addTriangle (const Standard_Integer (&theEdgesId)[3],
@@ -253,6 +258,9 @@ private:
                                                 BRepMesh::SequenceOfBndB2d&  thePolyBoxes);
   
   //! Creates the triangles on new nodes.
+  void createTrianglesOnNewVertices (BRepMesh::Array1OfInteger& theVertexIndices,
+                                     Message_ProgressSentry&    theProgressEntry);
+  //! Creates the triangles on new nodes.
   void createTrianglesOnNewVertices (BRepMesh::Array1OfInteger& theVertexIndices);
 
   //! Cleanup mesh from the free triangles.
@@ -323,6 +331,9 @@ private:
   //! Performs insertion of internal edges into mesh.
   void insertInternalEdges();
 
+  //! Performs insertion of internal edges into mesh.
+  void insertInternalEdges(Message_ProgressSentry& theProgressEntry);
+
 private:
 
   Handle(BRepMesh_DataStructureOfDelaun) myMeshData;
index f3834204dfa94f55c833c891218f879011dc29cd..788747321aa16a6cdaec7657fb8bff625825ca49 100644 (file)
@@ -18,6 +18,7 @@
 #include <Standard_Type.hxx>
 #include <TopoDS_Shape.hxx>
 #include <Standard_Transient.hxx>
+#include <Message_ProgressIndicator.hxx>
 
 //! This is a common interface for meshing algorithms 
 //! instantiated by Mesh Factory and implemented by plugins.
@@ -46,7 +47,7 @@ public:
   }
 
   //! Compute triangulation for set shape.
-  Standard_EXPORT virtual void Perform() = 0;
+  Standard_EXPORT virtual void Perform (const Handle(Message_ProgressIndicator) &theProgress = NULL) = 0;
 
 
   DEFINE_STANDARD_RTTIEXT(BRepMesh_DiscretRoot,Standard_Transient)
diff --git a/src/BRepMesh/BRepMesh_FaceSentry.hxx b/src/BRepMesh/BRepMesh_FaceSentry.hxx
new file mode 100644 (file)
index 0000000..6674785
--- /dev/null
@@ -0,0 +1,64 @@
+// Created: 2020-07-27 
+// 
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef BRepMesh_FaceSentry_HeaderFile
+#define BRepMesh_FaceSentry_HeaderFile
+
+#include <TopoDS_Face.hxx>
+
+class Message_ProgressSentry;
+
+class BRepMesh_FaceSentry
+{
+public:
+  BRepMesh_FaceSentry()
+    :mySentry(0L), isParallel(Standard_False)
+  {
+  }
+
+  BRepMesh_FaceSentry (const TopoDS_Face& theFace,
+                       Message_ProgressSentry* theSentry = 0L,
+                       Standard_Boolean theParallel = Standard_False)
+    :myFace(theFace), mySentry(theSentry),
+    isParallel(theParallel)
+  {
+  }
+
+  //! Get progress sentry
+  Message_ProgressSentry* GetProgressEntry() const
+  {
+    return mySentry;
+  }
+
+  //! Return reference on TopoDS_Face
+  const TopoDS_Face& GetFace() const
+  {
+    return myFace;
+  }
+
+  //! Returns isParallel
+  Standard_Boolean IsParallel() const
+  {
+    return isParallel;
+  }
+
+
+private:
+  TopoDS_Face myFace;
+  Message_ProgressSentry* mySentry;
+  Standard_Boolean isParallel;
+};
+
+#endif
\ No newline at end of file
index 1d453897ff34488535ab856926a24707482749f5..3f0de789446c6c35eb6271b88c4a7aca7be8e60f 100644 (file)
@@ -128,10 +128,10 @@ void BRepMesh_FastDiscret::Perform(const TopoDS_Shape& theShape)
 //function : Process
 //purpose  : 
 //=======================================================================
-void BRepMesh_FastDiscret::Process(const TopoDS_Face& theFace) const
+void BRepMesh_FastDiscret::Process(const TopoDS_Face& theFace, Message_ProgressSentry& theProgrEntry) const
 {
   Handle(BRepMesh_FaceAttribute) anAttribute;
-  if (GetFaceAttribute(theFace, anAttribute))
+  if (GetFaceAttribute(theFace, anAttribute) && theProgrEntry.More())
   {
     try
     {
@@ -139,7 +139,7 @@ void BRepMesh_FastDiscret::Process(const TopoDS_Face& theFace) const
 
       BRepMesh_FastDiscretFace aTool(myParameters.Angle, myParameters.MinSize, 
         myParameters.InternalVerticesMode, myParameters.ControlSurfaceDeflection);
-      aTool.Perform(anAttribute);
+      aTool.Perform(anAttribute, theProgrEntry);
     }
     catch (Standard_Failure)
     {
index 3db6feeae21d616f11b26435674a6ab62dfd82cb..b7691afd76a880da9c22226cc553c6376341b0cd 100644 (file)
@@ -34,6 +34,9 @@
 #include <BRepMesh_ShapeTool.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <Message_ProgressSentry.hxx>
+#include <BRepMesh_FaceSentry.hxx>
+#include <OSD_Parallel.hxx>
 
 class BRepMesh_DataStructureOfDelaun;
 class Bnd_Box;
@@ -127,11 +130,24 @@ public:
   //! Triangulate a face previously recorded for 
   //! processing by call to Add(). Can be executed in 
   //! parallel threads.
-  Standard_EXPORT void Process(const TopoDS_Face& face) const;
+  Standard_EXPORT void Process(const TopoDS_Face& theFace, Message_ProgressSentry& theProgrEntry) const;
 
-  void operator () (const TopoDS_Face& face) const
+  void operator () (const BRepMesh_FaceSentry& aFaceSentry) const
   {
-    Process(face);
+    if (!aFaceSentry.GetProgressEntry()->More())
+    {
+      return;
+    }
+    Process(aFaceSentry.GetFace(), *aFaceSentry.GetProgressEntry());  
+   
+    if (aFaceSentry.IsParallel())
+    {
+      aFaceSentry.GetProgressEntry()->Next(OSD_Parallel::NbLogicalProcessors());
+    }
+    else
+    {
+      aFaceSentry.GetProgressEntry()->Next();
+    }
   }
   
   //! Returns parameters of meshing
index 89cbc895402456441cc2ee1f8fa9c0039e21c76b..ef2011f9fc5c3ad3bbb8cebf99e858aa276dc437 100644 (file)
@@ -185,9 +185,14 @@ BRepMesh_FastDiscretFace::BRepMesh_FastDiscretFace(
 //function : Perform
 //purpose  : 
 //=======================================================================
-void BRepMesh_FastDiscretFace::Perform(const Handle(BRepMesh_FaceAttribute)& theAttribute)
+void BRepMesh_FastDiscretFace::Perform (const Handle(BRepMesh_FaceAttribute)& theAttribute,
+                                        Message_ProgressSentry&               theProgressEntry)
 {
-  add(theAttribute);
+  add(theAttribute, theProgressEntry);
+  if (!theProgressEntry.More())
+  {
+    return;
+  }
   commitSurfaceTriangulation();
 }
 
@@ -345,7 +350,8 @@ void BRepMesh_FastDiscretFace::addLinkToMesh(
 //function : Add
 //purpose  : 
 //=======================================================================
-void BRepMesh_FastDiscretFace::add(const Handle(BRepMesh_FaceAttribute)& theAttribute)
+void BRepMesh_FastDiscretFace::add (const Handle(BRepMesh_FaceAttribute)& theAttribute,
+                                    Message_ProgressSentry& theProgressEntry)
 {
   if (!theAttribute->IsValid() || theAttribute->ChangeMeshNodes()->IsEmpty())
     return;
@@ -397,12 +403,20 @@ void BRepMesh_FastDiscretFace::add(const Handle(BRepMesh_FaceAttribute)& theAttr
      (vmax - vmin) < Precision::PConfusion());
 
   Standard_Real aDef = -1;
+  if (!theProgressEntry.More())
+  {
+    return;
+  }
   if ( !isaline && myStructure->ElementsOfDomain().Extent() > 0 )
   {
     if (!rajout)
     {
       // compute maximal deflection
-      aDef = control(trigu, Standard_True);
+      aDef = control(trigu, Standard_True, theProgressEntry);
+      if (!theProgressEntry.More())
+      {
+        return;
+      }
       rajout = (aDef > myAttribute->GetDefFace() || aDef < 0.);
     }
     if (thetype != GeomAbs_Plane)
@@ -415,11 +429,21 @@ void BRepMesh_FastDiscretFace::add(const Handle(BRepMesh_FaceAttribute)& theAttr
 
       if (rajout)
       {
-        insertInternalVertices(trigu);
+        insertInternalVertices(trigu, theProgressEntry);
+        if (!theProgressEntry.More())
+        {
+          return;
+        }
 
         //control internal points
         if (myIsControlSurfaceDeflection)
-          aDef = control(trigu, Standard_False);
+        {
+          aDef = control(trigu, Standard_False, theProgressEntry);
+          if (!theProgressEntry.More())
+          {
+            return;
+          }
+        }
       }
     }
   }
@@ -447,7 +471,8 @@ void BRepMesh_FastDiscretFace::add(const Handle(BRepMesh_FaceAttribute)& theAttr
 //=======================================================================
 Standard_Boolean BRepMesh_FastDiscretFace::addVerticesToMesh(
   const BRepMesh::ListOfVertex& theVertices,
-  BRepMesh_Delaun&              theMeshBuilder)
+  BRepMesh_Delaun&              theMeshBuilder,
+  Message_ProgressSentry&       theProgressEntry)
 {
   if (theVertices.IsEmpty())
     return Standard_False;
@@ -457,8 +482,8 @@ Standard_Boolean BRepMesh_FastDiscretFace::addVerticesToMesh(
   for (Standard_Integer aVertexId = 0; aVertexIt.More(); aVertexIt.Next())
     aArrayOfNewVertices(++aVertexId) = aVertexIt.Value();
 
-  theMeshBuilder.AddVertices(aArrayOfNewVertices);
-  return Standard_True;
+  theMeshBuilder.AddVertices(aArrayOfNewVertices, theProgressEntry);
+  return theProgressEntry.More();
 }
 
 //=======================================================================
@@ -527,7 +552,8 @@ static void filterParameters(const BRepMesh::IMapOfReal& theParams,
 //function : insertInternalVertices
 //purpose  : 
 //=======================================================================
-void BRepMesh_FastDiscretFace::insertInternalVertices(BRepMesh_Delaun& theMeshBuilder)
+void BRepMesh_FastDiscretFace::insertInternalVertices (BRepMesh_Delaun& theMeshBuilder,
+                                                       Message_ProgressSentry& theProgressEntry)
 {
   Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
   BRepMesh::ListOfVertex aNewVertices(anAlloc);
@@ -555,7 +581,7 @@ void BRepMesh_FastDiscretFace::insertInternalVertices(BRepMesh_Delaun& theMeshBu
     break;
   }
   
-  addVerticesToMesh(aNewVertices, theMeshBuilder);
+  addVerticesToMesh(aNewVertices, theMeshBuilder, theProgressEntry);
 }
 
 //=======================================================================
@@ -1182,7 +1208,8 @@ Standard_Boolean BRepMesh_FastDiscretFace::checkDeflectionAndInsert(
 //=======================================================================
 Standard_Real BRepMesh_FastDiscretFace::control(
   BRepMesh_Delaun&         theTrigu,
-  const Standard_Boolean   theIsFirst)
+  const Standard_Boolean   theIsFirst,
+  Message_ProgressSentry&  theProgressEntry)
 {
   Standard_Integer aTrianglesNb = myStructure->ElementsOfDomain().Extent();
   if (aTrianglesNb < 1)
@@ -1219,6 +1246,10 @@ Standard_Real BRepMesh_FastDiscretFace::control(
     new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE);
   for (; aPass <= aPassesNb && aInsertedNb && !isAllDegenerated; ++aPass)
   {
+    if (!theProgressEntry.More())
+    {
+      return 0;
+    }
     aTempAlloc->Reset(Standard_False);
     BRepMesh::ListOfVertex aNewVertices(aTempAlloc);
 
@@ -1236,6 +1267,10 @@ Standard_Real BRepMesh_FastDiscretFace::control(
     BRepMesh::MapOfInteger::Iterator aTriangleIt(aTriangles);
     for (; aTriangleIt.More(); aTriangleIt.Next())
     {
+      if (!theProgressEntry.More())
+      {
+        return 0;
+      }
       const Standard_Integer aTriangleId = aTriangleIt.Key();
       const BRepMesh_Triangle& aCurrentTriangle = myStructure->GetElement(aTriangleId);
 
@@ -1397,9 +1432,12 @@ Standard_Real BRepMesh_FastDiscretFace::control(
       ftt << "vertex vt" << aPass << "_" << i << " "
         << aP.X() << " " << aP.Y() << " " << aP.Z() << endl;
     }
-#endif
-
-    if (addVerticesToMesh(aNewVertices, theTrigu))
+#endif    
+    if (!theProgressEntry.More())
+    {
+      return 0;
+    }
+    if (addVerticesToMesh(aNewVertices, theTrigu, theProgressEntry))
       ++aInsertedNb;
   }
 
index 76b00e1914d75028e6e350247d1824b666370735..a3a111be18f4039ff4f4ff3666b5bea6539cc9db 100644 (file)
@@ -27,6 +27,7 @@
 #include <BRepMesh_Triangle.hxx>
 #include <BRepMesh_Classifier.hxx>
 #include <ElSLib.hxx>
+#include <Message_ProgressSentry.hxx>
 
 class BRepMesh_DataStructureOfDelaun;
 class BRepMesh_FaceAttribute;
@@ -60,17 +61,18 @@ public:
     const Standard_Boolean isInternalVerticesMode,
     const Standard_Boolean isControlSurfaceDeflection);
 
-  Standard_EXPORT void Perform(const Handle(BRepMesh_FaceAttribute)& theAttribute);
-
+  Standard_EXPORT void Perform(const Handle(BRepMesh_FaceAttribute)& theAttribute, Message_ProgressSentry& theProgressEntry);
   DEFINE_STANDARD_RTTIEXT(BRepMesh_FastDiscretFace,Standard_Transient)
 
 private:
 
-  void add(const Handle(BRepMesh_FaceAttribute)& theAttribute);
+  void add(const Handle(BRepMesh_FaceAttribute)& theAttribute, Message_ProgressSentry& theProgressEntry);
   void add(const TopoDS_Vertex& theVertex);
 
   Standard_Real control(BRepMesh_Delaun&         theMeshBuilder,
-                        const Standard_Boolean   theIsFirst);
+                        const Standard_Boolean   theIsFirst,
+                        Message_ProgressSentry&  theProgressEntry);
 
   //! Registers the given nodes in mesh data structure and
   //! performs refinement of existing mesh.
@@ -80,12 +82,14 @@ private:
   //! @return TRUE if vertices were been inserted, FALSE elewhere.
   Standard_Boolean addVerticesToMesh(
     const BRepMesh::ListOfVertex& theVertices,
-    BRepMesh_Delaun&              theMeshBuilder);
+    BRepMesh_Delaun&              theMeshBuilder,
+    Message_ProgressSentry&       theProgressEntry);
 
   //! Calculates nodes lying on face's surface and inserts them to a mesh.
   //! @param theMeshBuilder initialized tool refining mesh 
   //! in respect to inserting nodes.
-  void insertInternalVertices(BRepMesh_Delaun&         theMeshBuilder);
+  void insertInternalVertices(BRepMesh_Delaun&         theMeshBuilder, 
+                              Message_ProgressSentry&  theProgressEntry);
 
   //! Calculates nodes lying on spherical surface.
   //! @param theNewVertices list of vertices to be extended and added to mesh.
index 70278be25991cf217e1b4228a58e00ca659e00c2..40d4f8905bb27a07737c9c9f7894c1f1b6c675b5 100644 (file)
 
 #include <GCPnts_TangentialDeflection.hxx>
 
+#include <Message_ProgressSentry.hxx>
+#include <BRepMesh_FaceSentry.hxx>
+
+
 IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot)
 
 namespace
@@ -103,13 +107,14 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape&    theSh
 //function : Constructor
 //purpose  : 
 //=======================================================================
-BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape,
-                                                   const BRepMesh_FastDiscret::Parameters& theParameters)
+BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
+                                                    const BRepMesh_FastDiscret::Parameters& theParameters,
+                                                    const Handle(Message_ProgressIndicator) &theProgress)
   : myParameters(theParameters)
 {
   myShape       = theShape;
   
-  Perform();
+  Perform(theProgress);
 }
 
 //=======================================================================
@@ -201,25 +206,34 @@ void BRepMesh_IncrementalMesh::collectFaces()
 //function : Perform
 //purpose  : 
 //=======================================================================
-void BRepMesh_IncrementalMesh::Perform()
+void BRepMesh_IncrementalMesh::Perform(const Handle(Message_ProgressIndicator) &theProgress)
 {
   init();
 
   if (myMesh.IsNull())
     return;
 
-  update();
+  update(theProgress);
 }
 
 //=======================================================================
 //function : update()
 //purpose  : 
 //=======================================================================
-void BRepMesh_IncrementalMesh::update()
+void BRepMesh_IncrementalMesh::update(const Handle(Message_ProgressIndicator) &theProgress)
 {
+  Message_ProgressSentry anOuterSentry(theProgress, "Updating", 0, 100, 1);
+  
   // Update edges data
   TopExp_Explorer aExplorer(myShape, TopAbs_EDGE);
-  for (; aExplorer.More(); aExplorer.Next())
+  int aEdgeSize = 0;
+  for ( ; aExplorer.More(); aExplorer.Next(), aEdgeSize++)
+  {
+  }
+  anOuterSentry.Next(9);
+  aExplorer.Init(myShape, TopAbs_EDGE);
+  for (Message_ProgressSentry anEdgeSentry(theProgress, "Update edges data", 0, aEdgeSize, 1); 
+    aExplorer.More() && anEdgeSentry.More(); aExplorer.Next(), anEdgeSentry.Next())
   {
     const TopoDS_Edge& aEdge = TopoDS::Edge(aExplorer.Current());
     if(!BRep_Tool::IsGeometric(aEdge))
@@ -228,15 +242,45 @@ void BRepMesh_IncrementalMesh::update()
     update(aEdge);
   }
 
+  if (!anOuterSentry.More())
+  {
+    myStatus = BRepMesh_UserBreak;
+    return;
+  }
+  anOuterSentry.Next(5);
+  
+  NCollection_Vector<BRepMesh_FaceSentry> aFaces;
   // Update faces data
   NCollection_Vector<TopoDS_Face>::Iterator aFaceIt(myFaces);
-  for (; aFaceIt.More(); aFaceIt.Next())
+  for (Message_ProgressSentry aFacesSentry(theProgress, "Update faces data", 0, myFaces.Size(), 1);
+    aFaceIt.More() && aFacesSentry.More(); aFaceIt.Next(), aFacesSentry.Next())
+  {
     update(aFaceIt.Value());
+  }
 
-  // Mesh faces
-  OSD_Parallel::ForEach(myFaces.begin(), myFaces.end(), *myMesh, !myParameters.InParallel);
+  if (!anOuterSentry.More())
+  {
+    myStatus = BRepMesh_UserBreak;
+    return;
+  }
+  anOuterSentry.Next(80);
 
-  commit();
+  Message_ProgressSentry aProgrSentry(theProgress, "Mesh faces", 0, myFaces.Size(), 1);
+  for (NCollection_Vector<TopoDS_Face>::Iterator aFaceIter(myFaces); aFaceIter.More(); aFaceIter.Next())
+  {
+    aFaces.Append(BRepMesh_FaceSentry(aFaceIter.Value(), &aProgrSentry, myParameters.InParallel));
+  }
+  // Mesh faces
+  OSD_Parallel::ForEach(aFaces.begin(), aFaces.end(), *myMesh, !myParameters.InParallel);
+  if (!anOuterSentry.More())
+  {
+    myStatus = BRepMesh_UserBreak;
+    return;
+  }
+  anOuterSentry.Next(5);
+  Message_ProgressSentry aSentry(theProgress, "Commit", 0, myFaces.Size(), 1);
+  commit(aSentry);
+  anOuterSentry.Next();
   clear();
 }
 
@@ -493,10 +537,10 @@ void BRepMesh_IncrementalMesh::update(const TopoDS_Face& theFace)
 //function : commit
 //purpose  : 
 //=======================================================================
-void BRepMesh_IncrementalMesh::commit()
+void BRepMesh_IncrementalMesh::commit(Message_ProgressSentry& theSentry)
 {
   NCollection_Vector<TopoDS_Face>::Iterator aFaceIt(myFaces);
-  for (; aFaceIt.More(); aFaceIt.Next())
+  for (; aFaceIt.More() && theSentry.More(); aFaceIt.Next(), theSentry.Next())
     commitEdges(aFaceIt.Value());
 
   discretizeFreeEdges();
index 5e7d4f3bdc97a877adf804449e8161d31c0a506c..5cd50633ee2017d3700511161cd8ccc6f88312ac 100644 (file)
@@ -22,6 +22,7 @@
 #include <TopTools_DataMapOfShapeReal.hxx>
 #include <BRepMesh_DiscretRoot.hxx>
 #include <BRepMesh.hxx>
+#include <Message_ProgressIndicator.hxx>
 
 #include <vector>
 
@@ -51,7 +52,7 @@ public: //! @name mesher API
   //! used for the faces will be the maximum deflection of their edges.
   //! @param theAngDeflection angular deflection.
   //! @param isInParallel if TRUE shape will be meshed in parallel.
-  Standard_EXPORT BRepMesh_IncrementalMesh(
+  Standard_EXPORT BRepMesh_IncrementalMesh (
     const TopoDS_Shape&    theShape,
     const Standard_Real    theLinDeflection,
     const Standard_Boolean isRelative = Standard_False,
@@ -64,10 +65,11 @@ public: //! @name mesher API
   //! @param theShape shape to be meshed.
   //! @param theParameters - parameters of meshing
   Standard_EXPORT BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
-                                            const BRepMesh_FastDiscret::Parameters& theParameters);
+                                            const BRepMesh_FastDiscret::Parameters& theParameters,
+                                            const Handle(Message_ProgressIndicator) &theProgress = NULL);
 
   //! Performs meshing ot the shape.
-  Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
+  Standard_EXPORT virtual void Perform(const Handle(Message_ProgressIndicator) &theProgress = NULL) Standard_OVERRIDE;
   
 public: //! @name accessing to parameters.
 
@@ -126,7 +128,7 @@ protected:
 private:
 
   //! Builds the incremental mesh for the shape.
-  void update();
+  void update(const Handle(Message_ProgressIndicator) &theProgress = NULL);
 
   //! Checks triangulation of the given face for consistency 
   //! with the chosen tolerance. If some edge of face has no
@@ -167,7 +169,7 @@ private:
                               const Standard_Boolean isWithCheck);
 
   //! Stores mesh to the shape.
-  void commit();
+  void commit(Message_ProgressSentry& theSentry);
 
   //! Stores mesh of internal edges to the face.
   void commitEdges(const TopoDS_Face& theFace);
index a9b45457172d1cc4c57aa6b9ef10ee960daedbfe..0c4ce44179e3bcdd1e768e35bd1730f6a3dc1caf 100644 (file)
@@ -23,7 +23,8 @@ enum BRepMesh_Status
   BRepMesh_OpenWire             = 0x1,
   BRepMesh_SelfIntersectingWire = 0x2,
   BRepMesh_Failure              = 0x4,
-  BRepMesh_ReMesh               = 0x8
+  BRepMesh_ReMesh               = 0x8,
+  BRepMesh_UserBreak            = 0x16
 };
 
 #endif
index ec3909484278e7b4aacbb7c346f77c1920ce6874..35ebcbd75985d078c5a10f486aca1f84ffc89c7d 100755 (executable)
@@ -23,6 +23,7 @@ BRepMesh_EdgeTessellator.cxx
 BRepMesh_EdgeTessellator.hxx
 BRepMesh_FaceAttribute.cxx
 BRepMesh_FaceAttribute.hxx
+BRepMesh_FaceSentry.hxx
 BRepMesh_FactoryError.hxx
 BRepMesh_FastDiscret.cxx
 BRepMesh_FastDiscret.hxx
index 9ee7595246a7f997860eb213ec18c968a3d2d855..c411dbd8374851487b61252623d4fcdbaa6a5748 100644 (file)
@@ -80,6 +80,7 @@
 #include <TopoDS_Wire.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <Draw_ProgressIndicator.hxx>
 
 #include <stdio.h>
 //epa Memory leaks test
@@ -195,7 +196,8 @@ options:\n\
   aMeshParams.ControlSurfaceDeflection = isControlSurDef;
   aMeshParams.AdaptiveMin = isAdaptiveMin;
   
-  BRepMesh_IncrementalMesh aMesher (aShape, aMeshParams);
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
+  BRepMesh_IncrementalMesh aMesher(aShape, aMeshParams, aProgress);
 
   di << "Meshing statuses: ";
   Standard_Integer statusFlags = aMesher.GetStatusFlags();
@@ -206,7 +208,7 @@ options:\n\
   else
   {
     Standard_Integer i;
-    for( i = 0; i < 4; i++ )
+    for( i = 0; i < 5; i++ )
     {
       if( (statusFlags >> i) & (Standard_Integer)1 )
       {
@@ -224,6 +226,9 @@ options:\n\
           case 4:
             di << "ReMesh ";
             break;
+          case 5:
+            di << "UserBreak";
+            break;
         }
       }
     }
index 2648816f5b31c5358cbd4aa9a3632ffa174621a1..8ce27755a4005efe73cc6d891071d8ec784ef24b 100644 (file)
@@ -27,7 +27,8 @@ Message_ProgressSentry::Message_ProgressSentry (const Handle(Message_ProgressInd
                                                   const Standard_Real step,
                                                   const Standard_Boolean isInf,
                                                   const Standard_Real newScopeSpan) :
-       myProgress(progress), myActive(!progress.IsNull())
+    myProgress(progress), myActive(!progress.IsNull()),
+    myThreadId(OSD_Thread::Current())
 {
   if ( ! myActive ) return;
   progress->SetName ( name );
@@ -47,7 +48,8 @@ Message_ProgressSentry::Message_ProgressSentry (const Handle(Message_ProgressInd
                                                   const Standard_Real step,
                                                   const Standard_Boolean isInf,
                                                   const Standard_Real newScopeSpan) :
-       myProgress(progress), myActive(!progress.IsNull())
+    myProgress(progress), myActive(!progress.IsNull()),
+    myThreadId(OSD_Thread::Current())
 {
   if ( ! myActive ) return;
   progress->SetName ( name );
index 0e7a094a5dcbc3ae0502ac1b8a0ba49df43ad728..8cc137c2720e558968e049f296b2d93e4bdf6582 100644 (file)
 #include <Standard_Boolean.hxx>
 #include <Standard_CString.hxx>
 #include <Standard_Real.hxx>
+
+#include <Standard_ThreadId.hxx>
+#include <OSD_Thread.hxx>
+
 class Message_ProgressIndicator;
 class TCollection_HAsciiString;
 
@@ -109,6 +113,7 @@ private:
 
   Handle(Message_ProgressIndicator) myProgress;
   Standard_Boolean myActive;
+  Standard_ThreadId myThreadId;
 
 
 };
index e083a8ce46d999edc0e4982c5b997da3d3a6633e..86d921112870f5271f05f1216319143fec27f16f 100644 (file)
@@ -20,7 +20,7 @@
 
 inline void Message_ProgressSentry::Relieve ()
 {
-  if ( ! myActive ) return;
+  if ( !myActive || myThreadId != OSD_Thread::Current()) return;
   myProgress->EndScope();
   myActive = 0;
 }
@@ -32,7 +32,10 @@ inline void Message_ProgressSentry::Relieve ()
 
 inline void Message_ProgressSentry::Next (const Standard_CString name) const
 {
-  if ( myActive ) myProgress->NextScope(name);
+  if ( myActive && myThreadId == OSD_Thread::Current()) 
+  {
+    myProgress->NextScope(name);
+  }
 }
 
 //=======================================================================
@@ -43,7 +46,10 @@ inline void Message_ProgressSentry::Next (const Standard_CString name) const
 inline void Message_ProgressSentry::Next (const Standard_Real span, 
                                          const Standard_CString name) const
 {
-  if ( myActive ) myProgress->NextScope(span, name);
+  if ( myActive && myThreadId == OSD_Thread::Current())
+  {
+    myProgress->NextScope(span, name);
+  }
 }
 
 //=======================================================================
@@ -54,7 +60,8 @@ inline void Message_ProgressSentry::Next (const Standard_Real span,
 inline void Message_ProgressSentry::Next (const Standard_Real span, 
                                          const Handle(TCollection_HAsciiString)& name) const
 {
-  if ( myActive ) {
+  if ( myActive && myThreadId == OSD_Thread::Current()) 
+  {
     myProgress->EndScope();
     myProgress->NewScope(span, name);
   }
@@ -77,5 +84,8 @@ inline Standard_Boolean Message_ProgressSentry::More () const
 
 inline void Message_ProgressSentry::Show () const
 {
-  if ( ! myProgress.IsNull() ) myProgress->Show();
+  if ( !myProgress.IsNull() && myThreadId == OSD_Thread::Current()) 
+  {
+    myProgress->Show();
+  }
 }