Salome HOME
#16479 [CEA 12950] ViscousLayers hypothesis and periodic condition
[modules/smesh.git] / src / SMESH / SMESH_Mesh.cxx
index c4b6c65d1a0059743c6e46266e2befb11c34247e..77d19984f10bb7c4b445b7f426dbc85a939fd680 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -1191,8 +1191,12 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h
   if ( !GetMeshDS()->IsUsedHypothesis( hyp ))
     return;
 
-  if (_callUp && hyp)
-    _callUp->HypothesisModified( hyp->GetID() );
+  int nbEntities = ( _myMeshDS->NbNodes() + _myMeshDS->NbElements() );
+  if ( hyp && _callUp && !_callUp->IsLoaded() ) // for not loaded mesh (#16648)
+  {
+    _callUp->HypothesisModified( hyp->GetID(), /*updateIcons=*/true );
+    nbEntities = ( _myMeshDS->NbNodes() + _myMeshDS->NbElements() ); // after loading mesh
+  }
 
   SMESH_Algo *algo;
   const SMESH_HypoFilter* compatibleHypoKind;
@@ -1260,6 +1264,10 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h
   }
   HasModificationsToDiscard(); // to reset _isModified flag if mesh becomes empty
   GetMeshDS()->Modified();
+
+  int newNbEntities = ( _myMeshDS->NbNodes() + _myMeshDS->NbElements() );
+  if ( hyp && _callUp )
+    _callUp->HypothesisModified( hyp->GetID(), newNbEntities != nbEntities );
 }
 
 //=============================================================================
@@ -2038,8 +2046,7 @@ SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType,
   SMESH_Group* aGroup = new SMESH_Group ( id, this, theType, theName, theShape, thePredicate );
   GetMeshDS()->AddGroup( aGroup->GetGroupDS() );
   _mapGroup[ id ] = aGroup;
-  while ( _mapGroup.count( _groupId ))
-    ++_groupId;
+  _groupId = 1 + _mapGroup.rbegin()->first;
   return aGroup;
 }
 
@@ -2051,7 +2058,7 @@ SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType,
 
 SMESH_Group* SMESH_Mesh::AddGroup (SMESHDS_GroupBase* groupDS) throw(SALOME_Exception)
 {
-  if ( !groupDS ) 
+  if ( !groupDS )
     throw SALOME_Exception(LOCALIZED ("SMESH_Mesh::AddGroup(): NULL SMESHDS_GroupBase"));
 
   std::map <int, SMESH_Group*>::iterator i_g = _mapGroup.find( groupDS->GetID() );
@@ -2066,8 +2073,7 @@ SMESH_Group* SMESH_Mesh::AddGroup (SMESHDS_GroupBase* groupDS) throw(SALOME_Exce
   _mapGroup[ groupDS->GetID() ] = aGroup;
   GetMeshDS()->AddGroup( aGroup->GetGroupDS() );
 
-  while ( _mapGroup.count( _groupId ))
-    ++_groupId;
+  _groupId = 1 + _mapGroup.rbegin()->first;
 
   return aGroup;
 }
@@ -2077,7 +2083,7 @@ SMESH_Group* SMESH_Mesh::AddGroup (SMESHDS_GroupBase* groupDS) throw(SALOME_Exce
 /*!
  * \brief Creates SMESH_Groups for not wrapped SMESHDS_Groups
  *  \retval bool - true if new SMESH_Groups have been created
- * 
+ *
  */
 //================================================================================
 
@@ -2093,8 +2099,8 @@ bool SMESH_Mesh::SynchronizeGroups()
     if ( !_mapGroup.count( _groupId ))
       _mapGroup[_groupId] = new SMESH_Group( groupDS );
   }
-  while ( _mapGroup.count( _groupId ))
-    ++_groupId;
+  if ( !_mapGroup.empty() )
+    _groupId = 1 + _mapGroup.rbegin()->first;
 
   return nbGroups < _mapGroup.size();
 }