Salome HOME
bos #24596 [CEA] New MeshGems license:: fix regressions in tests
[plugins/hexoticplugin.git] / src / HexoticPlugin / MG_Hexotic_API.cxx
index 6dcf7f84778f273e2a631ec71fa6cd55b400877a..5f88f1ce28c2ae3207bc6cbf24480c8051c3d1d9 100644 (file)
@@ -23,6 +23,7 @@
 #define NOMINMAX
 #endif
 
+#include <DriverGMF_Read.hxx>
 #include <SMESH_Comment.hxx>
 #include <SMESH_File.hxx>
 #include <SMESH_MGLicenseKeyGen.hxx>
@@ -1108,9 +1109,9 @@ void MG_Hexotic_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nb )
   if ( iMesh == 1 && _isMesh )
   {
     switch ( what ) {
-    case GmfVertices:  _nbNodes = nb; break;
-    case GmfEdges:     _nbEdges = nb; break;
-    case GmfTriangles: _nbFaces = nb; break;
+    case GmfVertices:  _nbNodes += nb; break;
+    case GmfEdges:     _nbEdges += nb; break;
+    case GmfTriangles: _nbFaces += nb; break;
     default:;
     }
   }
@@ -1131,6 +1132,26 @@ void MG_Hexotic_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nb )
   ::GmfSetKwd(iMesh, what, nb );
 }
 
+//================================================================================
+/*!
+ * \brief Set GMF file made by MG-CADSurf to get nb of mesh entities from it
+ */
+//================================================================================
+
+void MG_Hexotic_API::SetInputFile( const std::string mesh2DFile )
+{
+  DriverGMF_Read fileReader;
+  fileReader.SetFile( mesh2DFile );
+
+  smIdType nbVertex, nbEdge, nbFace, nbVol;
+  if ( fileReader.GetMeshInfo(nbVertex, nbEdge, nbFace, nbVol))
+  {
+    _nbNodes += nbVertex;
+    _nbEdges += nbEdge;
+    _nbFaces += nbFace;
+  }
+}
+
 //================================================================================
 /*!
  * \brief Add coordinates of a node
@@ -1297,5 +1318,5 @@ std::string MG_Hexotic_API::GetLog()
 #endif
   }
   SMESH_File file( _logFile );
-  return file.getPos();
+  return file.exists() ? file.getPos() : "";
 }