Salome HOME
fix a comment
[modules/smesh.git] / src / SMESH / SMESH_Algo.cxx
index 63d2320278cc07e916c5835dd666d7bea1a52b9c..263a1e673fe1779932eaff6e1e1b68121154d308 100644 (file)
@@ -175,7 +175,7 @@ const SMESH_Algo::Features& SMESH_Algo::GetFeatures( const std::string& algoType
 SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen)
   : SMESH_Hypothesis(hypId, studyId, gen)
 {
-  gen->_mapAlgo[hypId] = this;
+  //gen->_mapAlgo[hypId] = this;
 
   _onlyUnaryInput = _requireDiscreteBoundary = _requireShape = true;
   _quadraticMesh = _supportSubmeshes = false;
@@ -205,28 +205,28 @@ SMESH_0D_Algo::SMESH_0D_Algo(int hypId, int studyId, SMESH_Gen* gen)
 {
   _shapeType = (1 << TopAbs_VERTEX);
   _type = ALGO_0D;
-  gen->_map0D_Algo[hypId] = this;
+  //gen->_map0D_Algo[hypId] = this;
 }
 SMESH_1D_Algo::SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen)
   : SMESH_Algo(hypId, studyId, gen)
 {
   _shapeType = (1 << TopAbs_EDGE);
   _type = ALGO_1D;
-  gen->_map1D_Algo[hypId] = this;
+  //gen->_map1D_Algo[hypId] = this;
 }
 SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
   : SMESH_Algo(hypId, studyId, gen)
 {
   _shapeType = (1 << TopAbs_FACE);
   _type = ALGO_2D;
-  gen->_map2D_Algo[hypId] = this;
+  //gen->_map2D_Algo[hypId] = this;
 }
 SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen)
   : SMESH_Algo(hypId, studyId, gen)
 {
   _shapeType = (1 << TopAbs_SOLID);
   _type = ALGO_3D;
-  gen->_map3D_Algo[hypId] = this;
+  //gen->_map3D_Algo[hypId] = this;
 }
 
 //=============================================================================
@@ -681,6 +681,17 @@ void SMESH_Algo::CancelCompute()
   _error = COMPERR_CANCELED;
 }
 
+//================================================================================
+/*
+ * If possible, returns progress of computation [0.,1.]
+ */
+//================================================================================
+
+double SMESH_Algo::GetProgress() const
+{
+  return _progress;
+}
+
 //================================================================================
 /*!
  * \brief store error and comment and then return ( error == COMPERR_OK )
@@ -728,7 +739,7 @@ SMESH_ComputeErrorPtr SMESH_Algo::GetComputeError() const
 
 //================================================================================
 /*!
- * \brief initialize compute error
+ * \brief initialize compute error before call of Compute()
  */
 //================================================================================
 
@@ -743,6 +754,27 @@ void SMESH_Algo::InitComputeError()
   _badInputElements.clear();
 
   _computeCanceled = false;
+  _progressTic     = 0;
+  _progress        = 0.;
+}
+
+//================================================================================
+/*!
+ * \brief Return compute progress by nb of calls of this method
+ */
+//================================================================================
+
+double SMESH_Algo::GetProgressByTic() const
+{
+  int computeCost = 0;
+  for ( size_t i = 0; i < _smToCompute.size(); ++i )
+    computeCost += _smToCompute[i]->GetComputeCost();
+
+  const_cast<SMESH_Algo*>( this )->_progressTic++;
+
+  double x = 5 * _progressTic;
+  x = ( x < computeCost ) ? ( x / computeCost ) : 1.;
+  return 0.9 * sin( x * M_PI / 2 );
 }
 
 //================================================================================