Salome HOME
Merge branch 'occ/new_mg_licnese'
[modules/smesh.git] / src / SMESH / MG_ADAPT.cxx
index 6253f497574ce5d49293e631bad06802edfcd8cd..27a57c894cc24edb5544fa21a0d1b1b1807641dc 100644 (file)
 
 #include "MG_ADAPT.hxx"
 
-#include "SMESH_File.hxx"
-#include "SMESH_Comment.hxx"
+#include <DriverGMF_Read.hxx>
+#include <SMESH_Comment.hxx>
+#include <SMESH_File.hxx>
+#include <SMESH_MGLicenseKeyGen.hxx>
+#include <SMESH_TypeDefs.hxx>
 
 #include <MEDFileData.hxx>
 #include <MEDFileField.hxx>
@@ -320,7 +323,7 @@ MgAdaptHypothesisData* MgAdapt::getData() const
 }
 void MgAdapt::setMedFileIn(std::string fileName)
 {
-  if ( isFileExist(fileName) )
+  if ( isFileExist( fileName ))
   {
     medFileIn = fileName;
 
@@ -1006,7 +1009,7 @@ std::string MgAdapt::getCommandToRun()
         cmd += " --";
       else
         cmd += " ";
-//       std::cout << "--- option: '" << option << ", value: '" << value <<"'"<< std::endl;
+      //       std::cout << "--- option: '" << option << ", value: '" << value <<"'"<< std::endl;
       cmd += option + " " + value;
     }
   }
@@ -1016,13 +1019,31 @@ std::string MgAdapt::getCommandToRun()
   {
     cmd+= " --verbose "+ ToComment(verbosityLevel);
   }
-    //~}
-//~cmd+= " >"
+  // get license key
+  {
+    smIdType nbVertex, nbEdge, nbFace, nbVol;
+    DriverGMF_Read gmfReader;
+    gmfReader.SetFile( meshIn );
+    gmfReader.GetMeshInfo( nbVertex, nbEdge, nbFace, nbVol );
+
+    std::string errorTxt;
+    std::string key = SMESHUtils_MGLicenseKeyGen::GetKey( meshIn,
+                                                          FromSmIdType<int>( nbVertex ),
+                                                          FromSmIdType<int>( nbEdge ),
+                                                          FromSmIdType<int>( nbFace ),
+                                                          FromSmIdType<int>( nbVol ),
+                                                          errorTxt );
+    if ( key.empty() )
+      return ToComment( "Problem with library SalomeMeshGemsKeyGenerator: " + errorTxt );
+
+    cmd += " --key " + key;
+  }
+
 #ifdef WIN32
-    cmd += " < NUL";
+  cmd += " < NUL";
 #endif
-//   std::cout << "--- cmd :"<< std::endl;
-//   std::cout << cmd << std::endl;
+  //   std::cout << "--- cmd :"<< std::endl;
+  //   std::cout << cmd << std::endl;
 
   return cmd;
 }
@@ -1074,7 +1095,9 @@ std::string MgAdapt::defaultWorkingDirectory()
   {
     aTmpDir = Tmp_dir;
   }
-  else {
+
+  if ( ! isFileExist( aTmpDir ))
+  {
 #ifdef WIN32
     aTmpDir = "C:\\";
 #else