Salome HOME
Change from double to long to handle the max memory size in the hypothesis creator... fbt/max_memory_param_float V7_6_0b1
authorFlorian BRUNET <FB15EB3N@dsp0657834.(none)>
Wed, 8 Apr 2015 15:46:47 +0000 (17:46 +0200)
committerFlorian BRUNET <FB15EB3N@dsp0657834.(none)>
Fri, 10 Apr 2015 08:45:02 +0000 (10:45 +0200)
idl/GHS3DPlugin_Algorithm.idl
src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx
src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx
src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx
src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx
src/GUI/GHS3DPluginGUI_AdvWidget_QTD.ui
src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx
src/GUI/GHS3DPluginGUI_HypothesisCreator.h

index f1a630649823ab47dd68184296bfd93ec8a992ae..18e7a380d89bce6b21f5c4f03b116194f9c81392 100644 (file)
@@ -82,15 +82,15 @@ module GHS3DPlugin
      * Maximal size of memory to be used by the algorithm (in Megabytes).
      * Negative value means not to use this option
      */
-    void SetMaximumMemory(in double MB) raises (SALOME::SALOME_Exception);
-    double GetMaximumMemory();
+    void SetMaximumMemory(in long MB) raises (SALOME::SALOME_Exception);
+    long GetMaximumMemory();
     /*!
      * Initial size of memory to be used by the algorithm (in Megabytes) in
      * automatic memory adjustment mode. Default is zero.
      * Negative value means not to use this option
      */
-    void SetInitialMemory(in double MB) raises (SALOME::SALOME_Exception);
-    double GetInitialMemory();
+    void SetInitialMemory(in long MB) raises (SALOME::SALOME_Exception);
+    long GetInitialMemory();
     /*!
      * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium
      */
