Salome HOME
Implement Cancel Compute
authoradam <adam>
Thu, 17 Mar 2011 11:03:40 +0000 (11:03 +0000)
committeradam <adam>
Thu, 17 Mar 2011 11:03:40 +0000 (11:03 +0000)
src/NETGENPlugin/NETGENPlugin_Mesher.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D.hxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.hxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.hxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx

index 484001260eb265e19aa3eadf08baeb37969ecc18..2c8a24c36bfd5b30928fec5904bb6da9b21049cf 100644 (file)
@@ -1661,6 +1661,10 @@ bool NETGENPlugin_Mesher::Compute()
     {
       OCC_CATCH_SIGNALS;
       err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+      if(netgen::multithread.terminate)
+        return false;
+#endif
       comment << text(err);
     }
     catch (Standard_Failure& ex)
@@ -1726,6 +1730,10 @@ bool NETGENPlugin_Mesher::Compute()
       {
         OCC_CATCH_SIGNALS;
         netgen::OCCGenerateMesh(occgeo, tmpNgMesh, startWith, endWith, optstr);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+        if(netgen::multithread.terminate)
+          return false;
+#endif
         // compute mesh on internal edges
         endWith = netgen::MESHCONST_MESHEDGES;
         err = netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, startWith, endWith, optstr);
@@ -1760,6 +1768,10 @@ bool NETGENPlugin_Mesher::Compute()
       {
         OCC_CATCH_SIGNALS;
         err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+        if(netgen::multithread.terminate)
+          return false;
+#endif
         comment << text(err);
       }
       catch (Standard_Failure& ex)
@@ -1825,6 +1837,10 @@ bool NETGENPlugin_Mesher::Compute()
       {
         OCC_CATCH_SIGNALS;
         err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+        if(netgen::multithread.terminate)
+          return false;
+#endif
         comment << text (err);
       }
       catch (Standard_Failure& ex)
@@ -1887,6 +1903,10 @@ bool NETGENPlugin_Mesher::Compute()
       {
         OCC_CATCH_SIGNALS;
         err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+        if(netgen::multithread.terminate)
+          return false;
+#endif
         comment << text(err);
       }
       catch (Standard_Failure& ex)
@@ -1907,6 +1927,10 @@ bool NETGENPlugin_Mesher::Compute()
         {
           OCC_CATCH_SIGNALS;
           err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+          if(netgen::multithread.terminate)
+            return false;
+#endif
           comment << text(err);
         }
         catch (Standard_Failure& ex)
@@ -2062,6 +2086,10 @@ bool NETGENPlugin_Mesher::Evaluate(MapShapeNbElems& aResMap)
   int startWith = netgen::MESHCONST_ANALYSE;
   int endWith   = netgen::MESHCONST_MESHEDGES;
   int err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  if(netgen::multithread.terminate)
