- if (!aMesh->_is_nil()) {
- myMainShape = aMesh->GetShapeToMesh();
- if ( !myMainShape->_is_nil() ) {
- SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
- SMESH::algo_error_array_var errors = gen->GetAlgoState(aMesh,myMainShape);
- if ( errors->length() > 0 ) {
- SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"),
- SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
- tr("SMESH_BUT_OK"));
- onCancel();
- return;
- }
- SUIT_OverrideCursor aWaitCursor;
- try {
- if (gen->Compute(aMesh, myMainShape)) {
- computeFailed = false;
- }
- else {
- anErrors = gen->GetComputeErrors( aMesh, myMainShape );
-// if ( anErrors->length() == 0 ) {
-// SUIT_MessageBox::warn1(desktop(),
-// tr("SMESH_WRN_WARNING"),
-// tr("SMESH_WRN_COMPUTE_FAILED"),
-// tr("SMESH_BUT_OK"));
-// onCancel();
-// return;
-// }
- }
- }
- catch(const SALOME::SALOME_Exception & S_ex){
- SalomeApp_Tools::QtCatchCorbaException(S_ex);
- }
- if ( _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh)) {
- myDlg->myMeshName->setText( aMeshSObj->GetName() );
- SMESH::ModifiedMesh(aMeshSObj, !computeFailed, aMesh->NbNodes() == 0);
- }
+ if (aMesh->_is_nil()) {
+ SUIT_MessageBox::warning(desktop(),
+ tr("SMESH_WRN_WARNING"),
+ tr("SMESH_WRN_NO_AVAILABLE_DATA"));
+ onCancel();
+ return;
+ }
+
+ // COMPUTE MESH
+
+ SMESH::MemoryReserve aMemoryReserve;
+
+ SMESH::compute_error_array_var aCompErrors;
+ QString aHypErrors;
+
+ bool computeFailed = true, memoryLack = false;
+
+ _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
+ myMainShape = aMesh->GetShapeToMesh();
+ bool hasShape = aMesh->HasShapeToMesh();
+ bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
+ if ( shapeOK && aMeshSObj )
+ {
+ myDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
+ SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
+ SMESH::algo_error_array_var errors = gen->GetAlgoState(aMesh,myMainShape);
+ if ( errors->length() > 0 ) {
+ aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
+ }
+ 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;
+ }
+ catch(const SALOME::SALOME_Exception & S_ex){
+ memoryLack = true;
+ }
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ aCompErrors = gen->GetComputeErrors( aMesh, myMainShape );
+ // check if there are memory problems
+ for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
+ memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
+ }
+ catch(const SALOME::SALOME_Exception & S_ex){
+ memoryLack = true;
+ }
+
+ // NPAL16631: if ( !memoryLack )
+ {
+ SMESH::ModifiedMesh(aMeshSObj, !computeFailed, aMesh->NbNodes() == 0);