diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index a7669cb..b997fb3 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -29,6 +29,7 @@ #include "/EgtDev/Include/EGkCurveLocal.h" #include "/EgtDev/Include/EGkCurveAux.h" #include "/EgtDev/Include/EGkOffsetCurve.h" +#include "/EgtDev/Include/EGkMedialAxis.h" #include "/EgtDev/Include/EGkChainCurves.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/EGkExtTExt.h" @@ -145,6 +146,39 @@ ExeOffsetCurveAdv( int nId, double dDist, int nType, int* pnCount) return nFirstId ; } +//---------------------------------------------------------------------------- +int +ExeCurveMedialAxis( int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero la curva + const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; + // eseguo il calcolo + PolyLine PL ; + if ( ! CurveSimpleMedialAxis( pCurve, PL)) + return GDB_ID_NULL ; + // creo la curva + PtrOwner pCompo( CreateCurveComposite()) ; + if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL)) + return GDB_ID_NULL ; + // la inserisco nel DB geometrico + int nNewId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_AFTER, Release( pCompo)) ; + // copio gli attributi + pGeomDB->CopyAttributes( nId, nNewId) ; + // notifico la modifica + if ( nNewId != GDB_ID_NULL) + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua ; + sLua = "EgtCurveMedialAxis(" + ToString( nId) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return nNewId ; +} + //------------------------------------------------------------------------------- bool ExeApproxCurve( int nId, int nApprType, double dLinTol) diff --git a/EXE_Lua.cpp b/EXE_Lua.cpp index 711cc9d..73d3d15 100644 --- a/EXE_Lua.cpp +++ b/EXE_Lua.cpp @@ -202,6 +202,14 @@ ExeLuaResetGlobVar( const string& sVar) return LuaResetGlobVar( sVar) ; } +//----------------------------------------------------------------------------- +bool +ExeLuaExistsFunction( const string& sFun) +{ + // verifica esistenza funzione + return LuaExistsFunction( sFun) ; +} + //----------------------------------------------------------------------------- bool ExeLuaCallFunction( const string& sFun) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index f3a1091..4f73b14 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/LUA_Base.h b/LUA_Base.h index 5d344c2..3e67898 100644 --- a/LUA_Base.h +++ b/LUA_Base.h @@ -1,13 +1,13 @@ //---------------------------------------------------------------------------- -// EgalTech 2015-2015 +// EgalTech 2015-2022 //---------------------------------------------------------------------------- -// File : LUA_Base.h Data : 21.03.15 Versione : 1.6c6 +// File : LUA_Base.h Data : 26.08.22 Versione : 2.4h4 // Contenuto : Dichiarazioni per funzioni di base gestione LUA. // // // // Modifiche : 21.03.15 DS Creazione modulo. -// +// 26.08.22 DS Aggiunta funzione LuaExistsFunction. // //---------------------------------------------------------------------------- @@ -29,6 +29,8 @@ bool LuaGetGlobVar( const std::string& sVar, T& Val) { return LuaGetGlobVar( LuaGetLuaMgr().GetLuaState(), sVar, Val) ; } bool LuaResetGlobVar( const std::string& sVar) ; bool LuaCreateGlobTable( const std::string& sVar) ; +inline bool LuaExistsFunction( const std::string& sFunName) + { return LuaGetLuaMgr().ExistsFunction( sFunName) ; } template bool LuaCallFunction( const std::string& sFunName, int nRets, const Args&... params) { return LuaGetLuaMgr().CallFunction( sFunName, nRets, params...) ; } diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 36778d4..de26271 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -81,6 +81,23 @@ LuaOffsetCurveAdv( lua_State* L) return 2 ; } +//------------------------------------------------------------------------------- +static int +LuaCurveMedialAxis( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // calcolo del Medial Axis della curva + int nNewId = ExeCurveMedialAxis( nId) ; + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaApproxCurve( lua_State* L) @@ -901,6 +918,7 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtInvertCurve", LuaInvertCurve) ; bOk = bOk && luaMgr.RegisterFunction( "EgtOffsetCurve", LuaOffsetCurve) ; bOk = bOk && luaMgr.RegisterFunction( "EgtOffsetCurveAdv", LuaOffsetCurveAdv) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCurveMedialAxis", LuaCurveMedialAxis) ; bOk = bOk && luaMgr.RegisterFunction( "EgtApproxCurve", LuaApproxCurve) ; bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnPlane", LuaProjectCurveOnPlane) ; bOk = bOk && luaMgr.RegisterFunction( "EgtChangeClosedCurveStart", LuaChangeClosedCurveStart) ; diff --git a/LUA_General.cpp b/LUA_General.cpp index 154706f..7d69e59 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -949,6 +949,20 @@ LuaGetLanguage( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaGetMsg( lua_State* L) +{ + // 1 parametro : nMsg + int nMsg ; + LuaCheckParam( L, 1, nMsg) + LuaClearStack( L) ; + // recupero il nome della lingua corrente + string sMsg = ExeGetMsg( nMsg) ; + LuaSetParam( L, sMsg) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaWinExec( lua_State* L) @@ -1202,6 +1216,7 @@ LuaInstallGeneral( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetVersion", LuaGetVersion) ; bOk = bOk && luaMgr.RegisterFunction( "EgtIs64bit", LuaIs64bit) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetLanguage", LuaGetLanguage) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtMsg", LuaGetMsg) ; bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBox", LuaDialogBox) ; bOk = bOk && luaMgr.RegisterFunction( "EgtWinExec", LuaWinExec) ;