From a3fa91244dab821232feb80e57dcd9da08598a1d Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 14 Feb 2024 14:42:16 +0100 Subject: [PATCH] EgtExecutor : - aggiunta la funzione per creare una sfera come superficie bezier. --- EXE_GdbCreateSurf.cpp | 31 +++++++++++++++++++++++++++++++ LUA_GdbCreateSurf.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 59ae3e7..5e8cb83 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -33,6 +33,8 @@ #include "/EgtDev/Include/EGkCurveLocal.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EGkExtText.h" +#include "/EgtDev/Include/EGkSbzStandard.h" + using namespace std ; //------------------------------------------------------------------------------- @@ -1782,3 +1784,32 @@ ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight, bool b *pnCount = nCount ; return nFirstId ; } + +//------------------------------------------------------------------------------- +int +ExeCreateBezierSphere( int nParentId, const Point3d& ptCenter, double dR, int nRefType) { + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + bool bOk = true ; + // recupero il riferimento di immersione della superficie + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // reucpero il punto in locale + Point3d ptCenterLoc = GetPointLocal( pGeomDB, ptCenter, nRefType, frLoc) ; + // Creo la superficie + PtrOwner pSurfBez( CreateBezierSphere( ptCenterLoc, dR)) ; + int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSurfBez)) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtCreateBezierSphere(" + IdToString( nParentId) + "," + + ToString( ptCenter) + "," + + ToString( dR) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // resituisco l'identificativo dell'entità creata + return nId ; +} diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 13db858..6549194 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -903,6 +903,34 @@ LuaCreateSurfBezierLeaves( lua_State* L) return 2 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateBezierSphere( lua_State* L) +{ + // 3 o 4 parametri : ParentId, ptCenter, dRad [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + Point3d ptCenter ; + LuaCheckParam( L, 2, ptCenter) + double dRad ; + LuaCheckParam( L, 3, dRad) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 4, nRefType) ; + // creo la superficie + int nCount = 0 ; + int nId = ExeCreateBezierSphere( nParentId, ptCenter, dRad, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) { + LuaSetParam( L, nId) ; + LuaSetParam( L, nCount) ; + } + else { + LuaSetParam( L) ; + LuaSetParam( L) ; + } + return 2 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbCreateSurf( LuaMgr& luaMgr) @@ -940,5 +968,6 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezier", LuaCreateSurfBezier) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierRat", LuaCreateSurfBezierRational) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierLeaves", LuaCreateSurfBezierLeaves) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCreateBezierSphere", LuaCreateBezierSphere) ; return bOk ; }