From: Anthony Geay Date: Mon, 1 Feb 2021 14:15:38 +0000 (+0100) Subject: WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=87c2149a588c0448dd98db8a673f1d88cfa32620;p=modules%2Fsmesh.git WIP --- diff --git a/src/SMESH_I/SMESH_Gen_No_Session_i.cxx b/src/SMESH_I/SMESH_Gen_No_Session_i.cxx index 3c216192f..f4f1f7877 100644 --- a/src/SMESH_I/SMESH_Gen_No_Session_i.cxx +++ b/src/SMESH_I/SMESH_Gen_No_Session_i.cxx @@ -18,7 +18,7 @@ // #include "SMESH_Gen_No_Session_i.hxx" - +#include "SALOMEDS_Study_i.hxx" #include "SALOME_KernelServices.hxx" SMESH_Gen_No_Session_i::SMESH_Gen_No_Session_i( CORBA::ORB_ptr orb, @@ -36,3 +36,8 @@ GEOM::GEOM_Gen_var SMESH_Gen_No_Session_i::GetGeomEngine( bool isShaper ) myGeomGen = GEOM::GEOM_Gen::_narrow( temp ); return myGeomGen; } + +SALOMEDS::Study_var SMESH_Gen_No_Session_i::getStudyServant() const +{ + return SALOMEDS::Study::_duplicate(KERNEL::getStudyServantSA()); +} diff --git a/src/SMESH_I/SMESH_Gen_No_Session_i.hxx b/src/SMESH_I/SMESH_Gen_No_Session_i.hxx index f3fd462fb..da65157a8 100644 --- a/src/SMESH_I/SMESH_Gen_No_Session_i.hxx +++ b/src/SMESH_I/SMESH_Gen_No_Session_i.hxx @@ -30,4 +30,5 @@ public: const char* instanceName, const char* interfaceName); GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override; + SALOMEDS::Study_var getStudyServant() const override; }; diff --git a/src/SMESH_I/SMESH_Gen_Session_i.cxx b/src/SMESH_I/SMESH_Gen_Session_i.cxx index a9b4c6bb0..e15c8ea7e 100644 --- a/src/SMESH_I/SMESH_Gen_Session_i.cxx +++ b/src/SMESH_I/SMESH_Gen_Session_i.cxx @@ -18,7 +18,7 @@ // #include "SMESH_Gen_Session_i.hxx" - +#include "SALOME_KernelServices.hxx" #include "SALOME_LifeCycleCORBA.hxx" @@ -38,6 +38,11 @@ GEOM::GEOM_Gen_var SMESH_Gen_Session_i::GetGeomEngine( bool isShaper ) return myGeomGen; } +SALOMEDS::Study_var SMESH_Gen_Session_i::getStudyServant() const +{ + return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant()); +} + extern "C" { SMESH_I_EXPORT PortableServer::ObjectId* SMESHEngine_factory( CORBA::ORB_ptr orb, diff --git a/src/SMESH_I/SMESH_Gen_Session_i.hxx b/src/SMESH_I/SMESH_Gen_Session_i.hxx index 464d13d0e..4ce067823 100644 --- a/src/SMESH_I/SMESH_Gen_Session_i.hxx +++ b/src/SMESH_I/SMESH_Gen_Session_i.hxx @@ -30,4 +30,6 @@ public: const char* instanceName, const char* interfaceName); GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override; + // Get the SALOMEDS::Study from naming service + SALOMEDS::Study_var getStudyServant() const override; }; diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 23f735111..66f8570a3 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -812,7 +812,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam SALOMEDS::SObject_wrap aSO = PublishHypothesis( hyp ); if ( !aSO->_is_nil() ) { // Update Python script - TPythonDump() << aSO << " = " << this << ".CreateHypothesis('" + TPythonDump(this) << aSO << " = " << this << ".CreateHypothesis('" << theHypName << "', '" << theLibName << "')"; } } @@ -847,7 +847,7 @@ SMESH_Gen_i::CreateHypothesisByAverageLength( const char* theHypType, initParams ); SALOMEDS::SObject_wrap so = PublishHypothesis( hyp ); - TPythonDump() << hyp << " = " << this << ".CreateHypothesisByAverageLength( '" + TPythonDump(this) << hyp << " = " << this << ".CreateHypothesisByAverageLength( '" << theHypType << "', '" << theLibName << "', " << theAverageLength << ", " @@ -1202,7 +1202,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj aStudyBuilder->CommitCommand(); if ( !aSO->_is_nil() ) { // Update Python script - TPythonDump() << aSO << " = " << this << ".CreateMesh(" << theShapeObject << ")"; + TPythonDump(this) << aSO << " = " << this << ".CreateMesh(" << theShapeObject << ")"; } } @@ -1232,7 +1232,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateEmptyMesh() aStudyBuilder->CommitCommand(); if ( !aSO->_is_nil() ) { // Update Python script - TPythonDump() << aSO << " = " << this << ".CreateEmptyMesh()"; + TPythonDump(this) << aSO << " = " << this << ".CreateEmptyMesh()"; } } @@ -1286,7 +1286,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName aStudyBuilder->CommitCommand(); if ( !aSO->_is_nil() ) { // Update Python script - TPythonDump() << aSO << " = " << this << ".CreateMeshesFromUNV(r'" << theFileName << "')"; + TPythonDump(this) << aSO << " = " << this << ".CreateMeshesFromUNV(r'" << theFileName << "')"; } } @@ -1333,7 +1333,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileNa { // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups() // Python Dump - TPythonDump aPythonDump; + TPythonDump aPythonDump(this); aPythonDump << "(["; if (theStatus == SMESH::DRS_OK) { @@ -1483,7 +1483,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName aStudyBuilder->CommitCommand(); if ( !aSO->_is_nil() ) { // Update Python script - TPythonDump() << aSO << " = " << this << ".CreateMeshesFromSTL(r'" << theFileName << "')"; + TPythonDump(this) << aSO << " = " << this << ".CreateMeshesFromSTL(r'" << theFileName << "')"; } } @@ -1521,7 +1521,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char* { // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups() // Python Dump - TPythonDump aPythonDump; + TPythonDump aPythonDump(this); aPythonDump << "(["; if (theStatus == SMESH::DRS_OK) @@ -1609,7 +1609,7 @@ SMESH_Gen_i::CreateMeshesFromGMF( const char* theFileName, aStudyBuilder->CommitCommand(); if ( !aSO->_is_nil() ) { // Update Python script - TPythonDump() << "("<< aSO << ", error) = " << this << ".CreateMeshesFromGMF(r'" + TPythonDump(this) << "("<< aSO << ", error) = " << this << ".CreateMeshesFromGMF(r'" << theFileName << "', " << theMakeRequiredGroups << " )"; } @@ -1879,7 +1879,7 @@ SMESH_Gen_i::MakeGroupsOfBadInputElements( SMESH::SMESH_Mesh_ptr theMesh, if ( SMESH_Mesh_i* meshServant = SMESH::DownCast( theMesh )) { groups = meshServant->MakeGroupsOfBadInputElements( theSubShapeID, theGroupName ); - TPythonDump() << groups << " = " << this + TPythonDump(this) << groups << " = " << this << ".MakeGroupsOfBadInputElements( " << theMesh << ", " << theSubShapeID << ", '" << theGroupName << "' )"; } @@ -2049,7 +2049,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, SALOME::BAD_PARAM ); // Update Python script - TPythonDump() << "isDone = " << this << ".Compute( " + TPythonDump(this) << "isDone = " << this << ".Compute( " << theMesh << ", " << theShapeObject << ")"; try { @@ -2335,7 +2335,7 @@ SMESH::long_array* SMESH_Gen_i::Evaluate(SMESH::SMESH_Mesh_ptr theMesh, nbels[i] = 0; // Update Python script - TPythonDump() << "theNbElems = " << this << ".Evaluate( " + TPythonDump(this) << "theNbElems = " << this << ".Evaluate( " << theMesh << ", " << theShapeObject << ")"; try { @@ -2592,7 +2592,7 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::ListOfIDSources& theMeshesArray, CORBA::Boolean theCommonGroups, SMESH::SMESH_Mesh_ptr theMeshToAppendTo) { - std::unique_ptr< TPythonDump > pPythonDump( new TPythonDump ); + std::unique_ptr< TPythonDump > pPythonDump( new TPythonDump(this) ); TPythonDump& pythonDump = *pPythonDump; // prevent dump of called methods // create mesh if theMeshToAppendTo not provided @@ -2873,7 +2873,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CopyMesh(SMESH::SMESH_IDSource_ptr meshPart, { Unexpect aCatch(SALOME_SalomeException); - TPythonDump* pyDump = new TPythonDump; // prevent dump from CreateMesh() + TPythonDump* pyDump = new TPythonDump(this); // prevent dump from CreateMesh() std::unique_ptr pyDumpDeleter( pyDump ); // 1. Get source mesh @@ -3655,7 +3655,7 @@ CORBA::Boolean SMESH_Gen_i::CopyMeshWithGeom( SMESH::SMESH_Mesh_ptr theSou bool ok = true; SMESH_TRY; - TPythonDump pyDump; // prevent dump from CreateMesh() + TPythonDump pyDump(this); // prevent dump from CreateMesh() theNewMesh = CreateMesh( theNewGeometry ); theNewGroups = new SMESH::ListOfGroups(); @@ -4215,7 +4215,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, SMESH::SMESH_Mesh_var myMesh = SMESH::SMESH_Mesh::_narrow( anObject ) ; if ( !myMesh->_is_nil() ) { myMesh->Load(); // load from study file if not yet done - TPythonDump pd; // not to dump GetGroups() + TPythonDump pd(this); // not to dump GetGroups() SMESH::ListOfGroups_var groups = myMesh->GetGroups(); for ( CORBA::ULong i = 0; i < groups->length(); ++i ) { @@ -5211,7 +5211,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, return false; } - TPythonDump pd; // prevent dump during loading + TPythonDump pd(this); // prevent dump during loading // For PAL13473 ("Repetitive mesh") implementation. // New dependencies between SMESH objects are established: diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index f2c4c4801..580340ab9 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -109,14 +109,19 @@ public: // Retrieve and get GEOM engine reference virtual GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) = 0; static GEOM::GEOM_Gen_var GetGeomEngine( GEOM::GEOM_Object_ptr ); + // Retrieve Study depending on Session / Standalone mode + virtual SALOMEDS::Study_var getStudyServant() const = 0; + SALOMEDS::SObject_ptr publish(CORBA::Object_ptr theIOR, + SALOMEDS::SObject_ptr theFatherObject, + const int theTag = 0, + const char* thePixMap = 0, + const bool theSelectable = true); // Get object of the CORBA reference static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject ); // Get CORBA object corresponding to the SALOMEDS::SObject static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject ); // Get the SALOMEDS::SObject corresponding to a CORBA object - static SALOMEDS::SObject_ptr ObjectToSObject( CORBA::Object_ptr theObject ); - // Get the SALOMEDS::Study from naming service - static SALOMEDS::Study_var getStudyServant(); + SALOMEDS::SObject_ptr ObjectToSObject( CORBA::Object_ptr theObject ); // Get GEOM Object corresponding to TopoDS_Shape static GEOM::GEOM_Object_ptr ShapeToGeomObject( const TopoDS_Shape& theShape ); // Get TopoDS_Shape corresponding to GEOM_Object @@ -467,7 +472,7 @@ public: void CleanPythonTrace(); - static int CountInPyDump(const TCollection_AsciiString& text); + int CountInPyDump(const TCollection_AsciiString& text); // ***************************************** // Internal methods @@ -521,12 +526,12 @@ public: SMESH::SMESH_Hypothesis_ptr theHyp); SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh, GEOM::GEOM_Object_ptr theShape); - static void SetName(SALOMEDS::SObject_ptr theSObject, - const char* theName, - const char* theDefaultName = 0); + void SetName(SALOMEDS::SObject_ptr theSObject, + const char* theName, + const char* theDefaultName = 0); - static void SetPixMap(SALOMEDS::SObject_ptr theSObject, - const char* thePixMap); + void SetPixMap(SALOMEDS::SObject_ptr theSObject, const char *thePixMap); + void addReference (SALOMEDS::SObject_ptr theSObject, CORBA::Object_ptr theToObject, int theTag = 0); // Get study context StudyContext* GetStudyContext(); diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index a2577de8b..26946cc28 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -40,7 +40,6 @@ #include #include #include -#include "SALOMEDS_Study_i.hxx" #include "SALOME_KernelServices.hxx" #include "SALOME_ModuleCatalog_impl.hxx" @@ -211,15 +210,6 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(CORBA::Object_ptr theObject) return aSO._retn(); } -//======================================================================= -//function : GetStudyPtr -//purpose : Get study from naming service -//======================================================================= -SALOMEDS::Study_var SMESH_Gen_i::getStudyServant() -{ - return SALOMEDS::Study::_duplicate(KERNEL::getStudyServantSA()); -} - //======================================================================= //function : objectToServant //purpose : @@ -293,14 +283,14 @@ GEOM::GEOM_Object_ptr SMESH_Gen_i::GetGeomObjectByEntry( const std::string& entr //purpose : //======================================================================= -static SALOMEDS::SObject_ptr publish(CORBA::Object_ptr theIOR, +SALOMEDS::SObject_ptr SMESH_Gen_i::publish(CORBA::Object_ptr theIOR, SALOMEDS::SObject_ptr theFatherObject, - const int theTag = 0, - const char* thePixMap = 0, - const bool theSelectable = true) + const int theTag, + const char* thePixMap, + const bool theSelectable) { - SALOMEDS::Study_var theStudy = SMESH_Gen_i::getStudyServant(); - SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theIOR ); + SALOMEDS::Study_var theStudy = getStudyServant(); + SALOMEDS::SObject_wrap SO = ObjectToSObject( theIOR ); SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder(); bool isNewSO = false, isInUseCaseTree = false; @@ -441,9 +431,7 @@ void SMESH_Gen_i::SetPixMap(SALOMEDS::SObject_ptr theSObject, //purpose : //======================================================================= -static void addReference (SALOMEDS::SObject_ptr theSObject, - CORBA::Object_ptr theToObject, - int theTag = 0) +void SMESH_Gen_i::addReference (SALOMEDS::SObject_ptr theSObject, CORBA::Object_ptr theToObject, int theTag) { SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant(); SALOMEDS::SObject_wrap aToObjSO = SMESH_Gen_i::ObjectToSObject( theToObject ); diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index b5c003e4c..267c82b14 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -299,7 +299,7 @@ void SMESH_Mesh_i::Clear() THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); } - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".Clear()"; + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".Clear()"; SMESH::SMESH_Mesh_var mesh = _this(); _gen_i->UpdateIcons( mesh ); @@ -325,7 +325,7 @@ void SMESH_Mesh_i::ClearSubMesh(CORBA::Long ShapeID) } _impl->GetMeshDS()->Modified(); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ClearSubMesh( " << ShapeID << " )"; + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ClearSubMesh( " << ShapeID << " )"; } //============================================================================= @@ -661,7 +661,7 @@ SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubShape, if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status ); // Update Python script - TPythonDump() << "status = " << mesh << ".AddHypothesis( " + TPythonDump(_gen_i) << "status = " << mesh << ".AddHypothesis( " << aSubShape << ", " << anHyp << " )"; return ConvertHypothesisStatus(status); @@ -745,10 +745,10 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr } // Update Python script if(_impl->HasShapeToMesh()) - TPythonDump() << "status = " << mesh << ".RemoveHypothesis( " + TPythonDump(_gen_i) << "status = " << mesh << ".RemoveHypothesis( " << aSubShape << ", " << anHyp << " )"; else - TPythonDump() << "status = " << mesh << ".RemoveHypothesis( " + TPythonDump(_gen_i) << "status = " << mesh << ".RemoveHypothesis( " << anHyp << " )"; return ConvertHypothesisStatus(status); @@ -855,7 +855,7 @@ SMESH::submesh_array* SMESH_Mesh_i::GetSubMeshes() SMESH::submesh_array_var aList = new SMESH::submesh_array(); // Python Dump - TPythonDump aPythonDump; + TPythonDump aPythonDump(_gen_i); if ( !_mapSubMeshIor.empty() ) aPythonDump << "[ "; @@ -924,7 +924,7 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShap _gen_i->PublishSubMesh( aMesh, subMesh, aSubShape, theName ); if ( !aSO->_is_nil()) { // Update Python script - TPythonDump() << aSO << " = " << aMesh << ".GetSubMesh( " + TPythonDump(_gen_i) << aSO << " = " << aMesh << ".GetSubMesh( " << aSubShape << ", '" << theName << "' )"; } } @@ -967,7 +967,7 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh ) builder->RemoveObjectWithChildren( anSO ); // Update Python script - TPythonDump() << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )"; + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )"; } if ( removeSubMesh( theSubMesh, aSubShape.in() )) @@ -1000,7 +1000,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType _gen_i->PublishGroup( mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName); if ( !aSO->_is_nil()) // Update Python script - TPythonDump() << aSO << " = " << mesh << ".CreateGroup( " + TPythonDump(_gen_i) << aSO << " = " << mesh << ".CreateGroup( " << theElemType << ", '" << theName << "' )"; } return aNewGroup._retn(); @@ -1035,7 +1035,7 @@ SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementType theElemType, SALOMEDS::SObject_wrap aSO = _gen_i->PublishGroup( mesh, aNewGroup, theGeomObj, theName ); if ( !aSO->_is_nil()) - TPythonDump() << aSO << " = " << mesh << ".CreateGroupFromGEOM( " + TPythonDump(_gen_i) << aSO << " = " << mesh << ".CreateGroupFromGEOM( " << theElemType << ", '" << theName << "', " << theGeomObj << " )"; } } @@ -1072,7 +1072,7 @@ SMESH_Mesh_i::CreateGroupFromFilter(SMESH::ElementType theElemType, SMESH::SMESH_GroupOnFilter_var aNewGroup = SMESH::SMESH_GroupOnFilter::_narrow ( createGroup( theElemType, theName, /*id=*/-1, TopoDS_Shape(), predicate )); - TPythonDump pd; + TPythonDump pd(_gen_i); if ( !aNewGroup->_is_nil() ) aNewGroup->SetFilter( theFilter ); @@ -1114,10 +1114,10 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup ) if ( !aGroupSO->_is_nil() ) { // Update Python script - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )"; + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )"; // Remove group's SObject - SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder(); + SALOMEDS::StudyBuilder_var builder = _gen_i->getStudyServant()->NewBuilder(); builder->RemoveObjectWithChildren( aGroupSO ); } aGroup->Modified(/*removed=*/true); // notify dependent Filter with FT_BelongToMeshGroup criterion @@ -1165,7 +1165,7 @@ void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup std::vector< const SMDS_MeshElement* > elems( theGroup->Size() ); elems.assign( elemBeg, elemEnd ); - TPythonDump pyDump; // Suppress dump from RemoveGroup() + TPythonDump pyDump(_gen_i); // Suppress dump from RemoveGroup() // Remove group RemoveGroup( theGroup ); @@ -1219,7 +1219,7 @@ SMESH::ListOfGroups * SMESH_Mesh_i::GetGroups() SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups(); // Python Dump - TPythonDump aPythonDump; + TPythonDump aPythonDump(_gen_i); if ( !_mapGroups.empty() ) { aPythonDump << "[ "; @@ -1278,7 +1278,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the if ( theGroup1->GetType() != theGroup2->GetType() ) THROW_SALOME_CORBA_EXCEPTION("UnionGroups(): different group types", SALOME::BAD_PARAM); - TPythonDump pyDump; + TPythonDump pyDump(_gen_i); // Create Union aResGrp = CreateGroup( theGroup1->GetType(), theName ); @@ -1335,7 +1335,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionListOfGroups(const SMESH::ListOfGroups if ( aType == SMESH::ALL ) return SMESH::SMESH_Group::_nil(); - TPythonDump pyDump; + TPythonDump pyDump(_gen_i); // Create Union aResGrp = CreateGroup( aType, theName ); @@ -1384,7 +1384,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr if ( theGroup1->GetType() != theGroup2->GetType() ) THROW_SALOME_CORBA_EXCEPTION("IntersectGroups(): different group types", SALOME::BAD_PARAM); - TPythonDump pyDump; + TPythonDump pyDump(_gen_i); // Create Intersection aResGrp = CreateGroup( theGroup1->GetType(), theName ); @@ -1474,7 +1474,7 @@ SMESH_Mesh_i::IntersectListOfGroups(const SMESH::ListOfGroups& theGroups, if ( aType == SMESH::ALL ) // all groups are nil return SMESH::SMESH_Group::_nil(); - TPythonDump pyDump; + TPythonDump pyDump(_gen_i); // Create a group aResGrp = CreateGroup( aType, theName ); @@ -1532,7 +1532,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr if ( theGroup1->GetType() != theGroup2->GetType() ) THROW_SALOME_CORBA_EXCEPTION("CutGroups(): different group types", SALOME::BAD_PARAM); - TPythonDump pyDump; + TPythonDump pyDump(_gen_i); aResGrp = CreateGroup( theGroup1->GetType(), theName ); if ( aResGrp->_is_nil() ) @@ -1633,7 +1633,7 @@ SMESH_Mesh_i::CutListOfGroups(const SMESH::ListOfGroups& theMainGroups, toolGroupVec.push_back( grpDS ); } - TPythonDump pyDump; + TPythonDump pyDump(_gen_i); // Create a group aResGrp = CreateGroup( aType, theName ); @@ -1743,7 +1743,7 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfIDSources& theGroups, // Create a group - TPythonDump pyDump; + TPythonDump pyDump(_gen_i); aResGrp = CreateGroup( theElemType, theName ); if ( aResGrp->_is_nil() ) @@ -1903,7 +1903,7 @@ SMESH_Mesh_i::FaceGroupsSeparatedByEdges( CORBA::Double theSharpAngle, SMESH::ListOfGroups_var resultGroups = new SMESH::ListOfGroups; - TPythonDump pyDump; + TPythonDump pyDump(_gen_i); SMESH_TRY; if ( _preMeshInfo ) @@ -2159,10 +2159,10 @@ void SMESH_Mesh_i::ReplaceShape(GEOM::GEOM_Object_ptr theNewGeom) _gen_i->UpdateIcons( SMESH::SMESH_Mesh_var( _this() )); } - TPythonDump() << "SHAPERSTUDY.breakLinkForSubElements(salome.ObjectToSObject(" + TPythonDump(_gen_i) << "SHAPERSTUDY.breakLinkForSubElements(salome.ObjectToSObject(" << me <<".GetMesh()), " << entry.in() << ")"; - TPythonDump() << me << ".ReplaceShape( " << entry.in() << " )"; + TPythonDump(_gen_i)<< me << ".ReplaceShape( " << entry.in() << " )"; } @@ -2350,7 +2350,7 @@ void SMESH_Mesh_i::CheckGeomModif( bool theIsBreakLink ) SMESH::SMESH_Mesh_var me = _this(); GEOM::GEOM_Object_var mainGO = GetShapeToMesh(); - TPythonDump dumpNothing; // prevent any dump + TPythonDump dumpNothing(_gen_i); // prevent any dump //bool removedFromClient = false; @@ -3055,7 +3055,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase SALOMEDS::StudyBuilder_var builder; SALOMEDS::SObject_wrap aGroupSO; - SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant(); + SALOMEDS::Study_var aStudy = _gen_i->getStudyServant(); if ( !aStudy->_is_nil() ) { builder = aStudy->NewBuilder(); aGroupSO = _gen_i->ObjectToSObject( theGroup ); @@ -3070,7 +3070,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase builder->RemoveObject( so ); } // Update Python script - TPythonDump() << aGroupSO << " = " << SMESH::SMESH_Mesh_var(_this()) + TPythonDump(_gen_i) << aGroupSO << " = " << SMESH::SMESH_Mesh_var(_this()) << ".ConvertToStandalone( " << aGroupSO << " )"; // change icon of Group on Filter @@ -3510,7 +3510,7 @@ SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor() aMeshEdVar = _editor->_this(); // Update Python script - TPythonDump() << _editor << " = " + TPythonDump(_gen_i) << _editor << " = " << SMESH::SMESH_Mesh_var(_this()) << ".GetMeshEditor()"; SMESH_CATCH( SMESH::throwCorbaException ); @@ -3601,7 +3601,7 @@ void SMESH_Mesh_i::SetAutoColor(CORBA::Boolean theAutoColor) Unexpect aCatch(SALOME_SalomeException); _impl->SetAutoColor(theAutoColor); - TPythonDump pyDump; // not to dump group->SetColor() from below code + TPythonDump pyDump(_gen_i); // not to dump group->SetColor() from below code pyDump << SMESH::SMESH_Mesh_var(_this()) <<".SetAutoColor( "< aReservedColors; @@ -3693,7 +3693,7 @@ string SMESH_Mesh_i::prepareMeshNameAndGroups(const char* file, // Perform Export PrepareForWriting(file, overwrite); string aMeshName = "Mesh"; - SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant(); + SALOMEDS::Study_var aStudy = _gen_i->getStudyServant(); if ( !aStudy->_is_nil() ) { SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( _this() ); if ( !aMeshSO->_is_nil() ) { @@ -3717,7 +3717,7 @@ string SMESH_Mesh_i::prepareMeshNameAndGroups(const char* file, } // Update Python script // set name of mesh before export - TPythonDump() << _gen_i << ".SetName(" + TPythonDump(_gen_i) << _gen_i << ".SetName(" << SMESH::SMESH_Mesh_var(_this()) << ", '" << aMeshName.c_str() << "')"; // check names of groups @@ -3746,7 +3746,7 @@ void SMESH_Mesh_i::ExportMED(const char* file, string aMeshName = prepareMeshNameAndGroups(file, overwrite); _impl->ExportMED( file, aMeshName.c_str(), auto_groups, version, 0, autoDimension ); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'" + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'" << file << "', " << "auto_groups=" <FullLoadFromFile(); string aMeshName = prepareMeshNameAndGroups(file, true); - TPythonDump() << SMESH::SMESH_Mesh_var( _this()) + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var( _this()) << ".ExportSAUV( r'" << file << "', " << auto_groups << " )"; _impl->ExportSAUV(file, aMeshName.c_str(), auto_groups); } @@ -3792,7 +3792,7 @@ void SMESH_Mesh_i::ExportDAT (const char *file) // Update Python script // check names of groups checkGroupNames(); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportDAT( r'" << file << "' )"; + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportDAT( r'" << file << "' )"; // Perform Export PrepareForWriting(file); @@ -3814,7 +3814,7 @@ void SMESH_Mesh_i::ExportUNV (const char *file) // Update Python script // check names of groups checkGroupNames(); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportUNV( r'" << file << "' )"; + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportUNV( r'" << file << "' )"; // Perform Export PrepareForWriting(file); @@ -3836,7 +3836,7 @@ void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii) // Update Python script // check names of groups checkGroupNames(); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportSTL( r'" << file << "', " << isascii << " )"; CORBA::String_var name; @@ -3956,7 +3956,7 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, GEOM::GEOM_BaseObject_var gbo = GEOM::GEOM_BaseObject::_narrow( fields[i] ); goList[i] = gbo; } - TPythonDump() << _this() << ".ExportPartToMED( " + TPythonDump(_gen_i) << _this() << ".ExportPartToMED( " << meshPart << ", r'" << file << "', " << auto_groups << ", " @@ -4258,7 +4258,7 @@ void SMESH_Mesh_i::ExportPartToDAT(::SMESH::SMESH_IDSource_ptr meshPart, SMESH_MeshPartDS partDS( meshPart ); _impl->ExportDAT(file,&partDS); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportPartToDAT( " << meshPart << ", r'" << file << "' )"; } //================================================================================ @@ -4279,7 +4279,7 @@ void SMESH_Mesh_i::ExportPartToUNV(::SMESH::SMESH_IDSource_ptr meshPart, SMESH_MeshPartDS partDS( meshPart ); _impl->ExportUNV(file, &partDS); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportPartToUNV( " << meshPart<< ", r'" << file << "' )"; } //================================================================================ @@ -4306,7 +4306,7 @@ void SMESH_Mesh_i::ExportPartToSTL(::SMESH::SMESH_IDSource_ptr meshPart, SMESH_MeshPartDS partDS( meshPart ); _impl->ExportSTL( file, isascii, name.in(), &partDS ); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportPartToSTL( " + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportPartToSTL( " << meshPart<< ", r'" << file << "', " << isascii << ")"; } @@ -4342,7 +4342,7 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart, SMESH_CATCH( SMESH::throwCorbaException ); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportCGNS( " + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportCGNS( " << meshPart<< ", r'" << file << "', " << overwrite << ")"; #else THROW_SALOME_CORBA_EXCEPTION("CGNS library is unavailable", SALOME::INTERNAL_ERROR); @@ -4368,7 +4368,7 @@ void SMESH_Mesh_i::ExportGMF(::SMESH::SMESH_IDSource_ptr meshPart, SMESH_MeshPartDS partDS( meshPart ); _impl->ExportGMF(file, &partDS, withRequiredGroups); - TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportGMF( " + TPythonDump(_gen_i) << SMESH::SMESH_Mesh_var(_this()) << ".ExportGMF( " << meshPart<< ", r'" << file << "', " << withRequiredGroups << ")"; @@ -5786,7 +5786,7 @@ void SMESH_Mesh_i::CreateGroupServants() set::iterator it = addedIDs.find( i_grp->first ); if ( it != addedIDs.end() ) { - TPythonDump() << i_grp->second << " = " << aMesh << ".GetGroups()[ "<< index << " ]"; + TPythonDump(_gen_i) << i_grp->second << " = " << aMesh << ".GetGroups()[ "<< index << " ]"; addedIDs.erase( it ); if ( addedIDs.empty() ) break; @@ -5904,7 +5904,7 @@ void SMESH_Mesh_i::checkGroupNames() // avoid dump of "GetGroups" { // store python dump into a local variable inside local scope - SMESH::TPythonDump pDump; // do not delete this line of code + SMESH::TPythonDump pDump(_gen_i); // do not delete this line of code grpList = GetGroups(); } @@ -5955,7 +5955,7 @@ SMESH::string_array* SMESH_Mesh_i::GetLastParameters() SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); if(gen) { CORBA::String_var aParameters = GetParameters(); - SALOMEDS::ListOfListOfStrings_var aSections = SMESH_Gen_i::getStudyServant()->ParseVariables(aParameters); + SALOMEDS::ListOfListOfStrings_var aSections = _gen_i->getStudyServant()->ParseVariables(aParameters); if ( aSections->length() > 0 ) { SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ]; aResult->length( aVars.length() ); @@ -6824,7 +6824,7 @@ TListOfListOfInt SMESH_Mesh_i::findConcurrentSubMeshes() bool res = false; ::SMESH_Mesh& mesh = GetImpl(); - TPythonDump aPythonDump; // prevent dump of called methods + TPythonDump aPythonDump(_gen_i); // prevent dump of called methods aPythonDump << "isDone = " << SMESH::SMESH_Mesh_var(_this()) << ".SetMeshOrder( [ "; TListOfListOfInt subMeshOrder; @@ -6886,7 +6886,7 @@ void SMESH_Mesh_i::convertMeshOrder (const TListOfListOfInt& theIdsOrder, const bool theIsDump) { int nbSet = theIdsOrder.size(); - TPythonDump aPythonDump; // prevent dump of called methods + TPythonDump aPythonDump(_gen_i); // prevent dump of called methods if ( theIsDump ) aPythonDump << "[ "; theResOrder.length(nbSet); diff --git a/src/SMESH_I/SMESH_PythonDump.cxx b/src/SMESH_I/SMESH_PythonDump.cxx index 3ecff6184..1ac3511b5 100644 --- a/src/SMESH_I/SMESH_PythonDump.cxx +++ b/src/SMESH_I/SMESH_PythonDump.cxx @@ -69,8 +69,7 @@ namespace SMESH myVals[i] = SMESH_Comment(value[i]); } - TPythonDump:: - TPythonDump():myVarsCounter(0) + TPythonDump::TPythonDump(SMESH_Gen_i *smesh):myVarsCounter(0),mySmesh(smesh) { ++myCounter; } @@ -304,7 +303,7 @@ namespace SMESH operator<<(CORBA::Object_ptr theArg) { SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg); + SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg); if(!aSObject->_is_nil()) { CORBA::String_var id = aSObject->GetID(); myStream << id; @@ -323,7 +322,7 @@ namespace SMESH TPythonDump:: operator<<(SMESH::SMESH_Hypothesis_ptr theArg) { - SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg); + SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg); if(aSObject->_is_nil() && !CORBA::is_nil(theArg)) myStream << "hyp_" << theArg->GetId(); else @@ -337,7 +336,7 @@ namespace SMESH { if ( CORBA::is_nil( theArg ) ) return *this << "None"; - SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg); + SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg); if(!aSObject->_is_nil()) { return *this << aSObject; @@ -352,7 +351,7 @@ namespace SMESH SMESH::long_array_var anElementsId = theArg->GetIDs(); SMESH::array_of_ElementType_var types = theArg->GetTypes(); SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL; - SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(mesh); + SALOMEDS::SObject_wrap meshSO = mySmesh->ObjectToSObject(mesh); if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects return *this << mesh << ".GetIDSource([], " << type << ")"; else diff --git a/src/SMESH_I/SMESH_PythonDump.hxx b/src/SMESH_I/SMESH_PythonDump.hxx index 1025f4cf8..9d5138c5e 100644 --- a/src/SMESH_I/SMESH_PythonDump.hxx +++ b/src/SMESH_I/SMESH_PythonDump.hxx @@ -121,8 +121,9 @@ namespace SMESH std::ostringstream myStream; static size_t myCounter; int myVarsCounter; // counts stored TVar's + SMESH_Gen_i *mySmesh = nullptr; public: - TPythonDump(); + TPythonDump(SMESH_Gen_i *smesh); virtual ~TPythonDump(); TPythonDump&