]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Bug #487: dump/load script - problem with obstacle. BR_hydro_v_1_0_4
authormzn <mzn@opencascade.com>
Thu, 6 Nov 2014 13:35:06 +0000 (13:35 +0000)
committermzn <mzn@opencascade.com>
Thu, 6 Nov 2014 13:35:06 +0000 (13:35 +0000)
src/HYDROData/HYDROData_Obstacle.cxx
src/HYDROData/HYDROData_Obstacle.h

index b7c8eb54c8eb67c8bcd3b8e14ce4e3228773e869..7d0469ca666487a7b60f89e18154611947cab1e2 100644 (file)
@@ -41,6 +41,9 @@
 
 #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)
 
@@ -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 )
index 3641ba9d592f978e8f87c5243df000762f2eeb74..85373efd445e591ed92df6a8e18ab5893a9e81aa 100644 (file)
@@ -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.