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)
{
// 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 ));
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
//=============================================================================
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;
}
//=============================================================================
return aNotebook._retn();
}
+//=================================================================================
+// function : FindObjectByInternalEntry()
+// purpose :
+//=================================================================================
+SALOME::GenericObj_ptr SMESH_Gen_i::FindObjectByInternalEntry( CORBA::Long theStudyID, const char* theEntry )
+{
+ map<int, StudyContext*>::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
}
// 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 ) {
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
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,
//=============================================================================
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;
//=============================================================================
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 );
}
#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
#include "SMESH_Hypothesis.hxx"
-#include "SALOME_GenericObj_i.hh"
+#include "SALOME_ParameterizedObject.hxx"
#include "SMESH_Gen.hxx"
// ======================================================
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
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;
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 );
//=============================================================================
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 );
}
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<int, SMESH::SMESH_subMesh_ptr>::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
//#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;
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();
*/
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
*/
void checkGroupNames();
+ /*!
+ * Store dependencies for mesh
+ */
+ virtual void StoreDependenciesForShape( SALOME::Notebook_ptr theNotebook,
+ GEOM::GEOM_Object_ptr theShapeObject,
+ bool theIsStoreShape );
+
private:
static int myIdGenerator;