X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHexoticPlugin%2FMG_Hexotic_API.cxx;h=6dcf7f84778f273e2a631ec71fa6cd55b400877a;hb=bab67ddbc81236f836227f26fb7b869a75af49a3;hp=5e6e1610d14f18d400b38cb7e5d438ec02b60b90;hpb=a331ad4c5cd665ab4f33f4ac132ab55ce9a0a3eb;p=plugins%2Fhexoticplugin.git diff --git a/src/HexoticPlugin/MG_Hexotic_API.cxx b/src/HexoticPlugin/MG_Hexotic_API.cxx index 5e6e161..6dcf7f8 100644 --- a/src/HexoticPlugin/MG_Hexotic_API.cxx +++ b/src/HexoticPlugin/MG_Hexotic_API.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2004-2016 CEA/DEN, EDF R&D +// Copyright (C) 2004-2021 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,11 +25,13 @@ #include #include +#include #include -#include -#include #include +#include +#include +#include #ifdef USE_MG_LIBS @@ -373,7 +375,7 @@ struct MG_Hexotic_API::LibData _nbRequiredTria = nb; } - void AddNode( double x, double y, double z, int domain ) + void AddNode( double x, double y, double z, int /*domain*/ ) { _xyz.push_back( x ); _xyz.push_back( y ); @@ -667,6 +669,14 @@ void MG_Hexotic_API::LibData::Init() bool MG_Hexotic_API::LibData::Compute() { + // MG license + std::string errorTxt; + if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( _tria_mesh, errorTxt )) + { + AddError( SMESH_Comment( "Problem with library SalomeMeshGemsKeyGenerator: ") << errorTxt ); + return false; + } + // Set surface mesh status_t ret = hexa_set_surface_mesh( _session, _tria_mesh ); if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh"); @@ -701,6 +711,14 @@ bool MG_Hexotic_API::LibData::Compute() return true; } +#else // ifdef USE_MG_LIBS + +struct MG_Hexotic_API::LibData // to avoid compiler warnings +{ + volatile bool& _cancelled_flag; + double& _progress; + LibData(volatile bool& cancelled_flag, double& progress): _cancelled_flag{cancelled_flag}, _progress{progress} {} +}; #endif // ifdef USE_MG_LIBS @@ -711,12 +729,13 @@ bool MG_Hexotic_API::LibData::Compute() */ //================================================================================ -MG_Hexotic_API::MG_Hexotic_API(volatile bool& cancelled_flag, double& progress) +MG_Hexotic_API::MG_Hexotic_API(volatile bool& cancelled_flag, double& progress): + _isMesh(true), _nbNodes(0), _nbEdges(0), _nbFaces(0), _nbVolumes(0) { _useLib = false; + _libData = new LibData( cancelled_flag, progress ); #ifdef USE_MG_LIBS _useLib = true; - _libData = new LibData( cancelled_flag, progress ); _libData->Init(); if ( getenv("MG_HEXA_USE_EXE")) _useLib = false; @@ -805,7 +824,7 @@ bool MG_Hexotic_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 @@ -813,6 +832,20 @@ bool MG_Hexotic_API::Compute( const std::string& cmdLine, std::string& errStr ) return ok; #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 @@ -901,7 +934,7 @@ void MG_Hexotic_API::GmfGotoKwd( int iMesh, GmfKwdCod what ) */ //================================================================================ -void MG_Hexotic_API::GmfGetLin( int iMesh, GmfKwdCod what, int* nbNodes, int* faceInd, int* ori, int* domain, int dummy ) +void MG_Hexotic_API::GmfGetLin( int iMesh, GmfKwdCod what, int* nbNodes, int* faceInd, int* ori, int* domain, int /*dummy*/ ) { if ( _useLib ) { #ifdef USE_MG_LIBS @@ -919,7 +952,7 @@ void MG_Hexotic_API::GmfGetLin( int iMesh, GmfKwdCod what, int* nbNodes, int* fa //================================================================================ void MG_Hexotic_API::GmfGetLin(int iMesh, GmfKwdCod what, - double* x, double* y, double *z, int* domain ) + double* x, double* y, double *z, int* domain ) { if ( _useLib ) { #ifdef USE_MG_LIBS @@ -937,7 +970,7 @@ void MG_Hexotic_API::GmfGetLin(int iMesh, GmfKwdCod what, //================================================================================ void MG_Hexotic_API::GmfGetLin(int iMesh, GmfKwdCod what, - float* x, float* y, float *z, int* domain ) + float* x, float* y, float *z, int* domain ) { if ( _useLib ) { #ifdef USE_MG_LIBS @@ -993,7 +1026,7 @@ void MG_Hexotic_API::GmfGetLin(int iMesh, GmfKwdCod what, int* node1, int* node2 //================================================================================ void MG_Hexotic_API::GmfGetLin(int iMesh, GmfKwdCod what, - int* node1, int* node2, int* node3, int* domain ) + int* node1, int* node2, int* node3, int* domain ) { if ( _useLib ) { #ifdef USE_MG_LIBS @@ -1011,7 +1044,7 @@ void MG_Hexotic_API::GmfGetLin(int iMesh, GmfKwdCod what, //================================================================================ void MG_Hexotic_API::GmfGetLin(int iMesh, GmfKwdCod what, - int* node1, int* node2, int* node3, int* node4, int* domain ) + int* node1, int* node2, int* node3, int* node4, int* domain ) { if ( _useLib ) { #ifdef USE_MG_LIBS @@ -1032,9 +1065,9 @@ void MG_Hexotic_API::GmfGetLin(int iMesh, GmfKwdCod what, //================================================================================ void MG_Hexotic_API::GmfGetLin(int iMesh, GmfKwdCod what, - int* node1, int* node2, int* node3, int* node4, - int* node5, int* node6, int* node7, int* node8, - int* domain ) + int* node1, int* node2, int* node3, int* node4, + int* node5, int* node6, int* node7, int* node8, + int* domain ) { if ( _useLib ) { #ifdef USE_MG_LIBS @@ -1072,6 +1105,16 @@ int MG_Hexotic_API::GmfOpenMesh(const char* theFile, int rdOrWr, int ver, int d void MG_Hexotic_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nb ) { + if ( iMesh == 1 && _isMesh ) + { + 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 ) { @@ -1204,6 +1247,9 @@ void MG_Hexotic_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, void MG_Hexotic_API::GmfCloseMesh( int iMesh ) { + if ( iMesh == 1 ) + _isMesh = false; + if ( _useLib ) { #ifdef USE_MG_LIBS return;