Salome HOME
Mesh object not deleted in Python + deleting temporary folder when destructing SMESH_Mesh
[modules/smesh.git] / src / SMESH / SMESH_subMesh.cxx
index d37172d90e79f60075aa8270cb7aa3e3f086a2c9..4edd75cd5583a8cec9c9801f8b86f85b6335f0be 100644 (file)
@@ -65,6 +65,7 @@ using namespace std;
 //#define PRINT_WHO_COMPUTE_WHAT
 #endif
 
+//#define PRINT_WHO_COMPUTE_WHAT
 //=============================================================================
 /*!
  * \brief Allocate some memory at construction and release it at destruction.
@@ -256,7 +257,7 @@ bool SMESH_subMesh::IsMeshComputed() const
       TopExp_Explorer exp( _subShape, (TopAbs_ShapeEnum) type );
       for ( ; exp.More(); exp.Next() )
       {
-        if ( SMESHDS_SubMesh * smDS = meshDS->MeshElements( exp.Current() ))
+        if ( SMESHDS_SubMesh * smDS = meshDS->MeshElements( exp.Current() ) )
         {
           bool computed = (dim > 0) ? smDS->NbElements() : smDS->NbNodes();
           if ( computed )
@@ -1392,6 +1393,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
     else if (( event == COMPUTE || event == COMPUTE_SUBMESH )
              && !_alwaysComputed )
     {
+      // LOCK: Adding node to mesh
       _father->Lock();
       const TopoDS_Vertex & V = TopoDS::Vertex( _subShape );
       gp_Pnt P = BRep_Tool::Pnt(V);
@@ -1400,6 +1402,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
         _computeState = COMPUTE_OK;
       }
       _father->Unlock();
+      // UNLOCK
     }
     if ( event == MODIF_ALGO_STATE )
       cleanDependants();
@@ -1502,10 +1505,12 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
     case COMPUTE:
     case COMPUTE_SUBMESH:
       {
-        _father->Lock();
         algo = GetAlgo();
         ASSERT(algo);
-        ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+        if(!_father->IsParallel())
+          ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+        else
+          ret = true;
         if (!ret)
         {
           MESSAGE("***** verify compute state *****");
@@ -1514,9 +1519,11 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
           break;
         }
         TopoDS_Shape shape = _subShape;
-        algo->SubMeshesToCompute().assign( 1, this );
+        if(!_father->IsParallel())
+          algo->SubMeshesToCompute().assign( 1, this );
         // check submeshes needed
-        if (_father->HasShapeToMesh() ) {
+        // In parallel there would be no submesh to check
+        if (_father->HasShapeToMesh() && !_father->IsParallel()) {
           bool subComputed = false, subFailed = false;
           if (!algo->OnlyUnaryInput()) {
             //  --- commented for bos#22320 to compute all sub-shapes at once if possible;
@@ -1544,7 +1551,6 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
             break; // goto exit
           }
         }
-        _father->Unlock();
         // Compute
 
         // to restore cout that may be redirected by algo
@@ -1573,7 +1579,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
           }
           else
           {
-            std::cout<<"Running compute for " << _father << " of shape type " << shape.ShapeType() << std::endl;
+            // TODO: Do switch of compute here instead of within algo
             ret = algo->Compute((*_father), shape);
           }
           // algo can set _computeError of submesh
@@ -1647,8 +1653,10 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
 #ifdef PRINT_WHO_COMPUTE_WHAT
         for (subS.ReInit(); subS.More(); subS.Next())
         {
-          const std::list <const SMESHDS_Hypothesis *> & hyps =
+          _father->Lock();
+          const std::list <const SMESHDS_Hypothesis *> hyps =
             _algo->GetUsedHypothesis( *_father, _subShape );
+          _father->Unlock();
           SMESH_Comment hypStr;
           if ( !hyps.empty() )
           {
@@ -1734,9 +1742,8 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
             updateDependantsState( SUBMESH_COMPUTED );
         }
         // let algo clear its data gathered while algo->Compute()
-        _father->Lock();
-        algo->CheckHypothesis((*_father), _subShape, hyp_status);
-        _father->Unlock();
+        if(!_father->IsParallel())
+          algo->CheckHypothesis((*_father), _subShape, hyp_status);
       }
       break;
     case COMPUTE_CANCELED:               // nothing to do