Salome HOME
Bug PAL7444 - display mesh takes a lot of more memory in 2.1.0 than in 2.0.0.
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.cxx
index 8cb0c86c1caf8e712a3218406f7467114a1b5373..9eb0f79ffff02736c7124f8a7f99068630484f85 100644 (file)
@@ -418,7 +418,6 @@ void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy )
   if ( myStudyContextMap.find( studyId ) == myStudyContextMap.end() ) {
     myStudyContextMap[ studyId ] = new StudyContext;      
   }
-  SetStudyID(studyId);
   // set current study for geom engine
   /*
   if ( !CORBA::is_nil( GetGeomEngine() ) )
@@ -491,9 +490,6 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj
      throw ( SALOME::SALOME_Exception )
 {
   Unexpect aCatch(SALOME_SalomeException);
-  using namespace SMESH;
-  FactoryHandler aFactory;
-
   if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMesh" );
   // create mesh
   SMESH::SMESH_Mesh_var mesh = this->createMesh();
@@ -502,17 +498,12 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj
   ASSERT( meshServant );
   meshServant->SetShape( theShapeObject );
   // publish mesh in the study
-  if ( CanPublishInStudy( mesh ) )
+  if( CanPublishInStudy( mesh ) ){
+    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+    aStudyBuilder->NewCommand();  // There is a transaction
     PublishMesh( myCurrentStudy, mesh.in() );
-
-  CORBA::String_var anEntry = theShapeObject->GetEntry();
-  aFactory->Register(TInvocationID(TResultCont(1,meshServant->GetID()),
-                                  GetID(),
-                                  "SMESH_Mesh",
-                                  "CreateMesh",
-                                  TArgumentCont(),
-                                  anEntry.in()));
-
+    aStudyBuilder->CommitCommand();
+  }
   return mesh._retn();
 }
 
@@ -533,8 +524,12 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName
   SMESH::SMESH_Mesh_var aMesh = createMesh();
   string aFileName; // = boost::filesystem::path(theFileName).leaf();
   // publish mesh in the study
-  if ( CanPublishInStudy( aMesh ) )
+  if ( CanPublishInStudy( aMesh ) ){
+    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+    aStudyBuilder->NewCommand();  // There is a transaction
     PublishMesh( myCurrentStudy, aMesh.in(), aFileName.c_str() );
+    aStudyBuilder->CommitCommand();
+  }
 
   SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( aMesh ).in() );
   ASSERT( aServant );
@@ -555,9 +550,6 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
      throw ( SALOME::SALOME_Exception )
 {
   Unexpect aCatch(SALOME_SalomeException);
-  using namespace SMESH;
-  FactoryHandler aFactory;
-
   if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
 
   // Retrieve mesh names from the file
@@ -569,10 +561,12 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
   SMESH::mesh_array_var aResult = new SMESH::mesh_array();
   theStatus = (SMESH::DriverMED_ReadStatus)aStatus;
   if(theStatus == SMESH::DRS_OK){
+    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+    aStudyBuilder->NewCommand();  // There is a transaction
+
     aResult->length( aNames.size() );
-    TResultCont aResultCont;
     int i = 0;
-    
+   
     // Iterate through all meshes and create mesh objects
     for ( list<string>::iterator it = aNames.begin(); it != aNames.end(); it++ ) {
       // create mesh
@@ -591,15 +585,8 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
        theStatus = status1;
 
       aResult[i++] = SMESH::SMESH_Mesh::_duplicate( mesh );
-
-      aResultCont.push_back(meshServant->GetID());
     }
-    aFactory->Register(TInvocationID(aResultCont,
-                                    GetID(),
-                                    "SMESH_Mesh",
-                                    "CreateMeshesFromMED",
-                                    TArgumentCont(1,std::string(theFileName)),
-                                    ""));
+    aStudyBuilder->CommitCommand();
   }
   return aResult._retn();
 }
@@ -621,8 +608,12 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName
   SMESH::SMESH_Mesh_var aMesh = createMesh();
   string aFileName; // = boost::filesystem::path(theFileName).leaf();
   // publish mesh in the study
-  if ( CanPublishInStudy( aMesh ) )
+  if( CanPublishInStudy( aMesh ) ){
+    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+    aStudyBuilder->NewCommand();  // There is a transaction
     PublishInStudy( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
+    aStudyBuilder->CommitCommand();
+  }
 
   SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( aMesh ).in() );
   ASSERT( aServant );
@@ -803,10 +794,6 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
 {
   INFOS( "SMESH_Gen_i::Save" );
 
-  CORBA::Boolean anIsValidScript;
-  SALOMEDS::Study_var aStudy = theComponent->GetStudy(); 
-  SALOMEDS::TMPFile_var aDump = DumpPython(aStudy,false,anIsValidScript);
-
 //  ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() )
   // san -- in case <myCurrentStudy> differs from theComponent's study,
   // use that of the component