Salome HOME
Fix Break Link called from TUI
authoreap <eap@opencascade.com>
Fri, 14 Feb 2020 11:16:51 +0000 (14:16 +0300)
committereap <eap@opencascade.com>
Fri, 14 Feb 2020 11:16:51 +0000 (14:16 +0300)
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Mesh_i.cxx

index f5c36db7877995e66933b320912ae4ade5394068..6117d454742e8c3c4bb6ef369673f683e770e2f8 100644 (file)
@@ -731,6 +731,25 @@ void SMESH_Gen_i::UpdateStudy()
   }
 }
 
+//================================================================================
+/*!
+ * \brief Return true if mesh has ICON_SMESH_TREE_GEOM_MODIF icon
+ */
+//================================================================================
+
+bool SMESH_Gen_i::isGeomModifIcon( SMESH::SMESH_Mesh_ptr mesh )
+{
+  SALOMEDS::SObject_wrap so = ObjectToSObject( mesh );
+  SALOMEDS::GenericAttribute_wrap attr;
+  if ( ! so->_is_nil() && so->FindAttribute( attr.inout(), "AttributePixMap" ))
+  {
+    SALOMEDS::AttributePixMap_wrap pm = attr;
+    CORBA::String_var             ico = pm->GetPixMap();
+    return ( strcmp( ico.in(), "ICON_SMESH_TREE_GEOM_MODIF" ) == 0 );
+  }
+  return false;
+}
+
 //=================================================================================
 // function : hasObjectInfo()
 // purpose  : shows if module provides information for its objects
@@ -756,18 +775,9 @@ char* SMESH_Gen_i::getObjectInfo( const char* entry )
   SALOMEDS::SObject_wrap  so = getStudyServant()->FindObjectID( entry );
   CORBA::Object_var      obj = SObjectToObject( so );
   SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
-  if ( !mesh->_is_nil() )
+  if ( isGeomModifIcon( mesh ))
   {
-    SALOMEDS::GenericAttribute_wrap attr;
-    if ( so->FindAttribute( attr.inout(), "AttributePixMap" ))
-    {
-      SALOMEDS::AttributePixMap_wrap pm = attr;
-      CORBA::String_var             ico = pm->GetPixMap();
-      if ( strcmp( ico.in(), "ICON_SMESH_TREE_GEOM_MODIF" ) == 0 )
-      {
-        txt << "The geometry was changed and the mesh needs to be recomputed";
-      }
-    }
+    txt << "The geometry was changed and the mesh needs to be recomputed";
   }
 
   if ( txt.empty() )
