Salome HOME
IPAL54700: TC-9.6.0: 0D Mesh - several items are missed in the OB popup menu
[modules/smesh.git] / src / SMESH_I / SMESH_Mesh_i.cxx
index cf2a16ea647d3354553b1c95a1b5c4f3d3056bb3..8455f6b4681a3886ab21329db943221ea44f882f 100644 (file)
@@ -649,11 +649,12 @@ SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr       aSubShape,
   throw(SALOME::SALOME_Exception)
 {
   Unexpect aCatch(SALOME_SalomeException);
+
+  const int prevNbMeshEnt = NbNodes() + NbElements();
+
   if ( _preMeshInfo )
     _preMeshInfo->ForgetOrLoad();
 
-  const int prevNbMeshEnt = _impl->NbNodes() + _impl->GetMeshDS()->NbElements();
-
   std::string error;
   SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShape, anHyp, &error );
   anErrorText = error.c_str();
@@ -1212,6 +1213,9 @@ void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup
       if ( n->NbInverseElements() == 0 )
         _impl->GetMeshDS()->RemoveFreeNode( n, /*sm=*/0 );
 
+  _impl->GetMeshDS()->Modified();
+  _impl->SetIsModified( true );
+
   // Update Python script (theGroup must be alive for this)
   pyDump << SMESH::SMESH_Mesh_var(_this())
          << ".RemoveGroupWithContents( " << theGroup << " )";
@@ -2052,18 +2056,17 @@ void SMESH_Mesh_i::ReplaceShape(GEOM::GEOM_Object_ptr theNewGeom)
   bool geomChanged = true;
   GEOM::GEOM_Object_var oldGeom = GetShapeToMesh();
   if ( !theNewGeom->_is_nil() && !oldGeom->_is_nil() )
-    geomChanged = ( //oldGeom->_is_equivalent( theNewGeom ) ||
-                   oldGeom->GetTick() < theNewGeom->GetTick() );
+    geomChanged = ( oldGeom->GetTick() != theNewGeom->GetTick() );
 
   TopoDS_Shape S = _impl->GetShapeToMesh();
   GEOM_Client* geomClient = _gen_i->GetShapeReader();
   TCollection_AsciiString aIOR;
-  CORBA::String_var ior;
   if ( geomClient->Find( S, aIOR ))
     geomClient->RemoveShapeFromBuffer( aIOR );
 
   // clear buffer also for sub-groups
-  const std::set<SMESHDS_GroupBase*>& groups = _impl->GetMeshDS()->GetGroups();
+  SMESHDS_Mesh* meshDS = _impl->GetMeshDS();
+  const std::set<SMESHDS_GroupBase*>& groups = meshDS->GetGroups();
   std::set<SMESHDS_GroupBase*>::const_iterator g = groups.begin();
   for (; g != groups.end(); ++g)
     if (const SMESHDS_GroupOnGeom* group = dynamic_cast<SMESHDS_GroupOnGeom*>(*g))
@@ -2073,12 +2076,21 @@ void SMESH_Mesh_i::ReplaceShape(GEOM::GEOM_Object_ptr theNewGeom)
         geomClient->RemoveShapeFromBuffer( aIOR );
     }
 
+  // clear buffer also for sub-meshes
+  std::map<int, SMESH_subMesh_i*>::const_iterator aSubMeshIter = _mapSubMesh_i.cbegin();
+  for(; aSubMeshIter != _mapSubMesh_i.cend(); aSubMeshIter++) {
+    int aShapeID = aSubMeshIter->first;
+    const TopoDS_Shape& aSubShape = meshDS->IndexToShape(aShapeID);
+    TCollection_AsciiString aShapeIOR;
+    if ( geomClient->Find( aSubShape, aShapeIOR ))
+      geomClient->RemoveShapeFromBuffer( aShapeIOR );
+  }
+
   typedef struct {
     int shapeID, fromID, toID; // indices of elements of a sub-mesh
   } TRange;
   std::vector< TRange > elemRanges, nodeRanges; // elements of sub-meshes
   std::vector< SMDS_PositionPtr > positions; // node positions
