Merge branch 'occ/new_mg_licnese' of https://codev-tuleap.cea.fr/plugins/git/salome/smesh into occ/new_mg_licnese

This commit is contained in:
Anthony Geay 2021-09-10 15:24:05 +02:00
commit abc53b03ca
12 changed files with 86 additions and 73 deletions

View File

@ -152,12 +152,16 @@ namespace
0,
NULL
);
if ( msgLen > 0 )
error = (char*) cstr;
if ( msgLen > 0 ) {
# if defined( UNICODE )
error = Kernel_Utils::encode_s((wchar_t*)cstr);
# else
error = (char*)cstr;
# endif
LocalFree(cstr);
}
return msgLen;
return (bool)msgLen;
#endif
}
@ -259,11 +263,11 @@ namespace
#ifdef WIN32
std::string outFile = tmpDir + "libMeshGemsKeyGenerator.dll";
std::string outFile = tmpDir + "MeshGemsKeyGenerator.dll";
// use wget (== Invoke-WebRequest) PowerShell command available since Windows 7
std::string psCmd = "wget -Uri " + url + " -OutFile " + outFile;
std::string cmd = "start powershell.exe " + psCmd;
std::string cmd = "powershell.exe " + psCmd;
#else
@ -290,6 +294,8 @@ namespace
if ( ok )
libraryFile._name = outFile;
else
error = "Can't download file " + url;
return ok;
}
@ -372,6 +378,7 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
if ( !loadLibrary( error, libraryFile ))
return false;
bool ok = false;
typedef bool (*SignFun)(void* );
SignFun signFun = (SignFun) GetProc( theLibraryHandle, "SignCAD" );
if ( !signFun )
@ -379,9 +386,8 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
if ( ! getLastError( error ))
error = SMESH_Comment( "Can't find symbol 'SignCAD' in '") << getenv( theEnvVar ) << "'";
}
bool ok;
else
{
SMESH_TRY;
ok = signFun( meshgems_cad );
@ -392,7 +398,7 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
ok = false;
else if ( !ok )
error = "SignCAD() failed (located in '" + libraryFile._name + "')";
}
return ok;
}
@ -411,6 +417,7 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
if ( !loadLibrary( error, libraryFile ))
return false;
bool ok = false;
typedef bool (*SignFun)(void* );
SignFun signFun = (SignFun) GetProc( theLibraryHandle, "SignMesh" );
if ( !signFun )
@ -418,8 +425,8 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
if ( ! getLastError( error ))
error = SMESH_Comment( "Can't find symbol 'SignMesh' in '") << getenv( theEnvVar ) << "'";
}
bool ok;
else
{
SMESH_TRY;
ok = signFun( meshgems_mesh );
@ -430,7 +437,7 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
ok = false;
else if ( !ok )
error = "SignMesh() failed (located in '" + libraryFile._name + "')";
}
return ok;
}
@ -463,8 +470,10 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
if ( ! getLastError( error ))
error = SMESH_Comment( "Can't find symbol 'GetKey' in '") << getenv( theEnvVar ) << "'";
}
else
{
key = keyFun( gmfFile, nbVertex, nbEdge, nbFace, nbVol );
}
if ( key.empty() )
error = "GetKey() failed (located in '" + libraryFile._name + "')";

View File

@ -44,7 +44,7 @@ namespace SMESHUtils_MGLicenseKeyGen
int nbVol,
std::string& error);
SMESHUtils_EXPORT bool CheckKeyGeLibrary( std::string& error );
SMESHUtils_EXPORT bool CheckKeyGenLibrary( std::string& error );
SMESHUtils_EXPORT std::string GetLibraryName();
}

View File

@ -25,6 +25,8 @@ include_directories(
${PROJECT_SOURCE_DIR}/src/SMDS
${PROJECT_SOURCE_DIR}/src/SMESH
${PROJECT_SOURCE_DIR}/src/SMESH_I
${PROJECT_SOURCE_DIR}/src/Driver
${PROJECT_SOURCE_DIR}/src/DriverGMF
${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_BINARY_DIR}/idl
)
@ -123,7 +125,7 @@ IF(${CMAKE_VERSION} VERSION_LESS "3.8.0")
ELSE()
SWIG_ADD_LIBRARY(SMeshHelper LANGUAGE python SOURCES ${SMeshHelper_SOURCES})
ENDIF()
SWIG_LINK_LIBRARIES(SMeshHelper ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SMESHEngine )
SWIG_LINK_LIBRARIES(SMeshHelper ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SMESHEngine MeshDriverGMF )
SWIG_CHECK_GENERATION(SMeshHelper)
IF(WIN32)
SET_TARGET_PROPERTIES(_SMeshHelper PROPERTIES DEBUG_OUTPUT_NAME _SMeshHelper_d)

View File

