Salome HOME
Merge branch 'V9_9_BR'
[modules/smesh.git] / src / SMESH_SWIG / SMeshHelper.cxx
index ee2d54b05f57210512fe23eccb0696af91b19bcc..7b9c7b1e6932c2df3718b108b796f96070423822 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2021-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 
 #include "SALOME_KernelServices.hxx"
 
-#include "SMESH_Component_Generator.hxx"
-
 #include <cstring>
 
-std::string BuildSMESHInstanceInternal()
+#include <DriverGMF_Read.hxx>
+#include <SMESH_MGLicenseKeyGen.hxx>
+
+std::string GetMGLicenseKeyImpl(const char* gmfFile)
 {
-  Engines::EngineComponent_var zeRef = RetrieveSMESHInstance();
-  CORBA::String_var ior = KERNEL::getORB()->object_to_string(zeRef);
-  return std::string(ior.in());
+  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;
 }