From c36ce0a26fbf2b887f8f753fa648f3ac4645fa48 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 7 Jul 2025 14:59:59 +0200 Subject: [PATCH] EgtExecutor : - prime sistemazioni per offset superfici trimesh tramite Zmap - eliminate funzioni exe/lua CreateVolZmapFromSurfTmOffset e CreateVolZmapFromSurfTmThickeningOffset. --- EXE_GdbCreateSurf.cpp | 128 +------------------------ EXE_GdbCreateVol.cpp | 114 ----------------------- EXE_GdbModifySurf.cpp | 212 ++++++++++++++++++++++++++++++------------ LUA_GdbCreateSurf.cpp | 46 --------- LUA_GdbCreateVol.cpp | 87 ----------------- LUA_GdbModifySurf.cpp | 129 +++++++++++++++++-------- LUA_GdbModifyVol.cpp | 32 +++++++ 7 files changed, 276 insertions(+), 472 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index ab1832f..7ab640e 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -20,9 +20,7 @@ #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EGkDistPointLine.h" -#include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/EGkSfrCreate.h" -#include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkStmStandard.h" #include "/EgtDev/Include/EGkStmFromCurves.h" #include "/EgtDev/Include/EGkStmFromTriangleSoup.h" @@ -1492,7 +1490,7 @@ ExeCreateSurfTmSwept( int nParentId, int nSectId, int nGuideId, const Vector3d& } // controllo se la sezione è definita da una regione piana else if ( nSecType == SRF_FLATRGN) { - // recupero la regione sezion in locale + // recupero la regione sezione in locale SurfLocal SrfSect( pGeomDB, nSectId, frLoc) ; const ISurfFlatRegion* pSFrSect = GetSurfFlatRegion( SrfSect.Get()) ; bOk = bOk && ( pSFrSect != nullptr) ; @@ -1834,130 +1832,6 @@ ExeCreateSurfTmByVolZmap( int nParentId, int nZmapId, int nPart) return nNewId ; } -//---------------------------------------------------------------------------- -int -ExeSurfTmOffset( int nParentId, const INTVECTOR& vStmIds, double dOffs, double dLinTol, int nType) -{ - 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, nType)) ; - bool bOk = ( ! IsNull( pStmOffs) && pStmOffs->IsValid()) ; - // dealloco le superfici - for ( auto& pStm : vpStm) { - delete ( pStm) ; - pStm = nullptr ; - } - if ( bOk) - nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmOffs)) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmOffset(" + 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 -ExeSurfTmThickeningOffset( int nParentId, const INTVECTOR& vStmIds, double dOffs, double dLinTol, int nType) -{ - 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( CreateSurfTriMeshesThickeningOffset( vpStm, dOffs, dLinTol, nType)) ; - bool bOk = ( ! IsNull( pStmOffs) && pStmOffs->IsValid()) ; - // dealloco le superfici - for ( auto& pStm : vpStm) { - delete ( pStm) ; - pStm = nullptr ; - } - if ( bOk) - nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmOffs)) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmThickeningOffset(" + 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_GdbCreateVol.cpp b/EXE_GdbCreateVol.cpp index e6fc4d5..87a43c2 100644 --- a/EXE_GdbCreateVol.cpp +++ b/EXE_GdbCreateVol.cpp @@ -188,120 +188,6 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe return nNewId ; } -//------------------------------------------------------------------------------- -int ExeCreateVolZmapFromSurfTmOffset( int nParentId, const INTVECTOR& vStmId, double dOffs, double dPrec, int nType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // definisco il vettore di puntatori esclusivi alle superfici TriMesh - CISURFTMPVECTOR vStm ; - // recupero le superfici - for ( size_t i = 0 ; i < vStmId.size() ; ++ i) { - int nStmId = vStmId[i] ; - // recupero il riferimento della regione - Frame3d frStm ; - if ( ! pGeomDB->GetGlobFrame( nStmId, frStm)) - return GDB_ID_NULL ; - // recupero la superficie trimesh - ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nStmId)) ; - if ( pStm == nullptr) - return GDB_ID_NULL ; - // ne faccio una copia - PtrOwner pCopyStm( pStm->Clone()) ; - if ( IsNull( pCopyStm)) - return false ; - // eseguo la trasformazione (viene eseguita solo se i riferimenti sono diversi) - pCopyStm->LocToLoc( frStm, frLoc) ; - // lo assegno al vettore di superfici - vStm.emplace_back( Release( pCopyStm)) ; - } - // creo lo Zmap nel riferimento intrinseco - PtrOwner pVZM( CreateVolZmap()) ; - bool bOk = ( ! IsNull( pVZM)) ; - bOk = bOk && pVZM->CreateFromTriMeshOffset( vStm, dOffs, dPrec, nType) ; - // dealloco le superfici - for ( auto& pStm : vStm) { - delete ( pStm) ; - pStm = nullptr ; - } - // inserisco lo Zmap nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pVZM)) : GDB_ID_NULL) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtVolZmapFromSurfTmOffset(" + IdToString( nParentId) + "," + - ToString( vStmId) + "," + - ToString( dOffs) + "," + - ToString( dPrec) + "," ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; -} - -//------------------------------------------------------------------------------- -int ExeCreateVolZmapFromSurfTmThickeningOffset( int nParentId, const INTVECTOR& vStmId, double dOffs, double dPrec, int nType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // definisco il vettore di puntatori esclusivi alle superfici TriMesh - CISURFTMPVECTOR vStm ; - // recupero le superfici - for ( size_t i = 0 ; i < vStmId.size() ; ++ i) { - int nStmId = vStmId[i] ; - // recupero il riferimento della regione - Frame3d frStm ; - if ( ! pGeomDB->GetGlobFrame( nStmId, frStm)) - return GDB_ID_NULL ; - // recupero la superficie trimesh - ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nStmId)) ; - if ( pStm == nullptr) - return GDB_ID_NULL ; - // ne faccio una copia - PtrOwner pCopyStm( pStm->Clone()) ; - if ( IsNull( pCopyStm)) - return false ; - // eseguo la trasformazione (viene eseguita solo se i riferimenti sono diversi) - pCopyStm->LocToLoc( frStm, frLoc) ; - // lo assegno al vettore di superfici - vStm.emplace_back( Release( pCopyStm)) ; - } - // creo lo Zmap nel riferimento intrinseco - PtrOwner pVZM( CreateVolZmap()) ; - bool bOk = ( ! IsNull( pVZM)) ; - bOk = bOk && pVZM->CreateFromTriMeshThickeningOffset( vStm, dOffs, dPrec, nType) ; - // dealloco le superfici - for ( auto& pStm : vStm) { - delete ( pStm) ; - pStm = nullptr ; - } - // inserisco lo Zmap nel DB - int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pVZM)) : GDB_ID_NULL) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCreateVolZmapFromSurfTmThickeningOffset(" + IdToString( nParentId) + "," + - ToString( vStmId) + "," + - ToString( dOffs) + "," + - ToString( dPrec) + "," ")" + - " -- Id=" + ToString( nNewId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della nuova entità - return nNewId ; -} - //------------------------------------------------------------------------------- bool ExeUpdateVolZmapByAddingSurfTm( int nVolZmapId, int nStmId) diff --git a/EXE_GdbModifySurf.cpp b/EXE_GdbModifySurf.cpp index dc0b01d..6306bb3 100644 --- a/EXE_GdbModifySurf.cpp +++ b/EXE_GdbModifySurf.cpp @@ -23,7 +23,7 @@ #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkCurveLocal.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" -#include "/EgtDev/Include/EGkSurfTriMesh.h" +#include "/EgtDev/Include/EGkSurfTriMeshAux.h" #include "/EgtDev/Include/EGkSurfBezier.h" #include "/EgtDev/Include/EGkSurfLocal.h" #include "/EgtDev/Include/EGkStmFromTriangleSoup.h" @@ -745,41 +745,6 @@ ExeCutSurfTmPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, bool bSave return bOk ; } -//------------------------------------------------------------------------------- -bool -ExeCutSurfBzPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, bool bSaveOnEq, int nRefType) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero la superficie TriMesh - ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nId)) ; - bool bOk = ( pSbz != nullptr) ; - // recupero il riferimento locale - Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; - // porto in locale il punto e la normale del piano - Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; - // calcolo il piano di taglio - Plane3d plPlane ; - bOk = bOk && plPlane.Set( ptOnL, vtNL) ; - // eseguo il taglio - bOk = bOk && pSbz->Cut( plPlane, bSaveOnEq) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCutSurfBzPlane(" + IdToString( nId) + ",{" + - ToString( ptOn) + "},{" + - ToString( vtN) + "}," + - ( bSaveOnEq ? "true" : "false") + "," + - RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return bOk ; -} - //------------------------------------------------------------------------------- bool ExeCutSurfTmClosedCurve( int nSurfId, int nCurveId, bool bSaveOnEq) @@ -1224,6 +1189,160 @@ ExeSurfTmGetShowEdges( int nId, bool& bShow) return bOk ; } +//---------------------------------------------------------------------------- +bool +ExeSurfTmSetSmoothAng( int nId, double dAngDeg) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie trimseh da trimmare + ISurfTriMesh* pSrfTm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pSrfTm == nullptr) + return false ; + pSrfTm->SetSmoothAngle( dAngDeg) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmSetSmoothAng(" + ToString( nId) + "," + + ToString( dAngDeg) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return true ; +} + +//---------------------------------------------------------------------------- +static double +GetStmOffsPrec( double dOffs, double dLinTol) +{ + return max( min( abs( dOffs) / 4, 100 * max( dLinTol, EPS_SMALL)), 0.5) ; +} + +//---------------------------------------------------------------------------- +int +ExeSurfTmOffset( int nParentId, const INTVECTOR& vStmIds, double dOffs, double dLinTol, int nType) +{ + 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 del gruppo di inserimento + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + // recupero le superfici TriMesh e le porto tutte in locale + SURFLOCALVECTOR vSurfL ; vSurfL.reserve( vStmIds.size()) ; + CISURFTMPVECTOR vpStm ; vpStm.reserve( vStmIds.size()) ; + for ( int i = 0 ; i < int( vStmIds.size()) ; ++ i) { + vSurfL.emplace_back( pGeomDB, vStmIds[i], frLoc) ; + if ( vSurfL[i].Get() == nullptr) + return GDB_ID_NULL ; + vpStm.emplace_back( GetSurfTriMesh( vSurfL[i].Get())) ; + } + // precisione per Tridexel in funzione dell'offset e della tolleranza lineare + double dPrec = GetStmOffsPrec( dOffs, dLinTol) ; + // recupero la superficie risultante + PtrOwner pStmOffs( CreateSurfTriMeshesOffset( vpStm, dOffs, dPrec, nType)) ; + bool bOk = ( ! IsNull( pStmOffs) && pStmOffs->IsValid()) ; + int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmOffs)) : GDB_ID_NULL) ; + // copio gli attributi + pGeomDB->CopyAttributes( vStmIds[0], nId) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmOffset(" + ToString( nParentId) + ")" + + ToString( vStmIds) + "," + + ToString( dOffs) + "," + + ToString( dLinTol) + "," + + ToString( nType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return nId ; +} + +//------------------------------------------------------------------------------- +int +ExeSurfTmThickeningOffset( int nParentId, const INTVECTOR& vStmIds, double dOffs, double dLinTol, int nType) +{ + 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 del gruppo di inserimento + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + // recupero le superfici TriMesh e le porto tutte in locale + SURFLOCALVECTOR vSurfL ; vSurfL.reserve( vStmIds.size()) ; + CISURFTMPVECTOR vpStm ; vpStm.reserve( vStmIds.size()) ; + for ( int i = 0 ; i < int( vStmIds.size()) ; ++ i) { + vSurfL.emplace_back( pGeomDB, vStmIds[i], frLoc) ; + if ( vSurfL[i].Get() == nullptr) + return GDB_ID_NULL ; + vpStm.emplace_back( GetSurfTriMesh( vSurfL[i].Get())) ; + } + // precisione per Tridexel in funzione dell'offset e della tolleranza lineare + double dPrec = GetStmOffsPrec( dOffs, dLinTol) ; + // recupero la superficie risultante + PtrOwner pStmOffs( CreateSurfTriMeshesThickeningOffset( vpStm, dOffs, dPrec, nType)) ; + bool bOk = ( ! IsNull( pStmOffs) && pStmOffs->IsValid()) ; + int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmOffs)) : GDB_ID_NULL) ; + // copio gli attributi + pGeomDB->CopyAttributes( vStmIds[0], nId) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmThickeningOffset(" + ToString( nParentId) + ")" + + ToString( vStmIds) + "," + + ToString( dOffs) + "," + + ToString( dLinTol) + "," + + ToString( nType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return nId ; +} + +//------------------------------------------------------------------------------- +bool +ExeCutSurfBzPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, bool bSaveOnEq, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie TriMesh + ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pSbz != nullptr) ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; + // porto in locale il punto e la normale del piano + Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ; + Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; + // calcolo il piano di taglio + Plane3d plPlane ; + bOk = bOk && plPlane.Set( ptOnL, vtNL) ; + // eseguo il taglio + bOk = bOk && pSbz->Cut( plPlane, bSaveOnEq) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtCutSurfBzPlane(" + IdToString( nId) + ",{" + + ToString( ptOn) + "},{" + + ToString( vtN) + "}," + + ( bSaveOnEq ? "true" : "false") + "," + + RefTypeToString( nRefType) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + //---------------------------------------------------------------------------- static bool MySurfBzTrim( int nId, int nTrimmerId) @@ -1267,24 +1386,3 @@ ExeSurfBzTrim( int nId, int nCutterId) } return bOk ; } - -//---------------------------------------------------------------------------- -bool -ExeSurfTmSetSmoothAng( int nId, double dAngDeg) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero la superficie trimseh da trimmare - ISurfTriMesh* pSrfTm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - if ( pSrfTm == nullptr) - return false ; - pSrfTm->SetSmoothAngle( dAngDeg) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtSurfTmSetSmoothAng(" + ToString( nId) + "," + - ToString( dAngDeg) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - return true ; -} diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 3e12c88..2d88ffc 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -956,50 +956,6 @@ LuaCreateSurfTmByVolZmap( lua_State* L) return 1 ; } -//------------------------------------------------------------------------------- -static int -LuaSurfTmOffset( lua_State* L) -{ - // 4 parametri : ParentId, vIds, dOffs, dLinTol, nType - int nParentId ; - LuaGetParam( L, 1, nParentId) ; - INTVECTOR vIds ; - LuaCheckParam( L, 2, vIds) - double dOffs ; - LuaCheckParam( L, 3, dOffs) - double dLinTol ; - LuaCheckParam( L, 4, dLinTol) ; - int nType = ISurfTriMesh::OFF_FILLET ; - LuaGetParam( L, 5, nType) ; - LuaClearStack( L) ; - // interseco la prima superficie con la seconda - int nId = ExeSurfTmOffset( nParentId, vIds, dOffs, dLinTol, nType) ; - LuaSetParam( L, nId) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaSurfTmThickeningOffset( lua_State* L) -{ - // 4 parametri : ParentId, vIds, dOffs, dLinTol, nType - int nParentId ; - LuaGetParam( L, 1, nParentId) ; - INTVECTOR vIds ; - LuaCheckParam( L, 2, vIds) - double dOffs ; - LuaCheckParam( L, 3, dOffs) - double dLinTol ; - LuaCheckParam( L, 4, dLinTol) ; - int nType = ISurfTriMesh::OFF_FILLET ; - LuaGetParam( L, 5, nType) ; - LuaClearStack( L) ; - // interseco la prima superficie con la seconda - int nId = ExeSurfTmThickeningOffset( nParentId, vIds, dOffs, dLinTol, nType) ; - LuaSetParam( L, nId) ; - return 1 ; -} - //------------------------------------------------------------------------------- static int LuaCreateSurfBezier( lua_State* L) @@ -1501,8 +1457,6 @@ 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( "EgtSurfTmThickeningOffset", LuaSurfTmThickeningOffset) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezier", LuaCreateSurfBezier) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierRat", LuaCreateSurfBezierRational) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierLeaves", LuaCreateSurfBezierLeaves) ; diff --git a/LUA_GdbCreateVol.cpp b/LUA_GdbCreateVol.cpp index 3d553c5..494d4a6 100644 --- a/LUA_GdbCreateVol.cpp +++ b/LUA_GdbCreateVol.cpp @@ -141,89 +141,6 @@ LuaCreateVolZmapFromSurfTm( lua_State* L) return 1 ; } -//------------------------------------------------------------------------------- -static int -LuaCreateVolZmapFromSurfTmOffset( lua_State* L) -{ - // 5 parametri : ParentId, StmIds, dOffs, dPrec, nType - int nParentId ; - LuaCheckParam( L, 1, nParentId) - INTVECTOR vStmId ; - LuaCheckParam( L, 2, vStmId) - double dOffs ; - LuaCheckParam( L, 3, dOffs) - double dPrec ; - LuaCheckParam( L, 4, dPrec) - int nType = ISurfTriMesh::OFF_FILLET ; - LuaGetParam( L, 5, nType) ; - LuaClearStack( L) ; - // creo VZM da offset di superficie trimesh - int nId = ExeCreateVolZmapFromSurfTmOffset( nParentId, vStmId, dOffs, dPrec, nType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetParam( L, nId) ; - else - LuaSetParam( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateVolZmapFromSurfTmThickeningOffset( lua_State* L) -{ - // 5 parametri : ParentId, StmIds, dOffs, dPrec, nType - int nParentId ; - LuaCheckParam( L, 1, nParentId) - INTVECTOR vStmId ; - LuaCheckParam( L, 2, vStmId) - double dOffs ; - LuaCheckParam( L, 3, dOffs) - double dPrec ; - LuaCheckParam( L, 4, dPrec) - int nType = ISurfTriMesh::OFF_FILLET ; - LuaGetParam( L, 5, nType) ; - LuaClearStack( L) ; - // creo VZM da offset di superficie trimesh - int nId = ExeCreateVolZmapFromSurfTmThickeningOffset( nParentId, vStmId, dOffs, dPrec, nType) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetParam( L, nId) ; - else - LuaSetParam( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaUpdateVolZmapByAddingSurfTm( lua_State* L) -{ - // 2 parametri : nVolZmapId, StmId, - int nVolZmapId ; - LuaCheckParam( L, 1, nVolZmapId) ; - int nStmId ; - LuaCheckParam( L, 2, nStmId) ; - LuaClearStack( L) ; - bool bOk = ExeUpdateVolZmapByAddingSurfTm( nVolZmapId, nStmId) ; - LuaSetParam( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaUniformVolZmap( lua_State* L) -{ - // 1 o 2 parametri : nVolZmapId [, dToler] - int nVolZmapId ; - LuaCheckParam( L, 1, nVolZmapId) ; - double dToler = EPS_SMALL ; - LuaGetParam( L, 2, dToler) ; - LuaClearStack( L) ; - bool bOk = ExeUniformVolZmap( nVolZmapId, dToler) ; - LuaSetParam( L, bOk) ; - return 1 ; -} - - //------------------------------------------------------------------------------- bool LuaInstallGdbCreateVol( LuaMgr& luaMgr) @@ -233,9 +150,5 @@ LuaInstallGdbCreateVol( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapEmpty", LuaCreateVolZmapEmpty) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapByRegionExtrusion", LuaCreateVolZmapByRegionExtrusion) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTm", LuaCreateVolZmapFromSurfTm) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTmOffset", LuaCreateVolZmapFromSurfTmOffset) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTmThickeningOffset", LuaCreateVolZmapFromSurfTmThickeningOffset) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtUpdateVolZmapByAddingSurfTm", LuaUpdateVolZmapByAddingSurfTm ) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtUniformZmap", LuaUniformVolZmap) ; return bOk ; } diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp index bba6dff..a775a48 100644 --- a/LUA_GdbModifySurf.cpp +++ b/LUA_GdbModifySurf.cpp @@ -18,6 +18,7 @@ #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EGkCurve.h" +#include "/EgtDev/Include/EGkSurfTriMeshAux.h" #include "/EgtDev/Include/EGkGdbConst.h" #include "/EgtDev/Include/EGkLuaAux.h" @@ -325,29 +326,6 @@ LuaCutSurfTmPlane( lua_State* L) return 1 ; } -//---------------------------------------------------------------------------- -static int -LuaCutSurfBzPlane( lua_State* L) -{ - // 4 o 5 parametri : Id, ptOn, vtN, bSaveOnEq [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptOn ; - LuaCheckParam( L, 2, ptOn) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - bool bSaveOnEq ; - LuaGetParam( L, 4, bSaveOnEq) ; - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // taglio la superficie con ilpiano - bool bOk = ExeCutSurfBzPlane( nId, ptOn, vtN, bSaveOnEq, nRefType) ; - // restituisco il risultato - LuaSetParam( L, bOk) ; - return 1 ; -} - //---------------------------------------------------------------------------- static int LuaCutSurfTmClosedCurve( lua_State* L) @@ -583,22 +561,6 @@ LuaSurfTmGetShowEdges( lua_State* L) return 1 ; } -//------------------------------------------------------------------------------- -static int -LuaSurfBzTrim( lua_State* L) -{ - // 2 parametri : nId, nCutterId - int nId ; - LuaCheckParam( L, 1, nId) - int nCutterId ; - LuaCheckParam( L, 2, nCutterId) - LuaClearStack( L) ; - // taglio la prima superficie in base alla seconda - bool bOk = ExeSurfBzTrim( nId, nCutterId) ; - LuaSetParam( L, bOk) ; - return 1 ; -} - //------------------------------------------------------------------------------- static int LuaSurfTmSetSmoothAng( lua_State* L) @@ -615,6 +577,89 @@ LuaSurfTmSetSmoothAng( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaSurfTmOffset( lua_State* L) +{ + // 4 o 5 parametri : ParentId, vIds, dOffs, dLinTol [, nType] + int nParentId ; + LuaGetParam( L, 1, nParentId) ; + INTVECTOR vIds ; + LuaCheckParam( L, 2, vIds) + double dOffs ; + LuaCheckParam( L, 3, dOffs) + double dLinTol ; + LuaCheckParam( L, 4, dLinTol) ; + int nType = STMOFF_FILLET ; + LuaGetParam( L, 5, nType) ; + LuaClearStack( L) ; + // interseco la prima superficie con la seconda + int nId = ExeSurfTmOffset( nParentId, vIds, dOffs, dLinTol, nType) ; + LuaSetParam( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSurfTmThickeningOffset( lua_State* L) +{ + // 4 o 5 parametri : ParentId, vIds, dOffs, dLinTol [, nType] + int nParentId ; + LuaGetParam( L, 1, nParentId) ; + INTVECTOR vIds ; + LuaCheckParam( L, 2, vIds) + double dOffs ; + LuaCheckParam( L, 3, dOffs) + double dLinTol ; + LuaCheckParam( L, 4, dLinTol) ; + int nType = STMOFF_FILLET ; + LuaGetParam( L, 5, nType) ; + LuaClearStack( L) ; + // interseco la prima superficie con la seconda + int nId = ExeSurfTmThickeningOffset( nParentId, vIds, dOffs, dLinTol, nType) ; + LuaSetParam( L, nId) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaCutSurfBzPlane( lua_State* L) +{ + // 4 o 5 parametri : Id, ptOn, vtN, bSaveOnEq [, nRefType] + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptOn ; + LuaCheckParam( L, 2, ptOn) + Vector3d vtN ; + LuaCheckParam( L, 3, vtN) + bool bSaveOnEq ; + LuaGetParam( L, 4, bSaveOnEq) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // taglio la superficie con ilpiano + bool bOk = ExeCutSurfBzPlane( nId, ptOn, vtN, bSaveOnEq, nRefType) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSurfBzTrim( lua_State* L) +{ + // 2 parametri : nId, nCutterId + int nId ; + LuaCheckParam( L, 1, nId) + int nCutterId ; + LuaCheckParam( L, 2, nCutterId) + LuaClearStack( L) ; + // taglio la prima superficie in base alla seconda + bool bOk = ExeSurfBzTrim( nId, nCutterId) ; + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbModifySurf( LuaMgr& luaMgr) @@ -636,7 +681,6 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSwapFacets", LuaSurfTmSwapFacets) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRemovePart", LuaSurfTmRemovePart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfTmPlane", LuaCutSurfTmPlane) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfBzPlane", LuaCutSurfBzPlane) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfTmClosedCurve", LuaCutSurfTmClosedCurve) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmAdd", LuaSurfTmAdd) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSubtract", LuaSurfTmSubtract) ; @@ -649,7 +693,10 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmResetTwoColors", LuaSurfTmResetTwoColors) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSetShowEdges", LuaSurfTmSetShowEdges) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetShowEdges", LuaSurfTmGetShowEdges) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzTrim", LuaSurfBzTrim) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSetSmoothAng", LuaSurfTmSetSmoothAng) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmOffset", LuaSurfTmOffset) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmThickeningOffset", LuaSurfTmThickeningOffset) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfBzPlane", LuaCutSurfBzPlane) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzTrim", LuaSurfBzTrim) ; return bOk ; } diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index 1dedd66..96a76df 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -385,6 +385,36 @@ LuaCutVolZmapPlane( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaUpdateVolZmapByAddingSurfTm( lua_State* L) +{ + // 2 parametri : nVolZmapId, StmId, + int nVolZmapId ; + LuaCheckParam( L, 1, nVolZmapId) ; + int nStmId ; + LuaCheckParam( L, 2, nStmId) ; + LuaClearStack( L) ; + bool bOk = ExeUpdateVolZmapByAddingSurfTm( nVolZmapId, nStmId) ; + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaUniformVolZmap( lua_State* L) +{ + // 1 o 2 parametri : nVolZmapId [, dToler] + int nVolZmapId ; + LuaCheckParam( L, 1, nVolZmapId) ; + double dToler = EPS_SMALL ; + LuaGetParam( L, 2, dToler) ; + LuaClearStack( L) ; + bool bOk = ExeUniformVolZmap( nVolZmapId, dToler) ; + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbModifyVol( LuaMgr& luaMgr) @@ -405,5 +435,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetToolOutline", LuaVolZmapGetToolOutline) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCutVolZmapPlane", LuaCutVolZmapPlane) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtUpdateVolZmapByAddingSurfTm", LuaUpdateVolZmapByAddingSurfTm ) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtUniformZmap", LuaUniformVolZmap) ; return bOk ; } \ No newline at end of file