Salome HOME
23315: [CEA 1929] Too much memory used to display a mesh in shading and wireframe
authoreap <eap@opencascade.com>
Fri, 18 Nov 2016 16:39:59 +0000 (19:39 +0300)
committereap <eap@opencascade.com>
Fri, 18 Nov 2016 16:39:59 +0000 (19:39 +0300)
    Use my1DActor only to show edge numbers and controls of all edges
       => 10% decrease memory usage

src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_CellLabelActor.cxx
src/OBJECT/SMESH_DeviceActor.cxx

index dbc69f410ebdf2596780c08a2366a9ee630ddb58..8ef0667e8e6aa47d861ce9304915039e4ffe9dbf 100644 (file)
@@ -323,6 +323,10 @@ SMESH_ActorDef::SMESH_ActorDef()
   myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
   myEdgeProp->SetLineWidth(aLineWidth);
 
   myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
   myEdgeProp->SetLineWidth(aLineWidth);
 
+  // my1DActor is used to
+  // - show numbers
+  // - show controls on all edges (eg Length)
+  // since edges are shown by myHighlitableActor
   my1DActor = SMESH_CellLabelActor::New();
   my1DActor->SetStoreClippingMapping(true);
   my1DActor->SetUserMatrix(aMatrix);
   my1DActor = SMESH_CellLabelActor::New();
   my1DActor->SetStoreClippingMapping(true);
   my1DActor->SetUserMatrix(aMatrix);
@@ -350,6 +354,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
   my1DExtProp->SetPointSize(aElem0DSize);
 
   my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
   my1DExtProp->SetPointSize(aElem0DSize);
 
+  // my1DExtActor is used to show filtered edges or links between nodes
   my1DExtActor = SMESH_DeviceActor::New();
   my1DExtActor->SetUserMatrix(aMatrix);
   my1DExtActor->PickableOff();
   my1DExtActor = SMESH_DeviceActor::New();
   my1DExtActor->SetUserMatrix(aMatrix);
   my1DExtActor->PickableOff();
@@ -995,8 +1000,7 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
       return;
     }
 
       return;
     }
 
-    vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
-    vtkIdType aNbCells = aGrid->GetNumberOfCells();
+    int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
     bool aShowOnlyScalarBarTitle = false;
     if(aNbCells) {
       myControlMode = theMode;
     bool aShowOnlyScalarBarTitle = false;
     if(aNbCells) {
       myControlMode = theMode;
@@ -1055,25 +1059,13 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
         SetEntityMode(eEdges);
       }
       else if(myControlActor == my2DActor) {
         SetEntityMode(eEdges);
       }
       else if(myControlActor == my2DActor) {
-        switch(myControlMode) {
-        case eLength2D:
-        case eFreeEdges:
-        case eFreeFaces:
-        case eMultiConnection2D:
-          if (!myIsEntityModeCache){
-            myEntityModeCache = GetEntityMode();
-            myIsEntityModeCache=true;
-          }
-          SetEntityMode(eFaces);
-          break;
-        default:
-          if (!myIsEntityModeCache){
-            myEntityModeCache = GetEntityMode();
-            myIsEntityModeCache=true;
-          }
-          SetEntityMode(eFaces);
+        if (!myIsEntityModeCache){
+          myEntityModeCache = GetEntityMode();
+          myIsEntityModeCache=true;
         }
         }
-      }else if(myControlActor == my3DActor) {
+        SetEntityMode(eFaces);
+      }
+      else if(myControlActor == my3DActor) {
         if (!myIsEntityModeCache){
             myEntityModeCache = GetEntityMode();
             myIsEntityModeCache=true;
         if (!myIsEntityModeCache){
             myEntityModeCache = GetEntityMode();
             myIsEntityModeCache=true;
@@ -1487,9 +1479,15 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
       case eCoincidentNodes:
         myNodeExtActor->VisibilityOn();
         break;
       case eCoincidentNodes:
         myNodeExtActor->VisibilityOn();
         break;
+      case eLength:
+      case eMultiConnection:
+        my1DActor->VisibilityOn();
+        break;
       case eFreeEdges:
       case eFreeBorders:
       case eCoincidentElems1D:
       case eFreeEdges:
       case eFreeBorders:
       case eCoincidentElems1D:
+      case eLength2D:
+      case eMultiConnection2D:
         my1DExtActor->VisibilityOn();
         break;
       case eFreeFaces:
         my1DExtActor->VisibilityOn();
         break;
       case eFreeFaces:
@@ -1503,39 +1501,31 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
       case eCoincidentElems3D:
         my3DExtActor->VisibilityOn();
         break;
       case eCoincidentElems3D:
         my3DExtActor->VisibilityOn();
         break;
-      case eLength2D:
-      case eMultiConnection2D:
-        my1DExtActor->VisibilityOn();
-        break;
       default:;
       }
       default:;
       }
-      if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
+      if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
         myScalarBarActor->VisibilityOn();
     }
 
         myScalarBarActor->VisibilityOn();
     }
 
