mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-27 23:00:33 +05:00
fix bug 10638: add and use SMESH_Mesh::GetGroups() allowing correct PythonDump of groups of imported mesh
This commit is contained in:
parent
9aa3a7211b
commit
22967ffd3f
@ -699,6 +699,10 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName
|
||||
SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( aMesh ).in() );
|
||||
ASSERT( aServant );
|
||||
aServant->ImportUNVFile( theFileName );
|
||||
|
||||
// Dump creation of groups
|
||||
aServant->GetGroups();
|
||||
|
||||
return aMesh._retn();
|
||||
}
|
||||
|
||||
@ -717,11 +721,6 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
|
||||
Unexpect aCatch(SALOME_SalomeException);
|
||||
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
|
||||
|
||||
// Python Dump
|
||||
TPythonDump aPythonDump;
|
||||
aPythonDump << "([";
|
||||
//TCollection_AsciiString aStr ("([");
|
||||
|
||||
// Retrieve mesh names from the file
|
||||
DriverMED_R_SMESHDS_Mesh myReader;
|
||||
myReader.SetFile( theFileName );
|
||||
@ -730,6 +729,14 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
|
||||
list<string> aNames = myReader.GetMeshNames(aStatus);
|
||||
SMESH::mesh_array_var aResult = new SMESH::mesh_array();
|
||||
theStatus = (SMESH::DriverMED_ReadStatus)aStatus;
|
||||
|
||||
{ // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
|
||||
|
||||
// Python Dump
|
||||
TPythonDump aPythonDump;
|
||||
aPythonDump << "([";
|
||||
//TCollection_AsciiString aStr ("([");
|
||||
|
||||
if (theStatus == SMESH::DRS_OK) {
|
||||
SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
|
||||
aStudyBuilder->NewCommand(); // There is a transaction
|
||||
@ -775,6 +782,10 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
|
||||
|
||||
// Update Python script
|
||||
aPythonDump << "], status) = " << this << ".CreateMeshesFromMED('" << theFileName << "')";
|
||||
}
|
||||
// Dump creation of groups
|
||||
for ( int i = 0; i < aResult->length(); ++i )
|
||||
aResult[ i ]->GetGroups();
|
||||
|
||||
return aResult._retn();
|
||||
}
|
||||
|
@ -728,6 +728,47 @@ void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup
|
||||
_gen_i->RemoveLastFromPythonScript(_gen_i->GetCurrentStudy()->StudyId());
|
||||
}
|
||||
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Get the list of groups existing in the mesh
|
||||
* \retval SMESH::ListOfGroups * - list of groups
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
SMESH::ListOfGroups * SMESH_Mesh_i::GetGroups() throw(SALOME::SALOME_Exception)
|
||||
{
|
||||
Unexpect aCatch(SALOME_SalomeException);
|
||||
if (MYDEBUG) MESSAGE("GetGroups");
|
||||
|
||||
SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
|
||||
// Python Dump
|
||||
TPythonDump aPythonDump;
|
||||
aPythonDump << "[ ";
|
||||
|
||||
try {
|
||||
aList->length( _mapGroups.size() );
|
||||
int i = 0;
|
||||
map<int, SMESH::SMESH_GroupBase_ptr>::iterator it = _mapGroups.begin();
|
||||
for ( ; it != _mapGroups.end(); it++ ) {
|
||||
if ( CORBA::is_nil( it->second )) continue;
|
||||
aList[i++] = SMESH::SMESH_GroupBase::_duplicate( it->second );
|
||||
// Python Dump
|
||||
if (i > 1) aPythonDump << ", ";
|
||||
aPythonDump << it->second;
|
||||
}
|
||||
aList->length( i );
|
||||
}
|
||||
catch(SALOME_Exception & S_ex) {
|
||||
THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
|
||||
}
|
||||
|
||||
// Update Python script
|
||||
aPythonDump << " ] = " << _this() << ".GetGroups()";
|
||||
|
||||
return aList._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*! UnionGroups
|
||||
* New group is created. All mesh elements that are
|
||||
|
@ -99,6 +99,9 @@ public:
|
||||
void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
|
||||
throw (SALOME::SALOME_Exception);
|
||||
|
||||
SMESH::ListOfGroups* GetGroups()
|
||||
throw (SALOME::SALOME_Exception);
|
||||
|
||||
SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
|
||||
SMESH::SMESH_GroupBase_ptr theGroup2,
|
||||
const char* theName )
|
||||
|
Loading…
Reference in New Issue
Block a user