-// 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
#ifdef WIN32
#define NOMINMAX
#endif
+
#include <SMESH_Comment.hxx>
#include <SMESH_File.hxx>
+#include <SMESH_MGLicenseKeyGen.hxx>
#include <Utils_SALOME_Exception.hxx>
-#include <vector>
-#include <iterator>
#include <cstring>
+#include <iostream>
+#include <iterator>
+#include <vector>
#ifdef USE_MG_LIBS
bool MG_Tetra_API::LibData::Compute()
{
status_t ret;
+ std::string errorTxt;
if ( _tetraNodes.empty() )
{
+ // Sign the surface mesh
+ if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( _tria_mesh, "tetra", 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
{
+ // Sign the volume mesh
+ // TOOD: check if there is a typo here. Should be _tetra_mesh ?
+ if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( _tria_mesh, "tetra", errorTxt ))
+ {
+ AddError( SMESH_Comment( "Problem with library SalomeMeshGemsKeyGenerator: ") << errorTxt );
+ return false;
+ }
+ // TOOD: check if there is a typo here. Should be _tetra_mesh ?
ret = tetra_set_volume_mesh( _session, _tria_mesh );
if ( ret != STATUS_OK ) MG_Error( "unable to set volume mesh");
}
{
volatile bool& _cancelled_flag;
double& _progress;
- LibData(volatile bool& cancelled_flag, double& progress): _cancelled_flag{cancelled_flag}, _progress{progress} {}
+ LibData(volatile bool& cancelled_flag, double& progress):
+ _cancelled_flag{cancelled_flag}, _progress{progress}
+ {}
};
#endif // ifdef USE_MG_LIBS
*/
//================================================================================
-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 );
}
// compute
- bool ok = _libData->Compute();
+ bool ok = _libData->Compute();
GetLog(); // write a log file
_logFile = ""; // not to write it again
#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 )
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;
+ case GmfTetrahedra: _nbVolumes += nb; break;
+ default:;
+ }
+ }
+
if ( _useLib ) {
#ifdef USE_MG_LIBS
switch ( what ) {