Salome HOME
0020982: EDF 1547 SMESH: Creation of non-conformal quadratic pyramids
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_VTKUtils.cxx
index 52274c685ddfbafa024e3e936789ae5fc45473ea..71df5c8e6f6fcb282ba0a04252f49acd36e8a731 100644 (file)
@@ -118,7 +118,7 @@ namespace SMESH
     } else {
       SUIT_ViewManager* aVM = app->getViewManager(SVTK_Viewer::Type(), true);
       if(aVM)
-       aList.append(aVM);
+        aList.append(aVM);
     }    
     bool actorRemoved = false;
     ViewManagerList::ConstIterator it = aList.begin();
@@ -127,13 +127,13 @@ namespace SMESH
       aViewManager = *it;
       QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
       for ( int iV = 0; iV < views.count(); ++iV ) {
-       if ( SMESH_Actor* actor = FindActorByEntry( views[iV], theEntry)) {
-         if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
-           vtkWnd->RemoveActor(actor);
-           actorRemoved = true;
-         }
-         actor->Delete();
-       }
+        if ( SMESH_Actor* actor = FindActorByEntry( views[iV], theEntry)) {
+          if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
+            vtkWnd->RemoveActor(actor);
+            actorRemoved = true;
+          }
+          actor->Delete();
+        }
       }
     }
     
@@ -142,9 +142,9 @@ namespace SMESH
       TVisualObjCont::key_type aKey(aStudyId,theEntry);
       TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(aKey);
       if(anIter != VISUAL_OBJ_CONT.end()) {
-       // for unknown reason, object destructor is not called, so clear object manually
-       anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
-       anIter->second->GetUnstructuredGrid()->SetPoints(0);
+        // for unknown reason, object destructor is not called, so clear object manually
+        anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
+        anIter->second->GetUnstructuredGrid()->SetPoints(0);
       }
       VISUAL_OBJ_CONT.erase(aKey);
     }
@@ -373,34 +373,31 @@ namespace SMESH
 
     if ( objModified ) {
       // PAL16631. Mesurements showed that to show aVisualObj in SHADING(default) mode,
-      // ~10 times more memory is used than it occupies.
+      // ~5 times more memory is used than it occupies.
       // Warn the user if there is less free memory than 30 sizes of a grid
       // TODO: estimate memory usage in other modes and take current mode into account
       int freeMB = SMDS_Mesh::CheckMemory(true);
       int usedMB = aVisualObj->GetUnstructuredGrid()->GetActualMemorySize() / 1024;
-      if ( freeMB > 0 && usedMB * 30 > freeMB ) {
-#ifdef _DEBUG_
-        MESSAGE ( "SMESHGUI_VTKUtils::GetVisualObj(), freeMB=" << freeMB
-               << ", usedMB=" << usedMB );
-#endif
-//        bool continu = false;
-//        if ( usedMB * 10 > freeMB )
-//          // even dont try to show
-//          SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
-//                                   QObject::tr("SMESH_NO_MESH_VISUALIZATION"));
-//        else
-//          // there is a chance to succeed
-//          continu = SUIT_MessageBox::warning
-//            (SMESHGUI::desktop(),
-//             QObject::tr("SMESH_WRN_WARNING"),
-//             QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"),
-//             SUIT_MessageBox::Yes | SUIT_MessageBox::No,
-//             SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes;
-//        if ( !continu ) {
-//          // remove the corresponding actors from all views
-//          RemoveVisualObjectWithActors( theEntry );
-//          aVisualObj.reset();
-//        }
+      MESSAGE("SMESHGUI_VTKUtils::GetVisualObj(), freeMB=" << freeMB << ", usedMB=" <<usedMB);
+      if ( freeMB > 0 && usedMB * 5 > freeMB ) {
+       bool continu = false;
+       if ( usedMB * 3 > freeMB )
+         // even dont try to show
+         SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
+                                  QObject::tr("SMESH_NO_MESH_VISUALIZATION"));
+       else
+         // there is a chance to succeed
+         continu = SUIT_MessageBox::warning
+           (SMESHGUI::desktop(),
+            QObject::tr("SMESH_WRN_WARNING"),
+            QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"),
+            SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+            SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes;
+       if ( !continu ) {
+         // remove the corresponding actors from all views
+         RemoveVisualObjectWithActors( theEntry );
+         aVisualObj.reset();
+       }
       }
     }
 
@@ -611,7 +608,7 @@ namespace SMESH
         }
 
         SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( aSObj ));
-        if(!CORBA::is_nil(aGroup))
+        if(!CORBA::is_nil(aGroup) && anActor)
         {
           SALOMEDS::Color aColor = aGroup->GetColor();
           if( !( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 ) )
@@ -732,12 +729,12 @@ namespace SMESH
                 MESSAGE("--- display " << anActor);
             anActor->SetVisibility(true);
 
-           if(anActor->hasIO()){
-             Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
-             if(anIO->hasEntry()){
-               aStudy->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
-             }
-           }
+            if(anActor->hasIO()){
+              Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+              if(anIO->hasEntry()){
+                aStudy->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
+              }
+            }
           }
         }
         break;
@@ -751,7 +748,7 @@ namespace SMESH
             anActor->SetVisibility(false);
           }
         }
-       aStudy->setVisibilityStateForAll(Qtx::HiddenState);
+        aStudy->setVisibilityStateForAll(Qtx::HiddenState);
       }
       default: {
         if (SMESH_Actor *anActor = FindActorByEntry(theWnd,theEntry)) {
@@ -759,15 +756,15 @@ namespace SMESH
             case eDisplay:
             case eDisplayOnly:
                 //MESSAGE("--- display " << anActor);
-             anActor->Update();
+              anActor->Update();
               anActor->SetVisibility(true);
               if (theAction == eDisplayOnly) aRenderer->ResetCameraClippingRange();
-             aStudy->setVisibilityState(theEntry, Qtx::ShownState);
+              aStudy->setVisibilityState(theEntry, Qtx::ShownState);
               break;
             case eErase:
                 //MESSAGE("--- erase " << anActor);
               anActor->SetVisibility(false);
-             aStudy->setVisibilityState(theEntry, Qtx::HiddenState);
+              aStudy->setVisibilityState(theEntry, Qtx::HiddenState);
               break;
           }
         } else {
@@ -786,7 +783,7 @@ namespace SMESH
                 if ((anActor = CreateActor(aDocument,theEntry,true))) {
                   bool needFitAll = noSmeshActors(theWnd); // fit for the first object only
                   DisplayActor(theWnd,anActor);
-                 aStudy->setVisibilityState(theEntry, Qtx::ShownState);
+                  aStudy->setVisibilityState(theEntry, Qtx::ShownState);
                   // FitAll(); - PAL16770(Display of a group performs an automatic fit all)
                   if (needFitAll) FitAll();
                 } else {
@@ -1270,7 +1267,7 @@ namespace SMESH
                                                 {theBounds[0],theBounds[3],theBounds[5]}, 
                                                 {theBounds[1],theBounds[3],theBounds[5]}};
 
-    int aMaxId = 0, aMinId = aMaxId;
+    int aMaxId = 0;
     theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
     theMinBoundPrj = theMaxBoundPrj;
     for(int i = 1; i < 8; i++){
@@ -1281,7 +1278,6 @@ namespace SMESH
       }
       if(theMinBoundPrj > aTmp){
         theMinBoundPrj = aTmp;
-        aMinId = i;
       }
     }
     vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];