+    return false;
+#endif
   ngLib.setMesh(( Ng_Mesh*) ngMesh );
   if (err) {
     if ( SMESH_subMesh* sm = _mesh->GetSubMeshContaining( _shape ))
index ed5526adc7f3aecb1f40384df171d4a772bd1808..4d6d898cef7e20249e5ea8424f719b4ed5401b3d 100644 (file)
 
 #include <list>
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+namespace nglib {
+#include <nglib.h>
+}
+#include <meshing.hpp>
+#endif
+
 using namespace std;
 
 //=============================================================================
@@ -122,6 +129,9 @@ bool NETGENPlugin_NETGEN_2D::CheckHypothesis
 bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh&         aMesh,
                                      const TopoDS_Shape& aShape)
 {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  netgen::multithread.terminate = 0;
+#endif
   //SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
 
   NETGENPlugin_Mesher mesher(&aMesh, aShape, false);
@@ -131,6 +141,12 @@ bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh&         aMesh,
   return mesher.Compute();
 }
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+void NETGENPlugin_NETGEN_2D::CancelCompute()
+{
+  netgen::multithread.terminate = 1;
+}
+#endif
 
 //=============================================================================
 /*!
index 2c25b823bfed1611e13cb94beb368ab24eb4fe70..018d526c91719aad8d64876a631f0281a365506e 100644 (file)
@@ -53,6 +53,10 @@ public:
   virtual bool Compute(SMESH_Mesh& aMesh,
                        const TopoDS_Shape& aShape);
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  virtual void CancelCompute();
+#endif
+
   virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
                         MapShapeNbElems& aResMap);
 
index 3ce64cc2c3f46d694d364731eef1633adcc7ab5b..99465237e4027f59f170602ce2f544e767cfd70d 100644 (file)
 
 #include <list>
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+namespace nglib {
+#include <nglib.h>
+}
+#include <meshing.hpp>
+#endif
+
 using namespace std;
 
 //=============================================================================
@@ -125,6 +132,9 @@ bool NETGENPlugin_NETGEN_2D3D::CheckHypothesis
 bool NETGENPlugin_NETGEN_2D3D::Compute(SMESH_Mesh&         aMesh,
                                        const TopoDS_Shape& aShape)
 {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  netgen::multithread.terminate = 0;
+#endif
 //   SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
 
   NETGENPlugin_Mesher mesher(&aMesh, aShape, true);
@@ -134,6 +144,12 @@ bool NETGENPlugin_NETGEN_2D3D::Compute(SMESH_Mesh&         aMesh,
   return mesher.Compute();
 }
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+void NETGENPlugin_NETGEN_2D3D::CancelCompute()
+{
+  netgen::multithread.terminate = 1;
+}
+#endif
 
 //=============================================================================
 /*!
index 539dc25c8cdfab8c123d447c0eace00a2672abcc..a37a0561829372c8acf3e66b8ed1f2d02dcf4562 100644 (file)
@@ -53,6 +53,10 @@ public:
   virtual bool Compute(SMESH_Mesh& aMesh,
                        const TopoDS_Shape& aShape);
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  virtual void CancelCompute();
+#endif
+
   virtual bool Evaluate(SMESH_Mesh& aMesh,
                         const TopoDS_Shape& aShape,
                         MapShapeNbElems& aResMap);
index 298c948d6f41b31aeacca091c15a05b6a1113956..883823a5e048fe0c7692923520b09e9ac01d6cd7 100644 (file)
@@ -362,6 +362,9 @@ static TError AddSegmentsToMesh(netgen::Mesh&                    ngMesh,
 bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
                                           const TopoDS_Shape& aShape)
 {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  netgen::multithread.terminate = 0;
+#endif
   MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::Compute()");
 
   SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
@@ -461,6 +464,10 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
     OCC_CATCH_SIGNALS;
 #endif
     err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+    if(netgen::multithread.terminate)
+      return false;
+#endif
     if ( err )
       error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task);
   }
@@ -537,6 +544,12 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
   return !err;
 }
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+void NETGENPlugin_NETGEN_2D_ONLY::CancelCompute()
+{
+  netgen::multithread.terminate = 1;
+}
+#endif
 
 //=============================================================================
 /*!
index b608cafda606c23f2c468c76436bcd91e2fa8fb0..1a9fee84c83b979abac9bd36d39eca239fbfbceb 100644 (file)
@@ -53,6 +53,10 @@ public:
   virtual bool Compute(SMESH_Mesh&         aMesh,
                        const TopoDS_Shape& aShape);
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  virtual void CancelCompute();
+#endif
+
   virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
                         MapShapeNbElems& aResMap);
 
index a28ad1f3aad4b1cdf23365ad2fe02539b7353222..8ab7b3ebec9d8607b10017518350e74eba3ab5b7 100644 (file)
@@ -180,6 +180,9 @@ bool NETGENPlugin_NETGEN_3D::CheckHypothesis (SMESH_Mesh&         aMesh,
 bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh&         aMesh,
                                      const TopoDS_Shape& aShape)
 {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  netgen::multithread.terminate = 0;
+#endif
   MESSAGE("NETGENPlugin_NETGEN_3D::Compute with maxElmentsize = " << _maxElementVolume);
 
   SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
@@ -335,6 +338,9 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh&                     aMesh,
                                      vector< const SMDS_MeshNode* >& nodeVec,
                                      Ng_Mesh *                       Netgen_mesh)
 {
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  netgen::multithread.terminate = 0;
+#endif
   netgen::Mesh* ngMesh = (netgen::Mesh*)Netgen_mesh;
   int Netgen_NbOfNodes = Ng_GetNP(Netgen_mesh);
 
@@ -375,6 +381,10 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh&                     aMesh,
 #endif
     ngMesh->CalcLocalH();
     err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+    if(netgen::multithread.terminate)
+      return false;
+#endif
     if ( err )
       error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task);
   }
@@ -541,6 +551,13 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh&         aMesh,
   return compute( aMesh, *aHelper, nodeVec, Netgen_mesh);
 }
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+void NETGENPlugin_NETGEN_3D::CancelCompute()
+{
+  netgen::multithread.terminate = 1;
+}
+#endif
+
 //=============================================================================
 /*!
  *
index 54ba49f971b2e0e007e8448340c87f3a6c2401e1..9a795f08aef48ad1a183117a52a9f5ff549d22eb 100644 (file)
@@ -57,6 +57,10 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
   virtual bool Compute(SMESH_Mesh& aMesh,
                        SMESH_MesherHelper* aHelper);
 
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+  virtual void CancelCompute();
+#endif
+
   virtual bool Evaluate(SMESH_Mesh& aMesh,
                         const TopoDS_Shape& aShape,
                         MapShapeNbElems& aResMap);