mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-04-13 10:27:26 +05:00
PAL13473 (Build repetitive mesh):
1) add int GetObjectId(CORBA::Object_ptr) 2) in GetAlgoState(), treat a new algo error 3) modify Load() to restore references of hypos to meshes and shapes
This commit is contained in:
parent
5b836386bb
commit
a1a9ed2c4d
@ -102,7 +102,7 @@ using SMESH::TPythonDump;
|
||||
#define NUM_TMP_FILES 2
|
||||
|
||||
#ifdef _DEBUG_
|
||||
static int MYDEBUG = 1;
|
||||
static int MYDEBUG = 0;
|
||||
#else
|
||||
static int MYDEBUG = 0;
|
||||
#endif
|
||||
@ -934,6 +934,7 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes
|
||||
case ::SMESH_Gen::MISSING_ALGO: errName = SMESH::MISSING_ALGO; break;
|
||||
case ::SMESH_Gen::MISSING_HYPO: errName = SMESH::MISSING_HYPO; break;
|
||||
case ::SMESH_Gen::NOT_CONFORM_MESH: errName = SMESH::NOT_CONFORM_MESH; break;
|
||||
case ::SMESH_Gen::BAD_PARAM_VALUE: errName = SMESH::BAD_PARAM_VALUE; break;
|
||||
default:
|
||||
THROW_SALOME_CORBA_EXCEPTION( "bad error name",SALOME::BAD_PARAM );
|
||||
}
|
||||
@ -1086,7 +1087,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
|
||||
// Update Python script
|
||||
TPythonDump() << "isDone = " << this << ".Compute( "
|
||||
<< theMesh << ", " << theShapeObject << ")";
|
||||
TPythonDump() << "if not isDone: print 'Mesh " << theMesh << " : computation failed'";
|
||||
TPythonDump() << "if not isDone: print 'Mesh', " << theMesh << ", ': computation failed'";
|
||||
|
||||
try {
|
||||
// get mesh servant
|
||||
@ -2098,7 +2099,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
theComponent->GetStudy()->StudyId() != myCurrentStudy->StudyId() )
|
||||
SetCurrentStudy( theComponent->GetStudy() );
|
||||
|
||||
/* if( !theComponent->_is_nil() )
|
||||
/* if( !theComponent->_is_nil() )
|
||||
{
|
||||
//SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( theComponent->GetStudy() );
|
||||
if( !myCurrentStudy->FindComponent( "GEOM" )->_is_nil() )
|
||||
@ -2145,6 +2146,19 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
DriverMED_R_SMESHDS_Mesh myReader;
|
||||
myReader.SetFile( meshfile.ToCString() );
|
||||
|
||||
// For PAL13473 ("Repetitive mesh") implementation.
|
||||
// New dependencies between SMESH objects are established:
|
||||
// now hypotheses can refer to meshes, shapes and other hypotheses.
|
||||
// To keep data consistent, the following order of data restoration
|
||||
// imposed:
|
||||
// 1. Create hypotheses
|
||||
// 2. Create all meshes
|
||||
// 3. Load hypotheses' data
|
||||
// 4. All the rest
|
||||
|
||||
list< pair< SMESH_Hypothesis_i*, string > > hypDataList;
|
||||
list< pair< SMESH_Mesh_i*, HDFgroup* > > meshGroupList;
|
||||
|
||||
// get total number of top-level groups
|
||||
int aNbGroups = aFile->nInternalObjects();
|
||||
if ( aNbGroups > 0 ) {
|
||||
@ -2231,7 +2245,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
|
||||
SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
|
||||
if ( myImpl ) {
|
||||
myImpl->LoadFrom( hypdata.c_str() );
|
||||
// myImpl->LoadFrom( hypdata.c_str() );
|
||||
hypDataList.push_back( make_pair( myImpl, hypdata ));
|
||||
string iorString = GetORB()->object_to_string( myHyp );
|
||||
int newId = myStudyContext->findId( iorString );
|
||||
myStudyContext->mapOldToNew( id, newId );
|
||||
@ -2329,7 +2344,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
|
||||
SMESH_Hypothesis_i* myImpl = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( myHyp ).in() );
|
||||
if ( myImpl ) {
|
||||
myImpl->LoadFrom( hypdata.c_str() );
|
||||
//myImpl->LoadFrom( hypdata.c_str() );
|
||||
hypDataList.push_back( make_pair( myImpl, hypdata ));
|
||||
string iorString = GetORB()->object_to_string( myHyp );
|
||||
int newId = myStudyContext->findId( iorString );
|
||||
myStudyContext->mapOldToNew( id, newId );
|
||||
@ -2355,8 +2371,6 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
if ( id <= 0 )
|
||||
continue;
|
||||
|
||||
bool hasData = false;
|
||||
|
||||
// open mesh HDF group
|
||||
aTopGroup = new HDFgroup( meshName, aFile );
|
||||
aTopGroup->OpenOnDisk();
|
||||
@ -2370,13 +2384,43 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
SMESH_Mesh_i* myNewMeshImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( myNewMesh ).in() );
|
||||
if ( !myNewMeshImpl )
|
||||
continue;
|
||||
meshGroupList.push_back( make_pair( myNewMeshImpl, aTopGroup ));
|
||||
|
||||
string iorString = GetORB()->object_to_string( myNewMesh );
|
||||
int newId = myStudyContext->findId( iorString );
|
||||
myStudyContext->mapOldToNew( id, newId );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// As all object that can be referred by hypothesis are created,
|
||||
// we can restore hypothesis data
|
||||
|
||||
list< pair< SMESH_Hypothesis_i*, string > >::iterator hyp_data;
|
||||
for ( hyp_data = hypDataList.begin(); hyp_data != hypDataList.end(); ++hyp_data )
|
||||
{
|
||||
SMESH_Hypothesis_i* hyp = hyp_data->first;
|
||||
string & data = hyp_data->second;
|
||||
hyp->LoadFrom( data.c_str() );
|
||||
}
|
||||
|
||||
// Restore the rest mesh data
|
||||
|
||||
list< pair< SMESH_Mesh_i*, HDFgroup* > >::iterator meshi_group;
|
||||
for ( meshi_group = meshGroupList.begin(); meshi_group != meshGroupList.end(); ++meshi_group )
|
||||
{
|
||||
aTopGroup = meshi_group->second;
|
||||
SMESH_Mesh_i* myNewMeshImpl = meshi_group->first;
|
||||
::SMESH_Mesh& myLocMesh = myNewMeshImpl->GetImpl();
|
||||
SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS();
|
||||
|
||||
bool hasData = false;
|
||||
|
||||
// get mesh old id
|
||||
string iorString = GetORB()->object_to_string( myNewMeshImpl->_this() );
|
||||
int newId = myStudyContext->findId( iorString );
|
||||
int id = myStudyContext->getOldId( newId );
|
||||
|
||||
// try to find mesh data dataset
|
||||
if ( aTopGroup->ExistInternalObject( "Has data" ) ) {
|
||||
// load mesh "has data" flag
|
||||
@ -2567,19 +2611,19 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
continue;
|
||||
|
||||
// VSR: Get submesh data from MED convertor
|
||||
// int anInternalSubmeshId = aSubMesh->GetId(); // this is not a persistent ID, it's an internal one computed from sub-shape
|
||||
// if (myNewMeshImpl->_mapSubMesh.find(anInternalSubmeshId) != myNewMeshImpl->_mapSubMesh.end()) {
|
||||
// if(MYDEBUG) MESSAGE("VSR - SMESH_Gen_i::Load(): loading from MED file submesh with ID = " <<
|
||||
// subid << " for subshape # " << anInternalSubmeshId);
|
||||
// SMESHDS_SubMesh* aSubMeshDS =
|
||||
// myNewMeshImpl->_mapSubMesh[anInternalSubmeshId]->CreateSubMeshDS();
|
||||
// if ( !aSubMeshDS ) {
|
||||
// if(MYDEBUG) MESSAGE("VSR - SMESH_Gen_i::Load(): FAILED to create a submesh for subshape # " <<
|
||||
// anInternalSubmeshId << " in current mesh!");
|
||||
// }
|
||||
// else
|
||||
// myReader.GetSubMesh( aSubMeshDS, subid );
|
||||
// }
|
||||
// int anInternalSubmeshId = aSubMesh->GetId(); // this is not a persistent ID, it's an internal one computed from sub-shape
|
||||
// if (myNewMeshImpl->_mapSubMesh.find(anInternalSubmeshId) != myNewMeshImpl->_mapSubMesh.end()) {
|
||||
// if(MYDEBUG) MESSAGE("VSR - SMESH_Gen_i::Load(): loading from MED file submesh with ID = " <<
|
||||
// subid << " for subshape # " << anInternalSubmeshId);
|
||||
// SMESHDS_SubMesh* aSubMeshDS =
|
||||
// myNewMeshImpl->_mapSubMesh[anInternalSubmeshId]->CreateSubMeshDS();
|
||||
// if ( !aSubMeshDS ) {
|
||||
// if(MYDEBUG) MESSAGE("VSR - SMESH_Gen_i::Load(): FAILED to create a submesh for subshape # " <<
|
||||
// anInternalSubmeshId << " in current mesh!");
|
||||
// }
|
||||
// else
|
||||
// myReader.GetSubMesh( aSubMeshDS, subid );
|
||||
// }
|
||||
|
||||
// try to get applied algorithms
|
||||
if ( aSubGroup->ExistInternalObject( "Applied Algorithms" ) ) {
|
||||
@ -2954,8 +2998,6 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
// close mesh group
|
||||
aTopGroup->CloseOnDisk();
|
||||
}
|
||||
}
|
||||
}
|
||||
// close HDF file
|
||||
aFile->CloseOnDisk();
|
||||
delete aFile;
|
||||
@ -3086,6 +3128,24 @@ int SMESH_Gen_i::RegisterObject(CORBA::Object_ptr theObject)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return id of registered object
|
||||
* \param theObject - the Object
|
||||
* \retval int - Object id
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
int SMESH_Gen_i::GetObjectId(CORBA::Object_ptr theObject)
|
||||
{
|
||||
StudyContext* myStudyContext = GetCurrentStudyContext();
|
||||
if ( myStudyContext && !CORBA::is_nil( theObject )) {
|
||||
string iorString = GetORB()->object_to_string( theObject );
|
||||
return myStudyContext->findId( iorString );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SMESHEngine_factory
|
||||
|
Loading…
x
Reference in New Issue
Block a user