From d4764b46c066db8e7989b727f5bb96f118ac10e3 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Wed, 10 Jul 2019 10:13:18 +0200 Subject: [PATCH] add a Python function to change the container name to use for GEOM: parametric and/or distributed studies with HYDRO --- src/HYDROData/HYDROData_CalculationCase.cxx | 7 +++++++ src/HYDROData/HYDROData_CalculationCase.h | 7 +++++++ src/HYDROData/HYDROData_GeomTool.cxx | 11 +++++++++-- src/HYDROData/HYDROData_GeomTool.h | 9 +++++++++ src/HYDROPy/HYDROData_CalculationCase.sip | 6 ++++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index e6a640f6..80d85921 100755 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -1290,6 +1290,13 @@ Handle(HYDROData_SplitShapesGroup) HYDROData_CalculationCase::addNewSplitGroup( return aNewGroup; } +void HYDROData_CalculationCase::SetContainerName( const QString& theContainerName ) +{ +#ifndef LIGHT_MODE + HYDROData_GeomTool::SetContainerName( theContainerName ); +#endif +} + QString HYDROData_CalculationCase::Export() const { #ifdef LIGHT_MODE diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index 5ac3d069..479e49e5 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -285,6 +285,13 @@ public: HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetBoundaryPolygons() const; + /** + * \brief Set the Container Name to use when not default (FactoryServer). + * \param theContainerName the name of the container used for GEOM + * (to be used by scripts for distributed execution) + */ + HYDRODATA_EXPORT virtual void SetContainerName( const QString& theContainerName ); + /** * Exports the calculation case data (shell and groups) to GEOM module. * \return the entry of the GEOM object (empty string in the case of error) diff --git a/src/HYDROData/HYDROData_GeomTool.cxx b/src/HYDROData/HYDROData_GeomTool.cxx index 23c7b9a8..54273a42 100644 --- a/src/HYDROData/HYDROData_GeomTool.cxx +++ b/src/HYDROData/HYDROData_GeomTool.cxx @@ -49,6 +49,13 @@ static SALOME_NamingService _NS( _ORB ); static SALOME_LifeCycleCORBA _LCC( &_NS ); static SALOMEDS::Study_var _STUDY = SALOMEDS::Study::_nil(); +QString HYDROData_GeomTool::myContainerName = "FactoryServer"; + +void HYDROData_GeomTool::SetContainerName( const QString& theContainerName ) +{ + myContainerName = theContainerName; +} + TopoDS_Shape HYDROData_GeomTool::GetShapeFromIOR( const QString& theIOR ) { // Note that GEOMBase::GetShape() cause crash in batch mode @@ -60,7 +67,7 @@ TopoDS_Shape HYDROData_GeomTool::GetShapeFromIOR( const QString& theIOR ) GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( aCorbaObj ); Engines::EngineComponent_var aComp = - _LCC.FindOrLoad_Component( "FactoryServer", "GEOM" ); + _LCC.FindOrLoad_Component( myContainerName.toStdString().c_str(), "GEOM" ); GEOM::GEOM_Gen_var aComponentGeom = GEOM::GEOM_Gen::_narrow( aComp ); aResShape = GEOM_Client::get_client().GetShape( aComponentGeom, aGeomObj ); @@ -71,7 +78,7 @@ TopoDS_Shape HYDROData_GeomTool::GetShapeFromIOR( const QString& theIOR ) GEOM::GEOM_Gen_var HYDROData_GeomTool::GetGeomGen() { - Engines::EngineComponent_var aComponent = _LCC.FindOrLoad_Component( "FactoryServer", "GEOM" ); + Engines::EngineComponent_var aComponent = _LCC.FindOrLoad_Component( myContainerName.toStdString().c_str(), "GEOM" ); GEOM::GEOM_Gen_var aGEOMEngine = GEOM::GEOM_Gen::_narrow( aComponent ); return aGEOMEngine._retn(); diff --git a/src/HYDROData/HYDROData_GeomTool.h b/src/HYDROData/HYDROData_GeomTool.h index 419c49c6..9f7d85ff 100644 --- a/src/HYDROData/HYDROData_GeomTool.h +++ b/src/HYDROData/HYDROData_GeomTool.h @@ -41,6 +41,13 @@ class HYDRODATA_EXPORT HYDROData_GeomTool { public: + /** + * \brief Set the Container Name to use when not default (FactoryServer). + * \param theContainerName the name of the container used for GEOM + * (to be used by scripts for distributed execution) + */ + static void SetContainerName( const QString& theContainerName ); + /** * \brief Get shape by the specified IOR. * \param theIOR the GEOM object IOR @@ -112,6 +119,8 @@ public: const QString& theName, QString& theGeomObjEntry); +protected: + static QString myContainerName; }; #endif diff --git a/src/HYDROPy/HYDROData_CalculationCase.sip b/src/HYDROPy/HYDROData_CalculationCase.sip index 10532be6..b46ac06e 100644 --- a/src/HYDROPy/HYDROData_CalculationCase.sip +++ b/src/HYDROPy/HYDROData_CalculationCase.sip @@ -374,6 +374,12 @@ public: */ void RemoveSplitGroups(); + /** + * \brief Set the Container Name to use when not default (FactoryServer). + * \param theContainerName the name of the container used for GEOM + * (to be used by scripts for distributed execution) + */ + void SetContainerName( const QString& theContainerName ); /** * Exports the calculation case data (shell and groups) to GEOM module. -- 2.39.2