]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Avoid MED file reading failure caused by low memory
authoreap <eap@opencascade.com>
Fri, 29 Jan 2016 12:47:48 +0000 (15:47 +0300)
committereap <eap@opencascade.com>
Fri, 29 Jan 2016 12:47:48 +0000 (15:47 +0300)
 Failure reason: system(...) command exits with "Cannot allocate memory"

src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx
src/MEDWrapper/Factory/MED_Factory.cxx
src/SMESH/SMESH_Mesh.cxx
src/SMESH_SWIG/smeshBuilder.py

index 74c3e6da8b73f060b0de531b9d2a06d2c29093aa..58f9c0ca024bcb095ba5b5b63407b84149060769 100644 (file)
@@ -172,7 +172,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
       //------------------------------------------------------
       PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
       if (!aNodeInfo) {
-        aResult = DRS_FAIL;
+        aResult = addMessage("No nodes", /*isFatal=*/true );
         continue;
       }
       aMeshInfo->myDim=aMeshInfo->mySpaceDim;// ignore meshdim in MEDFile because it can be false
@@ -365,9 +365,9 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
                 }
 #ifndef _DEXCEPT_
               } catch(const std::exception& exc) {
-                aResult = DRS_FAIL;
+                aResult = addMessage( exc.what(), /*isFatal=*/true );
               } catch (...) {
-                aResult = DRS_FAIL;
+                aResult = addMessage( "Unknown exception", /*isFatal=*/true );
               }
 #endif
               if ( !anElement ) {
@@ -522,10 +522,10 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
 #ifndef _DEXCEPT_
               }catch(const std::exception& exc){
                 INFOS("Following exception was caught:\n\t"<<exc.what());
-                aResult = DRS_FAIL;
+                aResult = addMessage( exc.what(), /*isFatal=*/true );
               }catch(...){
                 INFOS("Unknown exception was caught !!!");
-                aResult = DRS_FAIL;
+                aResult = addMessage( "Unknown exception", /*isFatal=*/true );
               }
 #endif          
               if(!anIsValidConnect)
@@ -958,10 +958,10 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
 #ifndef _DEXCEPT_
               } catch(const std::exception& exc) {
                 INFOS("The following exception was caught:\n\t"<<exc.what());
-                aResult = DRS_FAIL;
+                aResult = addMessage( exc.what(), /*isFatal=*/true );
               } catch(...) {
                 INFOS("Unknown exception was caught !!!");
-                aResult = DRS_FAIL;
+                aResult = addMessage( "Unknown exception", /*isFatal=*/true );
               }
 #endif
               if (!anElement) {
@@ -993,12 +993,12 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
   catch(const std::exception& exc)
   {
     INFOS("The following exception was caught:\n\t"<<exc.what());
-    aResult = DRS_FAIL;
+    aResult = addMessage( exc.what(), /*isFatal=*/true );
   }
   catch(...)
   {
     INFOS("Unknown exception was caught !!!");
-    aResult = DRS_FAIL;
+    aResult = addMessage( "Unknown exception", /*isFatal=*/true );
   }
 #endif
   if (myMesh)
index 3bb54574e402c2106f117aae1986d71e1b00bb22..f4108be584cd1a671031c1d2b4def94335926624 100644 (file)
@@ -25,6 +25,7 @@
 #include "MED_V2_2_Wrapper.hxx"
 
 #include <stdio.h>
+#include <errno.h>
 #include <sstream>
 
 #include <med.h>
@@ -53,7 +54,7 @@ namespace MED
 #ifndef WIN32
     if (access(theFileName.c_str(),F_OK))
       return aVersion;
-    if(theDoPreCheckInSeparateProcess){
+    if ( theDoPreCheckInSeparateProcess ) {
       // First check, is it possible to deal with the file
       std::ostringstream aStr;
       // File name is in quotes for the case of space(s) inside it (PAL13009)
@@ -64,8 +65,9 @@ namespace MED
       std::string aCommand = aStr.str();
       int aStatus = system(aCommand.c_str());
 
-      BEGMSG(MYDEBUG,"aCommand = '"<<aCommand<<"'; aStatus = "<<aStatus<<std::endl);
-      if(aStatus != 0)
+      BEGMSG( MYDEBUG,"aCommand = '" << aCommand << "'; aStatus = " << aStatus
+             << "; errno = " << errno << " = " << strerror( errno ) << std::endl );
+      if ( aStatus != 0 && errno != EAGAIN && errno != ENOMEM ) // "Cannot allocate memory" is OK
         return aVersion;
     }
 #endif
index 6436b9a5d3c440ad7c38308b5e9f25963e218f02..ecc7888e7329341334607a3bbb45fdc22dd9355c 100644 (file)
@@ -536,6 +536,10 @@ int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName)
     MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
     MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
   }
+#ifdef _DEBUG_
+  SMESH_ComputeErrorPtr er = myReader.GetError();
+  if ( er && !er->IsOK() ) cout << er->myComment << endl;
+#endif
 
   // Reading groups (sub-meshes are out of scope of MED import functionality)
   list<TNameAndType> aGroupNames = myReader.GetGroupNamesAndTypes();
index 0dc3b25f05890e36ef4893fdce7f48ef9e29ceac..2c98e16531d3c1bfe36890986f53e22cb43d70a6 100644 (file)
@@ -1424,8 +1424,10 @@ class Mesh:
 
             # Treat compute errors
             computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
+            shapeText = ""
             for err in computeErrors:
-                shapeText = " on %s" % self.GetSubShapeName( err.subShapeID )
+                if self.mesh.HasShapeToMesh():
+                    shapeText = " on %s" % self.GetSubShapeName( err.subShapeID )
                 errText = ""
                 stdErrors = ["OK",                   #COMPERR_OK
                              "Invalid input mesh",   #COMPERR_BAD_INPUT_MESH