]> SALOME platform Git repositories - plugins/hybridplugin.git/commitdiff
Salome HOME
Upgrade to new MG license mechanism and keep compatibility with old ones cbr/new_mg_license_215
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Tue, 7 Mar 2023 14:14:33 +0000 (15:14 +0100)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Tue, 7 Mar 2023 14:14:33 +0000 (15:14 +0100)
src/HYBRIDPlugin/MG_HYBRID_API.cxx

index 7481104210c1ded905f582613ce971703ba7b0ff..d2b9ed8b26eadaff3ceeea876f98e3af3de1ec27 100644 (file)
@@ -36,6 +36,9 @@ extern "C"{
 #include <meshgems/hybrid.h>
 }
 
+#define MESHGEMS_VERSION_HEX (MESHGEMS_VERSION_MAJOR << 16 | MESHGEMS_VERSION_MINOR << 8 | MESHGEMS_VERSION_PATCH)
+#define MESHGEMS_215 (2 << 16 | 15 << 8 | 0)
+
 struct MG_HYBRID_API::LibData
 {
   // MG objects
@@ -698,14 +701,28 @@ bool MG_HYBRID_API::LibData::Compute()
 {
   // MG license
   std::string errorTxt;
+  status_t ret;
+#if MESHGEMS_VERSION_HEX > MESHGEMS_215
+  // unlock Hybrid license
+  std::string SPATIAL_LICENSE = SMESHUtils_MGLicenseKeyGen::GetKey(errorTxt);
+  ret = meshgems_hybrid_unlock_product(SPATIAL_LICENSE.c_str());
+  if STATUS_IS_ERROR( ret )
+    {
+    AddError( SMESH_Comment( "Problem with SPATIAL_LICENSE to unlock Hybrid: ") << errorTxt );
+    return false;
+    }
+  else
+    MESSAGE("SPATIAL_LICENSE unlock Hybrid: " << ret);
+#else
   if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( _surf_mesh, errorTxt ))
   {
     AddError( SMESH_Comment( "Problem with library SalomeMeshGemsKeyGenerator: ") << errorTxt );
     return false;
   }
+#endif
 
   // Set surface mesh
-  status_t ret = hybrid_set_surface_mesh( _session, _surf_mesh );
+  ret = hybrid_set_surface_mesh( _session, _surf_mesh );
   if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh");
 
 #ifndef WIN32