From 788e2d8114c165bb56dbf48e803deacb13da8314 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 14 Feb 2020 14:16:51 +0300 Subject: [PATCH] Fix Break Link called from TUI --- src/SMESH_I/SMESH_Gen_i.cxx | 39 +++++++++++++++++----------- src/SMESH_I/SMESH_Gen_i.hxx | 3 +++ src/SMESH_I/SMESH_Mesh_i.cxx | 49 ++++++++++++++++++++++-------------- 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index f5c36db78..6117d4547 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -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( 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; diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index 3f03b67b2..0cb93fbb9 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -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, diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 04e0371bc..2b831f8c9 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -270,25 +270,30 @@ void SMESH_Mesh_i::ReplaceShape(GEOM::GEOM_Object_ptr theNewGeom) geomClient->RemoveShapeFromBuffer(aIOR); } + // update the reference to theNewGeom (needed for correct execution of a dumped python script) + 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 ); + } + } + // 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())); - } - } - - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ReplaceShape( " - << theNewGeom->GetStudyEntry() << " )"; - 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 ) {