extractContainers( sel_objects, to_process );
- if (vtkwnd) {
- SALOME_ListIteratorOfListIO It( to_process );
- for (; It.More(); It.Next()) {
- Handle(SALOME_InteractiveObject) IOS = It.Value();
- if (IOS->hasEntry()) {
- SMESH::UpdateView(anAction, IOS->getEntry());
- if (anAction == SMESH::eDisplayOnly)
- anAction = SMESH::eDisplay;
- }
- }
- }
+ try {
+ if (vtkwnd) {
+ SALOME_ListIteratorOfListIO It( to_process );
+ for (; It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ if (IOS->hasEntry()) {
+ SMESH::UpdateView(anAction, IOS->getEntry());
+ if (anAction == SMESH::eDisplayOnly)
+ anAction = SMESH::eDisplay;
+ }
+ }
+ }
- // PAL13338 + PAL15161 -->
- if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) /*&& !automaticUpdate()*/ )
- SMESH::UpdateView();
- // PAL13338 + PAL15161 <--
+ // PAL13338 + PAL15161 -->
+ if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
+ SMESH::UpdateView();
+ // PAL13338 + PAL15161 <--
+ }
+ catch (...) { // PAL16774 (Crash after display of many groups)
+ SMESH::OnVisuException();
+ }
if (anAction == SMESH::eErase) {
SALOME_ListIO l1;
if (checkLock(aStudy)) break;
startOperation( 701 );
-// LightApp_SelectionMgr *Sel = selectionMgr();
-// SALOME_ListIO selected; Sel->selectedObjects( selected );
-
-// int nbSel = selected.Extent();
-// if (nbSel != 1) {
-// SUIT_MessageBox::warn1(desktop(),
-// tr("SMESH_WRN_WARNING"),
-// tr("SMESH_WRN_NO_AVAILABLE_DATA"),
-// tr("SMESH_BUT_OK"));
-// break;
-// }
-
-// SMESH::SMESH_Mesh_var aMesh;
-// SMESH::SMESH_subMesh_var aSubMesh;
-// Handle(SALOME_InteractiveObject) IObject = selected.First();
-// if (IObject->hasEntry()) {
-// _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
-// GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
-// if ( aShapeObject->_is_nil() ) {
-// // imported mesh
-// break;
-// }
-// if ( aMeshSObj ) {
-// aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
-// aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
-// if ( !aSubMesh->_is_nil() )
-// aMesh = aSubMesh->GetFather();
-
-// if (!aMesh->_is_nil()) {
-// SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
-// if ( errors->length() > 0 ) {
-// SUIT_MessageBox::warn1(desktop(),
-// tr("SMESH_WRN_WARNING"),
-// SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
-// tr("SMESH_BUT_OK"));
-// break;
-// }
-
-// try {
-// if (GetSMESHGen()->Compute(aMesh, aShapeObject))
-// SMESH::ModifiedMesh(aMeshSObj, true);
-// else
-// SUIT_MessageBox::warn1(desktop(),
-// tr("SMESH_WRN_WARNING"),
-// tr("SMESH_WRN_COMPUTE_FAILED"),
-// tr("SMESH_BUT_OK"));
-// }
-// catch(const SALOME::SALOME_Exception & S_ex){
-// SalomeApp_Tools::QtCatchCorbaException(S_ex);
-// }
-
-// updateObjBrowser();
-
-// if (automaticUpdate()) {
-// SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(this, /*create*/true);
-// if (aVTKView) {
-// CORBA::Long anId = aStudy->StudyId();
-// TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
-// if (aVisualObj) {
-// aVisualObj->Update();
-// SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
-// if (!anActor) {
-// anActor = SMESH::CreateActor(aStudy, IObject->getEntry());
-// if (anActor) {
-// SMESH::DisplayActor(aVTKView, anActor); //apo
-// SMESH::FitAll();
-// }
-// }
-// SMESH::RepaintCurrentView();
-// Sel->setSelectedObjects( selected );
-// }
-// }
-// }
-// }
-// }
-// }
}
break;
#include "SMESHGUI_HypothesesUtils.h"
#include "SMDS_SetIterator.hxx"
+#include <SMDS_Mesh.hxx>
#include "GEOMBase.h"
#include "GEOM_Actor.h"
#include <BRepBndLib.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
+#include <Standard_ErrorHandler.hxx>
+
// QT Includes
#include <qframe.h>
#include <qlayout.h>
}
SUIT_OverrideCursor aWaitCursor;
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (gen->Compute(aMesh, myMainShape))
computeFailed = false;
}
//SalomeApp_Tools::QtCatchCorbaException(S_ex);
}
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
anErrors = gen->GetComputeErrors( aMesh, myMainShape );
// if ( anErrors->length() == 0 ) {
// SUIT_MessageBox::warn1(desktop(),
{
SMESH::ModifiedMesh(aMeshSObj, !computeFailed, aMesh->NbNodes() == 0);
update( UF_ObjBrowser | UF_Model );
+ Sel->setSelectedObjects( selected );
// SHOW MESH
- // NPAL16631: if ( getSMESHGUI()->automaticUpdate() ) {
- if ( !memoryLack && getSMESHGUI()->automaticUpdate() ) // NPAL16631
+ // NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
+ if ( !memoryLack && getSMESHGUI()->automaticUpdate() )
{
try {
- SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(getSMESHGUI(), true);
- if (aVTKView) {
- int anId = study()->id();
- TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
- if (aVisualObj) {
- aVisualObj->Update();
- SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
- if (!anActor) {
- anActor = SMESH::CreateActor(studyDS(), IObject->getEntry());
- if (anActor) {
- SMESH::DisplayActor(aVTKView, anActor); //apo
- SMESH::FitAll();
- }
- }
- SMESH::RepaintCurrentView();
- Sel->setSelectedObjects( selected );
- }
- }
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ SMESH::UpdateView(eDisplay, IObject->getEntry());
}
catch (...) {
- memoryLack = true;
+#ifdef _DEBUG_
+ cout << "Exception thrown during mesh visualization" << endl;
+#endif
+ if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning?
+ SMESH::OnVisuException();
+ }
+ else {
+ memoryLack = true;
+ }
}
}
}
}
else if ( noError )
{
+ SUIT_OverrideCursor aWaitCursor;
myDlg->myFullInfo->SetInfoByMesh( aMesh );
myDlg->myFullInfo->show();
myDlg->myBriefInfo->hide();
#include "SMESHGUI.h"
#include "SMESH_Actor.h"
#include "SMESH_ObjectDef.h"
+#include <SMDS_Mesh.hxx>
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <SUIT_Study.h>
+#include <SUIT_MessageBox.h>
#include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
// VTK
#include <vtkRenderer.h>
#include <vtkActorCollection.h>
+#include <vtkUnstructuredGrid.h>
// OCCT
#include <TColStd_IndexedMapOfInteger.hxx>
+#include <Standard_ErrorHandler.hxx>
// STL
#include <set>
typedef map<TKeyOfVisualObj,TVisualObjPtr> TVisualObjCont;
static TVisualObjCont VISUAL_OBJ_CONT;
+ //================================================================================
+ /*!
+ * \brief Remove VisualObj and its actor from all views
+ */
+ //================================================================================
+
+ void RemoveVisualObjectWithActors( const char* theEntry )
+ {
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
+ ( SUIT_Session::session()->activeApplication() );
+ SUIT_ViewManager* aViewManager =
+ app ? app->getViewManager(SVTK_Viewer::Type(), true) : 0;
+ if ( aViewManager ) {
+ QPtrVector<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);
+ actor->Delete();
+ }
+ }
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( aViewManager->study() );
+ int aStudyId = aStudy->id();
+ 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);
+ anIter->second->GetUnstructuredGrid()->SetPoints(0);
+ }
+ VISUAL_OBJ_CONT.erase(aKey);
+ }
+ }
+ //================================================================================
+ /*!
+ * \brief Remove all VisualObjs and their actors from all views
+ */
+ //================================================================================
+
+ void RemoveAllObjectsWithActors()
+ {
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
+ ( SUIT_Session::session()->activeApplication() );
+ SUIT_ViewManager* aViewManager =
+ app ? app->getViewManager(SVTK_Viewer::Type(), true) : 0;
+ if ( aViewManager ) {
+ QPtrVector<SUIT_ViewWindow> views = aViewManager->getViews();
+ for ( int iV = 0; iV < views.count(); ++iV ) {
+ if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
+ vtkRenderer *aRenderer = vtkWnd->getRenderer();
+ vtkActorCollection *aCollection = aRenderer->GetActors();
+ aCollection->InitTraversal();
+ while(vtkActor *anAct = aCollection->GetNextActor()){
+ if(SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(anAct)){
+ vtkWnd->RemoveActor(actor);
+ actor->Delete();
+ }
+ }
+ }
+ }
+ TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin();
+ for ( ; anIter != VISUAL_OBJ_CONT.end(); ++anIter ) {
+ // for unknown reason, object destructor is not called, so clear object manually
+ anIter->second->GetUnstructuredGrid()->SetCells(0,0,0);
+ anIter->second->GetUnstructuredGrid()->SetPoints(0);
+ }
+ VISUAL_OBJ_CONT.clear();
+ }
+ }
+ //================================================================================
+ /*!
+ * \brief Notify the user on problems during visualization
+ */
+ //================================================================================
+
+ void OnVisuException()
+ {
+ SUIT_MessageBox::warn1 (SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_VISU_PROBLEM"),
+ QObject::tr("SMESH_BUT_OK"));
+ }
+ //================================================================================
+ /*!
+ * \brief Returns an updated visual object
+ */
+ //================================================================================
+
TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry){
TVisualObjPtr aVisualObj;
+ TVisualObjCont::key_type aKey(theStudyId,theEntry);
try{
- TVisualObjCont::key_type aKey(theStudyId,theEntry);
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(aKey);
if(anIter != VISUAL_OBJ_CONT.end()){
aVisualObj = anIter->second;
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj);
if(!aMesh->_is_nil()){
aVisualObj.reset(new SMESH_MeshObj(aMesh));
- aVisualObj->Update();
TVisualObjCont::value_type aValue(aKey,aVisualObj);
VISUAL_OBJ_CONT.insert(aValue);
- return aVisualObj;
}
//Try narrow to SMESH_Group interafce
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObj);
TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in());
if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj));
- aVisualObj->Update();
TVisualObjCont::value_type aValue(aKey,aVisualObj);
VISUAL_OBJ_CONT.insert(aValue);
- return aVisualObj;
}
}
//Try narrow to SMESH_subMesh interafce
TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in());
if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj));
- aVisualObj->Update();
TVisualObjCont::value_type aValue(aKey,aVisualObj);
VISUAL_OBJ_CONT.insert(aValue);
- return aVisualObj;
}
}
}
}
}catch(...){
INFOS("GetMeshObj - There is no SMESH_Mesh object for the SALOMEDS::Strudy and Entry!!!");
+ return TVisualObjPtr();
}
+ // Update object
+ bool objModified = false;
+ if ( aVisualObj ) {
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ objModified = aVisualObj->Update();
+ }
+ catch (...) {
+#ifdef _DEBUG_
+ cout << "Exception in SMESHGUI_VTKUtils::GetVisualObj()" << endl;
+#endif
+ OnVisuException();
+ RemoveVisualObjectWithActors( theEntry ); // remove this object
+ aVisualObj.reset();
+ }
+ }
+
+ if ( objModified ) {
+ // PAL16631. Mesurements showed that to show aVisualObj in shading mode,
+ // ~10 times more memory is used than it occupies.
+ // Warn the user if there is less free memory than 30 sizes of a grid
+ int freeMB = SMDS_Mesh::CheckMemory(true);
+ int usedMB = aVisualObj->GetUnstructuredGrid()->GetActualMemorySize() / 1024;
+ if ( freeMB > 0 && usedMB * 30 > freeMB ) {
+ int continu = SUIT_MessageBox::warn2
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"),
+ QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
+ 1, 0, 1);
+ if ( !continu ) {
+ // remove the corresponding actors from all views
+ RemoveVisualObjectWithActors( theEntry );
+ aVisualObj.reset();
+ }
+ }
+ }
+
return aVisualObj;
}
void RepaintCurrentView()
{
if (SVTK_ViewWindow* wnd = GetCurrentVtkView())
- {
- wnd->getRenderer()->Render();
- wnd->Repaint(false);
+ {
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ wnd->getRenderer()->Render();
+ wnd->Repaint(false);
+ }
+ catch (...) {
+ OnVisuException();
+#ifdef _DEBUG_
+ cout << "Exception in SMESHGUI_VTKUtils::RepaintCurrentView()" << endl;
+#endif
}
+ }
}
void RepaintViewWindow(SVTK_ViewWindow* theWindow)
{
- theWindow->getRenderer()->Render();
- theWindow->Repaint();
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ theWindow->getRenderer()->Render();
+ theWindow->Repaint();
+ }
+ catch (...) {
+ OnVisuException();
+#ifdef _DEBUG_
+ cout << "Exception in SMESHGUI_VTKUtils::RepaintViewWindow(SVTK_ViewWindow)" << endl;
+#endif
+ }
}
void RenderViewWindow(SVTK_ViewWindow* theWindow)
{
- theWindow->getRenderer()->Render();
- theWindow->Repaint();
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ theWindow->getRenderer()->Render();
+ theWindow->Repaint();
+ }
+ catch (...) {
+ OnVisuException();
+#ifdef _DEBUG_
+ cout << "Exception in SMESHGUI_VTKUtils::RenderViewWindow(SVTK_ViewWindow)" << endl;
+#endif
+ }
}
void FitAll(){
if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ){
- wnd->onFitAll();
- wnd->Repaint();
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ wnd->onFitAll();
+ wnd->Repaint();
+ }
+ catch (...) {
+ OnVisuException();
+#ifdef _DEBUG_
+ cout << "Exception in SMESHGUI_VTKUtils::FitAll()" << endl;
+#endif
+ }
}
}
void DisplayActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
- vtkWnd->AddActor(theActor);
- vtkWnd->Repaint();
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ vtkWnd->AddActor(theActor);
+ vtkWnd->Repaint();
+ }
+ catch (...) {
+ OnVisuException();
+#ifdef _DEBUG_
+ cout << "Exception in SMESHGUI_VTKUtils::DisplayActor()" << endl;
+#endif
+ }
}
}
}
}
-
void UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
{
if(SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd)){
{
_PTR(Study) aStudy = GetActiveStudyDocument();
CORBA::Long anId = aStudy->StudyId();
- TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry());
- if( aVisualObj )
- aVisualObj->Update();
- if ( theDisplay )
- UpdateView(SMESH::eDisplay,theIO->getEntry());
+ if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry())) {
+ // if( aVisualObj )
+ // aVisualObj->Update(); -> PAL16631, already done in GetVisualObj()
+ if ( theDisplay )
+ UpdateView(SMESH::eDisplay,theIO->getEntry());
+ }
}