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 / SMESHGUI / SMESHGUI_VTKUtils.cxx
index 42e6db2615853cf3a6ad4abc84d8ff0a828f941a..89cebc3c456091b5c434993698eb8579379e459e 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "SMESHGUI_VTKUtils.h"
 #include "SMESHGUI_Utils.h"
+#include "SMESHGUI_Filter.h"
 
 #include <vtkRenderer.h>
 #include <vtkActorCollection.h>
@@ -50,6 +51,7 @@
 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
 
 #include "SMESH_Actor.h"
+#include "SMESH_ObjectDef.h"
 
 using namespace std;
 
@@ -155,6 +157,19 @@ namespace SMESH{
   }
 
 
+  void RepaintViewFrame(VTKViewer_ViewFrame* theFrame)
+  {
+    theFrame->Repaint();
+  }
+
+
+  void RenderViewFrame(VTKViewer_ViewFrame* theFrame)
+  {
+    theFrame->getRW()->getRenderWindow()->Render();
+    theFrame->Repaint();
+  }
+
+
   SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame, 
                                const char* theEntry)
   {
@@ -229,6 +244,17 @@ namespace SMESH{
   void RemoveActor(QAD_StudyFrame *theStudyFrame, SMESH_Actor* theActor){
     if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){
       aViewFrame->RemoveActor(theActor);
+      if(theActor->hasIO()){
+       Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
+       if(anIO->hasEntry()){
+         std::string anEntry = anIO->getEntry();
+         QAD_Study* aStudy = theStudyFrame->getStudy();
+         int aStudyId = aStudy->getStudyId();
+         TVisualObjCont::key_type aKey(aStudyId,anEntry);
+         VISUAL_OBJ_CONT.erase(aKey);
+       }
+      }
+      theActor->Delete();
       aViewFrame->Repaint();
     }
   }
@@ -455,6 +481,11 @@ namespace SMESH{
     theStyle->RemoveFilter(theId);
   }
 
+  void RemoveFilters(VTKViewer_InteractorStyleSALOME* theStyle){
+    for ( int id = SMESHGUI_NodeFilter; theStyle && id < SMESHGUI_LastFilter; id++ )
+      theStyle->RemoveFilter( id );
+  }
+
   bool IsValid(SALOME_Actor* theActor, int theCellId,
               VTKViewer_InteractorStyleSALOME* theStyle)
   {
@@ -506,7 +537,7 @@ namespace SMESH{
   {
     theName = "";
     if(theIO->hasEntry()){
-      if(SMESH_Actor *anActor = FindActorByEntry(theIO->getEntry())){
+      if(FindActorByEntry(theIO->getEntry())){
        TColStd_IndexedMapOfInteger aMapIndex;
        theSel->GetIndex(theIO,aMapIndex);
        for(int i = 1; i <= aMapIndex.Extent(); i++){
@@ -535,7 +566,7 @@ namespace SMESH{
   {
     theName = "";
     if(theIO->hasEntry()){
-      if(SMESH_Actor *anActor = FindActorByEntry(theIO->getEntry())){
+      if(FindActorByEntry(theIO->getEntry())){
        TColStd_IndexedMapOfInteger aMapIndex;
        theSel->GetIndex(theIO,aMapIndex);
        typedef std::set<int> TIdContainer;