mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-13 02:00:34 +05:00
Fix exception at Break Link after shaper group modification
Scenario: - Create a mesh on a box with sub-mesh on a group - Modify group in shaper - Switch to SMESH and Break Link ==> SIGSEGV
This commit is contained in:
parent
fe414fe4e7
commit
c4d4c3be32
@ -1280,7 +1280,7 @@ void SMESHGUI_BaseComputeOp::onPublishShape()
|
|||||||
// look for myMainShape in the table
|
// look for myMainShape in the table
|
||||||
for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
|
for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
|
||||||
if ( table()->item( r, COL_SHAPEID )->text() == "1" ) {
|
if ( table()->item( r, COL_SHAPEID )->text() == "1" ) {
|
||||||
if ( so->_is_nil() ) {
|
if ( !so->_is_nil() ) {
|
||||||
CORBA::String_var name = so->GetName();
|
CORBA::String_var name = so->GetName();
|
||||||
CORBA::String_var entry = so->GetID();
|
CORBA::String_var entry = so->GetID();
|
||||||
QString shapeText = QString("%1 (%2)").arg( name.in() ).arg( entry.in() );
|
QString shapeText = QString("%1 (%2)").arg( name.in() ).arg( entry.in() );
|
||||||
|
@ -1083,6 +1083,8 @@ bool SMESHGUI_GroupDlg::onApply()
|
|||||||
|
|
||||||
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
|
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
|
||||||
GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
|
GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
|
||||||
|
if ( aGroupVar->_is_nil() )
|
||||||
|
return false;
|
||||||
op->UnionList(aGroupVar, myGeomObjects);
|
op->UnionList(aGroupVar, myGeomObjects);
|
||||||
|
|
||||||
if (op->IsDone()) {
|
if (op->IsDone()) {
|
||||||
|
@ -2002,8 +2002,7 @@ void SMESH_Mesh_i::addGeomGroupData(GEOM::GEOM_Object_ptr theGeomObj,
|
|||||||
return;
|
return;
|
||||||
// group indices
|
// group indices
|
||||||
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine( theGeomObj );
|
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine( theGeomObj );
|
||||||
GEOM::GEOM_IGroupOperations_ptr groupOp =
|
GEOM::GEOM_IGroupOperations_ptr groupOp = geomGen->GetIGroupOperations();
|
||||||
geomGen->GetIGroupOperations();
|
|
||||||
GEOM::ListOfLong_var ids = groupOp->GetObjects( theGeomObj );
|
GEOM::ListOfLong_var ids = groupOp->GetObjects( theGeomObj );
|
||||||
|
|
||||||
// store data
|
// store data
|
||||||
@ -2347,6 +2346,8 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
|
|||||||
ids2Hyps.push_back( make_pair( meshDS->ShapeToIndex( s ), hyps ));
|
ids2Hyps.push_back( make_pair( meshDS->ShapeToIndex( s ), hyps ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map< std::set<int>, int > ii2iMap; // group sub-ids to group id in SMESHDS
|
||||||
|
|
||||||
// count shapes excluding compounds corresponding to geom groups
|
// count shapes excluding compounds corresponding to geom groups
|
||||||
int oldNbSubShapes = meshDS->MaxShapeIndex();
|
int oldNbSubShapes = meshDS->MaxShapeIndex();
|
||||||
for ( ; oldNbSubShapes > 0; --oldNbSubShapes )
|
for ( ; oldNbSubShapes > 0; --oldNbSubShapes )
|
||||||
@ -2354,6 +2355,11 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
|
|||||||
const TopoDS_Shape& s = meshDS->IndexToShape( oldNbSubShapes );
|
const TopoDS_Shape& s = meshDS->IndexToShape( oldNbSubShapes );
|
||||||
if ( s.IsNull() || s.ShapeType() != TopAbs_COMPOUND )
|
if ( s.IsNull() || s.ShapeType() != TopAbs_COMPOUND )
|
||||||
break;
|
break;
|
||||||
|
// fill ii2iMap
|
||||||
|
std::set<int> subIds;
|
||||||
|
for ( TopoDS_Iterator it( s ); it.More(); it.Next() )
|
||||||
|
subIds.insert( meshDS->ShapeToIndex( it.Value() ));
|
||||||
|
ii2iMap.insert( std::make_pair( subIds, oldNbSubShapes ));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if shape topology changes - save shape type per shape ID
|
// check if shape topology changes - save shape type per shape ID
|
||||||
@ -2374,9 +2380,15 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// re-add shapes (compounds) of geom groups
|
// re-add shapes (compounds) of geom groups
|
||||||
|
std::map< int, int > old2newIDs; // group IDs
|
||||||
std::list<TGeomGroupData>::iterator data = _geomGroupData.begin();
|
std::list<TGeomGroupData>::iterator data = _geomGroupData.begin();
|
||||||
for ( ; data != _geomGroupData.end(); ++data )
|
for ( ; data != _geomGroupData.end(); ++data )
|
||||||
{
|
{
|
||||||
|
int oldID = 0;
|
||||||
|
std::map< std::set<int>, int >::iterator ii2i = ii2iMap.find( data->_indices );
|
||||||
|
if ( ii2i != ii2iMap.end() )
|
||||||
|
oldID = ii2i->second;
|
||||||
|
|
||||||
TopoDS_Shape newShape = newGroupShape( *data, isBreakLink ? IS_BREAK_LINK : MAIN_TRANSFORMED );
|
TopoDS_Shape newShape = newGroupShape( *data, isBreakLink ? IS_BREAK_LINK : MAIN_TRANSFORMED );
|
||||||
if ( !newShape.IsNull() )
|
if ( !newShape.IsNull() )
|
||||||
{
|
{
|
||||||
@ -2387,7 +2399,9 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
|
|||||||
BRep_Builder().Add( compound, newShape );
|
BRep_Builder().Add( compound, newShape );
|
||||||
newShape = compound;
|
newShape = compound;
|
||||||
}
|
}
|
||||||
_impl->GetSubMesh( newShape );
|
int newID = _impl->GetSubMesh( newShape )->GetId();
|
||||||
|
if ( oldID && oldID != newID )
|
||||||
|
old2newIDs.insert( std::make_pair( oldID, newID ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2396,7 +2410,11 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
|
|||||||
{
|
{
|
||||||
if ( !sameTopology && ids2Hyps[i].first != 1 )
|
if ( !sameTopology && ids2Hyps[i].first != 1 )
|
||||||
continue; // assign only global hypos
|
continue; // assign only global hypos
|
||||||
const TopoDS_Shape& s = meshDS->IndexToShape( ids2Hyps[i].first );
|
int sID = ids2Hyps[i].first;
|
||||||
|
std::map< int, int >::iterator o2n = old2newIDs.find( sID );
|
||||||
|
if ( o2n != old2newIDs.end() )
|
||||||
|
sID = o2n->second;
|
||||||
|
const TopoDS_Shape& s = meshDS->IndexToShape( sID );
|
||||||
const THypList& hyps = ids2Hyps[i].second;
|
const THypList& hyps = ids2Hyps[i].second;
|
||||||
THypList::const_iterator h = hyps.begin();
|
THypList::const_iterator h = hyps.begin();
|
||||||
for ( ; h != hyps.end(); ++h )
|
for ( ; h != hyps.end(); ++h )
|
||||||
@ -2430,6 +2448,21 @@ void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
|
|||||||
g->GetGroupDS()->SetColor( data._color );
|
g->GetGroupDS()->SetColor( data._color );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map< int, int >::iterator o2n = old2newIDs.begin();
|
||||||
|
for ( ; o2n != old2newIDs.end(); ++o2n )
|
||||||
|
{
|
||||||
|
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 ];
|
||||||
|
_mapSubMesh. erase(oldID);
|
||||||
|
_mapSubMesh_i. erase(oldID);
|
||||||
|
_mapSubMeshIor.erase(oldID);
|
||||||
|
_mapSubMesh_i [ newID ]->changeLocalId( newID );
|
||||||
|
}
|
||||||
|
|
||||||
// update _mapSubMesh
|
// update _mapSubMesh
|
||||||
std::map<int, ::SMESH_subMesh*>::iterator i_sm = _mapSubMesh.begin();
|
std::map<int, ::SMESH_subMesh*>::iterator i_sm = _mapSubMesh.begin();
|
||||||
for ( ; i_sm != _mapSubMesh.end(); ++i_sm )
|
for ( ; i_sm != _mapSubMesh.end(); ++i_sm )
|
||||||
|
@ -123,6 +123,7 @@ protected:
|
|||||||
|
|
||||||
void changeLocalId(int localId) { _localId = localId; }
|
void changeLocalId(int localId) { _localId = localId; }
|
||||||
friend void SMESH_Mesh_i::CheckGeomGroupModif();
|
friend void SMESH_Mesh_i::CheckGeomGroupModif();
|
||||||
|
friend void SMESH_Mesh_i::CheckGeomModif(bool);
|
||||||
|
|
||||||
SMESH_PreMeshInfo* _preMeshInfo; // mesh info before full loading from study file
|
SMESH_PreMeshInfo* _preMeshInfo; // mesh info before full loading from study file
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user