]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #482: new function for export calculation case
authorasl <asl@opencascade.com>
Tue, 28 Oct 2014 06:40:40 +0000 (06:40 +0000)
committerasl <asl@opencascade.com>
Tue, 28 Oct 2014 06:40:40 +0000 (06:40 +0000)
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx
src/HYDROPy/HYDROData_CalculationCase.sip

index 4a5d2fe67cf589a1656f4842ffef72f39565bf47..5c5760130d4124f270dfc528dd99a1e8612f68f8 100644 (file)
 
 #define EXPORT_NAME "HYDRO_" + GetName()
 
+#include <SALOME_NamingService.hxx>
+#include <SALOME_LifeCycleCORBA.hxx>
+
+
+
+
+
 IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity)
 
@@ -852,8 +859,28 @@ Handle(HYDROData_SplittedShapesGroup) HYDROData_CalculationCase::addNewSplittedG
   return aNewGroup;
 }
 
+QString HYDROData_CalculationCase::Export( int theStudyId ) const
+{
+  int argc = 0;
+  char** argv = 0;
+  CORBA::ORB_var anORB = CORBA::ORB_init( argc, argv, "omniORB4"/*CORBA::ORB_ID*/ );
+  SALOME_NamingService aNameService( anORB );
+  SALOME_LifeCycleCORBA aLCC( &aNameService );
+  Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component( "FactoryServer", "GEOM" );
+  GEOM::GEOM_Gen_var aGEOMEngine = GEOM::GEOM_Gen::_narrow( aComponent );
+  
+  CORBA::Object_var aSMObject = aNameService.Resolve("/myStudyManager");
+  SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
+  SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID( theStudyId );
+
+  QString aGeomObjEntry;
+  bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry );
+  return isOK ? aGeomObjEntry : QString();
+}
+
 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
-                                        SALOMEDS::Study_ptr theStudy ) const
+                                        SALOMEDS::Study_ptr theStudy,
+                                        QString& theGeomObjEntry ) const
 {
   HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs;
 
@@ -892,13 +919,14 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
     aFaces.Append( aRegionShape );
   }
 
-  return Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs );
+  return Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry );
 }
 
 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var                            theGeomEngine,
                                         SALOMEDS::Study_ptr                           theStudy,
                                         const TopTools_ListOfShape&                   theFaces,
-                                        const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs ) const
+                                        const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
+                                        QString& theGeomObjEntry ) const
 {
   // Sew faces
   BRepBuilderAPI_Sewing aSewing( Precision::Confusion() * 10.0 );
@@ -952,7 +980,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var
   // Publish the sewed shape
   QString aName = EXPORT_NAME;
   GEOM::GEOM_Object_ptr aMainShape = 
-    publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName );
+    publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName, theGeomObjEntry );
 
   if ( aMainShape->_is_nil() )  
     return false;
@@ -1051,8 +1079,10 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var
 
 GEOM::GEOM_Object_ptr HYDROData_CalculationCase::publishShapeInGEOM( 
   GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy,
-  const TopoDS_Shape& theShape, const QString& theName ) const
+  const TopoDS_Shape& theShape, const QString& theName,
+  QString& theGeomObjEntry ) const
 {
+  theGeomObjEntry = "";
   GEOM::GEOM_Object_var aGeomObj;
 
   if ( theGeomEngine->_is_nil() || theStudy->_is_nil() ||
@@ -1086,6 +1116,8 @@ GEOM::GEOM_Object_ptr HYDROData_CalculationCase::publishShapeInGEOM(
     if ( aResultSO->_is_nil() ) {
       aGeomObj = GEOM::GEOM_Object::_nil();
     }
+    else
+      theGeomObjEntry = aResultSO->GetID();
   }
 
   return aGeomObj._retn();
index a47afd74d100f78ea8c460052d5e754fd6f9c5c5..8104fbb261ab4b664ef431e9ae9ff1572c222864 100644 (file)
@@ -207,6 +207,12 @@ public:
    */
   HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
 
+  /**
+   * Exports the calculation case data (shell and groups) to GEOM module.
+   * \param theStudyId the id of the study where the GEOM module should be used for export
+   * \return the entry of the GEOM object (empty string in the case of error)
+   */
+  HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
 
   /**
    * Exports the calculation case data (shell and groups) to GEOM module.
@@ -215,7 +221,8 @@ public:
    * \return true in case of success
    */
   HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var  theGeomEngine,
-                                        SALOMEDS::Study_ptr theStudy ) const;
+                                        SALOMEDS::Study_ptr theStudy,
+                                        QString& theGeomObjEntry ) const;
 
 public:      
   // Public methods to work with Calculation services
@@ -333,7 +340,8 @@ private:
   bool Export( GEOM::GEOM_Gen_var                            theGeomEngine,
                SALOMEDS::Study_ptr                           theStudy,
                const TopTools_ListOfShape&                   theFaces,
-               const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs ) const;
+               const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
+               QString& theGeomObjEntry ) const;
 
   /**
    * Publish the given shape in GEOM as a GEOM object.
@@ -346,7 +354,8 @@ private:
   GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var  theGeomEngine,
                                             SALOMEDS::Study_ptr theStudy,
                                             const TopoDS_Shape& theShape, 
-                                            const QString&      theName ) const;
+                                            const QString&      theName,
+                                            QString& theGeomObjEntry ) const;
 
   void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
                          const HYDROData_SplitToZonesTool::SplitDataList& theZones );
index d91522bbe093b1b6dc28b9f2b7e710c037949675..f5128a9b1df2befd1c3f40b208d3e77329a9de69 100644 (file)
@@ -91,7 +91,8 @@ bool HYDROGUI_ExportCalculationOp::processApply( int& theUpdateFlags,
   if ( aStudy ) {
     SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
     GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
-    if ( aCalculation->Export( aGeomEngine, aDSStudy ) ) {
+    QString anEntry;
+    if ( aCalculation->Export( aGeomEngine, aDSStudy, anEntry ) ) {
       theUpdateFlags = UF_ObjBrowser;
       isOk = true;
     }
index fc09eeb1b535a23e9cb92729c517e58e7fa46fbc..6bcfe0d244d1619abc0de70860e02217b9d7402f 100644 (file)
@@ -293,6 +293,8 @@ public:
    */
 //TODO:  virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
 //                       SALOMEDS::Study_ptr theStudy );
+       
+       QString Export( int theStudyId ) const;
 
 public:      
   // Public methods to work with Calculation services