From: asl Date: Tue, 28 Oct 2014 06:40:40 +0000 (+0000) Subject: refs #482: new function for export calculation case X-Git-Tag: BR_hydro_v_1_0_4~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f217128f8d34b2082de78d2af90bf243bf9e8b1;p=modules%2Fhydro.git refs #482: new function for export calculation case --- diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 4a5d2fe6..5c576013 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -48,6 +48,13 @@ #define EXPORT_NAME "HYDRO_" + GetName() +#include +#include + + + + + 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(); diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index a47afd74..8104fbb2 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -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 ); diff --git a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx index d91522bb..f5128a9b 100644 --- a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx @@ -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; } diff --git a/src/HYDROPy/HYDROData_CalculationCase.sip b/src/HYDROPy/HYDROData_CalculationCase.sip index fc09eeb1..6bcfe0d2 100644 --- a/src/HYDROPy/HYDROData_CalculationCase.sip +++ b/src/HYDROPy/HYDROData_CalculationCase.sip @@ -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