diff --git a/DllExchange.cpp b/DllExchange.cpp index 662cb30..e4ebf1f 100644 --- a/DllExchange.cpp +++ b/DllExchange.cpp @@ -52,6 +52,7 @@ static const char* EEX_CREATEIMPORT3MF = "CreateImport3MF" ; static const char* EEX_CREATEEXPORTDXF = "CreateExportDxf" ; static const char* EEX_CREATEEXPORTSTL = "CreateExportStl" ; static const char* EEX_CREATEEXPORT3MF = "CreateExport3MF" ; +static const char* EEX_CREATEEXPORTTHREEJS = "CreateExportThreeJS" ; static const char* EEX_CREATEEXPORTSVG = "CreateExportSvg" ; static const char* EEX_CREATEEEXEXECUTOR = "CreateExcExecutor" ; @@ -359,6 +360,21 @@ MyCreateExport3MF( void) return pFun() ; } +//----------------------------------------------------------------------------- +IExportThreeJS* +MyCreateExportThreeJS( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IExportThreeJS* (* PF_CreateExportThreeJS) ( void) ; + PF_CreateExportThreeJS pFun = (PF_CreateExportThreeJS)GetProcAddress( s_hEEx, EEX_CREATEEXPORTTHREEJS) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + //----------------------------------------------------------------------------- IExportSvg* MyCreateExportSvg( void) diff --git a/DllExchange.h b/DllExchange.h index 3c87070..aaf27ac 100644 --- a/DllExchange.h +++ b/DllExchange.h @@ -28,6 +28,7 @@ class IImport3MF ; class IExportDxf ; class IExportStl ; class IExport3MF ; +class IExportThreeJS ; class IExportSvg ; class IExcExecutor ; @@ -52,5 +53,6 @@ IImport3MF* MyCreateImport3MF( void) ; IExportDxf* MyCreateExportDxf( void) ; IExportStl* MyCreateExportStl( void) ; IExport3MF* MyCreateExport3MF( void) ; +IExportThreeJS* MyCreateExportThreeJS( void) ; IExportSvg* MyCreateExportSvg( void) ; IExcExecutor* MyCreateExcExecutor(void) ; diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index 9332109..8a96040 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -23,6 +23,7 @@ #include "/EgtDev/Include/EExImportDxf.h" #include "/EgtDev/Include/EExImportStl.h" #include "/EgtDev/Include/EExImport3MF.h" +#include "/EgtDev/Include/EExExportThreeJS.h" #include "/EgtDev/Include/EExImportCnc.h" #include "/EgtDev/Include/EExImportCsf.h" #include "/EgtDev/Include/EExImportPnt.h" @@ -38,6 +39,7 @@ #include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/SELkKeyProc.h" +#include "/EgtDev/Include/EGrScene.h" using namespace std ; @@ -554,3 +556,29 @@ ExeExportSvg( int nId, const string& sFilePath, int nFilter) // restituisco il risultato return bOk ; } + +//----------------------------------------------------------------------------- +bool +ExeExportThreeJS( int nId, const string& sFilePath, const string& sFilePathM) +{ + IEGrScene* pScene = GetCurrScene(); + VERIFY_SCENE(pScene, false) ; + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + bool bOk = true ; + // esporto il file per ThreeJS + // preparo l'esportatore + PtrOwner pExpThreeJS( MyCreateExportThreeJS()) ; + bOk = bOk && ! IsNull( pExpThreeJS) ; + // eseguo l'esportazione + bOk = bOk && pExpThreeJS->Export( pGeomDB, nId, sFilePath, sFilePathM, pScene) ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtExportThreeJS(" + ToString( nId) + ",'" + + StringToLuaString( sFilePath) + "')" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} diff --git a/LUA_Exchange.cpp b/LUA_Exchange.cpp index 50d83a1..70498b1 100644 --- a/LUA_Exchange.cpp +++ b/LUA_Exchange.cpp @@ -224,6 +224,25 @@ LuaExport3MF( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaExportThreeJS( lua_State* L) +{ + // 2 parametri, GroupId e path del file da esportare + int nGroupId ; + LuaCheckParam( L, 1, nGroupId) + string sFilePath ; + LuaCheckParam( L, 2, sFilePath) + string sFilePathM; + LuaCheckParam(L, 3, sFilePathM) + LuaClearStack( L) ; + // creo il file + bool bOk = ExeExportThreeJS( nGroupId, sFilePath, sFilePathM) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaExportSvg( lua_State* L) @@ -260,6 +279,7 @@ LuaInstallExchange( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtExportDxf", LuaExportDxf) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExportStl", LuaExportStl) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExport3MF", LuaExport3MF) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtExportThreeJS", LuaExportThreeJS) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExportSvg", LuaExportSvg) ; return bOk ; }