From c2d7e637b6b23116ff675cee2f7f0f563f8eb437 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 5 Aug 2021 16:02:52 +0300 Subject: [PATCH] bos #24596 [CEA] New MeshGems license bos #24596 [CEA] New MeshGems license --- bin/mg-hybrid.bash | 14 +++++-- src/HYBRIDPlugin/CMakeLists.txt | 1 + src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx | 39 +++++++++---------- src/HYBRIDPlugin/MG_HYBRID_API.cxx | 40 +++++++++++++++++++- src/HYBRIDPlugin/MG_HYBRID_API.hxx | 6 +++ 5 files changed, 75 insertions(+), 25 deletions(-) diff --git a/bin/mg-hybrid.bash b/bin/mg-hybrid.bash index cb6fa2a..bdcadb7 100755 --- a/bin/mg-hybrid.bash +++ b/bin/mg-hybrid.bash @@ -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 $* diff --git a/src/HYBRIDPlugin/CMakeLists.txt b/src/HYBRIDPlugin/CMakeLists.txt index 4fbe4a6..08c2362 100644 --- a/src/HYBRIDPlugin/CMakeLists.txt +++ b/src/HYBRIDPlugin/CMakeLists.txt @@ -53,6 +53,7 @@ SET(_link_LIBRARIES ${SMESH_SMDS} ${SMESH_StdMeshers} ${SMESH_MeshDriverGMF} + ${SMESH_SMESHUtils} ${KERNEL_SalomeGenericObj} ${KERNEL_SALOMELocalTrace} ${KERNEL_SALOMEBasics} diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx index 31bdd19..e2f8e4d 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx @@ -945,26 +945,27 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::Elemen bool HYBRIDPlugin_Hypothesis::SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::smIdType_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName) { TIDSortedElemSet theElemSet; - if ( theIDs->length() == 0 ){MESSAGE("The source group is empty");} - for ( SMESH::smIdType i = 0; i < theIDs->length(); i++) { - SMESH::smIdType ind = theIDs[i]; - if (elementType == SMESH::NODE) - { - const SMDS_MeshNode * node = theMeshDS->FindNode(ind); - if (node) - theElemSet.insert( node ); - } - else - { - const SMDS_MeshElement * elem = theMeshDS->FindElement(ind); - if (elem) - theElemSet.insert( elem ); - } + if ( theIDs->length() == 0 ){MESSAGE("The source group is empty");} + for ( CORBA::ULong i = 0; i < theIDs->length(); i++) + { + SMESH::smIdType ind = theIDs[i]; + if (elementType == SMESH::NODE) + { + const SMDS_MeshNode * node = theMeshDS->FindNode(ind); + if (node) + theElemSet.insert( node ); } + else + { + const SMDS_MeshElement * elem = theMeshDS->FindElement(ind); + if (elem) + theElemSet.insert( elem ); + } + } -// SMDS_ElemIteratorPtr it = theGroup->GetGroupDS()->GetElements(); -// while ( it->more() ) -// theElemSet.insert( it->next() ); + // SMDS_ElemIteratorPtr it = theGroup->GetGroupDS()->GetElements(); + // while ( it->more() ) + // theElemSet.insert( it->next() ); bool added = SetEnforcedElements( theElemSet, elementType, groupName); if (added) { @@ -973,7 +974,7 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SM newEnfMesh->entry = entry; newEnfMesh->elementType = elementType; newEnfMesh->groupName = groupName; - + THYBRIDEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh); if (it == _enfMeshList.end()) { _entryEnfMeshMap[entry].insert(newEnfMesh); diff --git a/src/HYBRIDPlugin/MG_HYBRID_API.cxx b/src/HYBRIDPlugin/MG_HYBRID_API.cxx index 6d12bf0..c656b34 100644 --- a/src/HYBRIDPlugin/MG_HYBRID_API.cxx +++ b/src/HYBRIDPlugin/MG_HYBRID_API.cxx @@ -21,11 +21,13 @@ #include #include +#include #include -#include -#include #include +#include +#include +#include #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,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 ) { diff --git a/src/HYBRIDPlugin/MG_HYBRID_API.hxx b/src/HYBRIDPlugin/MG_HYBRID_API.hxx index bbc3e81..66aacec 100644 --- a/src/HYBRIDPlugin/MG_HYBRID_API.hxx +++ b/src/HYBRIDPlugin/MG_HYBRID_API.hxx @@ -84,6 +84,12 @@ 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 -- 2.39.2