From 6c640b902f383cfbc769fd2d4405ff9ba0d68423 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 27 Feb 2024 18:18:52 +0100 Subject: [PATCH] EgtExecuter : - aggiunta funzione Exe/Lua CreateSurfTmTransSwept. --- EXE_GdbCreateSurf.cpp | 37 +++++++++++++++++++++++++++++++++++++ LUA_GdbCreateSurf.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index f0bfbe5..9ece426 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -1286,6 +1286,43 @@ ExeCreateSurfTmSwept( int nParentId, int nSectId, int nGuideId, bool bCapEnds, d return nNewId ; } +//------------------------------------------------------------------------------- +int +ExeCreateSurfTmTransSwept( int nParentId, int nSectId, int nGuideId, bool bCapEnds, double dLinTol) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + bool bOk = true ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // recupero la sezione in locale + CurveLocal CrvSect( pGeomDB, nSectId, frLoc) ; + bOk = bOk && ( CrvSect.Get() != nullptr) ; + // recupero la guida in locale + CurveLocal CrvGuide( pGeomDB, nGuideId, frLoc) ; + bOk = bOk && ( CrvGuide.Get() != nullptr) ; + // creo la superficie trimesh + ISurfTriMesh* pSTM = nullptr ; + pSTM = ( bOk ? GetSurfTriMeshTransSwept( CrvSect, CrvGuide, bCapEnds, dLinTol) : nullptr) ; + // inserisco la superficie trimesh nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmTransSwept(" + IdToString( nParentId) + "," + + ToString( nSectId) + "," + + ToString( nGuideId) + "," + + ( bCapEnds ? "true" : "false") + "," + + ToString( dLinTol) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} + //------------------------------------------------------------------------------- int ExeCreateSurfTmRuled( int nParentId, int nPtOrCrvId1, int nPtOrCrvId2, int nType, double dLinTol) diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 13db858..1efa9da 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -682,6 +682,32 @@ LuaCreateSurfTmSwept( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateSurfTmTransSwept( lua_State* L) +{ + // 4 o 5 parametri : ParentId, SectId, GuideId, bCapEnds [, dTol] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nSectId ; + LuaCheckParam( L, 2, nSectId) + int nGuideId ; + LuaCheckParam( L, 3, nGuideId) + bool bCapEnds ; + LuaCheckParam( L, 4, bCapEnds) + double dLinTol = LIN_TOL_SRF ; + LuaGetParam( L, 5, dLinTol) ; + LuaClearStack( L) ; + // creo STM swept di traslazione + int nId = ExeCreateSurfTmTransSwept( nParentId, nSectId, nGuideId, bCapEnds, dLinTol) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateSurfTmRuled( lua_State* L) @@ -932,6 +958,7 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByScrewing", LuaCreateSurfTmByScrewing) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRectSwept", LuaCreateSurfTmRectSwept) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSwept", LuaCreateSurfTmSwept) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTransSwept", LuaCreateSurfTmTransSwept) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRuled", LuaCreateSurfTmRuled) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByTriangles", LuaCreateSurfTmByTriangles) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmBySewing", LuaCreateSurfTmBySewing) ;