From: eap Date: Thu, 5 Aug 2021 14:14:34 +0000 (+0300) Subject: bos #24596 [CEA] New MeshGems license X-Git-Tag: V9_8_0a1^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ddaac500e4eb3a157869397c340d0d4c1df7649c;p=plugins%2Fghs3dplugin.git bos #24596 [CEA] New MeshGems license --- diff --git a/src/GHS3DPlugin/MG_Tetra_API.cxx b/src/GHS3DPlugin/MG_Tetra_API.cxx index 1b6b83f..e11629a 100644 --- a/src/GHS3DPlugin/MG_Tetra_API.cxx +++ b/src/GHS3DPlugin/MG_Tetra_API.cxx @@ -22,13 +22,16 @@ #ifdef WIN32 #define NOMINMAX #endif + #include #include +#include #include -#include -#include #include +#include +#include +#include #ifdef USE_MG_LIBS @@ -645,15 +648,26 @@ void MG_Tetra_API::LibData::Init() bool MG_Tetra_API::LibData::Compute() { status_t ret; + std::string errorTxt; if ( _tetraNodes.empty() ) { + if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( _tria_mesh, errorTxt )) + { + AddError( SMESH_Comment( "Problem with library SalomeMeshGemsKeyGenerator: ") << errorTxt ); + return false; + } // Set surface mesh ret = tetra_set_surface_mesh( _session, _tria_mesh ); if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh"); } else { + if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( _tria_mesh, errorTxt )) + { + AddError( SMESH_Comment( "Problem with library SalomeMeshGemsKeyGenerator: ") << errorTxt ); + return false; + } ret = tetra_set_volume_mesh( _session, _tria_mesh ); if ( ret != STATUS_OK ) MG_Error( "unable to set volume mesh"); } @@ -709,7 +723,8 @@ struct MG_Tetra_API::LibData // to avoid compiler warnings */ //================================================================================ -MG_Tetra_API::MG_Tetra_API(volatile bool& cancelled_flag, double& progress) +MG_Tetra_API::MG_Tetra_API(volatile bool& cancelled_flag, double& progress): + _nbNodes(0), _nbEdges(0), _nbFaces(0), _nbVolumes(0) { _useLib = false; _libData = new LibData( cancelled_flag, progress ); @@ -803,7 +818,7 @@ bool MG_Tetra_API::Compute( const std::string& cmdLine, std::string& errStr ) } // compute - bool ok = _libData->Compute(); + bool ok = _libData->Compute(); GetLog(); // write a log file _logFile = ""; // not to write it again @@ -812,6 +827,21 @@ bool MG_Tetra_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 ) @@ -1069,6 +1099,16 @@ int MG_Tetra_API::GmfOpenMesh(const char* theFile, int rdOrWr, int ver, int dim void MG_Tetra_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 ) { diff --git a/src/GHS3DPlugin/MG_Tetra_API.hxx b/src/GHS3DPlugin/MG_Tetra_API.hxx index fa74ebc..82912c9 100644 --- a/src/GHS3DPlugin/MG_Tetra_API.hxx +++ b/src/GHS3DPlugin/MG_Tetra_API.hxx @@ -82,6 +82,13 @@ private: LibData* _libData; std::set _openFiles; std::string _logFile; + + // count mesh entities for MG license key generation + int _nbNodes; + int _nbEdges; + int _nbFaces; + int _nbVolumes; + }; #endif