Salome HOME
Merge multi-study removal branch.
[modules/smesh.git] / src / SMESH_I / SMESH_PreMeshInfo.cxx
index 3d8980ff9a3751a9efc1b144ceb9b4ba705bcf1d..e11046e1b4a459a0c4b8e4fc322abfc3ad288378 100644 (file)
@@ -63,8 +63,8 @@ namespace
 {
   enum {  GroupOnFilter_OutOfDate = -1 };
 
-  // a map to count not yet loaded meshes 
-  static std::map< int, int > theStudyIDToMeshCounter;
+  // count not yet loaded meshes
+  static int theMeshCounter = 0;
 
   //================================================================================
   /*!
@@ -74,9 +74,7 @@ namespace
 
   void meshInfoLoaded( SMESH_Mesh_i* mesh )
   {
-    std::map< int, int >::iterator id2counter =
-      theStudyIDToMeshCounter.insert( std::make_pair( (int) mesh->GetStudyId(), 0 )).first;
-    id2counter->second++;
+    theMeshCounter++;
   }
   //================================================================================
   /*!
@@ -88,18 +86,18 @@ namespace
                          std::string   medFile,
                          std::string   hdfFile)
   {
-    if ( --theStudyIDToMeshCounter[ (int) mesh->GetStudyId() ] == 0 )
+    if ( --theMeshCounter == 0 )
     {
       std::string tmpDir = SALOMEDS_Tool::GetDirFromPath( hdfFile );
 
-      SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
-      aFiles->length(2);
+      SALOMEDS_Tool::ListOfFiles aFiles;
+      aFiles.reserve(2);
       medFile = SALOMEDS_Tool::GetNameFromPath( medFile ) + ".med";
       hdfFile = SALOMEDS_Tool::GetNameFromPath( hdfFile ) + ".hdf";
-      aFiles[0] = medFile.c_str();
-      aFiles[1] = hdfFile.c_str();
+      aFiles.push_back(medFile.c_str());
+      aFiles.push_back(hdfFile.c_str());
 
-      SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles.in(), true );
+      SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles, true );
     }
   }
 
@@ -117,25 +115,22 @@ namespace
     SignalToGUI( SMESH_Mesh_i* mesh )
     {
       SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
-      SALOMEDS::Study_var study = gen->GetCurrentStudy();
-      if ( !study->_is_nil() && study->StudyId() == mesh->GetStudyId() )
+
+      SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( mesh->_this() );
+      CORBA::Object_var        obj = gen->GetNS()->Resolve( "/Kernel/Session" );
+      _session = SALOME::Session::_narrow( obj );
+      if ( !meshSO->_is_nil() && !_session->_is_nil() )
       {
-        SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject(study, mesh->_this() );
-        CORBA::Object_var        obj = gen->GetNS()->Resolve( "/Kernel/Session" );
-        _session = SALOME::Session::_narrow( obj );
-        if ( !meshSO->_is_nil() && !_session->_is_nil() )
-        {
-          CORBA::String_var meshEntry = meshSO->GetID();
-          _messagePrefix = "SMESH/mesh_loading/";
-          _messagePrefix += meshEntry.in();
+        CORBA::String_var meshEntry = meshSO->GetID();
+        _messagePrefix = "SMESH/mesh_loading/";
+        _messagePrefix += meshEntry.in();
 
-          std::string msgToGUI = _messagePrefix + "/";
-          msgToGUI += SMESH_Comment( mesh->NbNodes() );
-          msgToGUI += "/";
-          msgToGUI += SMESH_Comment( mesh->NbElements() );
+        std::string msgToGUI = _messagePrefix + "/";
+        msgToGUI += SMESH_Comment( mesh->NbNodes() );
+        msgToGUI += "/";
+        msgToGUI += SMESH_Comment( mesh->NbElements() );
 
-          _session->emitMessageOneWay( msgToGUI.c_str());
-        }
+        _session->emitMessageOneWay( msgToGUI.c_str());
       }
     }
     void sendStop()
@@ -1225,10 +1220,9 @@ bool SMESH_PreMeshInfo::IsMeshInfoCorrect() const
 
 void SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD(SALOMEDS::SComponent_ptr smeshComp)
 {
-  SALOMEDS::Study_var study = smeshComp->GetStudy();
-  if ( theStudyIDToMeshCounter[ (int) study->StudyId() ] > 0 )
+  if ( theMeshCounter > 0 )
   {
-    SALOMEDS::ChildIterator_wrap itBig = study->NewChildIterator( smeshComp );
+    SALOMEDS::ChildIterator_wrap itBig = SMESH_Gen_i::getStudyServant()->NewChildIterator( smeshComp );
     for ( ; itBig->More(); itBig->Next() ) {
       SALOMEDS::SObject_wrap gotBranch = itBig->Value();
       CORBA::Object_var       anObject = SMESH_Gen_i::SObjectToObject( gotBranch );