From 67fa0dd6f0929414a4b2f8bbe9f22b2d4cdace1a Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 23 Jan 2025 12:08:06 +0100 Subject: [PATCH] EgtExecutor : - modifiche per impostazione dati interprete lua a Exchange - aggiunta funzione Exe/Lua CreateSurfTmEmpty. --- DllExchange.cpp | 16 ++++++++++++++++ DllExchange.h | 1 + EXE_Exchange.cpp | 3 ++- EXE_GdbCreateSurf.cpp | 22 ++++++++++++++++++++++ LUA_GdbCreateSurf.cpp | 19 +++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/DllExchange.cpp b/DllExchange.cpp index 5101950..825f9c2 100644 --- a/DllExchange.cpp +++ b/DllExchange.cpp @@ -42,6 +42,7 @@ static const char* EEX_GETEEXVERSION = "GetEExVersion" ; static const char* EEX_SETEEXKEY = "SetEExKey" ; static const char* EEX_SETEEXNETHWKEY = "SetEExNetHwKey" ; static const char* EEX_SETBTLAUXDIR = "SetBtlAuxDir" ; +static const char* EEX_SETBTLLUADATA = "SetBtlLuaData" ; static const char* EEX_CREATEBEAMMGR = "CreateBeamMgr" ; static const char* EEX_CREATEIMPORTBTL = "CreateImportBtl" ; static const char* EEX_CREATEIMPORTBTLX = "CreateImportBtlx" ; @@ -184,6 +185,21 @@ MySetBtlAuxDir( const string& sBtlAuxDir) return pFun( sBtlAuxDir) ; } +//----------------------------------------------------------------------------- +bool +MySetBtlLuaData( const string& sLuaLibsDir, const string& sLuaLastRequire) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return false ; + // recupero funzione creazione oggetto + typedef bool (* PF_SetBtlLuaData) ( const string& sLuaLibsDir, const string& sLuaLastRequire) ; + PF_SetBtlLuaData pFun = (PF_SetBtlLuaData)GetProcAddress( s_hEEx, EEX_SETBTLLUADATA) ; + if ( pFun == nullptr) + return false ; + return pFun( sLuaLibsDir, sLuaLastRequire) ; +} + //----------------------------------------------------------------------------- IBeamMgr* MyCreateBeamMgr( void) diff --git a/DllExchange.h b/DllExchange.h index 4686437..2db510c 100644 --- a/DllExchange.h +++ b/DllExchange.h @@ -42,6 +42,7 @@ void MySetEExKey( const std::string& sKey) ; void MySetEExNetHwKey( bool bNetHwKey) ; const char* MyGetEExVersion( void) ; bool MySetBtlAuxDir( const std::string& sBtlAuxDir) ; +bool MySetBtlLuaData( const std::string& sLuaLibsDir, const std::string& sLuaLastRequire) ; IBeamMgr* MyCreateBeamMgr( void) ; IImportBtl* MyCreateImportBtl( void) ; IImportBtlx* MyCreateImportBtlx( void) ; diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index 6af54cf..0b2b413 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "EXE.h" #include "EXE_Macro.h" +#include "LUA_Base.h" #include "AuxTools.h" #include "DllExchange.h" #include "DllExch3dm.h" @@ -126,7 +127,7 @@ ExeGetFileType( const string& sFilePath) bool ExeSetBtlAuxDir( const string& sBtlAuxDir) { - return MySetBtlAuxDir( sBtlAuxDir) ; + return MySetBtlAuxDir( sBtlAuxDir) && MySetBtlLuaData( LuaGetLuaLibsDir(), LuaGetLastRequire()) ; } //----------------------------------------------------------------------------- diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 3e636fb..0e174d3 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -348,6 +348,28 @@ ExeCreateSurfFlatRegion( int nParentId, const INTVECTOR& vCrvIds, int* pnCount) return nFirstId ; } +//------------------------------------------------------------------------------- +int +ExeCreateSurfTmEmpty( int nParentId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // creo la superficie vuota + PtrOwner pStm( GetSurfTriMeshEmpty()) ; + // inserisco la superficie nel DB + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmEmpty(" + IdToString( nParentId) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} + //------------------------------------------------------------------------------- static int MyCreateSurfTmPlaneInBBox( int nParentId, const Point3d& ptP, const Vector3d& vtN, const BBox3d& b3Box, int nRefType) diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 26fac43..69e8c41 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -171,6 +171,24 @@ LuaCreateSurfFrFatCurve( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateSurfTmEmpty( lua_State* L) +{ + // 1 parametro : ParentId + int nParentId ; + LuaCheckParam( L, 1, nParentId) + LuaClearStack( L) ; + // creo STM vuoto + int nId = ExeCreateSurfTmEmpty( nParentId) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateSurfTmPlaneInBBox( lua_State* L) @@ -1290,6 +1308,7 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrDisk", LuaCreateSurfFrDisk) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrFatCurve", LuaCreateSurfFrFatCurve) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFlatRegion", LuaCreateSurfFlatRegion) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmEmpty", LuaCreateSurfTmEmpty) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPlaneInBBox", LuaCreateSurfTmPlaneInBBox) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmConvexHullInBBox", LuaCreateSurfTmConvexHullInBBox) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmBBox", LuaCreateSurfTmBBox) ;