From 9e14c158ff2e2e67436d9f06e184c7b8c22f9cb6 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 22 Jul 2026 09:27:01 +0200 Subject: [PATCH] EgtExecutor : - aggiunta funzione per estendere un gruppo di superfici indicandone il bordo. - piccola correzione. --- EXE_GdbCreateSurf.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++ LUA_GdbCreateSurf.cpp | 33 ++++++++++++++++++++++ LUA_GdbCreateVol.cpp | 4 +-- 3 files changed, 100 insertions(+), 2 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index b3a12ec..db5eb7e 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -3058,3 +3058,68 @@ ExeCreateSurfExtension( int nParentId, int nSurfId, double dExtLen, int nCrv, in return nNewId ; } + +//------------------------------------------------------------------------------- +int +ExeCreateSurfExtensionFromMany( int nParentId, const INTVECTOR& vSurfId, double dExtLen, int nCrvId, + bool bDrawOffEdge, int* pnCount, int nType, double dLinTol) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + + bool bOk = true ; + // Recupero il riferimento della prima superficie + Frame3d frSurf ; + bOk = bOk && pGeomDB->GetGlobFrame( vSurfId[0], frSurf) ; + // Recupero il riferimento dei gruppi di destinazione + Frame3d frDest ; + bOk = bOk && pGeomDB->GetGlobFrame( nParentId, frDest) ; + + // recupero le superfici e le porto in locale alla prima + SURFLOCALVECTOR vSurfL ; vSurfL.reserve( ssize( vSurfId)) ; + CISURFPVECTOR vpSurf ; + for ( int nSurfId : vSurfId) { + const ISurfTriMesh* pSurf = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfId)) ; + if ( pSurf == nullptr) { + const ISurfBezier* pSurfBz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ; + if ( pSurfBz == nullptr) + return GDB_ID_NULL ; + pSurf = pSurfBz->GetAuxSurfRefined() ; + } + vSurfL.emplace_back( pGeomDB, nSurfId, frSurf) ; + vpSurf.emplace_back( vSurfL.back().Get()) ; + } + + CurveLocal CrvLoc( pGeomDB, nCrvId, frSurf) ; + + ICurve* pOffEdge = nullptr ; + ISurfTriMesh* pExtension = GetSurfExtensionFromMany( vpSurf, dExtLen, CrvLoc.Get(), pOffEdge, nType, dLinTol) ; + //pExtension->ToLoc( frDest) ; + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pExtension) ; + if ( nNewId != GDB_ID_NULL) { + if ( pnCount != nullptr) + ++ *pnCount ; + } + if ( bDrawOffEdge && pOffEdge->IsValid()) { + int nEdgeId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pOffEdge) ; + if ( nEdgeId != GDB_ID_NULL) { + if ( pnCount != nullptr) + ++ *pnCount ; + } + } + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfExtend(" + IdToString( nParentId) + "," + + IdListToString( vSurfId) + "," + + ToString( dExtLen) + "," + + ToString( nCrvId) + "," + + ToString( nType) + ")" + + ToString( dLinTol) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return nNewId ; +} diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index e3027f8..2598bca 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -1511,6 +1511,38 @@ LuaCreateSurfExtension( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateSurfExtensionFromMany( lua_State* L) +{ + // 5 o 7 parametri : ParentId, vSurfId, dExtLen , nCrvId, bDrawOffEdge, [, nType, dTol] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + INTVECTOR vSurfId ; + LuaCheckParam( L, 2, vSurfId) + double dExtLen ; + LuaCheckParam( L, 3, dExtLen) + int nCrvId ; + LuaCheckParam( L, 4, nCrvId) + bool bDrawOffEdge = false ; + LuaCheckParam( L, 5, bDrawOffEdge) + int nType = OFFTYPE::GEOM ; + double dTol = LIN_TOL_STD ; + if ( LuaGetParam( L, 6, nType)) { + LuaGetParam( L, 7, dTol) ; + } + LuaClearStack( L) ; + int nCount = 0 ; + int nId = ExeCreateSurfExtensionFromMany( nParentId, vSurfId, dExtLen, nCrvId, bDrawOffEdge, &nCount, nType, dTol) ; + if ( nId != GDB_ID_NULL) { + LuaSetParam( L, nId) ; + LuaSetParam( L, nCount) ; + } + else + LuaSetParam( L) ; + return 2 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbCreateSurf( LuaMgr& luaMgr) @@ -1568,5 +1600,6 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzSkinned", LuaCreateSurfBzSkinned) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzSwept", LuaCreateSurfBzSwept) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfExtend", LuaCreateSurfExtension) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfExtendFromMany", LuaCreateSurfExtensionFromMany) ; return bOk ; } diff --git a/LUA_GdbCreateVol.cpp b/LUA_GdbCreateVol.cpp index f4d0b45..3810520 100644 --- a/LUA_GdbCreateVol.cpp +++ b/LUA_GdbCreateVol.cpp @@ -133,11 +133,11 @@ LuaCreateVolZmapFromSurfTm( lua_State* L) int nPar = 4 ; if ( LuaGetParam( L, nPar, bTriDex)) { ++ nPar ; - if ( LuaGetParam( L, nPar, dExtraBox)) ; + if ( LuaGetParam( L, nPar, dExtraBox)) ++ nPar ; } else { - if ( LuaGetParam( L, nPar, dExtraBox)) ; + if ( LuaGetParam( L, nPar, dExtraBox)) ++ nPar ; } bool bForceClosed = false ;