From: mzn Date: Thu, 6 Nov 2014 13:35:06 +0000 (+0000) Subject: Bug #487: dump/load script - problem with obstacle. X-Git-Tag: BR_hydro_v_1_0_4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=191c33b8fd827caa9af8886728e9df22ae55451e;p=modules%2Fhydro.git Bug #487: dump/load script - problem with obstacle. --- diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index b7c8eb54..7d0469ca 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -41,6 +41,9 @@ #include +#include +#include + IMPLEMENT_STANDARD_HANDLE(HYDROData_Obstacle,HYDROData_ArtificialObject) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Obstacle,HYDROData_ArtificialObject) @@ -66,14 +69,19 @@ QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObj if ( !aGeomObjectEntry.IsEmpty() ) { QString aSalomeObjName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "obstacle_sobj" ); - aResList << QString( "%1 = theStudy.FindObjectID( \"%2\" );" ) - .arg( aSalomeObjName ).arg( aGeomObjectEntry.ToCString() ); - - aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() );" ) - .arg( anObstacleName ).arg( aSalomeObjName ); - - aResList << QString( "%1.SetGeomObjectEntry( \"%2\" );" ) - .arg( anObstacleName ).arg( aGeomObjectEntry.ToCString() ); + // aResList << QString( "%1 = theStudy.FindObjectID( \"%2\" );" ) + // .arg( aSalomeObjName ).arg( aGeomObjectEntry.ToCString() ); + QString aGeomObjectName( GetGeomObjectName().ToCString() ); + if ( !aGeomObjectName.isEmpty() ) { + aResList << QString( "%1 = theStudy.FindObjectByName( \"%2\", \"GEOM\" )[0];" ) + .arg( aSalomeObjName ).arg( aGeomObjectName ); + + aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() );" ) + .arg( anObstacleName ).arg( aSalomeObjName ); + + aResList << QString( "%1.SetGeomObjectEntry( %2.GetID() );" ) + .arg( anObstacleName ).arg( aSalomeObjName ); + } aResList << QString( "" ); } else if ( !aFilePath.isEmpty() ) @@ -227,6 +235,33 @@ TCollection_AsciiString HYDROData_Obstacle::GetGeomObjectEntry() const return aRes; } +TCollection_AsciiString HYDROData_Obstacle::GetGeomObjectName() const +{ + TCollection_AsciiString aRes; + + int aDocId = -1; + if ( !HYDROData_Document::DocumentId( HYDROData_Document::Document( myLab ), aDocId ) || aDocId < 0 ) { + return aRes; + } + + int argc = 0; + char** argv = 0; + CORBA::ORB_var anORB = CORBA::ORB_init( argc, argv, "omniORB4"/*CORBA::ORB_ID*/ ); + SALOME_NamingService aNameService( anORB ); + + CORBA::Object_var aSMObject = aNameService.Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject); + SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID( aDocId ); + + TCollection_AsciiString anEntry = GetGeomObjectEntry(); + SALOMEDS::SObject_var aSObject = aDSStudy->FindObjectID( anEntry.ToCString() ); + if ( !aSObject->_is_nil() ) { + aRes = TCollection_AsciiString( aSObject->GetName() ); + } + + return aRes; +} + void HYDROData_Obstacle::Translate( const double theDx, const double theDy, const double theDz ) diff --git a/src/HYDROData/HYDROData_Obstacle.h b/src/HYDROData/HYDROData_Obstacle.h index 3641ba9d..85373efd 100644 --- a/src/HYDROData/HYDROData_Obstacle.h +++ b/src/HYDROData/HYDROData_Obstacle.h @@ -121,6 +121,10 @@ public: */ HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const; + /** + * Returns the imported GEOM object name. + */ + HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectName() const; /** * Translate the obstacle to the given distance.