From 9c5f48be88ee16e874a7db8bcefb16f02a52926e Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 16 Jun 2025 13:17:31 +0200 Subject: [PATCH] EgtExecutor : - ricollocazione funzioni di Offset per superfici TriMesh chiuse. --- EXE_GdbCreateSurf.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++ EXE_GdbModifySurf.cpp | 56 ------------------------------------------ LUA_GdbCreateSurf.cpp | 21 ++++++++++++++++ LUA_GdbModifySurf.cpp | 21 ---------------- 4 files changed, 78 insertions(+), 77 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 8288ce9..97e9548 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -1834,6 +1834,63 @@ ExeCreateSurfTmByVolZmap( int nParentId, int nZmapId, int nPart) return nNewId ; } +//---------------------------------------------------------------------------- +int +ExeSurfTmOffset( int nParentId, const INTVECTOR& vStmIds, double dOffs, double dLinTol) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // se non ci sono superfici non c'è niente da calcolare + if ( vStmIds.empty()) + return GDB_ID_NULL ; + // recupero il riferimento della prima superficie + Frame3d frSurf ; + if ( ! pGeomDB->GetGlobFrame( vStmIds[0], frSurf)) + return GDB_ID_NULL ; + // recupero il riferimento di locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + // recupero le superfici TriMesh e le porto tutte in locale alla prima + CISURFTMPVECTOR vpStm ; vpStm.reserve( vStmIds.size()) ; + for ( int i = 0 ; i < int( vStmIds.size()) ; ++ i) { + // recupero la superficie TriMesh + IGeoObj* pGeoObj = pGeomDB->GetGeoObj( vStmIds[i]) ; + if ( pGeoObj->GetType() != SRF_TRIMESH) + return GDB_ID_NULL ; + // recupero una copia della superficie TriMesh e la porto il locale + ISurfTriMesh* pStm = CloneSurfTriMesh( GetSurfTriMesh( pGeoObj)) ; + if ( pStm != nullptr) { + pStm->LocToLoc( frSurf, frLoc) ; + vpStm.emplace_back( pStm) ; + } + } + // recupero la superficie risultante + int nId = GDB_ID_NULL ; + PtrOwner pStmOffs( CreateSurfTriMeshesOffset( vpStm, dOffs, dLinTol)) ; + bool bOk = ( ! IsNull( pStmOffs) && pStmOffs->IsValid()) ; + if ( bOk) + nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmOffs)) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtOffsetSurfTm(" + ToString( nParentId) + ")" + + ToString( vStmIds) + "," + + ToString( dOffs) + "," + + ToString( dLinTol) + "," + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + for ( int i = 0 ; i < int( vpStm.size()) ; ++ i) { + if ( vpStm[i] != nullptr) + delete vpStm[i] ; + vpStm[i] = nullptr ; + } + return nId ; +} + //------------------------------------------------------------------------------- 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 66914d9..dc0b01d 100644 --- a/EXE_GdbModifySurf.cpp +++ b/EXE_GdbModifySurf.cpp @@ -916,62 +916,6 @@ ExeSurfTmIntersect( int nId1, int nId2, bool bTwoColors) return bOk ; } -//---------------------------------------------------------------------------- -int -ExeSurfTmOffset( const INTVECTOR& vStmIds, double dOffs, double dLinTol, int nDestGrpId) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // se non ci sono superfici non c'è niente da calcolare - if ( vStmIds.empty()) - return GDB_ID_NULL ; - // recupero il riferimento della prima superficie - Frame3d frSurf ; - if ( ! pGeomDB->GetGlobFrame( vStmIds[0], frSurf)) - return GDB_ID_NULL ; - // recupero il riferimento di destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) - return GDB_ID_NULL ; - // recupero le superfici TriMesh e le porto tutte in locale alla prima - CISURFTMPVECTOR vpStm ; vpStm.reserve( vStmIds.size()) ; - for ( int i = 0 ; i < int( vStmIds.size()) ; ++ i) { - // recupero la superficie TriMesh - IGeoObj* pGeoObj = pGeomDB->GetGeoObj( vStmIds[i]) ; - if ( pGeoObj->GetType() != SRF_TRIMESH) - return GDB_ID_NULL ; - // recupero una copia della superficie TriMesh e la porto il locale - ISurfTriMesh* pStm = CloneSurfTriMesh( GetSurfTriMesh( pGeoObj)) ; - if ( pStm != nullptr) { - pStm->LocToLoc( frSurf, frDest) ; - vpStm.emplace_back( pStm) ; - } - } - // recupero la superficie risultante - int nId = GDB_ID_NULL ; - PtrOwner pStmOffs( CreateSurfTriMeshesOffset( vpStm, dOffs, dLinTol)) ; - bool bOk = ( ! IsNull( pStmOffs) && pStmOffs->IsValid()) ; - if ( bOk) - nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pStmOffs)) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtOffsetSurfTm(" + ToString( vStmIds) + "," + - ToString( dOffs) + "," + - ToString( dLinTol) + "," + - ToString( nDestGrpId) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - for ( int i = 0 ; i < int( vpStm.size()) ; ++ i) { - if ( vpStm[i] != nullptr) - delete vpStm[i] ; - vpStm[i] = nullptr ; - } - return nId ; -} - //---------------------------------------------------------------------------- static ISurfTriMesh* MyCreateSubSurfTm( const ISurfTriMesh* pStm, const INTVECTOR& vTria, const INTVECTOR& vTria2) diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 4de0ccf..4c1f1ea 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -955,6 +955,26 @@ LuaCreateSurfTmByVolZmap( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaSurfTmOffset( lua_State* L) +{ + // 3 parametri : ParentId, vIds, dOffs, dLinTol + int nParentId ; + LuaGetParam( L, 1, nParentId) ; + INTVECTOR vIds ; + LuaCheckParam( L, 2, vIds) + double dOffs ; + LuaCheckParam( L, 3, dOffs) + double dLinTol ; + LuaGetParam( L, 4, dLinTol) ; + LuaClearStack( L) ; + // interseco la prima superficie con la seconda + int nId = ExeSurfTmOffset( nParentId, vIds, dOffs, dLinTol) ; + LuaSetParam( L, nId) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateSurfBezier( lua_State* L) @@ -1456,6 +1476,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( "EgtSurfTmOffset", LuaSurfTmOffset) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezier", LuaCreateSurfBezier) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierRat", LuaCreateSurfBezierRational) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierLeaves", LuaCreateSurfBezierLeaves) ; diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp index 67fff14..bba6dff 100644 --- a/LUA_GdbModifySurf.cpp +++ b/LUA_GdbModifySurf.cpp @@ -421,26 +421,6 @@ LuaSurfTmIntersect( lua_State* L) return 1 ; } -//------------------------------------------------------------------------------- -static int -LuaSurfTmOffset( lua_State* L) -{ - // 3 parametri : vIds, dOffs, dLinTol, nDestGrpId - INTVECTOR vIds ; - LuaCheckParam( L, 1, vIds) - double dOffs ; - LuaCheckParam( L, 2, dOffs) - double dLinTol ; - LuaGetParam( L, 3, dLinTol) ; - int nDestGrpId ; - LuaGetParam( L, 4, nDestGrpId) ; - LuaClearStack( L) ; - // interseco la prima superficie con la seconda - int nId = ExeSurfTmOffset( vIds, dOffs, dLinTol, nDestGrpId) ; - LuaSetParam( L, nId) ; - return 1 ; -} - //------------------------------------------------------------------------------- static int LuaSurfTmSplit( lua_State* L) @@ -661,7 +641,6 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmAdd", LuaSurfTmAdd) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSubtract", LuaSurfTmSubtract) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmIntersect", LuaSurfTmIntersect) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmOffs", LuaSurfTmOffset) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSplit", LuaSurfTmSplit) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCut", LuaSurfTmCut) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSubtractProjectedFacesOnFace", LuaSurfTmSubtractProjectedFacesOnFace) ;