Salome HOME
Merge from PHASE_25_BR 09/12/2010
[modules/smesh.git] / src / SMESH / SMESH_Mesh.cxx
index d7fb290db1224f5120d5897d6407493b346e83bf..a85e23e23d5e9b024ca354ae777d0c117207aa22 100644 (file)
@@ -101,6 +101,7 @@ SMESH_Mesh::SMESH_Mesh(int               theLocalId,
   _isAutoColor   = false;
   _isModified    = false;
   _shapeDiagonal = 0.0;
+  _rmGroupCallUp = 0;
   _myMeshDS->ShapeToMesh( PseudoShape() );
 }
 
@@ -126,6 +127,9 @@ SMESH_Mesh::~SMESH_Mesh()
     delete aGroup;
   }
   _mapGroup.clear();
+
+  if ( _rmGroupCallUp) delete _rmGroupCallUp;
+  _rmGroupCallUp = 0;
 }
 
 //=============================================================================
@@ -261,13 +265,12 @@ void SMESH_Mesh::Clear()
   _myMeshDS->ClearMesh();
 
   // update compute state of submeshes
-  if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) ) {
-    SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
-                                                             /*complexShapeFirst=*/false);
-    while ( smIt->more() ) {
-      sm = smIt->next();
-      sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
-    }
+  if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) )
+  {
+    sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+    sm->ComputeSubMeshStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+    sm->ComputeStateEngine( SMESH_subMesh::CLEAN ); // for event listeners (issue 0020918)
+    sm->ComputeSubMeshStateEngine( SMESH_subMesh::CLEAN );
   }
   _isModified = false;
 }
@@ -973,7 +976,7 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h
       }
     }
   }
-  HasModificationsToDiscard(); // to reset _isModified flag if mesh become empty
+  HasModificationsToDiscard(); // to reset _isModified flag if mesh becomes empty
 }
 
 //=============================================================================
@@ -1413,6 +1416,18 @@ list<int> SMESH_Mesh::GetGroupIds() const
   return anIds;
 }
 
+//================================================================================
+/*!
+ * \brief Set a caller of RemoveGroup() at level of CORBA API implementation.
+ * The set upCaller will be deleted by SMESH_Mesh
+ */
+//================================================================================
+
+void SMESH_Mesh::SetRemoveGroupCallUp( TRmGroupCallUp* upCaller )
+{
+  if ( _rmGroupCallUp ) delete _rmGroupCallUp;
+  _rmGroupCallUp = upCaller;
+}
 
 //=============================================================================
 /*!
@@ -1420,13 +1435,16 @@ list<int> SMESH_Mesh::GetGroupIds() const
  */
 //=============================================================================
 
-void SMESH_Mesh::RemoveGroup (const int theGroupID)
+bool SMESH_Mesh::RemoveGroup (const int theGroupID)
 {
   if (_mapGroup.find(theGroupID) == _mapGroup.end())
-    return;
+    return false;
   GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
   delete _mapGroup[theGroupID];
   _mapGroup.erase (theGroupID);
+  if (_rmGroupCallUp)
+    _rmGroupCallUp->RemoveGroup( theGroupID );
+  return true;
 }
 
 //=======================================================================