#19765 EDF 21730 - long time to load med file file with huge amount of groups

This commit is contained in:
eap 2020-07-20 10:13:03 +03:00
parent d55dbe18f5
commit e85e13ee2a
3 changed files with 57 additions and 28 deletions

View File

@ -74,6 +74,7 @@
#include <vtkActorCollection.h> #include <vtkActorCollection.h>
// OCCT includes // OCCT includes
#include <TColStd_MapOfAsciiString.hxx>
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
// Qt includes // Qt includes
@ -522,18 +523,37 @@ QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation)
return aName; return aName;
} }
//=======================================================================
//function : setDefaultName
//purpose :
//=======================================================================
void SMESHGUI_GroupDlg::setDefaultName() const void SMESHGUI_GroupDlg::setDefaultName() const
{ {
QString aResName; QString aResName;
const QString aPrefix ="Group_";
if ( myMesh->_is_nil() )
{
aResName = aPrefix + "1";
}
else
{
SMESH::ListOfGroups_var allGroups = myMesh->GetGroups();
TColStd_MapOfAsciiString allNames( allGroups->length() );
for ( CORBA::ULong i = 0; i < allGroups->length(); ++i )
{
CORBA::String_var name = allGroups[i]->GetName();
allNames.Add( name.in() );
}
int i = 1; int i = 1;
QString aPrefix ="Group_"; while ( true )
_PTR(SObject) anObj;
do
{ {
aResName = aPrefix + QString::number( i++ ); aResName = aPrefix + QString::number( i++ );
anObj = SMESH::getStudy()->FindObject( aResName.toUtf8().constData() ); if ( !allNames.Contains( aResName.toUtf8().constData() ))
break;
}
} }
while ( anObj );
myName->setText(aResName); myName->setText(aResName);
} }
@ -944,7 +964,8 @@ bool SMESHGUI_GroupDlg::onApply()
if (myGroup->_is_nil()) { // creation or conversion if (myGroup->_is_nil()) { // creation or conversion
// check if group on geometry is not null // check if group on geometry is not null
if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil()) { if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil())
{
if (myMesh->_is_nil()) if (myMesh->_is_nil())
return false; return false;
if ( myGroupOnGeom->_is_nil() ) if ( myGroupOnGeom->_is_nil() )
@ -958,7 +979,8 @@ bool SMESHGUI_GroupDlg::onApply()
} }
} }
if (myGroup->_is_nil()) { // creation if (myGroup->_is_nil()) // creation
{
if (myMesh->_is_nil()) if (myMesh->_is_nil())
return false; return false;
@ -990,10 +1012,10 @@ bool SMESHGUI_GroupDlg::onApply()
myGroup->Add(anIdList.inout()); myGroup->Add(anIdList.inout());
} }
} }
}
else // edition
} else { // edition {
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroup ); resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroup );
isCreation = false; isCreation = false;
@ -1111,6 +1133,7 @@ bool SMESHGUI_GroupDlg::onApply()
} }
anIsOk = true; anIsOk = true;
} }
if (myGrpTypeId == 2) // group on filter if (myGrpTypeId == 2) // group on filter
{ {
if ( myFilter->_is_nil() ) return false; if ( myFilter->_is_nil() ) return false;

View File

@ -5821,15 +5821,21 @@ void SMESH_Mesh_i::CreateGroupServants()
GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape ); GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape );
_gen_i->PublishGroup( aMesh, groupVar, shapeVar, group->GetName()); _gen_i->PublishGroup( aMesh, groupVar, shapeVar, group->GetName());
} }
if ( !addedIDs.empty() ) if ( !addedIDs.empty() )
{ {
// python dump // python dump
set<int>::iterator id = addedIDs.begin(); map<int, SMESH::SMESH_GroupBase_ptr>::iterator i_grp = _mapGroups.begin();
for ( ; id != addedIDs.end(); ++id ) for ( int index = 0; i_grp != _mapGroups.end(); ++index, ++i_grp )
{ {
map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.find(*id); set<int>::iterator it = addedIDs.find( i_grp->first );
int i = std::distance( _mapGroups.begin(), it ); if ( it != addedIDs.end() )
TPythonDump() << it->second << " = " << aMesh << ".GetGroups()[ "<< i << " ]"; {
TPythonDump() << i_grp->second << " = " << aMesh << ".GetGroups()[ "<< index << " ]";
addedIDs.erase( it );
if ( addedIDs.empty() )
break;
}
} }
} }
} }