From 00cfc8686035c10c4ad2dbc248864994bc35cc73 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 28 Dec 2015 10:40:11 +0000 Subject: [PATCH] Include : - aggiunti prototipi per ShortestPath - aggiornamenti vari. --- EGkLuaAux.h | 27 ++++++++++++++++++++ EGnLuaMgr.h | 15 ++++++++++- EInAPI.h | 3 ++- EMkMachMgr.h | 1 + EMkMachiningConst.h | 2 ++ ENkShortestPath.h | 62 +++++++++++++++++++++++++++++++++++++++++++++ EXeExecutor.h | 17 ++++++++++++- 7 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 ENkShortestPath.h diff --git a/EGkLuaAux.h b/EGkLuaAux.h index ef237c9..d31bbf3 100644 --- a/EGkLuaAux.h +++ b/EGkLuaAux.h @@ -392,3 +392,30 @@ LuaSetParam( lua_State* L, const Color& colPar) } return true ; } + +//------------------------------------------------------------------------------- +inline bool +LuaSetParam( lua_State* L, const SELVECTOR& vSel) +{ + try { + // recupero dimensione + int nDim = int( vSel.size()) ; + // creo tavola per vSel + lua_createtable( L, nDim, 0) ; + // creo e inserisco tavola per ogni componente + for ( int i = 1 ; i <= nDim ; ++ i) { + // creo tavola + lua_createtable( L, 2, 0) ; + lua_pushnumber( L, vSel[i-1].nId) ; + lua_rawseti( L, -2, 1) ; + lua_pushnumber( L, vSel[i-1].nSub) ; + lua_rawseti( L, -2, 2) ; + // la metto nel vettore + lua_rawseti( L, -2, i) ; + } + } + catch( ...) { + return false ; + } + return true ; +} diff --git a/EGnLuaMgr.h b/EGnLuaMgr.h index de570de..a85a356 100644 --- a/EGnLuaMgr.h +++ b/EGnLuaMgr.h @@ -91,7 +91,20 @@ bool LuaMgr::CallFunction( const std::string& sFunName, int nRets, const Args&... params) { // recupero la funzione - lua_getglobal( m_pL, sFunName.c_str()) ; + if ( sFunName.find( '.') == std::string::npos) { + // è direttamente il nome + lua_getglobal( m_pL, sFunName.c_str()) ; + } + else { + // è in una tavola + std::string sTab, sField ; + SplitFirst( sFunName, ".", sTab, sField) ; + lua_getglobal( m_pL, sTab.c_str()) ; + lua_getfield( m_pL, -1, sField.c_str()) ; + // porto la funzione uno slot sotto e diminuisco lo stack di uno (per essere come caso sopra) + lua_copy( m_pL, -1, -2) ; + lua_pop( m_pL, 1) ; + } // numero di parametri int nParNbr = sizeof...( Args) ; // inserisco i parametri sullo stack diff --git a/EInAPI.h b/EInAPI.h index cbcfd5b..8744443 100644 --- a/EInAPI.h +++ b/EInAPI.h @@ -98,6 +98,7 @@ EIN_EXPORT BOOL __stdcall EgtTscExecFile( const wchar_t* wsFilePath) ; EIN_EXPORT BOOL __stdcall EgtTscExecLine( const wchar_t* wsLine) ; // LUA Executor +EIN_EXPORT BOOL __stdcall EgtLuaCreateGlobTable( const wchar_t* wsVar) ; EIN_EXPORT BOOL __stdcall EgtLuaSetGlobBoolVar( const wchar_t* wsVar, BOOL bVal) ; EIN_EXPORT BOOL __stdcall EgtLuaSetGlobIntVar( const wchar_t* wsVar, int nVal) ; EIN_EXPORT BOOL __stdcall EgtLuaSetGlobNumVar( const wchar_t* wsVar, double dVal) ; @@ -107,7 +108,7 @@ EIN_EXPORT BOOL __stdcall EgtLuaGetGlobIntVar( const wchar_t* wsVar, int* pnVal) EIN_EXPORT BOOL __stdcall EgtLuaGetGlobNumVar( const wchar_t* wsVar, double* pdVal) ; EIN_EXPORT BOOL __stdcall EgtLuaGetGlobStringVar( const wchar_t* wsVar, wchar_t*& wsVal) ; EIN_EXPORT BOOL __stdcall EgtLuaResetGlobVar( const wchar_t* wsVar) ; -EIN_EXPORT BOOL __stdcall EgtLuaCreateGlobTable( const wchar_t* wsVar) ; +EIN_EXPORT BOOL __stdcall EgtLuaCallFunction( const wchar_t* wsFun) ; EIN_EXPORT BOOL __stdcall EgtLuaEvalNumExpr( const wchar_t* wsExpr, double* pdVal) ; EIN_EXPORT BOOL __stdcall EgtLuaEvalStringExpr( const wchar_t* wsExpr, wchar_t*& wsVal) ; EIN_EXPORT BOOL __stdcall EgtLuaExecLine( const wchar_t* wsLine) ; diff --git a/EMkMachMgr.h b/EMkMachMgr.h index 0de3c3e..6c4cafe 100644 --- a/EMkMachMgr.h +++ b/EMkMachMgr.h @@ -157,6 +157,7 @@ class __declspec( novtable) IMachMgr virtual bool GetMachiningParam( int nType, int& dVal) const = 0 ; virtual bool GetMachiningParam( int nType, double& dVal) const = 0 ; virtual bool GetMachiningParam( int nType, std::string& sVal) const = 0 ; + virtual bool GetMachiningGeometry( SELVECTOR& vIds) const = 0 ; // Simulation virtual bool SimStart( void) = 0 ; virtual bool SimMove( int& nStatus) = 0 ; diff --git a/EMkMachiningConst.h b/EMkMachiningConst.h index 0ce5958..b809b5d 100644 --- a/EMkMachiningConst.h +++ b/EMkMachiningConst.h @@ -74,6 +74,8 @@ enum MpaType { MPA_NONE = 0, MPA_LOPERP = ( MPA_DOU + 26), MPA_LOELEV = ( MPA_DOU + 27), MPA_LOCOMPLEN = ( MPA_DOU + 28), + MPA_STARTADDLEN = ( MPA_DOU + 29), + MPA_ENDADDLEN = ( MPA_DOU + 30), MPA_NAME = ( MPA_STR + 0), MPA_TOOL = ( MPA_STR + 1), MPA_DEPTH_STR = ( MPA_STR + 2), diff --git a/ENkShortestPath.h b/ENkShortestPath.h new file mode 100644 index 0000000..cfdc3a8 --- /dev/null +++ b/ENkShortestPath.h @@ -0,0 +1,62 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : ENkShortestPath.h Data : 22.12.15 Versione : 1.6l3 +// Contenuto : Classe per calcolo del percorso minimo di visita di +// un insieme di oggetti. +// +// +// Modifiche : 22.12.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EgtNumCollection.h" + +//----------------------- Macro per import/export ---------------------------- +#undef ENK_EXPORT +#if defined( I_AM_ENK) // da definirsi solo nella DLL + #define ENK_EXPORT __declspec( dllexport) +#else + #define ENK_EXPORT __declspec( dllimport) +#endif + +//---------------------------------------------------------------------------- +class __declspec( novtable) IShortestPath +{ + public : + virtual ~IShortestPath( void) {} + virtual bool AddPoint( double dX, double dY) = 0 ; + virtual bool AddPoint( double dXi, double dYi, double dXf, double dYf) = 0 ; + virtual bool AddPoint( double dXi, double dYi, double dZi, double dHi, double dVi, + double dXf, double dYf, double dZf, double dHf, double dVf) = 0 ; + virtual bool SetOpenBound( bool bStartVsEnd, int nFlag, double dX, double dY) = 0 ; + virtual bool SetOpenBound( bool bStartVsEnd, int nFlag, double dX, double dY, double dZ, double dH, double dV) = 0 ; + virtual bool SetAngularParams( double dAngHAdd, double dAngHMul, double dAngVAdd, double dAngVMul) = 0 ; + virtual bool SetZzOwStep( double dStep) = 0 ; + virtual bool Calculate( int nType) = 0 ; + virtual bool GetOrder( INTVECTOR& vOrder) = 0 ; + virtual bool GetMinLength( double& dMinLen) = 0 ; + + public : + enum SpType{ SP_NONE = 0, + SP_CLOSED = 1, + SP_OPEN = 2, + SP_ZIGZAG_X = 3, + SP_ZIGZAG_Y = 4, + SP_ONEWAY_XP = 5, + SP_ONEWAY_XM = 6, + SP_ONEWAY_YP = 7, + SP_ONEWAY_YM = 8} ; + enum ObType{ OB_NONE = 0, + OB_NEAR_PNT = 1, + OB_XMIN = 2, + OB_XMAX = 3, + OB_YMIN = 4, + OB_YMAX = 5} ; +} ; + +//----------------------------------------------------------------------------- +ENK_EXPORT IShortestPath* CreateShortestPath( void) ; diff --git a/EXeExecutor.h b/EXeExecutor.h index 3dad1b4..93e6b2a 100644 --- a/EXeExecutor.h +++ b/EXeExecutor.h @@ -100,6 +100,7 @@ EXE_EXPORT bool ExeTscExecFile( const std::string& sFilePath) ; EXE_EXPORT bool ExeTscExecLine( const std::string& sLine) ; // LUA Executor +EXE_EXPORT bool ExeLuaCreateGlobTable( const std::string& sVar) ; EXE_EXPORT bool ExeLuaSetGlobBoolVar( const std::string& sVar, bool bVal) ; EXE_EXPORT bool ExeLuaSetGlobIntVar( const std::string& sVar, int nVal) ; EXE_EXPORT bool ExeLuaSetGlobNumVar( const std::string& sVar, double dVal) ; @@ -109,7 +110,7 @@ EXE_EXPORT bool ExeLuaGetGlobIntVar( const std::string& sVar, int* pnVal) ; EXE_EXPORT bool ExeLuaGetGlobNumVar( const std::string& sVar, double* pdVal) ; EXE_EXPORT bool ExeLuaGetGlobStringVar( const std::string& sVar, std::string& sVal) ; EXE_EXPORT bool ExeLuaResetGlobVar( const std::string& sVar) ; -EXE_EXPORT bool ExeLuaCreateGlobTable( const std::string& sVar) ; +EXE_EXPORT bool ExeLuaCallFunction( const std::string& sFun) ; EXE_EXPORT bool ExeLuaEvalNumExpr( const std::string& sExpr, double* pdVal) ; EXE_EXPORT bool ExeLuaEvalStringExpr( const std::string& sExpr, std::string& sVal) ; EXE_EXPORT bool ExeLuaExecLine( const std::string& sLine) ; @@ -120,6 +121,19 @@ EXE_EXPORT bool ExeLuaGetLastError( std::string& sError) ; // LUA Base EXE_EXPORT bool LuaInstallEgtFunctions( LuaMgr& LuaMgr) ; +// ShortestPath +EXE_EXPORT bool ExeSpInit( void) ; +EXE_EXPORT bool ExeSpTerminate( void) ; +EXE_EXPORT bool ExeSpAddPoint( double dXi, double dYi, double dZi, double dHi, double dVi, + double dXf, double dYf, double dZf, double dHf, double dVf) ; +EXE_EXPORT bool ExeSpSetOpenBound( bool bStartVsEnd, int nFlag, + double dX, double dY, double dZ, double dH, double dV) ; +EXE_EXPORT bool ExeSpSetAngularParams( double dAngHAdd, double dAngHMul, double dAngVAdd, double dAngVMul) ; +EXE_EXPORT bool ExeSpSetZzOwStep( double dStep) ; +EXE_EXPORT bool ExeSpCalculate( int nType) ; +EXE_EXPORT bool ExeSpGetOrder( INTVECTOR& vOrder) ; +EXE_EXPORT bool ExeSpGetMinLength( double& dMinLen) ; + // GeomDB Create EXE_EXPORT int ExeCreateGroup( int nParentId, const Frame3d& frFrame, int nRefType) ; EXE_EXPORT int ExeCreateGeoPoint( int nParentId, const Point3d& ptP, int nRefType) ; @@ -577,6 +591,7 @@ EXE_EXPORT bool ExeGetMachiningParam( int nType, bool& bVal) ; EXE_EXPORT bool ExeGetMachiningParam( int nType, int& nVal) ; EXE_EXPORT bool ExeGetMachiningParam( int nType, double& dVal) ; EXE_EXPORT bool ExeGetMachiningParam( int nType, std::string& sVal) ; +EXE_EXPORT bool ExeGetMachiningGeometry( SELVECTOR& vIds) ; // Simulation EXE_EXPORT bool ExeSimStart( void) ; EXE_EXPORT bool ExeSimMove( int& nStatus) ;