Salome HOME
Merging with V3_2_4 T4_0_a1 V4_0a1 V4_0a2
authorabd <abd@opencascade.com>
Fri, 9 Feb 2007 12:51:10 +0000 (12:51 +0000)
committerabd <abd@opencascade.com>
Fri, 9 Feb 2007 12:51:10 +0000 (12:51 +0000)
configure.in.base
src/GHS3DPlugin_GHS3D.cxx
src/GHS3DPlugin_GHS3D.hxx

index f9755aae8075186cac7331c0bc5f347999bfbde7..93ab52d5133246012a5725600ecf8844e4e613b8 100644 (file)
@@ -22,8 +22,8 @@ AC_CANONICAL_HOST
 PACKAGE=salome
 AC_SUBST(PACKAGE)
 
-VERSION=3.2.2
-XVERSION=0x030202
+VERSION=4.0.0
+XVERSION=0x040000
 AC_SUBST(VERSION)
 AC_SUBST(XVERSION)
 
index cf89cf863f09c44cc02b1543e120efb655687cf5..b779e95e346cf1a3f53fac0fed93859b5fa68127 100644 (file)
@@ -399,6 +399,53 @@ static TCollection_AsciiString getTmpDir()
   return aTmpDir;
 }
 
+//================================================================================
+/*!
+ * \brief Decrease amount of memory GHS3D may use until it can allocate it
+  * \param nbMB - memory size to adjust
+  * \param aLogFileName - file for GHS3D output
+  * \retval bool - false if GHS3D can not run for any reason
+ */
+//================================================================================
+
+static bool adjustMemory(int & nbMB, const TCollection_AsciiString & aLogFileName)
+{
+  TCollection_AsciiString cmd( "ghs3d -m " );
+  cmd += nbMB;
+  cmd += " 1>";
+  cmd += aLogFileName;
+
+  system( cmd.ToCString() ); // run
+
+  // analyse log file
+
+  FILE * aLogFile = fopen( aLogFileName.ToCString(), "r" );
+  if ( aLogFile )
+  {
+    bool memoryOK = true;
+    char * aPtr;
+    char aBuffer[ GHS3DPlugin_BUFLENGTH ];
+    int aLineNb = 0;
+    do { 
+      GHS3DPlugin_ReadLine( aPtr, aBuffer, aLogFile, aLineNb );
+      if ( aPtr ) {
+        TCollection_AsciiString line( aPtr );
+        if ( line.Search( "UNABLE TO ALLOCATE MEMORY" ) > 0 )
+          memoryOK = false;
+      }
+    } while ( aPtr && memoryOK );
+
+    fclose( aLogFile );
+
+    if ( !memoryOK ) {
+      nbMB *= 0.75;
+      return adjustMemory( nbMB, aLogFileName );
+    }
+    return true;
+  }
+  return false;
+}
+
 //=============================================================================
 /*!
  *Here we are going to use the GHS3D mesher
@@ -481,8 +528,10 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   struct sysinfo si;
   int err = sysinfo( &si );
   if ( err == 0 ) {
+    int MB = 0.9 * ( si.freeram + si.freeswap ) * si.mem_unit / 1024 / 1024;
+    adjustMemory( MB, aLogFileName );
     memory = "-m ";
-    memory += int ( 0.8 * ( si.freeram + si.freeswap ) * si.mem_unit / 1024 / 1024 );
+    memory += MB;
   }
 #endif
 
@@ -533,48 +582,3 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   
   return Ok;
 }
-
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream & GHS3DPlugin_GHS3D::SaveTo(ostream & save)
-{
-  return save;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & GHS3DPlugin_GHS3D::LoadFrom(istream & load)
-{
-  return load;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream & operator << (ostream & save, GHS3DPlugin_GHS3D & hyp)
-{
-  return hyp.SaveTo( save );
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & operator >> (istream & load, GHS3DPlugin_GHS3D & hyp)
-{
-  return hyp.LoadFrom( load );
-}
index a3855abc2e4f5cc93c42fda957e7d81258684c7f..ebe1933952111f8656b0e2cf79c0198f74f59613 100644 (file)
@@ -43,11 +43,6 @@ public:
   virtual bool Compute(SMESH_Mesh&         aMesh,
                       const TopoDS_Shape& aShape);
 
-  ostream & SaveTo(ostream & save);
-  istream & LoadFrom(istream & load);
-  friend ostream & operator << (ostream & save, GHS3DPlugin_GHS3D & hyp);
-  friend istream & operator >> (istream & load, GHS3DPlugin_GHS3D & hyp);
-
 };
 
 #endif