Salome HOME
Debug
[modules/smesh.git] / src / SMESH_I / SMESH_Mesh_i.cxx
index a9235af91d71eafdbc8f4ca1ab0a4f69dd9b7c63..a74ddb487b39cf2b97b4f26000a0d6a1567304b4 100644 (file)
@@ -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 );
 
@@ -3380,17 +3383,31 @@ void SMESH_Mesh_i::checkGroupNames()
 
 //=============================================================================
 /*!
- * \brief ...
+ * \brief Get internal entry of mesh
  */
 //=============================================================================
 char* SMESH_Mesh_i::GetEntry()
 {
-  return NULL;
+  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", anId );
+  return CORBA::string_dup( aBuf );
 }
 
 //=============================================================================
 /*!
- * \brief ...
+ * \brief Get name of the component
  */
 //=============================================================================
 char* SMESH_Mesh_i::GetComponent()
@@ -3400,7 +3417,7 @@ char* SMESH_Mesh_i::GetComponent()
 
 //=============================================================================
 /*!
- * \brief ...
+ * \brief Get validity status of mesh
  */
 //=============================================================================
 CORBA::Boolean SMESH_Mesh_i::IsValid()
@@ -3415,6 +3432,21 @@ CORBA::Boolean SMESH_Mesh_i::IsValid()
 //=============================================================================
 void SMESH_Mesh_i::SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters )
 {
+  theNotebook->ClearDependencies( _this(), SALOME::Parameters );
+  std::list<std::string> aParams;
+  int n = theParameters.length();
+  for( int i=0; i<n; i++ )
+  {
+    std::string aParam = CORBA::string_dup( theParameters[i] );
+    aParams.push_back( aParam );
+    
+    SALOME::Parameter_ptr aParamPtr = theNotebook->GetParameter( aParam.c_str() );
+    if( !CORBA::is_nil( aParamPtr ) )
+      theNotebook->AddDependency( _this(), aParamPtr );
+  }
+  _impl->SetParameters( aParams );
+
+  UpdateStringAttribute( theParameters );
 }
 
 //=============================================================================
@@ -3424,18 +3456,105 @@ void SMESH_Mesh_i::SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME
 //=============================================================================
 SALOME::StringArray* SMESH_Mesh_i::GetParameters()
 {
-  return NULL;
+  std::list<std::string> aParams = _impl->GetParameters();
+  SALOME::StringArray_var aRes = new SALOME::StringArray();
+  aRes->length( aParams.size() );
+  std::list<std::string>::const_iterator it = aParams.begin(), last = aParams.end();
+  for( int i=0; it!=last; it++, i++ )
+    aRes[i] = CORBA::string_dup( it->c_str() );
+  return aRes._retn();
 }
 
 //=============================================================================
 /*!
- * \brief ...
+ * \brief Update mesh according to the SALOME Notebook
  */
 //=============================================================================
 void SMESH_Mesh_i::Update( SALOME::Notebook_ptr theNotebook )
 {
 }
 
+//=============================================================================
+/*!
+ * \brief Update string attribute of mesh
+ */
+//=============================================================================
+void SMESH_Mesh_i::UpdateStringAttribute( const SALOME::StringArray& theParameters )
+{
+  // implementation of the method has been temporarily changed
+  // previous implementation can be found in revision 1.23.2.7.2.2.2.6
+  SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+
+  SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+  SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject( aStudy, SMESH::SMESH_Mesh::_narrow( _this() ) );
+  if( CORBA::is_nil( aSObject ) )
+    return;
+
+  SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute( aSObject, "AttributeString" );
+  SALOMEDS::AttributeString_var aStringAttrib = SALOMEDS::AttributeString::_narrow( anAttr );
+
+  std::string aCurrentString = aStringAttrib->Value();
+  std::string aString;
+  if( aCurrentString != "" )
+    aString = aCurrentString + "|";
+
+  for( int i = 0, n = theParameters.length(); i < n; i++ ) {
+    std::string aParameter = theParameters[i].in();
+    aString += aParameter;
+    if( i != n-1 )
+      aString += ":";
+  }
+
+  aStringAttrib->SetValue( aString.c_str() );
+  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