Salome HOME
+ virtual double GetProgress() const;
authoreap <eap@opencascade.com>
Wed, 3 Jul 2013 16:22:00 +0000 (16:22 +0000)
committereap <eap@opencascade.com>
Wed, 3 Jul 2013 16:22:00 +0000 (16:22 +0000)
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 a8c887e97335a27daf3276c95aacb787bc310c82..bf3fbf201d5de2caf6ff33c44f1f9a19b6e5c67b 100644 (file)
@@ -128,6 +128,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh&         aMesh,
   _hypMaxElementArea = 0;
   _hypLengthFromEdges = 0;
   _hypQuadranglePreference = 0;
+  _isSurfaceMeshing = true;
 
   const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape, false);
 
@@ -181,6 +182,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
                                           const TopoDS_Shape& aShape)
 {
   netgen::multithread.terminate = 0;
+  netgen::multithread.task = "Surface meshing";
 
   SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
   int faceID = meshDS->ShapeToIndex( aShape );
@@ -372,6 +374,36 @@ void NETGENPlugin_NETGEN_2D_ONLY::CancelCompute()
   netgen::multithread.terminate = 1;
 }
 
+//================================================================================
+/*!
+ * \brief Return progress of Compute() [0.,1]
+ */
+//================================================================================
+
+double NETGENPlugin_NETGEN_2D_ONLY::GetProgress() const
+{
+  const char* task1 = "Surface meshing";
+  const char* task2 = "Optimizing surface";
+  double res = 0;
+  if ( _isSurfaceMeshing &&
+       strncmp( netgen::multithread.task, task1, 3 ) == 0 )
+  {
+    res = 0.3 * SMESH_Algo::GetProgressByTic(); // [0, 0.3]
+  }
+  else //if ( strncmp( netgen::multithread.task, task2, 3 ) == 0)
+  {
+    if ( _isSurfaceMeshing )
+    {
+      NETGENPlugin_NETGEN_2D_ONLY* me = (NETGENPlugin_NETGEN_2D_ONLY*) this;
+      me->_isSurfaceMeshing = false;
+      me->_progressTic = 0; // to re-start GetProgressByTic() from 0.
+    }
+    res = 0.3 + 0.7 * SMESH_Algo::GetProgressByTic(); // [0.3, 1.]
+  }
+  //cout << netgen::multithread.task << " " <<res << endl;
+  return res;
+}
+
 //=============================================================================
 /*!
  *
index c6fbe0c906b2bc3fb256dc876f85dda5c45bf933..0ff13685559e6b17ee294a189e0f1caf9e01a3d4 100644 (file)
@@ -52,9 +52,9 @@ public:
   virtual bool Compute(SMESH_Mesh&         aMesh,
                        const TopoDS_Shape& aShape);
 
-#ifdef WITH_SMESH_CANCEL_COMPUTE
   virtual void CancelCompute();
-#endif
+
+  virtual double GetProgress() const;
 
   virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
                         MapShapeNbElems& aResMap);
@@ -64,6 +64,8 @@ protected:
   const StdMeshers_LengthFromEdges*      _hypLengthFromEdges;
   const SMESHDS_Hypothesis*              _hypQuadranglePreference;
   const NETGENPlugin_Hypothesis_2D*      _hypParameters;
+
+  bool                                   _isSurfaceMeshing;
 };
 
 #endif
index cc05f2a40cf37cba476693654e6fb7363794122f..6d06c6559d607d8a9e480865fb6197481b147e1e 100644 (file)
@@ -140,6 +140,11 @@ bool NETGENPlugin_NETGEN_3D::CheckHypothesis (SMESH_Mesh&         aMesh,
   _viscousLayersHyp = NULL;
   _maxElementVolume = DBL_MAX;
 
+  // for correct work of GetProgress():
+  netgen::multithread.percent = 0.;
+  netgen::multithread.task = "Volume meshing";
+  _optimizationStarted = false;
+
   list<const SMESHDS_Hypothesis*>::const_iterator itl;
   const SMESHDS_Hypothesis* theHyp;
 
@@ -186,7 +191,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh&         aMesh,
                                      const TopoDS_Shape& aShape)
 {
   netgen::multithread.terminate = 0;
-
+  
   SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
 
   SMESH_MesherHelper helper(aMesh);
@@ -487,6 +492,8 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh&         aMesh,
 {
   const int invalid_ID = -1;
 
+  netgen::multithread.terminate = 0;
+
   SMESH_MesherHelper::MType MeshType = aHelper->IsQuadraticMesh();
   if ( MeshType == SMESH_MesherHelper::COMP )
     return error( COMPERR_BAD_INPUT_MESH,
@@ -573,6 +580,31 @@ void NETGENPlugin_NETGEN_3D::CancelCompute()
   netgen::multithread.terminate = 1;
 }
 
+//================================================================================
+/*!
+ * \brief Return Compute progress
+ */
+//================================================================================
+
+double NETGENPlugin_NETGEN_3D::GetProgress() const
+{
+  double res;
+  const char* volMeshing = "Volume meshing";
+  const char* dlnMeshing = "Delaunay meshing";
+  if ( !_optimizationStarted &&
+       ( strncmp( netgen::multithread.task, dlnMeshing, 3 ) == 0 ||
+         strncmp( netgen::multithread.task, volMeshing, 3 ) == 0 ))
+  {
+    res = 0.5 * netgen::multithread.percent / 100.; // [0., 0.5]
+  }
+  else // different otimizations
+  {
+    ((NETGENPlugin_NETGEN_3D*)this)->_optimizationStarted = true;
+    res = 0.5 + 0.5 * SMESH_Algo::GetProgressByTic(); // [0.5, 1.]
+  }
+  return res;
+}
+
 //=============================================================================
 /*!
  *
index df9f2c69dfa2ea3598d72238cc7f6e98d523960c..239fb37b0ac3c471556dc1d25660c000ff8f13fa 100644 (file)
@@ -57,9 +57,9 @@ 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 double GetProgress() const;
 
   virtual bool Evaluate(SMESH_Mesh& aMesh,
                         const TopoDS_Shape& aShape,
@@ -77,6 +77,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
   const NETGENPlugin_Hypothesis *    _hypParameters;
   const StdMeshers_MaxElementVolume* _hypMaxElementVolume;
   const StdMeshers_ViscousLayers*    _viscousLayersHyp;
+  bool                               _optimizationStarted;
 };
 
 #endif