-  SMESHDS_Mesh* meshDS = _impl->GetMeshDS();
   if ( !geomChanged )
   {
     // store positions of elements on geometry
@@ -3424,12 +3436,17 @@ namespace
   {
     SMESH_Mesh_i* _mesh;
     TCallUp_i(SMESH_Mesh_i* mesh):_mesh(mesh) {}
-    virtual void RemoveGroup (const int theGroupID) { _mesh->removeGroup( theGroupID ); }
-    virtual void HypothesisModified( int hypID,
-                                     bool updIcons) { _mesh->onHypothesisModified( hypID,
-                                                                                   updIcons ); }
-    virtual void Load ()                            { _mesh->Load(); }
-    virtual bool IsLoaded()                         { return _mesh->IsLoaded(); }
+    void RemoveGroup (const int theGroupID) override { _mesh->removeGroup( theGroupID ); }
+    void HypothesisModified( int hypID,
+                             bool updIcons) override { _mesh->onHypothesisModified( hypID,
+                                                                                    updIcons ); }
+    void Load ()                            override { _mesh->Load(); }
+    bool IsLoaded()                         override { return _mesh->IsLoaded(); }
+    TopoDS_Shape GetShapeByEntry(const std::string& entry) override
+    {
+      GEOM::GEOM_Object_var go = SMESH_Gen_i::GetGeomObjectByEntry( entry );
+      return SMESH_Gen_i::GeomObjectToShape( go );
+    }
   };
 }
 
@@ -3765,7 +3782,7 @@ void SMESH_Mesh_i::ExportMED(const char*        file,
   TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
                 << file << "', "
                 << "auto_groups=" <<auto_groups << ", "
-                << "minor=" << version <<  ", "
+                << "version=" << version <<  ", "
                 << "overwrite=" << overwrite << ", "
                 << "meshPart=None, "
                 << "autoDimension=" << autoDimension << " )";
@@ -5821,15 +5838,21 @@ void SMESH_Mesh_i::CreateGroupServants()
     GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape );
     _gen_i->PublishGroup( aMesh, groupVar, shapeVar, group->GetName());
   }
+
   if ( !addedIDs.empty() )
   {
     // python dump
-    set<int>::iterator id = addedIDs.begin();
-    for ( ; id != addedIDs.end(); ++id )
+    map<int, SMESH::SMESH_GroupBase_ptr>::iterator i_grp = _mapGroups.begin();
+    for ( int index = 0; i_grp != _mapGroups.end(); ++index, ++i_grp )
     {
-      map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.find(*id);
-      int i = std::distance( _mapGroups.begin(), it );
-      TPythonDump() << it->second << " = " << aMesh << ".GetGroups()[ "<< i << " ]";
+      set<int>::iterator it = addedIDs.find( i_grp->first );
+      if ( it != addedIDs.end() )
+      {
+        TPythonDump() << i_grp->second << " = " << aMesh << ".GetGroups()[ "<< index << " ]";
+        addedIDs.erase( it );
+        if ( addedIDs.empty() )
+          break;
+      }
     }
   }
 }
@@ -6757,7 +6780,8 @@ TListOfListOfInt SMESH_Mesh_i::findConcurrentSubMeshes()
   TDimHypList dimHypListArr[4]; // dimHyp list for each shape dimension
 
   map<int, ::SMESH_subMesh*>::iterator i_sm = _mapSubMesh.begin();
-  for ( ; i_sm != _mapSubMesh.end(); i_sm++ ) {
+  for ( ; i_sm != _mapSubMesh.end(); i_sm++ )
+  {
     ::SMESH_subMesh* sm = (*i_sm).second;
     // shape of submesh
     const TopoDS_Shape& aSubMeshShape = sm->GetSubShape();
@@ -6767,7 +6791,8 @@ TListOfListOfInt SMESH_Mesh_i::findConcurrentSubMeshes()
     // Find out dimensions where the submesh can be concurrent.
     // We define the dimensions by algo of each of hypotheses in hypList
     list <const SMESHDS_Hypothesis*>::const_iterator hypIt = hypList.begin();
-    for( ; hypIt != hypList.end(); hypIt++ ) {
+    for( ; hypIt != hypList.end(); hypIt++ )
+    {
       SMESH_Algo* anAlgo = 0;
       const SMESH_Hypothesis* hyp = dynamic_cast<const SMESH_Hypothesis*>(*hypIt);
       if ( hyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO )