mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-13 10:10:33 +05:00
#16459 EDF 14133 - Complete Merge Nodes / Merge Elements operations
fix crash + fix deletion of mesh objects (relates to #16478)
This commit is contained in:
parent
cc85955178
commit
0a237be4b9
@ -1920,8 +1920,8 @@ void SMESHGUI::OnEditDelete()
|
|||||||
|
|
||||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
|
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
|
||||||
|
|
||||||
// Put the whole hierarchy of sub-objects of the selected SO's into a list and
|
// Put one level of sub-objects of the selected SO's into a list
|
||||||
// then treat them all starting from the deepest objects (at list back)
|
// in order to get objects inside folders like "Assigned Algorithms"
|
||||||
std::list< _PTR(SObject) > listSO;
|
std::list< _PTR(SObject) > listSO;
|
||||||
SALOME_ListIteratorOfListIO It(selected);
|
SALOME_ListIteratorOfListIO It(selected);
|
||||||
for( ; It.More(); It.Next()) // loop on selected IO's
|
for( ; It.More(); It.Next()) // loop on selected IO's
|
||||||
@ -1942,43 +1942,47 @@ void SMESHGUI::OnEditDelete()
|
|||||||
aSO = aRefSObject; // Delete main Object instead of reference
|
aSO = aRefSObject; // Delete main Object instead of reference
|
||||||
|
|
||||||
listSO.push_back( aSO );
|
listSO.push_back( aSO );
|
||||||
std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
|
|
||||||
for ( ; itSO != listSO.end(); ++itSO ) {
|
_PTR(ChildIterator) it = aStudy->NewChildIterator( aSO );
|
||||||
_PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
|
for (it->InitEx(false); it->More(); it->Next())
|
||||||
for (it->InitEx(false); it->More(); it->Next())
|
listSO.push_back( it->Value() );
|
||||||
listSO.push_back( it->Value() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if none of objects to delete is referred from outside
|
// Check if none of objects to delete is referred from outside
|
||||||
std::list< _PTR(SObject) >::reverse_iterator ritSO;
|
std::list< _PTR(SObject) >::reverse_iterator ritSO;
|
||||||
|
std::vector< _PTR(SObject) > subSO;
|
||||||
for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
|
for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
|
||||||
{
|
{
|
||||||
_PTR(SObject) SO = *ritSO;
|
_PTR(SObject) SO = *ritSO;
|
||||||
if ( !SO ) continue;
|
if ( !SO ) continue;
|
||||||
std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
|
|
||||||
for (size_t i = 0; i < aReferences.size(); i++) {
|
int nbChildren = SO->GetLastChildTag();
|
||||||
_PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
|
subSO.clear();
|
||||||
std::string type = aComponent->ComponentDataType();
|
subSO.reserve( 1 + nbChildren );
|
||||||
if ( type != "SMESH" )
|
subSO.push_back( SO );
|
||||||
{
|
if ( nbChildren > 0 )
|
||||||
SUIT_MessageBox::warning( anApp->desktop(),
|
{
|
||||||
QObject::tr("WRN_WARNING"),
|
_PTR(ChildIterator) it = aStudy->NewChildIterator( SO );
|
||||||
QObject::tr("DEP_OBJECT") );
|
for ( it->InitEx( true ); it->More(); it->Next() )
|
||||||
return; // outside SMESH, there is an object depending on a SMESH object
|
subSO.push_back( it->Value() );
|
||||||
|
}
|
||||||
|
for ( size_t i = 0; i < subSO.size(); ++i )
|
||||||
|
{
|
||||||
|
std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( subSO[i] );
|
||||||
|
for ( size_t j = 0; j < aReferences.size(); j++ ) {
|
||||||
|
_PTR(SComponent) aComponent = aReferences[j]->GetFatherComponent();
|
||||||
|
std::string type = aComponent->ComponentDataType();
|
||||||
|
if ( type != "SMESH" )
|
||||||
|
{
|
||||||
|
SUIT_MessageBox::warning( anApp->desktop(),
|
||||||
|
QObject::tr("WRN_WARNING"),
|
||||||
|
QObject::tr("DEP_OBJECT") );
|
||||||
|
return; // outside SMESH, there is an object depending on a SMESH object
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
|
|
||||||
for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
|
|
||||||
{
|
|
||||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
|
||||||
SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
|
|
||||||
if ( !mesh->_is_nil() )
|
|
||||||
mesh->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Treat SO's in the list starting from the back
|
// Treat SO's in the list starting from the back
|
||||||
aStudyBuilder->NewCommand(); // There is a transaction
|
aStudyBuilder->NewCommand(); // There is a transaction
|
||||||
for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
|
for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
|
||||||
@ -1988,7 +1992,7 @@ void SMESHGUI::OnEditDelete()
|
|||||||
std::string anEntry = SO->GetID();
|
std::string anEntry = SO->GetID();
|
||||||
|
|
||||||
/** Erase graphical object and remove all its data **/
|
/** Erase graphical object and remove all its data **/
|
||||||
if(SO->FindAttribute(anAttr, "AttributeIOR")) {
|
if ( SO->FindAttribute( anAttr, "AttributeIOR" )) {
|
||||||
SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
|
SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
|
||||||
}
|
}
|
||||||
/** Remove an object from data structures **/
|
/** Remove an object from data structures **/
|
||||||
|
@ -1233,6 +1233,7 @@ void SMESHGUI_MergeDlg::SelectionIntoArgument()
|
|||||||
|
|
||||||
// process groups
|
// process groups
|
||||||
myGroups.clear();
|
myGroups.clear();
|
||||||
|
ListExclude->clear();
|
||||||
if ( isMeshSelected )
|
if ( isMeshSelected )
|
||||||
{
|
{
|
||||||
SMESH::ListOfGroups_var aListOfGroups = myMesh->GetGroups();
|
SMESH::ListOfGroups_var aListOfGroups = myMesh->GetGroups();
|
||||||
|
Loading…
Reference in New Issue
Block a user