-    if(myRepresentation != ePoint)
-      myPickableActor->VisibilityOn();
-    else {
-      myNodeActor->VisibilityOn();
-    }
-
-    if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
-      my0DActor->VisibilityOn();
-    }
-    if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
-      myBallActor->VisibilityOn();
-    }
-
-    if(myEntityMode & eEdges && GetRepresentation() != ePoint){
-      my1DActor->VisibilityOn();
-    }
-
-    if(myEntityMode & eFaces && GetRepresentation() != ePoint){
-      my2DActor->VisibilityOn();
-    }
+    myPickableActor->VisibilityOn();
 
 
-    if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
-      my3DActor->VisibilityOn();
+    if ( GetRepresentation() != ePoint )
+    {
+      if(myEntityMode & e0DElements  ){
+        my0DActor->VisibilityOn();
+      }
+      if(myEntityMode & eBallElem    ){
+        myBallActor->VisibilityOn();
+      }
+      if(myEntityMode & eEdges && GetCellsLabeled() ){ // my1DActor shows labels only
+        my1DActor->VisibilityOn();
+      }
+      if(myEntityMode & eFaces      ){
+        my2DActor->VisibilityOn();
+      }
+      if(myEntityMode & eVolumes    ){
+        my3DActor->VisibilityOn();
+      }
     }
 
     if(myNodeActor->GetPointsLabeled()){
     }
 
     if(myNodeActor->GetPointsLabeled()){
@@ -1750,8 +1740,6 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
   }
 
   myPickableActor = myBaseActor;
   }
 
   myPickableActor = myBaseActor;
-  myNodeActor->SetVisibility(false);
-  myNodeExtActor->SetVisibility(false);
   vtkProperty *aProp = NULL, *aBackProp = NULL;
   vtkProperty *aPropVN = NULL, *aPropVR = NULL;
   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
   vtkProperty *aProp = NULL, *aBackProp = NULL;
   vtkProperty *aPropVN = NULL, *aPropVR = NULL;
   SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
@@ -1759,7 +1747,6 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
   switch (myRepresentation) {
   case ePoint:
     myPickableActor = myNodeActor;
   switch (myRepresentation) {
   case ePoint:
     myPickableActor = myNodeActor;
-    myNodeActor->SetVisibility(true);
     aQuadraticMode = SMESH_Actor::eLines;
     aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
     aReperesent = SMESH_DeviceActor::ePoint;
     aQuadraticMode = SMESH_Actor::eLines;
     aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
     aReperesent = SMESH_DeviceActor::ePoint;
@@ -1777,54 +1764,50 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
     break;
   }
 
     break;
   }
 
