]> SALOME platform Git repositories - plugins/hybridplugin.git/commitdiff
Salome HOME
bos #24596 [CEA] New MeshGems license
authoreap <eap@opencascade.com>
Thu, 5 Aug 2021 13:02:52 +0000 (16:02 +0300)
committereap <eap@opencascade.com>
Thu, 5 Aug 2021 13:02:52 +0000 (16:02 +0300)
bin/mg-hybrid.bash
src/HYBRIDPlugin/CMakeLists.txt
src/HYBRIDPlugin/MG_HYBRID_API.cxx
src/HYBRIDPlugin/MG_HYBRID_API.hxx

index cb6fa2a504b81cdcfdb1d13d60e9e7fd661565b6..bdcadb7519110805f6e937198cd382ee56be6e07 100755 (executable)
@@ -49,13 +49,19 @@ resFindOutFile="None"
 echo "mg-hybrid.bash initial parameters are:" $*
 #$0 is ignored
 
-echo "mg-hybrid.bash assume licence file set:"
-env | grep DLIM
-
 findOutFile $*
 echo "result output File is:" $resFindOutFile
 
-$MESHGEMS_ROOT_DIR/bin/run_mg-hybrid.sh $*
+if test -f "$MESHGEMS_ROOT_DIR/bin/run_mg-hybrid.sh"; then
+
+    echo "mg-hybrid.bash assume licence file set:"
+    env | grep DLIM
+
+
+    $MESHGEMS_ROOT_DIR/bin/run_mg-hybrid.sh $*
+else
+    $MESHGEMS_ROOT_DIR/bin/Linux_64/mg-hybrid.exe $*
+fi
 
 #$MESHGEMS_ROOT_DIR/bin/Linux_64/mg-hybrid.exe $*
 
index c210e96bccc5cd26f342cf07c3d3805b07e709a4..86049b69ea10be786865f3f5fd13715ae031ca16 100644 (file)
@@ -54,6 +54,7 @@ SET(_link_LIBRARIES
   ${SMESH_SMDS}
   ${SMESH_StdMeshers}
   ${SMESH_MeshDriverGMF}
+  ${SMESH_SMESHUtils}
   ${KERNEL_SalomeGenericObj}
   ${KERNEL_SALOMELocalTrace}
   ${KERNEL_SALOMEBasics}
index 6d12bf0fcec2d4df1c247c13229a0a639662973f..b0f2f9d53dd5c89f646a05b2ca5c6b203a0b0172 100644 (file)
 
 #include <SMESH_Comment.hxx>
 #include <SMESH_File.hxx>
+#include <SMESH_MGLicenseKeyGen.hxx>
 #include <Utils_SALOME_Exception.hxx>
 
-#include <vector>
-#include <iterator>
 #include <cstring>
+#include <iostream>
+#include <iterator>
+#include <vector>
 
 #ifdef USE_MG_LIBS
 
@@ -694,6 +696,14 @@ void MG_HYBRID_API::LibData::Init()
 
 bool MG_HYBRID_API::LibData::Compute()
 {
+  // MG license
+  std::string errorTxt;
+  if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( _surf_mesh, errorTxt ))
+  {
+    AddError( SMESH_Comment( "Problem with library SalomeMeshGemsKeyGenerator: ") << errorTxt );
+    return false;
+  }
+
   // Set surface mesh
   status_t ret = hybrid_set_surface_mesh( _session, _surf_mesh );
   if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh");
@@ -749,6 +759,7 @@ struct MG_HYBRID_API::LibData // to avoid compiler warnings
 //================================================================================
 
 MG_HYBRID_API::MG_HYBRID_API(volatile bool& cancelled_flag, double& progress)
+  :_nbNodes(0), _nbEdges(0), _nbFaces(0), _nbVolumes(0)
 {
   _useLib = false;
   _libData = new LibData( cancelled_flag, progress );
@@ -851,6 +862,21 @@ bool MG_HYBRID_API::Compute( const std::string& cmdLine, std::string& errStr )
 #endif
   }
 
+  // add MG license key
+  {
+    std::string errorTxt, meshIn;
+    std::string key = SMESHUtils_MGLicenseKeyGen::GetKey( meshIn,
+                                                          _nbNodes, _nbEdges, _nbFaces, _nbVolumes,
+                                                          errorTxt );
+    if ( key.empty() )
+    {
+      errStr = "Problem with library SalomeMeshGemsKeyGenerator: " + errorTxt;
+      return false;
+    }
+
+    const_cast< std::string& >( cmdLine ) += " --key " + key;
+  }
+
   int err = system( cmdLine.c_str() ); // run
 
   if ( err )
@@ -1147,6 +1173,15 @@ int  MG_HYBRID_API::GmfOpenMesh(const char* theFile, int rdOrWr, int ver, int di
 
 void MG_HYBRID_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nb )
 {
+  if ( iMesh == 1 )
+  {
+    switch ( what ) {
+    case GmfVertices:  _nbNodes = nb; break;
+    case GmfEdges:     _nbEdges = nb; break;
+    case GmfTriangles: _nbFaces = nb; break;
+    default:;
+    }
+  }
   if ( _useLib ) {
 #ifdef USE_MG_LIBS
     switch ( what ) {
index bbc3e813584acc3bba04c903ee0cfc723b19d56a..66aacec730774db61a6baef38126da249c32baa9 100644 (file)
@@ -84,6 +84,12 @@ private:
   LibData*      _libData;
   std::set<int> _openFiles;
   std::string   _logFile;
+
+  // count mesh entities for MG license key generation
+  int           _nbNodes;
+  int           _nbEdges;
+  int           _nbFaces;
+  int           _nbVolumes;
 };
 
 #endif