From: eap Date: Wed, 3 Jul 2013 16:22:00 +0000 (+0000) Subject: + virtual double GetProgress() const; X-Git-Tag: V7_3_0a1~43 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=672042c687911f9690ed5fb0b67258609c2b819c;p=plugins%2Fnetgenplugin.git + virtual double GetProgress() const; --- diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx index a8c887e..bf3fbf2 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx @@ -128,6 +128,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh, _hypMaxElementArea = 0; _hypLengthFromEdges = 0; _hypQuadranglePreference = 0; + _isSurfaceMeshing = true; const list& 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 << " " <::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; +} + //============================================================================= /*! * diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx index df9f2c6..239fb37 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx @@ -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