-  my2DActor->SetProperty(aProp);
-  my2DActor->SetBackfaceProperty(aBackProp);
-  my2DActor->SetRepresentation(aReperesent);
+  if ( myRepresentation != ePoint )
+  {
+    my2DActor->SetProperty(aProp);
+    my2DActor->SetBackfaceProperty(aBackProp);
+    my2DActor->SetRepresentation(aReperesent);
 
 
-  if(aQuadraticMode == SMESH_Actor::eLines)
-    my2DActor->SetQuadraticArcMode(false);
-  else if(aQuadraticMode == SMESH_Actor::eArcs)
-    my2DActor->SetQuadraticArcMode(true);
+    if(aQuadraticMode == SMESH_Actor::eLines)
+      my2DActor->SetQuadraticArcMode(false);
+    else if(aQuadraticMode == SMESH_Actor::eArcs)
+      my2DActor->SetQuadraticArcMode(true);
 
 
-  my2DExtActor->SetRepresentation(aReperesent);
+    my2DExtActor->SetRepresentation(aReperesent);
 
 
-  my3DActor->SetProperty(aPropVN);
-  my3DActor->SetBackfaceProperty(aPropVR);
-  my3DActor->SetRepresentation(aReperesent);
+    my3DActor->SetProperty(aPropVN);
+    my3DActor->SetBackfaceProperty(aPropVR);
+    my3DActor->SetRepresentation(aReperesent);
 
 
+    my0DActor->SetRepresentation(aReperesent);
+    myBallActor->SetRepresentation(aReperesent);
 
 
-  my1DExtActor->SetVisibility(false);
-  my2DExtActor->SetVisibility(false);
-  my3DExtActor->SetVisibility(false);
-
-  my0DActor->SetRepresentation(aReperesent);
-  myBallActor->SetRepresentation(aReperesent);
-
-  switch ( myControlMode ) {
-  case eLength:
-  case eMultiConnection:
-    aProp = aBackProp = my1DProp;
-    if(myRepresentation != ePoint)
-      aReperesent = SMESH_DeviceActor::eInsideframe;
-    break;
-  default:;
-  }
+    switch ( myControlMode ) {
+    case eLength:
+    case eMultiConnection:
+      aProp = aBackProp = my1DProp;
+      if(myRepresentation != ePoint)
+        aReperesent = SMESH_DeviceActor::eInsideframe;
+      break;
+    default:;
+    }
 
 
-  if(aQuadraticMode == SMESH_Actor::eLines)
-    my1DActor->SetQuadraticArcMode(false);
-  else if(aQuadraticMode == SMESH_Actor::eArcs)
-    my1DActor->SetQuadraticArcMode(true);
+    if(aQuadraticMode == SMESH_Actor::eLines)
+      my1DActor->SetQuadraticArcMode(false);
+    else if(aQuadraticMode == SMESH_Actor::eArcs)
+      my1DActor->SetQuadraticArcMode(true);
 
 
-  my1DActor->SetProperty(aProp);
-  my1DActor->SetBackfaceProperty(aBackProp);
-  my1DActor->SetRepresentation(aReperesent);
+    my1DActor->SetProperty(aProp);
+    my1DActor->SetBackfaceProperty(aBackProp);
+    my1DActor->SetRepresentation(aReperesent);
 
 
-  my1DExtActor->SetRepresentation(aReperesent);
+    my1DExtActor->SetRepresentation(aReperesent);
+  }
 
   if(myIsPointsVisible)
     myPickableActor = myNodeActor;
 
   if(myIsPointsVisible)
     myPickableActor = myNodeActor;
-  if(GetPointRepresentation())
-    myNodeActor->SetVisibility(true);
 
   SetMapper(myPickableActor->GetMapper());
 
 
   SetMapper(myPickableActor->GetMapper());
 
@@ -1886,6 +1869,7 @@ void SMESH_ActorDef::UpdateHighlight()
       }
       myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
       myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
       }
       myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
       myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
+      myNodeActor->GetProperty()->Modified();
       break;
     }
   }
       break;
     }
   }
index afd31449ec82617b6ba99c647c4033c9e3aa0fc8..0172da00b49ebf2a048accfd735cf504e61fa84d 100644 (file)
@@ -198,7 +198,8 @@ void SMESH_CellLabelActor::RemoveFromRender(vtkRenderer* theRenderer)
   SMESH_DeviceActor::RemoveFromRender(theRenderer);
 }
 
   SMESH_DeviceActor::RemoveFromRender(theRenderer);
 }
 
