X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYBRIDPlugin%2FMG_HYBRID_API.cxx;h=3288283bfe72ec32c432576f873da4d8595b7eb1;hb=7972d6e3ce34777547876d3f4d52fc7c09d39334;hp=fb5856a15eab691fe7e15e76022db6f18a31ddb7;hpb=0f738de9cfb2695b6f35214bc7ce470a6ac05818;p=plugins%2Fhybridplugin.git diff --git a/src/HYBRIDPlugin/MG_HYBRID_API.cxx b/src/HYBRIDPlugin/MG_HYBRID_API.cxx index fb5856a..3288283 100644 --- a/src/HYBRIDPlugin/MG_HYBRID_API.cxx +++ b/src/HYBRIDPlugin/MG_HYBRID_API.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2004-2020 CEA/DEN, EDF R&D +// Copyright (C) 2004-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -21,11 +21,13 @@ #include #include +#include #include -#include -#include #include +#include +#include +#include #ifdef USE_MG_LIBS @@ -694,8 +696,18 @@ void MG_HYBRID_API::LibData::Init() bool MG_HYBRID_API::LibData::Compute() { + // MG license + std::string errorTxt; + status_t ret; + + if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( _surf_mesh, "hybrid", errorTxt )) + { + AddError( SMESH_Comment( "Problem with library SalomeMeshGemsKeyGenerator: ") << errorTxt ); + return false; + } + // 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 @@ -749,6 +761,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 +864,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; + } + if ( key != "0") + const_cast< std::string& >( cmdLine ) += " --key " + key; + } + int err = system( cmdLine.c_str() ); // run if ( err ) @@ -1147,6 +1175,16 @@ 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; + case GmfQuadrilaterals: _nbFaces += nb; break; + default:; + } + } if ( _useLib ) { #ifdef USE_MG_LIBS switch ( what ) {