@ -25,9 +25,35 @@
#include <cstring>
#include <DriverGMF_Read.hxx>
#include <SMESH_MGLicenseKeyGen.hxx>
std::string BuildSMESHInstanceInternal()
{
Engines::EngineComponent_var zeRef = RetrieveSMESHInstance();
CORBA::String_var ior = KERNEL::getORB()->object_to_string(zeRef);
return std::string(ior.in());
}
std::string GetMGLicenseKeyImpl(const char* gmfFile)
{
smIdType nbVertex, nbEdge, nbFace, nbVol;
DriverGMF_Read gmfReader;
gmfReader.SetFile( gmfFile );
gmfReader.GetMeshInfo( nbVertex, nbEdge, nbFace, nbVol );
std::string errorTxt;
std::string key = SMESHUtils_MGLicenseKeyGen::GetKey( gmfFile,
FromSmIdType<int>( nbVertex ),
FromSmIdType<int>( nbEdge ),
FromSmIdType<int>( nbFace ),
FromSmIdType<int>( nbVol ),
errorTxt );
if ( !errorTxt.empty() )
{
std::cerr << "Error: Pb with MeshGems license: " << errorTxt << std::endl;
key = "<" + errorTxt + ">";
}
return key;
}

View File

@ -22,3 +22,5 @@
#include <string>
std::string BuildSMESHInstanceInternal();
std::string GetMGLicenseKeyImpl(const char* gmfFile);

View File

@ -31,4 +31,9 @@
{
return BuildSMESHInstanceInternal();
}
std::string GetMGLicenseKey(const char* gmfFile)
{
return GetMGLicenseKeyImpl( gmfFile );
}
}

View File

@ -525,18 +525,6 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
def PrepareLigneCommande(self):
"""
#use doc examples of mg-cleaner:
ls -al /data/tmplgls/salome/prerequis/install/COMMON_64/MeshGems-1.0/bin
source /data/tmplgls/salome/prerequis/install/LICENSE/dlim8.var.sh
export PATH=/data/tmplgls/salome/prerequis/install/COMMON_64/MeshGems-1.0/bin/Linux_64:$PATH
cp -r /data/tmplgls/salome/prerequis/install/COMMON_64/MeshGems-1.0/examples .
cd examples
mg-cleaner.exe --help
mg-cleaner.exe --in case7.mesh --out case7-test.mesh --check
mg-cleaner.exe case7.mesh case7-fix.mesh --fix
mg-cleaner.exe --in Porsche.mesh --out Porsche-test.mesh --check
mg-cleaner.exe --in Porsche.mesh --out Porschefix.mesh --fix
mg-cleaner.exe --in Porsche.mesh --out PorscheNewfix.mesh --fix --resolution_length 0.03
"""
#self.commande="mg-cleaner.exe --in " + self.fichierIn + " --out " + self.fichierOut + " --fix2pass"
@ -577,6 +565,11 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget):
if not self.CB_ComputedOverlapDistance.isChecked(): #computed default
self.commande+=" --overlap_distance " + self.SP_toStr(self.SP_OverlapDistance)
self.commande+=" --overlap_angle " + str(self.SP_OverlapAngle.value())
import SMeshHelper
key = SMeshHelper.GetMGLicenseKey( self.fichierIn )
self.commande+=' --key ' + key
if verbose: print(("INFO: MGCCleaner command:\n %s" % self.commande))
return True

View File

@ -35,11 +35,6 @@ from MGCleanerViewText_ui import Ui_ViewExe
verbose = True
force = os.getenv("FORCE_DISTENE_LICENSE_FILE")
if force != None:
os.environ["DISTENE_LICENSE_FILE"] = force
os.environ["DLIM8VAR"] = "NOTHING"
class MGCleanerMonViewText(Ui_ViewExe, QDialog):
"""
Classe permettant la visualisation de texte

View File

@ -31,15 +31,6 @@ def MGCleanerLct(context):
import tempfile
from qtsalome import QFileDialog, QMessageBox
#prior test to avoid unnecessary user GUI work with ending crash
try :
os.environ['DISTENE_LICENSE_FILE']
except:
QMessageBox.warning(None, "Products", """\
Distene's product MeshGem Cleaner is not installed.
required environment variable:
DISTENE_LICENSE_FILE='.../dlim8.var.sh'""")
return
import MGCleanerMonPlugDialog
window = MGCleanerMonPlugDialog.getDialog()
window.show()

View File

@ -34,11 +34,6 @@ from ViewText_ui import Ui_ViewExe
verbose = True
force = os.getenv("FORCE_DISTENE_LICENSE_FILE")
if force != None:
os.environ["DISTENE_LICENSE_FILE"] = force
os.environ["DLIM8VAR"] = "NOTHING"
class MonViewText(Ui_ViewExe, QDialog):
"""
Classe permettant la visualisation de texte

View File

@ -546,6 +546,10 @@ class MonYamsPlugDialog(Ui_YamsPlugDialog,QWidget):
self.commande+=' --in "' + self.fichierIn +'"'
self.commande+=' --out "' + self.fichierOut +'"'
import SMeshHelper
key = SMeshHelper.GetMGLicenseKey( self.fichierIn )
self.commande+=' --key ' + key
print(self.commande)
return True

View File

@ -31,15 +31,6 @@ def YamsLct(context):
import tempfile
from qtsalome import QFileDialog, QMessageBox
#prior test to avoid unnecessary user GUI work with ending crash
try :
os.environ['DISTENE_LICENSE_FILE']
except:
QMessageBox.warning(None,"Products","""\
Distene's product MeshGem SurfOpt is not installed.
required environment variable:
DISTENE_LICENSE_FILE='.../dlim8.var.sh'""")
return
import monYamsPlugDialog
window = monYamsPlugDialog.getDialog()
window.show()