@@ -2019,10 +2029,11 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
     SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
     ASSERT( meshServant );
     if ( meshServant ) {
-      meshServant->Load();
+      if ( isGeomModifIcon( theMesh ))
+        meshServant->Clear();
+      else
+        meshServant->Load();
       // NPAL16168: "geometrical group edition from a submesh don't modify mesh computation"
-      // Clear meshy because it was not cleared in CheckGeomModif of previous call
-      meshServant->Clear();
       meshServant->CheckGeomModif();
       // get local TopoDS_Shape
       TopoDS_Shape myLocShape;
index 3f03b67b2363255e273dbfceb5b716ee5f665cbb..0cb93fbb95f2a1b240eb9f948d7cac02f1e7248d 100644 (file)
@@ -634,6 +634,9 @@ private:
   SMESH::SMESH_Mesh_ptr createMesh()
     throw ( SALOME::SALOME_Exception );
 
+  // Check mesh icon
+  bool isGeomModifIcon( SMESH::SMESH_Mesh_ptr mesh );
+
   // Create a sub-mesh on a geometry that is not a sub-shape of the main shape
   // for the case where a valid sub-shape not found by CopyMeshWithGeom()
   SMESH::SMESH_subMesh_ptr createInvalidSubMesh( SMESH::SMESH_Mesh_ptr mesh,
index 04e0371bc953e94c1595f6badd1be3c982a3f1d3..2b831f8c9d34e59a239517787b723be32316dfa5 100644 (file)
@@ -270,25 +270,30 @@ void SMESH_Mesh_i::ReplaceShape(GEOM::GEOM_Object_ptr theNewGeom)
     geomClient->RemoveShapeFromBuffer(aIOR);
   }
 
-  // re-assign global hypotheses to the new shape
-  _mainShapeTick = -1;
-  CheckGeomModif( true );
-
   // update the reference to theNewGeom (needed for correct execution of a dumped python script)
-  SALOMEDS::SObject_var aSO = _gen_i->ObjectToSObject(_this());
-  if (!aSO->_is_nil()) {
-    SALOMEDS::SObject_var aShapeRefSO;
-    if (aSO->FindSubObject(1, aShapeRefSO)) {
-      _gen_i->getStudyServant()->NewBuilder()->Addreference(
-        aShapeRefSO, _gen_i->getStudyServant()->FindObjectID(theNewGeom->GetStudyEntry()));
+  SMESH::SMESH_Mesh_var   me = _this();
+  SALOMEDS::SObject_wrap aSO = _gen_i->ObjectToSObject( me );
+  CORBA::String_var    entry = theNewGeom->GetStudyEntry();
+  if ( !aSO->_is_nil() )
+  {
+    SALOMEDS::SObject_wrap aShapeRefSO;
+    if ( aSO->FindSubObject( _gen_i->GetRefOnShapeTag(), aShapeRefSO.inout() ))
+    {
+      SALOMEDS::SObject_wrap    aShapeSO = _gen_i->getStudyServant()->FindObjectID( entry );
+      SALOMEDS::StudyBuilder_var builder = _gen_i->getStudyServant()->NewBuilder();
+      builder->Addreference( aShapeRefSO, aShapeSO );
     }
   }
 
-  TPythonDump() <<  SMESH::SMESH_Mesh_var(_this()) << ".ReplaceShape( "
-    << theNewGeom->GetStudyEntry() << " )";
+  // re-assign global hypotheses to the new shape
+  _mainShapeTick = -1;
+  CheckGeomModif( true );
 
   TPythonDump() << "SHAPERSTUDY.breakLinkForSubElements(salome.ObjectToSObject("
-    << SMESH::SMESH_Mesh_var(_this()) <<".GetMesh()), " << theNewGeom->GetStudyEntry() << ")";
+                << me <<".GetMesh()), " << entry.in() << ")";
+
+  TPythonDump() <<  me << ".ReplaceShape( " << entry.in() << " )";
+
 }
 
 //================================================================================
@@ -2077,6 +2082,8 @@ TopoDS_Shape SMESH_Mesh_i::newGroupShape( TGeomGroupData & groupData, int how )
       CORBA::Object_var  geomObj = _gen_i->SObjectToObject( geomSO );
       GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( geomObj );
       newShape = _gen_i->GeomObjectToShape( geom );
+      CORBA::String_var entry = geom->GetStudyEntry();
+      groupData._groupEntry = entry.in();
     }
   }
   else
@@ -2472,13 +2479,17 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
       int newID = o2n->second, oldID = o2n->first;
       if ( !_mapSubMesh.count( oldID ))
         continue;
-      _mapSubMesh   [ newID ] = _impl->GetSubMeshContaining( newID );
-      _mapSubMesh_i [ newID ] = _mapSubMesh_i [ oldID ];
-      _mapSubMeshIor[ newID ] = _mapSubMeshIor[ oldID ];
+      if ( newID > 0 )
+      {
+        _mapSubMesh   [ newID ] = _impl->GetSubMeshContaining( newID );
+        _mapSubMesh_i [ newID ] = _mapSubMesh_i [ oldID ];
+        _mapSubMeshIor[ newID ] = _mapSubMeshIor[ oldID ];
+      }
       _mapSubMesh.   erase(oldID);
       _mapSubMesh_i. erase(oldID);
       _mapSubMeshIor.erase(oldID);
-      _mapSubMesh_i [ newID ]->changeLocalId( newID );
+      if ( newID > 0 )
+        _mapSubMesh_i [ newID ]->changeLocalId( newID );
     }
 
     // update _mapSubMesh
@@ -2487,7 +2498,7 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
       i_sm->second = _impl->GetSubMesh( meshDS->IndexToShape( i_sm->first ));
   }
 
-  _gen_i->UpdateIcons( SMESH::SMESH_Mesh_var( _this() ));
+  _gen_i->UpdateIcons( me );
 
   if ( !isBreakLink )
   {