]> SALOME platform Git repositories - plugins/hexoticplugin.git/blobdiff - src/HexoticPlugin/MG_Hexotic_API.cxx
Salome HOME
Copyright update 2020
[plugins/hexoticplugin.git] / src / HexoticPlugin / MG_Hexotic_API.cxx
index 1946f4fd0d9dc70ad3becf46998fbfe242d5be26..82fc6ba90bb59195cbfbd7de742dbbd221187305 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2004-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2004-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 
 #include "MG_Hexotic_API.hxx"
 
+#ifdef WIN32
+#define NOMINMAX
+#endif
+
 #include <SMESH_Comment.hxx>
 #include <SMESH_File.hxx>
 #include <Utils_SALOME_Exception.hxx>
@@ -73,12 +77,12 @@ struct MG_Hexotic_API::LibData
   {
     if ( _hexa_mesh )
       hexa_regain_mesh( _session, _hexa_mesh );
-    if ( _session )
-      hexa_session_delete( _session );
     if ( _tria_mesh )
       mesh_delete( _tria_mesh );
     if ( _sizemap )
       sizemap_delete( _sizemap );
+    if ( _session )
+      hexa_session_delete( _session );
     if ( _context )
       context_delete( _context );
 
@@ -438,12 +442,12 @@ struct MG_Hexotic_API::LibData
 
   int IsVertexRequired( int iNode )
   {
-    return ! ( iNode < int( _xyz.size() - _nodeSize.size() ));
+    return ! ( iNode < int( NbNodes() - _nodeSize.size() ));
   }
 
   double GetSizeAtVertex( int iNode )
   {
-    return IsVertexRequired( iNode ) ? _nodeSize[ iNode - _xyz.size() + _nodeSize.size() ] : 0.;
+    return IsVertexRequired( iNode ) ? _nodeSize[ iNode - NbNodes() + _nodeSize.size() ] : 0.;
   }
 };
 
@@ -583,6 +587,10 @@ namespace // functions called by MG library to exchange with the application
     MG_Hexotic_API::LibData* data = (MG_Hexotic_API::LibData *) user_data;
     data->AddError( desc );
 
+#ifdef _DEBUG_
+    //std::cout << desc << std::endl;
+#endif
+
     // Compute progress
     // corresponding messages are:
     // " | Analyzing the surface mesh |"         => 1 %
@@ -705,13 +713,14 @@ bool MG_Hexotic_API::LibData::Compute()
 
 MG_Hexotic_API::MG_Hexotic_API(volatile bool& cancelled_flag, double& progress)
 {
+  _useLib = false;
 #ifdef USE_MG_LIBS
   _useLib = true;
   _libData = new LibData( cancelled_flag, progress );
   _libData->Init();
-#endif
   if ( getenv("MG_HEXA_USE_EXE"))
     _useLib = false;
+#endif
 }
 
 //================================================================================
@@ -786,6 +795,8 @@ bool MG_Hexotic_API::Compute( const std::string& cmdLine, std::string& errStr )
       value = "";
       while ( i+1 < args.size() && args[i+1][0] != '-' )
       {
+        if ( strncmp( "1>", args[i+1].c_str(), 2 ) == 0 )
+          break;
         if ( !value.empty() ) value += " ";
         value += args[++i];
       }
@@ -794,7 +805,12 @@ bool MG_Hexotic_API::Compute( const std::string& cmdLine, std::string& errStr )
     }
 
     // compute
-    return _libData->Compute();
+    bool ok =  _libData->Compute();
+
+    GetLog(); // write a log file
+    _logFile = ""; // not to write it again
+
+    return ok;
 #endif
   }
 
@@ -804,9 +820,6 @@ bool MG_Hexotic_API::Compute( const std::string& cmdLine, std::string& errStr )
     errStr = SMESH_Comment("system(mg-hexa.exe ...) command failed with error: ")
       << strerror( errno );
 
-  GetLog(); // write a log file
-  _logFile = ""; // not to write it again
-
   return !err;
 
 }