-void SMESH_CellLabelActor::UpdateLabels() {
+void SMESH_CellLabelActor::UpdateLabels()
+{
   if(myIsCellsLabeled)
     SetCellsLabeled(myIsCellsLabeled);
 }
   if(myIsCellsLabeled)
     SetCellsLabeled(myIsCellsLabeled);
 }
@@ -207,7 +208,8 @@ void SMESH_CellLabelActor::UpdateLabels() {
 void SMESH_CellLabelActor::ProcessEvents(vtkObject* vtkNotUsed(theObject),
                                          unsigned long theEvent,
                                          void* theClientData,
 void SMESH_CellLabelActor::ProcessEvents(vtkObject* vtkNotUsed(theObject),
                                          unsigned long theEvent,
                                          void* theClientData,
-                                         void* vtkNotUsed(theCallData)) {
+                                         void* vtkNotUsed(theCallData))
+{
   SMESH_CellLabelActor* self = reinterpret_cast<SMESH_CellLabelActor*>(theClientData);
   if(self)
     self->UpdateLabels();
   SMESH_CellLabelActor* self = reinterpret_cast<SMESH_CellLabelActor*>(theClientData);
   if(self)
     self->UpdateLabels();
index 66cb811bf2ae2d9c8f37f8f9f87ae8fa20907b37..f6db97d25e162aec96042df4255cdb7114ff7d03 100644 (file)
@@ -88,7 +88,7 @@ SMESH_DeviceActor
   myIsShrunk = false;
   myIsHighlited = false;
 
   myIsShrunk = false;
   myIsHighlited = false;
 
-  myRepresentation = eSurface;
+  myRepresentation = SMESH_DeviceActor::EReperesent(-1);
 
   myProperty = vtkProperty::New();
   myMapper = VTKViewer_PolyDataMapper::New();
 
   myProperty = vtkProperty::New();
   myMapper = VTKViewer_PolyDataMapper::New();
@@ -306,7 +306,7 @@ SMESH_DeviceActor
     vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
 
     // SetStoreIDMapping(true);
     vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
 
     // SetStoreIDMapping(true);
-    // myExtractUnstructuredGrid->Update();
+    myExtractUnstructuredGrid->Update();
     vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
 
     aDataSet->ShallowCopy(aGrid);
     vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
 
     aDataSet->ShallowCopy(aGrid);
@@ -619,7 +619,19 @@ unsigned long int
 SMESH_DeviceActor
 ::GetMTime()
 {
 SMESH_DeviceActor
 ::GetMTime()
 {
-  // cout << this->myExtractUnstructuredGrid
+  // cout << "DA " << this
+  //      << " GF " << myGeomFilter;
+  // if ( this->Property )
+  //   cout << " P " << this->Property->GetMTime();
+  // if ( this->BackfaceProperty != NULL )
+  //   cout << " BP " << BackfaceProperty->GetMTime();
+  // if ( this->Texture != NULL )
+  //   cout << " T " << this->Texture->GetMTime();
+  // cout << " U " << this->GetUserTransformMatrixMTime()
+  //      << " M " << this->MTime.GetMTime() << endl;
+
+  // cout << "DA " << this
+  //      << " GF " << myGeomFilter
   //      << " " << this->Superclass::GetMTime()
   //      << " " << myExtractGeometry->GetMTime()
   //      << " " << myExtractUnstructuredGrid->GetMTime()
   //      << " " << this->Superclass::GetMTime()
   //      << " " << myExtractGeometry->GetMTime()
   //      << " " << myExtractUnstructuredGrid->GetMTime()
@@ -745,6 +757,8 @@ void
 SMESH_DeviceActor
 ::SetRepresentation(EReperesent theMode)
 {
 SMESH_DeviceActor
 ::SetRepresentation(EReperesent theMode)
 {
+  if ( myRepresentation == theMode )
+    return;
   switch(theMode){
   case ePoint:
     myGeomFilter->SetInside(true);
   switch(theMode){
   case ePoint:
     myGeomFilter->SetInside(true);