From 740d3817dece53c2d1a6d34d01d0df3bda6a42ec Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 15 Dec 2025 11:32:21 +0100 Subject: [PATCH] EgtExecutor 2.7l2 : - Modificate le funzioni di Offset per superfici TriMesh aperte - Aggiunta la funzione per la creazione di Shell per TriMesh. --- EXE_GdbCreateSurf.cpp | 100 ++++++++++++++++++++++++++++++++++++++++++ EXE_GdbModifySurf.cpp | 2 +- EgtExecutor.rc | Bin 19660 -> 19660 bytes LUA_GdbCreateSurf.cpp | 24 ++++++++++ 4 files changed, 125 insertions(+), 1 deletion(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 24c7cf2..6263180 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -1832,6 +1832,106 @@ ExeCreateSurfTmByVolZmap( int nParentId, int nZmapId, int nPart) return nNewId ; } +//---------------------------------------------------------------------------- +static double +GetStmOffsPrec( double dOffs, double dLinTol) +{ + return max( min( abs( dOffs) / 4., 10. * max( dLinTol, EPS_SMALL)), 0.5) ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateSurfShell( int nParentId, int nSurfId, double dThick, double dLinTol) +{ + // Verifica del DB geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + + // Sistemo lo spessore ( diretto in direzione opposta alla normale della superficie) e ala tolleranza lineare + bool bOk = ( abs( dThick) > 10. * EPS_SMALL) ; + double dOffs = ( - abs( dThick)) ; + double dMyLinTol = max( EPS_SMALL, dLinTol) ; + + // Recupero la superficie + const ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nSurfId)) ; + bOk = bOk && ( pSurf != nullptr && pSurf->IsValid()) ; + + // Recupero il riferimento del gruppo di destinazione + Frame3d frDest ; + bOk = bOk && ( pGeomDB->GetGroupGlobFrame( nParentId, frDest)) ; + + // Definisco la TriMesh risultate + PtrOwner pStmRes( CreateSurfTriMesh()) ; + bOk = bOk && ( ! IsNull( pStmRes)) ; + + // Definisco la Shell in base al tipo di superficie + if ( bOk) { + switch ( pSurf->GetType()) { + case SRF_TRIMESH : { + // Recupero la superficie TriMesh ( deve essere aperta) + const ISurfTriMesh* pStm = GetSurfTriMesh( pSurf) ; + bOk = ( pStm != nullptr && pStm->IsValid() && ! pStm->IsClosed()) ; + if ( bOk) { + double dPrec = GetStmOffsPrec( dOffs, dMyLinTol) ; + bOk = ( pStmRes.Set( CreateSurfTriMeshShell( pStm, dOffs, dPrec))) ; + bOk = bOk && ( ! IsNull( pStmRes) && pStmRes->IsValid()) ; + } + } + break ; + case SRF_BEZIER : { + // Recupero la superficie di Bezier + const ISurfBezier* pSBz = GetSurfBezier( pSurf) ; + bOk = ( pSBz != nullptr && pSBz->IsValid()) ; + // TODO : + bOk = false ; // <--- + } + break ; + case SRF_FLATRGN : { + // Recupero la superficie piana + const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pSurf) ; + bOk = ( pSfr != nullptr && pSfr->IsValid()) ; + // Definisco la superficie di estrusione dai Loops della regione piana + CICURVEPVECTOR vLoops ; + for ( int nChunk = 0 ; bOk && nChunk < pSfr->GetChunkCount() ; ++ nChunk) { + for ( int nLoop = 0 ; bOk && nLoop < pSfr->GetLoopCount( nChunk) ; ++ nLoop) + bOk = ( vLoops.emplace_back( pSfr->GetLoop( nChunk, nLoop)) && vLoops.back()->IsValid()) ; + } + bOk = bOk && pStmRes.Set( GetSurfTriMeshByRegionExtrusion( vLoops, - dOffs * pSfr->GetNormVersor(), dMyLinTol)) ; + } + default : + bOk = false ; + break ; + } + } + + // Verifico che la superficie risultante sia valida + bOk = bOk && ( ! IsNull( pStmRes) && pStmRes->IsValid()) ; + + // Porto la superficie risultante nel frame di destinazione + bOk = bOk && ( pStmRes->ToLoc( frDest)) ; + + // Inserisco la superficie trimesh nel DB + int nNewId = GDB_ID_NULL ; + if ( bOk) { + nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmRes)) ; + bOk = ( nNewId != GDB_ID_NULL) ; + } + + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmShell(" + IdToString( nParentId) + "," + + IdToString( nSurfId) + "," + + ToString( dThick) + "," + + ToString( dLinTol) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return nNewId ; +} + //------------------------------------------------------------------------------- int ExeCreateSurfBezier( int nParentId, int nDegU, int nDegV, int nSpanU, int nSpanV, const PNTVECTOR& vPnt, int nRefType) diff --git a/EXE_GdbModifySurf.cpp b/EXE_GdbModifySurf.cpp index 6306bb3..1859831 100644 --- a/EXE_GdbModifySurf.cpp +++ b/EXE_GdbModifySurf.cpp @@ -1214,7 +1214,7 @@ ExeSurfTmSetSmoothAng( int nId, double dAngDeg) static double GetStmOffsPrec( double dOffs, double dLinTol) { - return max( min( abs( dOffs) / 4, 100 * max( dLinTol, EPS_SMALL)), 0.5) ; + return max( min( abs( dOffs) / 4., 10. * max( dLinTol, EPS_SMALL)), 0.5) ; } //---------------------------------------------------------------------------- diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 5eb5a441f1b33f1acd80c684885ca93902e2f9db..2eb5741bcf32818fd007cfdc81e6f0aa09204082 100644 GIT binary patch delta 107 zcmX>zlkv<<#tlE%7>zcc6}!$f`2uGiqtRqTVcpFRQhtn^cX8`61Eu!LU1plRM-VDC l*+I%|bDxkM3s{pYPytj!4M=3KoFh~Os!o7$bCGhCCIHFSA?W}B delta 107 zcmX>zlkv<<#tlE%7!5a{6}!$f`2uGiqv2#jVcpFRQhtn^cX8`61Eu!LU1plRM-VDC l*+I%|bDxkM3s{pYPytj!4M=3KoFh~Os!o7$bCGhCCIHAFA>jZ3 diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 38e6fcf..b4b1110 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -956,6 +956,29 @@ LuaCreateSurfTmByVolZmap( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateSurfShell( lua_State* L) +{ + // 4 parametri : nParentId, nSurfId, dThick, dLinTol + int nParentId ; + LuaCheckParam( L, 1, nParentId) ; + int nSurfId ; + LuaCheckParam( L, 2, nSurfId) ; + double dThick ; + LuaCheckParam( L, 3, dThick) ; + double dLinTol ; + LuaCheckParam( L, 4, dLinTol) ; + // creo la STM + int nId = ExeCreateSurfShell( nParentId, nSurfId, dThick, dLinTol) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateSurfBezier( lua_State* L) @@ -1489,6 +1512,7 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByTriangles", LuaCreateSurfTmByTriangles) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmBySewing", LuaCreateSurfTmBySewing) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByVolZmap", LuaCreateSurfTmByVolZmap) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCreateSurfShell", LuaCreateSurfShell) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezier", LuaCreateSurfBezier) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierRat", LuaCreateSurfBezierRational) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierLeaves", LuaCreateSurfBezierLeaves) ;