#include <HYDROData_Projection.h>
+#include <SALOMEDSClient.hxx>
+#include <SALOME_NamingService.hxx>
+
IMPLEMENT_STANDARD_HANDLE(HYDROData_Obstacle,HYDROData_ArtificialObject)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Obstacle,HYDROData_ArtificialObject)
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() )
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 )