index f8a7c6908652a254649e027acdc9878063d15330..f65da0a71128ec8d118676b9454ae7768851923b 100644 (file)
@@ -136,7 +136,7 @@ bool GHS3DPlugin_Hypothesis::GetToMakeGroupsOfDomains(const GHS3DPlugin_Hypothes
 //function : SetMaximumMemory
 //=======================================================================
 
-void GHS3DPlugin_Hypothesis::SetMaximumMemory(double MB)
+void GHS3DPlugin_Hypothesis::SetMaximumMemory(long MB)
 {
   if ( myMaximumMemory != MB ) {
     myMaximumMemory = MB;
@@ -149,7 +149,7 @@ void GHS3DPlugin_Hypothesis::SetMaximumMemory(double MB)
 //           * automatic memory adjustment mode. Default is zero
 //=======================================================================
 
-double GHS3DPlugin_Hypothesis::GetMaximumMemory() const
+long GHS3DPlugin_Hypothesis::GetMaximumMemory() const
 {
   return myMaximumMemory;
 }
@@ -158,7 +158,7 @@ double GHS3DPlugin_Hypothesis::GetMaximumMemory() const
 //function : SetInitialMemory
 //=======================================================================
 
-void GHS3DPlugin_Hypothesis::SetInitialMemory(double MB)
+void GHS3DPlugin_Hypothesis::SetInitialMemory(long MB)
 {
   if ( myInitialMemory != MB ) {
     myInitialMemory = MB;
@@ -170,7 +170,7 @@ void GHS3DPlugin_Hypothesis::SetInitialMemory(double MB)
 //function : GetInitialMemory
 //=======================================================================
 
-double GHS3DPlugin_Hypothesis::GetInitialMemory() const
+long GHS3DPlugin_Hypothesis::GetInitialMemory() const
 {
   return myInitialMemory;
 }
@@ -852,22 +852,22 @@ bool GHS3DPlugin_Hypothesis::DefaultToMakeGroupsOfDomains()
 #include <windows.h>
 #endif
 
-double  GHS3DPlugin_Hypothesis::DefaultMaximumMemory()
+long  GHS3DPlugin_Hypothesis::DefaultMaximumMemory()
 {
 #ifndef WIN32
   struct sysinfo si;
-  int err = sysinfo( &si );
+  long err = sysinfo( &si );
   if ( err == 0 ) {
-    int ramMB = si.totalram * si.mem_unit / 1024 / 1024;
+    long ramMB = si.totalram * si.mem_unit / 1024 / 1024;
     return ( 0.7 * ramMB );
   }
 #else
   // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
   MEMORYSTATUSEX statex;
   statex.dwLength = sizeof (statex);
-  int err = GlobalMemoryStatusEx (&statex);
+  long err = GlobalMemoryStatusEx (&statex);
   if (err != 0) {
-    int totMB = 
+    long totMB = 
       statex.ullTotalPhys / 1024 / 1024 +
       statex.ullTotalPageFile / 1024 / 1024 +
       statex.ullTotalVirtual / 1024 / 1024;
@@ -881,7 +881,7 @@ double  GHS3DPlugin_Hypothesis::DefaultMaximumMemory()
 //function : DefaultInitialMemory
 //=======================================================================
 
-double  GHS3DPlugin_Hypothesis::DefaultInitialMemory()
+long  GHS3DPlugin_Hypothesis::DefaultInitialMemory()
 {
   return DefaultMaximumMemory();
 }
@@ -1480,20 +1480,20 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h
   // Default memory is defined at MG-Tetra installation but it may be not enough,
   // so allow to use about all available memory
   if ( m ) {
-    double aMaximumMemory = hyp ? hyp->myMaximumMemory : -1;
+    long aMaximumMemory = hyp ? hyp->myMaximumMemory : -1;
     ostringstream tmpMaximumMemory;
     cmd += " -m ";
     if ( aMaximumMemory < 0 )
-      tmpMaximumMemory << std::fixed << std::setprecision(0) << DefaultMaximumMemory();
+      tmpMaximumMemory << DefaultMaximumMemory();
     else
-      tmpMaximumMemory << std::fixed << std::setprecision(0) << aMaximumMemory;
+      tmpMaximumMemory << aMaximumMemory;
     cmd += tmpMaximumMemory.str().c_str();
   }
   if ( M && !useBndRecovery ) {
-    double aInitialMemory = hyp ? hyp->myInitialMemory : -1;
+    long aInitialMemory = hyp ? hyp->myInitialMemory : -1;
     cmd += " -M ";
     if ( aInitialMemory > 0 )
-      cmd += aInitialMemory;
+      cmd += (int)aInitialMemory;
     else
       cmd += "100";
   }
index 5f217a4ea44f2a13cc33fdc19bda9bd1429495f1..4db812a903b781cd201ad92177a16018baaa95f6 100644 (file)
@@ -134,14 +134,14 @@ public:
   /*!
    * Maximal size of memory to be used by the algorithm (in Megabytes)
    */
-  void SetMaximumMemory(double MB);
-  double GetMaximumMemory() const;
+  void SetMaximumMemory(long MB);
+  long GetMaximumMemory() const;
   /*!
    * Initial size of memory to be used by the algorithm (in Megabytes) in
    * automatic memory adjustment mode. Default is zero
    */
-  void SetInitialMemory(double MB);
-  double GetInitialMemory() const;
+  void SetInitialMemory(long MB);
+  long GetInitialMemory() const;
   /*!
    * Optimization level: 0-none, 1-light, 2-medium, 3-standard+, 4-strong. Default is medium
    */
@@ -289,8 +289,8 @@ public:
   
   static bool   DefaultMeshHoles();
   static bool   DefaultToMakeGroupsOfDomains();
-  static double DefaultMaximumMemory();
-  static double DefaultInitialMemory();
+  static long   DefaultMaximumMemory();
+  static long   DefaultInitialMemory();
   static short  DefaultOptimizationLevel();
   static std::string DefaultWorkingDirectory();
   static bool   DefaultKeepFiles();
@@ -339,8 +339,8 @@ private:
 
   bool   myToMeshHoles;
   bool   myToMakeGroupsOfDomains;
-  double myMaximumMemory;
-  double myInitialMemory;
+  long   myMaximumMemory;
+  long   myInitialMemory;
   short  myOptimizationLevel;
   bool   myKeepFiles;
   std::string myWorkingDirectory;
index 49da13b79ebbc5c9def654d4f51e63eecccea2a7..5e839346b11ade2f98b71da2dd4ca24ec6c2b390 100644 (file)
@@ -115,7 +115,7 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
 //function : SetMaximumMemory
 //=======================================================================
 
-void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Double MB)
+void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB)
    throw ( SALOME::SALOME_Exception )
 {
   if ( MB == 0 )
@@ -129,7 +129,7 @@ void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Double MB)
 //function : GetMaximumMemory
 //=======================================================================
 
-CORBA::Double GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
+CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
 {
   ASSERT(myBaseImpl);
   return this->GetImpl()->GetMaximumMemory();
@@ -139,7 +139,7 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
 //function : SetInitialMemory
 //=======================================================================
 
-void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Double MB)
+void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB)
   throw ( SALOME::SALOME_Exception )
 {
   if ( MB == 0 )
@@ -153,7 +153,7 @@ void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Double MB)
 //function : GetInitialMemory
 //=======================================================================
 
-CORBA::Double GHS3DPlugin_Hypothesis_i::GetInitialMemory()
+CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory()
 {
   ASSERT(myBaseImpl);
   return this->GetImpl()->GetInitialMemory();
index 58a881bf0e11b2b5b8da99f9cf7faeb60adf03ab..fd75156f263549dc233d8991dda9632d6680e57a 100644 (file)
@@ -65,14 +65,14 @@ class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i:
   /*!
    * Maximal size of memory to be used by the algorithm (in Megabytes)
    */
-  void SetMaximumMemory(CORBA::Double MB) throw ( SALOME::SALOME_Exception );
-  CORBA::Double GetMaximumMemory();
+  void SetMaximumMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception );
+  CORBA::Long GetMaximumMemory();
   /*!
    * Initial size of memory to be used by the algorithm (in Megabytes) in
    * automatic memory adjustment mode. Default is zero
    */
-  void SetInitialMemory(CORBA::Double MB) throw ( SALOME::SALOME_Exception );
-  CORBA::Double GetInitialMemory();
+  void SetInitialMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception );
+  CORBA::Long GetInitialMemory();
   /*!
    * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium
    */
index 1913752d3548fbc90924e24280dd6ecc8bcc177f..5754262d19922ea9d23c53a13a3ddd907dc7bdc4 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>465</width>
+    <width>485</width>
     <height>477</height>
    </rect>
   </property>
        </widget>
       </item>
       <item row="0" column="2" colspan="2">
-       <widget class="SMESHGUI_SpinBox" name="initialMemorySpin">
+       <widget class="SalomeApp_IntSpinBox" name="initialMemorySpin">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
           <horstretch>1</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
+        <property name="maximum">
+         <number>999999999</number>
+        </property>
        </widget>
       </item>
       <item row="3" column="2" colspan="2">
-       <widget class="SMESHGUI_SpinBox" name="maxMemorySpin">
+       <widget class="SalomeApp_IntSpinBox" name="maxMemorySpin">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
           <horstretch>1</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
+        <property name="maximum">
+         <number>999999999</number>
+        </property>
        </widget>
       </item>
      </layout>
    <extends>QSpinBox</extends>
    <header>SMESHGUI_SpinBox.h</header>
   </customwidget>
+  <customwidget>
+   <class>SalomeApp_IntSpinBox</class>
+   <extends>QSpinBox</extends>
+   <header>SalomeApp_IntSpinBox.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
index fc57275243fd0bff44d860cf451d2ada9c9e152d..b21a1528cb847ed2b84bdb9a8b921081f4e132a2 100644 (file)
@@ -76,28 +76,28 @@ namespace {
 #include <sys/sysinfo.h>
 #endif
 
-  int maxAvailableMemory()
+  long maxAvailableMemory()
   {
 #ifdef WIN32
     // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
     MEMORYSTATUSEX statex;
     statex.dwLength = sizeof (statex);
-    int err = GlobalMemoryStatusEx (&statex);
+    long err = GlobalMemoryStatusEx (&statex);
     if (err != 0) {
-      int totMB = 
+      long totMB = 
         statex.ullTotalPhys / 1024 / 1024 +
         statex.ullTotalPageFile / 1024 / 1024 +
         statex.ullTotalVirtual / 1024 / 1024;
-      return (int) ( 0.7 * totMB );
+      return (long) ( 0.7 * totMB );
     }
 #else
     struct sysinfo si;
-    int err = sysinfo( &si );
+    long err = sysinfo( &si );
     if ( err == 0 ) {
-      int totMB =
+      long totMB =
         si.totalram * si.mem_unit / 1024 / 1024 +
         si.totalswap * si.mem_unit / 1024 / 1024 ;
-      return (int) ( 0.7 * totMB );
+      return (long) ( 0.7 * totMB );
     }
 #endif
     return 0;
@@ -416,11 +416,11 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
   myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
   myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
 
-  myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0);
-  myAdvWidget->maxMemorySpin->setValue( 128.0 );
+  myAdvWidget->maxMemorySpin->stepBy(10);
+  myAdvWidget->maxMemorySpin->setValue( 128 );
 
-  myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0);
-  myAdvWidget->initialMemorySpin->setValue( 100.0 );
+  myAdvWidget->initialMemorySpin->stepBy(10);
+  myAdvWidget->initialMemorySpin->setValue( 100 );
 
   myAdvWidget->initialMemoryLabel            ->setText (tr( "MEGABYTE" ));
   myAdvWidget->maxMemoryLabel                ->setText (tr( "MEGABYTE" ));
@@ -1422,10 +1422,10 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const
   myToMakeGroupsOfDomains                     ->setChecked    ( data.myToMakeGroupsOfDomains );
   myOptimizationLevelCombo                    ->setCurrentIndex( data.myOptimizationLevel );
   myAdvWidget->maxMemoryCheck                 ->setChecked    ( data.myMaximumMemory > 0 );
-  myAdvWidget->maxMemorySpin                  ->setValue      ( qMax( data.myMaximumMemory,
+  myAdvWidget->maxMemorySpin                  ->setValue      ( qMax( (int)data.myMaximumMemory,
                                                                       myAdvWidget->maxMemorySpin->minimum() ));
   myAdvWidget->initialMemoryCheck             ->setChecked    ( data.myInitialMemory > 0 );
-  myAdvWidget->initialMemorySpin              ->setValue      ( qMax( data.myInitialMemory,
+  myAdvWidget->initialMemorySpin              ->setValue      ( qMax( (int)data.myInitialMemory,
                                                                       myAdvWidget->initialMemorySpin->minimum() ));
   myAdvWidget->workingDirectoryLineEdit       ->setText       ( data.myWorkingDir );
   myAdvWidget->keepWorkingFilesCheck           ->setChecked    ( data.myKeepFiles );
index 5c3e57fdeeb44263a0545b6a69dfd6376d732cc3..671e105bf08f79586faa9af89cb912025a94871b 100644 (file)
@@ -143,7 +143,8 @@ typedef struct
 {
   bool    myToMeshHoles,myToMakeGroupsOfDomains,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint,
           myLogInStandardOutput, myRemoveLogOnSuccess;
-  double  myMaximumMemory,myInitialMemory;
+  long    myMaximumMemory;
+  long    myInitialMemory;
   int     myOptimizationLevel;
   QString myName,myWorkingDir,myTextOption;
   double  myGradation;