From: ouv Date: Mon, 21 Dec 2009 10:29:57 +0000 (+0000) Subject: Debug X-Git-Tag: PHASE_17_Part1_V4~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=da7d0ab212740fa475fdf77333aa20f9c547edac;p=modules%2Fsmesh.git Debug --- diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index a97fde5c2..3fad1a314 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -420,6 +420,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName myHypothesis_i = myHypCreatorMap[string(theHypName)]->Create(myPoa, GetCurrentStudyID(), &myGen); myHypothesis_i->SetLibName(aPlatformLibName/*theLibName*/); // for persistency assurance + myHypothesis_i->SetNotebook(GetNotebook(GetCurrentStudyID())); } catch (SALOME_Exception& S_ex) { @@ -456,7 +457,8 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh() // Get or create the GEOM_Client instance try { // create a new mesh object servant, store it in a map in study context - SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() ); + SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID(), + GetNotebook( GetCurrentStudyID() ) ); // create a new mesh object meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode )); @@ -607,6 +609,20 @@ SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy() return SALOMEDS::Study::_duplicate( myCurrentStudy ); } +//============================================================================= +/*! + * SMESH_Gen_i::GetStudyContext + * + * Get study context by study id + */ +//============================================================================= +StudyContext* SMESH_Gen_i::GetStudyContext( int theStudyId ) +{ + if ( myStudyContextMap.find( theStudyId ) != myStudyContextMap.end() ) + return myStudyContextMap[ theStudyId ]; + return 0; +} + //============================================================================= /*! * SMESH_Gen_i::GetCurrentStudyContext @@ -616,11 +632,9 @@ SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy() //============================================================================= StudyContext* SMESH_Gen_i::GetCurrentStudyContext() { - if ( !CORBA::is_nil( myCurrentStudy ) && - myStudyContextMap.find( GetCurrentStudyID() ) != myStudyContextMap.end() ) - return myStudyContextMap[ myCurrentStudy->StudyId() ]; - else - return 0; + if ( !CORBA::is_nil( myCurrentStudy ) ) + return GetStudyContext( GetCurrentStudyID() ); + return 0; } //============================================================================= @@ -4364,6 +4378,36 @@ SALOME::Notebook_ptr SMESH_Gen_i::GetNotebook( CORBA::Long theStudyID ) return aNotebook._retn(); } +//================================================================================= +// function : FindObjectByInternalEntry() +// purpose : +//================================================================================= +SALOME::GenericObj_ptr SMESH_Gen_i::FindObjectByInternalEntry( CORBA::Long theStudyID, const char* theEntry ) +{ + map::iterator it = myStudyContextMap.find( theStudyID ); + if ( it == myStudyContextMap.end() ) + return NULL; + + StudyContext* aStudyContext = it->second; + if ( !aStudyContext ) + return NULL; + + int id = atoi( theEntry ); + string anIOR = aStudyContext->getIORbyId( id ); + if ( !anIOR.empty() ) { + CORBA::Object_var anObject = GetORB()->string_to_object( anIOR.c_str() ); + if ( !CORBA::is_nil( anObject ) ) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); + if ( !aHyp->_is_nil() ) + return aHyp._retn(); + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( anObject ); + if ( !aMesh->_is_nil() ) + return aMesh._retn(); + } + } + return NULL; +} + //============================================================================= /*! * SMESHEngine_factory diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index 1a43e4b3e..fb0020799 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -102,7 +102,11 @@ public: } // maps old object id to the new one (used when restoring data) void mapOldToNew( const int oldId, const int newId ) { - mapIdToId[ oldId ] = newId; + if ( mapIdToIOR.find( newId ) != mapIdToIOR.end() ) { + mapIdToIOR[ oldId ] = mapIdToIOR[ newId ]; + mapIdToIOR.erase( newId ); + } + mapIdToId[ oldId ] = oldId; } // get old id by a new one int getOldId( const int newId ) { @@ -476,7 +480,10 @@ public: static void SetPixMap(SALOMEDS::SObject_ptr theSObject, const char* thePixMap); - // Get study context + // Get study context + StudyContext* GetStudyContext( int theStudyId ); + + // Get current study context StudyContext* GetCurrentStudyContext(); // Register an object in a StudyContext; return object id @@ -508,6 +515,8 @@ public: SALOMEDS::Study_ptr GetStudy(CORBA::Long theStudyID); SALOME::Notebook_ptr GetNotebook(CORBA::Long theStudyID); + virtual SALOME::GenericObj_ptr FindObjectByInternalEntry( CORBA::Long theStudyID, const char* theEntry ); + private: // Create hypothesis of given type SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName, diff --git a/src/SMESH_I/SMESH_Hypothesis_i.cxx b/src/SMESH_I/SMESH_Hypothesis_i.cxx index 6ff3ad77a..c90f693cf 100644 --- a/src/SMESH_I/SMESH_Hypothesis_i.cxx +++ b/src/SMESH_I/SMESH_Hypothesis_i.cxx @@ -42,7 +42,7 @@ using namespace std; //============================================================================= SMESH_Hypothesis_i::SMESH_Hypothesis_i( PortableServer::POA_ptr thePOA ) - : SALOME::GenericObj_i( thePOA ) + : SALOME_ParameterizedObject() { MESSAGE( "SMESH_Hypothesis_i::SMESH_Hypothesis_i / Début" ); myBaseImpl = 0; @@ -145,8 +145,23 @@ bool SMESH_Hypothesis_i::IsPublished(){ //============================================================================= char* SMESH_Hypothesis_i::GetEntry() { + int anId = 0; + SALOME::Notebook_ptr aNotebook = GetNotebook(); + if( !CORBA::is_nil( aNotebook ) ) + { + SALOMEDS::Study_ptr aStudy = aNotebook->GetStudy(); + if( SMESH_Gen_i* aGen = SMESH_Gen_i::GetSMESHGen() ) + { + if( StudyContext* aStudyContext = aGen->GetStudyContext( aStudy->StudyId() ) ) + { + CORBA::String_var anIOR = aGen->GetORB()->object_to_string( _this() ); + anId = aStudyContext->findId( anIOR.in() ); + } + } + } + char aBuf[100]; - sprintf( aBuf, "%i", GetId() ); + sprintf( aBuf, "%i", anId ); return CORBA::string_dup( aBuf ); } diff --git a/src/SMESH_I/SMESH_Hypothesis_i.hxx b/src/SMESH_I/SMESH_Hypothesis_i.hxx index 939c55c3a..3fc610788 100644 --- a/src/SMESH_I/SMESH_Hypothesis_i.hxx +++ b/src/SMESH_I/SMESH_Hypothesis_i.hxx @@ -34,7 +34,7 @@ #include CORBA_SERVER_HEADER(SMESH_Hypothesis) #include "SMESH_Hypothesis.hxx" -#include "SALOME_GenericObj_i.hh" +#include "SALOME_ParameterizedObject.hxx" #include "SMESH_Gen.hxx" @@ -43,7 +43,7 @@ // ====================================================== class SMESH_I_EXPORT SMESH_Hypothesis_i: public virtual POA_SMESH::SMESH_Hypothesis, - public virtual SALOME::GenericObj_i + public virtual SALOME_ParameterizedObject { public: // Constructor : placed in protected section to prohibit creation of generic class instance diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 01d394dcf..a74ddb487 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -96,8 +96,9 @@ int SMESH_Mesh_i::myIdGenerator = 0; SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA, SMESH_Gen_i* gen_i, - CORBA::Long studyId ) -: SALOME::GenericObj_i( thePOA ) + CORBA::Long studyId, + SALOME::Notebook_ptr theNotebook ) +: SALOME_ParameterizedObject( theNotebook ) { MESSAGE("SMESH_Mesh_i"); _impl = NULL; @@ -417,9 +418,11 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubS Unexpect aCatch(SALOME_SalomeException); SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShapeObject, anHyp ); - if ( !SMESH_Hypothesis::IsStatusFatal(status) ) + if ( !SMESH_Hypothesis::IsStatusFatal(status) ) { _gen_i->AddHypothesisToShape(_gen_i->GetCurrentStudy(), _this(), aSubShapeObject, anHyp ); + StoreDependencies( GetNotebook() ); + } if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status ); @@ -3385,8 +3388,20 @@ void SMESH_Mesh_i::checkGroupNames() //============================================================================= char* SMESH_Mesh_i::GetEntry() { + int anId = 0; + SALOME::Notebook_ptr aNotebook = GetNotebook(); + if( !CORBA::is_nil( aNotebook ) ) + { + SALOMEDS::Study_ptr aStudy = aNotebook->GetStudy(); + if( StudyContext* aStudyContext = GetGen()->GetStudyContext( aStudy->StudyId() ) ) + { + CORBA::String_var anIOR = GetGen()->GetORB()->object_to_string( _this() ); + anId = aStudyContext->findId( anIOR.in() ); + } + } + char aBuf[100]; - sprintf( aBuf, "%i", GetId() ); + sprintf( aBuf, "%i", anId ); return CORBA::string_dup( aBuf ); } @@ -3495,6 +3510,51 @@ void SMESH_Mesh_i::UpdateStringAttribute( const SALOME::StringArray& theParamete aStringAttrib->Destroy(); } +//============================================================================= +/*! + * \brief Internal method for storing dependencies for mesh + */ +//============================================================================= +void SMESH_Mesh_i::StoreDependenciesForShape( SALOME::Notebook_ptr theNotebook, + GEOM::GEOM_Object_ptr theShapeObject, + bool theIsStoreShape ) +{ + SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theShapeObject ); + for( int i = 0, n = aHypList->length(); i < n; i++ ) + { + SMESH::SMESH_Hypothesis_ptr aHypothesis = aHypList[i]; + if( CORBA::is_nil( aHypothesis ) ) + continue; + SMESH::SMESH_Algo_ptr anAlgo = SMESH::SMESH_Algo::_narrow( aHypothesis ); + if( !CORBA::is_nil( anAlgo ) ) // don't take into account algorithms + continue; + theNotebook->AddDependency( _this(), aHypothesis ); + } + + if( theIsStoreShape ) + theNotebook->AddDependency( _this(), theShapeObject ); +} + +//============================================================================= +/*! + * \brief Store dependencies for mesh + */ +//============================================================================= +void SMESH_Mesh_i::StoreDependencies( SALOME::Notebook_ptr theNotebook ) +{ + theNotebook->ClearDependencies( _this(), SALOME::Objects ); + + GEOM::GEOM_Object_ptr aShapeObject = GetShapeToMesh(); + StoreDependenciesForShape( theNotebook, aShapeObject, true ); + + std::map::iterator it = _mapSubMeshIor.begin(), itEnd = _mapSubMeshIor.end(); + for( ; it != itEnd; it++ ) { + SMESH::SMESH_subMesh_ptr aSubMesh = it->second; + GEOM::GEOM_Object_ptr aSubShape = aSubMesh->GetSubShape(); + StoreDependenciesForShape( theNotebook, aSubShape, false ); + } +} + //============================================================================= /*! * \brief Returns statistic of mesh elements diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index 13862b9a1..1f89035ae 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -41,7 +41,7 @@ //#include "SMESH_subMesh_i.hxx" #include "SMESH_subMesh.hxx" -#include "SALOME_GenericObj_i.hh" +#include "SALOME_ParameterizedObject.hxx" class SMESH_Gen_i; class SMESH_GroupBase_i; @@ -51,14 +51,15 @@ class SMESH_subMesh_i; class SMESH_I_EXPORT SMESH_Mesh_i: public virtual POA_SMESH::SMESH_Mesh, - public virtual SALOME::GenericObj_i + public virtual SALOME_ParameterizedObject { SMESH_Mesh_i(); SMESH_Mesh_i(const SMESH_Mesh_i&); public: SMESH_Mesh_i( PortableServer::POA_ptr thePOA, SMESH_Gen_i* myGen_i, - CORBA::Long studyId ); + CORBA::Long studyId, + SALOME::Notebook_ptr theNotebook ); virtual ~SMESH_Mesh_i(); @@ -506,6 +507,11 @@ public: */ virtual void UpdateStringAttribute( const SALOME::StringArray& theParameters ); + /*! + * Store dependencies for mesh + */ + virtual void StoreDependencies( SALOME::Notebook_ptr theNotebook ); + /*! * Returns statistic of mesh elements * Result array of number enityties @@ -529,6 +535,13 @@ private: */ void checkGroupNames(); + /*! + * Store dependencies for mesh + */ + virtual void StoreDependenciesForShape( SALOME::Notebook_ptr theNotebook, + GEOM::GEOM_Object_ptr theShapeObject, + bool theIsStoreShape ); + private: static int myIdGenerator;