Salome HOME
bos #24596 [CEA] New MeshGems license
authoreap <eap@opencascade.com>
Thu, 26 Aug 2021 15:23:22 +0000 (18:23 +0300)
committereap <eap@opencascade.com>
Thu, 26 Aug 2021 15:23:22 +0000 (18:23 +0300)
  Care of python plugins

src/SMESHUtils/SMESH_MGLicenseKeyGen.hxx
src/SMESH_SWIG/CMakeLists.txt
src/SMESH_SWIG/SMeshHelper.cxx
src/SMESH_SWIG/SMeshHelper.h
src/SMESH_SWIG/SMeshHelper.i
src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py
src/Tools/YamsPlug/monYamsPlugDialog.py

index c81fa3090ae331a467214159956244e0a751e65c..796cde4b58d2ad0c2cd5358b3280485460d71f82 100644 (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();
 }
index 53b87e321ee04ceeecd62bc65b467a9d6f7cf8f1..bd3a578d4c49517b490a2a57c8aaa9c7c73251fb 100644 (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)
index ee2d54b05f57210512fe23eccb0696af91b19bcc..cfa7d7ef8a59a9143c6ab82e8ae355e4534ce479 100644 (file)
 
 #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 MeshGens license: " << errorTxt << std::endl;
+    key = "<" + errorTxt + ">";
+  }
+  return key;
+}
index 58b2c5321ffc1b024a4b3e064c49c77c3eb1788b..9c912869ebadc71da439a40f3f350791ee975a4c 100644 (file)
@@ -22,3 +22,5 @@
 #include <string>
 
 std::string BuildSMESHInstanceInternal();
+
+std::string GetMGLicenseKeyImpl(const char* gmfFile);
index b73a87db93d123246656a1709710d10c44bd6299..d1220cb9021e06fbafbae93c6cd32ba575468d60 100644 (file)
@@ -31,4 +31,9 @@
   {
     return BuildSMESHInstanceInternal();
   }
+
+  std::string GetMGLicenseKey(const char* gmfFile)
+  {
+    return GetMGLicenseKeyImpl( gmfFile );
+  }
 }
index c701b3449f95ad76ab8b97fa8ccf13d0fa90266f..976b9bc7a6c35b12963c8f24074f79855d1f97fd 100644 (file)
@@ -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
 
index 63efd6c2d58d54f4497dbceb3328ea590918dee4..477a2b4e4fbd5345bc03a41040663b6e418115e0 100644 (file)
@@ -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