diff --git a/src/SMESHUtils/SMESH_MGLicenseKeyGen.hxx b/src/SMESHUtils/SMESH_MGLicenseKeyGen.hxx index c81fa3090..796cde4b5 100644 --- a/src/SMESHUtils/SMESH_MGLicenseKeyGen.hxx +++ b/src/SMESHUtils/SMESH_MGLicenseKeyGen.hxx @@ -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(); } diff --git a/src/SMESH_SWIG/CMakeLists.txt b/src/SMESH_SWIG/CMakeLists.txt index 53b87e321..bd3a578d4 100644 --- a/src/SMESH_SWIG/CMakeLists.txt +++ b/src/SMESH_SWIG/CMakeLists.txt @@ -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) diff --git a/src/SMESH_SWIG/SMeshHelper.cxx b/src/SMESH_SWIG/SMeshHelper.cxx index ee2d54b05..cfa7d7ef8 100644 --- a/src/SMESH_SWIG/SMeshHelper.cxx +++ b/src/SMESH_SWIG/SMeshHelper.cxx @@ -25,9 +25,35 @@ #include +#include +#include + + 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( nbVertex ), + FromSmIdType( nbEdge ), + FromSmIdType( nbFace ), + FromSmIdType( nbVol ), + errorTxt ); + if ( !errorTxt.empty() ) + { + std::cerr << "Error: Pb with MeshGens license: " << errorTxt << std::endl; + key = "<" + errorTxt + ">"; + } + return key; +} diff --git a/src/SMESH_SWIG/SMeshHelper.h b/src/SMESH_SWIG/SMeshHelper.h index 58b2c5321..9c912869e 100644 --- a/src/SMESH_SWIG/SMeshHelper.h +++ b/src/SMESH_SWIG/SMeshHelper.h @@ -22,3 +22,5 @@ #include std::string BuildSMESHInstanceInternal(); + +std::string GetMGLicenseKeyImpl(const char* gmfFile); diff --git a/src/SMESH_SWIG/SMeshHelper.i b/src/SMESH_SWIG/SMeshHelper.i index b73a87db9..d1220cb90 100644 --- a/src/SMESH_SWIG/SMeshHelper.i +++ b/src/SMESH_SWIG/SMeshHelper.i @@ -31,4 +31,9 @@ { return BuildSMESHInstanceInternal(); } + + std::string GetMGLicenseKey(const char* gmfFile) + { + return GetMGLicenseKeyImpl( gmfFile ); + } } diff --git a/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py index c701b3449..976b9bc7a 100644 --- a/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py +++ b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py @@ -577,6 +577,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.self.fichierIn ) + self.commande+=' --key ' + key + if verbose: print(("INFO: MGCCleaner command:\n %s" % self.commande)) return True diff --git a/src/Tools/YamsPlug/monYamsPlugDialog.py b/src/Tools/YamsPlug/monYamsPlugDialog.py index 63efd6c2d..477a2b4e4 100644 --- a/src/Tools/YamsPlug/monYamsPlugDialog.py +++ b/src/Tools/YamsPlug/monYamsPlugDialog.py @@ -545,6 +545,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