From e3530f6e907a2515c5d0678eb4e108d9d91b52f3 Mon Sep 17 00:00:00 2001 From: DarioS Date: Wed, 3 May 2023 09:46:05 +0200 Subject: [PATCH 01/17] EgtExecutor 2.5e1 : - ricompilazione per aggiornamento lua. --- EgtExecutor.rc | Bin 18890 -> 18890 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index fdde8b8087a299cb66b17076be8630c99f389fe0..b5b0ea219e7631c7cda936d2982b102ba42ba962 100644 GIT binary patch delta 105 zcmX>#neo(Q#tq-tSWOvp7z{W6W^-m{P6aX?xfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0DTG`Z~y=R delta 105 zcmX>#neo(Q#tq-tSWOso7>qanW^-m{P609;xfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0Dg`hcmMzZ From 4642188fd6e6911fd10283b0242f6f75be578a85 Mon Sep 17 00:00:00 2001 From: DarioS Date: Thu, 4 May 2023 17:05:22 +0200 Subject: [PATCH 02/17] EgtExecutor 2.5e2 : - se disabilitato UI esco subito da ExeDraw (evito verificare esistenza scena che poi non uso). --- EXE_Scene.cpp | 8 +++++--- EgtExecutor.rc | Bin 18890 -> 18890 bytes 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/EXE_Scene.cpp b/EXE_Scene.cpp index 53bf3c4..803425b 100644 --- a/EXE_Scene.cpp +++ b/EXE_Scene.cpp @@ -212,11 +212,13 @@ ExeResize( int nW, int nH) bool ExeDraw( void) { + // se interfaccia disabilitata, esco subito + if ( ! ExeGetEnableUI()) + return true ; GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_SCENE( pGseCtx, false) - // se abilitato, eseguo disegno - if ( ExeGetEnableUI()) - pGseCtx->m_pScene->Draw() ; + // eseguo disegno + pGseCtx->m_pScene->Draw() ; // valido la finestra disegnata ValidateRgn( pGseCtx->m_hWnd, NULL) ; return true ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index b5b0ea219e7631c7cda936d2982b102ba42ba962..f77cb65c3d218d345492339e4253b803699eef24 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7>zdnW^-i*QjT29S-`yGOp`YVRxuh)cH~Ol+$UrM5m>XaK delta 81 zcmX>#neo(Q#tpyN7!5c7W^-i*QjT29S-`yGOp`YVRxuh*cH~Ol+$UrM5 Date: Fri, 26 May 2023 08:42:05 +0200 Subject: [PATCH 03/17] =?UTF-8?q?EgtExecutor=202.5e3=20:=20-=20il=20Serial?= =?UTF-8?q?Number=20della=20chiave=20=C3=A8=20ricavato=20solo=20per=20chia?= =?UTF-8?q?vi=20USB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EXE_General.cpp | 4 ++-- EgtExecutor.rc | Bin 18890 -> 18890 bytes 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/EXE_General.cpp b/EXE_General.cpp index 43028a0..b80f87a 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -411,8 +411,8 @@ ExeGetKeyInfo( string& sKey) sLockId = sLockId.substr( 7, 6) ; if ( sLockId.empty()) return false ; - int nLockSN ; - if ( GetLockSN( nLockSN)) + int nLockSN = 0 ; + if ( s_bNetHwKey || GetLockSN( nLockSN)) sLockId += " (" + ToString( nLockSN) + ")" ; } // altrimenti diff --git a/EgtExecutor.rc b/EgtExecutor.rc index f77cb65c3d218d345492339e4253b803699eef24..1dc3b8701170146a7dda9efe8f8bbdad3826ad52 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7>zgoW^-i*QjT29S-`yGOp`YVRxuh+cH~Ol+$UrM5#neo(Q#tpyN7>zdnW^-i*QjT29S-`yGOp`YVRxuh)cH~Ol+$UrM5m>XaK From 173728605dd74642071cfa0e47ccda482fe11cc6 Mon Sep 17 00:00:00 2001 From: DarioS Date: Tue, 30 May 2023 10:28:53 +0200 Subject: [PATCH 04/17] EgtExecutor 2.5e5 : - migliorato controllo gestione chiave di rete. --- DllNesting.cpp | 9 ++++++++- DllNesting.h | 2 +- EXE_General.cpp | 10 ++++++++-- EgtExecutor.rc | Bin 18890 -> 18890 bytes 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/DllNesting.cpp b/DllNesting.cpp index 6ca5f71..d560f5f 100644 --- a/DllNesting.cpp +++ b/DllNesting.cpp @@ -45,8 +45,15 @@ HMODULE s_hENs = nullptr ; //----------------------------------------------------------------------------- bool -LoadNestingDll( ILogger* pLogger, const string& sKey, const string& sKey2) +LoadNestingDll( ILogger* pLogger, const string& sKey, const string& sKey2, bool bNetHwKey) { + // non ammessa con chiave di rete + if ( bNetHwKey) { + std::string sErr = "Warning on Key (ENS/NET)" ; + LOG_ERROR( pLogger, sErr.c_str()) ; + FreeNestingDll() ; + return false ; + } // verifico la chiave if ( ! TestKeyForENs( sKey, 0, pLogger)) { FreeNestingDll() ; diff --git a/DllNesting.h b/DllNesting.h index 89d6db9..2c59a3f 100644 --- a/DllNesting.h +++ b/DllNesting.h @@ -19,7 +19,7 @@ class ILogger ; class IAutoNester ; //---------------------------------------------------------------------------- -bool LoadNestingDll( ILogger* pLogger, const std::string& sKey, const std::string& sKey2) ; +bool LoadNestingDll( ILogger* pLogger, const std::string& sKey, const std::string& sKey2, bool bNetHwKey) ; bool FreeNestingDll( void) ; bool IsLoadedNestingDll( void) ; void MySetENsLogger( ILogger* pLogger) ; diff --git a/EXE_General.cpp b/EXE_General.cpp index b80f87a..e9158e9 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -29,6 +29,7 @@ #include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EGnGetModuleVer.h" #include "/EgtDev/Include/EGnPcInfo.h" +#include "/EgtDev/Include/EGnGetKeyData.h" #include "/EgtDev/Include/EgtIniFile.h" #include "/EgtDev/Include/EgtLogger.h" #include "/EgtDev/Include/EgtStringConverter.h" @@ -115,7 +116,7 @@ ExeInit( int nDebug, const string& sLogFile, const string& sLogMsg) LOG_INFO( s_pGenLog, MyGetEMkVersion()) // carico libreria nesting opzionale (non può usare la chiave di rete) - if ( LoadNestingDll( s_pGenLog, s_sKey, s_sNestKey)) + if ( LoadNestingDll( s_pGenLog, s_sKey, s_sNestKey, s_bNetHwKey)) LOG_INFO( s_pGenLog, MyGetENsVersion()) // Info sulla protezione e sul sistema @@ -218,6 +219,7 @@ bool ExeSetKey( const string& sKey) { s_sKey = sKey ; + SetEGnKey( s_sKey) ; return true ; } @@ -248,6 +250,7 @@ bool ExeSetLockType( int nType) { s_nKeyType = nType ; + SetEGnKeyType( s_nKeyType) ; return SetLockType( nType) ; } @@ -256,6 +259,7 @@ bool ExeSetNetHwKey( bool bNetHwKey) { s_bNetHwKey = bNetHwKey ; + SetEGnNetHwKey( s_bNetHwKey) ; return SetNetHwKey( bNetHwKey) ; } @@ -412,7 +416,7 @@ ExeGetKeyInfo( string& sKey) if ( sLockId.empty()) return false ; int nLockSN = 0 ; - if ( s_bNetHwKey || GetLockSN( nLockSN)) + if ( GetLockSN( nLockSN)) sLockId += " (" + ToString( nLockSN) + ")" ; } // altrimenti @@ -431,6 +435,7 @@ ExeGetKeyLevel( int nProd, int nVer, int nLev, int& nKLev) { // verifico la chiave e il livello int nRet = GetKeyLevel( s_sKey, nProd, nVer, nLev, nKLev, s_nKeyExpDays) ; + SetEGnKeyLevel( nRet, nKLev, s_nKeyExpDays) ; if ( nRet != KEY_OK) { string sErr = "Error on Key (EGKL/" + ToString( nRet) + ")" ; LOG_ERROR( s_pGenLog, sErr.c_str()) ; @@ -448,6 +453,7 @@ ExeGetKeyOptions( int nProd, int nVer, int nLev, unsigned int& nOpt2) // verifico la chiave e le opzioni unsigned int nOpt1 ; int nRet = GetKeyOptions( s_sKey, nProd, nVer, nLev, nOpt1, nOpt2, s_nKeyOptExpDays) ; + SetEGnKeyOptions( nRet, nOpt1, nOpt2, s_nKeyOptExpDays) ; if ( nRet != KEY_OK) { nOpt2 = 0 ; string sErr = "Error on Key (EGKO/" + ToString( nRet) + ")" ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 1dc3b8701170146a7dda9efe8f8bbdad3826ad52..66f546bfb73a67198761a4409faf390d7711354b 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7)>|-W^-i*QjT29S-`yGOp`YVRxz4RcH~Ol+$UrM5eQG delta 81 zcmX>#neo(Q#tpyN7>zgoW^-i*QjT29S-`yGOp`YVRxuh+cH~Ol+$UrM5 Date: Tue, 30 May 2023 17:09:20 +0200 Subject: [PATCH 05/17] EgtExecutor : - alla chiusura di Executor si rilascia eventuale chiave di rete. --- EXE_General.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/EXE_General.cpp b/EXE_General.cpp index e9158e9..7be2bd7 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -189,6 +189,10 @@ ExeExit( void) s_pGenLog = nullptr ; } + // libero eventuale chiave di rete + if ( s_bNetHwKey) + CloseNetHwKey() ; + return true ; } @@ -256,11 +260,43 @@ ExeSetLockType( int nType) //----------------------------------------------------------------------------- bool -ExeSetNetHwKey( bool bNetHwKey) +ExeSetLockId( string sLockId) +{ + // divido in tre parti XXX-YYY-ZZZ + STRVECTOR vsTok ; + Tokenize( sLockId, "-", vsTok) ; + if ( vsTok.size() != 3) + return false ; + // se chiave software + if ( vsTok[0] != KEY_LOCK_HW_START) { + ExeSetNetHwKey( false) ; + return ( s_nKeyType != KEY_LOCK_TYPE_HW) ; + } + // se chiave locale + if (vsTok[1].front() != '1') { + ExeSetNetHwKey( false) ; + return true ; + } + // altrimenti chiave di rete + int nKey ; + if ( ! FromString( vsTok[1], nKey)) { + ExeSetNetHwKey( false) ; + return false ; + } + int nUserId = ( nKey % 10) ; + if ( nKey < 100110) + nUserId = 0 ; + ExeSetNetHwKey( true, nUserId) ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +ExeSetNetHwKey( bool bNetHwKey, int nUserId) { s_bNetHwKey = bNetHwKey ; SetEGnNetHwKey( s_bNetHwKey) ; - return SetNetHwKey( bNetHwKey) ; + return SetNetHwKey( bNetHwKey, nUserId) ; } //----------------------------------------------------------------------------- From 7d3bec9f44ca84aabcbe9d646164463a36554404 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 5 Jun 2023 08:11:36 +0200 Subject: [PATCH 06/17] EgtExecutor 2.6f1 : - estesa gestione LockId - passato nuovo parametro LockId a EgtConverter. --- EXE.h | 1 + EXE_Exchange.cpp | 3 ++- EXE_General.cpp | 58 +++++++++++++++++++++++++++-------------------- EgtExecutor.rc | Bin 18890 -> 18890 bytes 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/EXE.h b/EXE.h index 5f3f333..fd6ee80 100644 --- a/EXE.h +++ b/EXE.h @@ -25,6 +25,7 @@ const std::string& ExeGetIniFile( void) ; //---------------------------------------------------------------------------- const std::string& ExeGetKey( void) ; const std::string& ExeGetNestKey( void) ; +const std::string& ExeGetLockId( void) ; //---------------------------------------------------------------------------- ILogger* GetLogger( void) ; diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index 2e3acab..dfba3e4 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -413,7 +413,8 @@ ExeAdvancedImport( const string& sFilePath, double dToler) sExec = "EgtConverterR32.exe" ; #endif string sCmdLine = "\"" + sExec + "\" \"" + sFilePath + "\" \"" + sFileOut + "\" \"" + - ToString( dToler, 3) + "\" \"" + ToString( ExeGetDebugLevel()) +"\" \"" + ExeGetKey() + "\"" ; + ToString( dToler, 3) + "\" \"" + ToString( ExeGetDebugLevel()) + "\" \"" + + ExeGetKey() + "\" \"" + ExeGetLockId() + "\"" ; STARTUPINFO si ; PROCESS_INFORMATION pi ; ZeroMemory( &si, sizeof( si)) ; diff --git a/EXE_General.cpp b/EXE_General.cpp index 7be2bd7..a4a11d7 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -52,6 +52,7 @@ static bool s_bNetHwKey = false ; static int s_nKeyExpDays = 0 ; static int s_nKeyOptExpDays = 0 ; static string s_sNestKey ; +static string s_sLockId ; static string s_sIniFile ; static bool s_bEnableUI = true ; static pfProcEvents s_pFunProcEvents = nullptr ; @@ -260,34 +261,41 @@ ExeSetLockType( int nType) //----------------------------------------------------------------------------- bool -ExeSetLockId( string sLockId) +ExeSetLockId( const string& sLockId) { - // divido in tre parti XXX-YYY-ZZZ - STRVECTOR vsTok ; - Tokenize( sLockId, "-", vsTok) ; - if ( vsTok.size() != 3) - return false ; - // se chiave software - if ( vsTok[0] != KEY_LOCK_HW_START) { + int nKeyType ; + bool bNetKey ; + int nUserId ; + GetLockIdStringInfo( sLockId, nKeyType, bNetKey, nUserId) ; + bool bOk ; + switch ( nKeyType) { + default : ExeSetNetHwKey( false) ; - return ( s_nKeyType != KEY_LOCK_TYPE_HW) ; - } - // se chiave locale - if (vsTok[1].front() != '1') { + bOk = false ; + break ; + case KEY_LOCK_TYPE_SW : ExeSetNetHwKey( false) ; - return true ; + bOk = ( s_nKeyType != KEY_LOCK_TYPE_HW) ; + break ; + case KEY_LOCK_TYPE_HW : + ExeSetNetHwKey( bNetKey, nUserId) ; + bOk = true ; + break ; } - // altrimenti chiave di rete - int nKey ; - if ( ! FromString( vsTok[1], nKey)) { - ExeSetNetHwKey( false) ; - return false ; - } - int nUserId = ( nKey % 10) ; - if ( nKey < 100110) - nUserId = 0 ; - ExeSetNetHwKey( true, nUserId) ; - return true ; + if ( bOk) + s_sLockId = sLockId ; + else + s_sLockId = "" ; + return bOk ; +} + +//----------------------------------------------------------------------------- +const string& +ExeGetLockId( void) +{ + if ( s_sLockId.empty()) + GetLockId( s_sLockId) ; + return s_sLockId ; } //----------------------------------------------------------------------------- @@ -296,7 +304,7 @@ ExeSetNetHwKey( bool bNetHwKey, int nUserId) { s_bNetHwKey = bNetHwKey ; SetEGnNetHwKey( s_bNetHwKey) ; - return SetNetHwKey( bNetHwKey, nUserId) ; + return SetNetHwKey( s_bNetHwKey, nUserId) ; } //----------------------------------------------------------------------------- diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 66f546bfb73a67198761a4409faf390d7711354b..aa7a34a6a0b80ac4c62bf19eac927d05f10a2b11 100644 GIT binary patch delta 105 zcmX>#neo(Q#tq-tSj`x87z{W6W^-m{P6IL=xfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0Dit6cmMzZ delta 105 zcmX>#neo(Q#tq-tSWOvp7)&?+W^-m{P6aX?xfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0E2oSkN^Mx From 16200549703a6c38877ae8ac59c367d667e77f95 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 19 Jun 2023 08:10:17 +0200 Subject: [PATCH 07/17] EgtExecutor 2.5f2 : - aggiunte funzioni Exe e Lua CDeSolidSolid. --- EXE_CDeObjSolid.cpp | 80 +++++++++++++++++++++++++++++++++++++++++--- EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_CDeObjSolid.cpp | 23 +++++++++++++ 3 files changed, 98 insertions(+), 5 deletions(-) diff --git a/EXE_CDeObjSolid.cpp b/EXE_CDeObjSolid.cpp index 0d9afc0..f24aeb3 100644 --- a/EXE_CDeObjSolid.cpp +++ b/EXE_CDeObjSolid.cpp @@ -25,7 +25,9 @@ #include "/EgtDev/Include/EGkCDeCylClosedSurfTm.h" #include "/EgtDev/Include/EGkCDeConeFrustumClosedSurfTm.h" #include "/EgtDev/Include/EGkCDeSpheClosedSurfTm.h" +#include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h" #include "/EgtDev/Include/EGkVolZmap.h" +#include "/EgtDev/Include/EGkSurfLocal.h" #include "/EgtDev/Include/EGkStringUtils3d.h" using namespace std ; @@ -67,7 +69,7 @@ MyCDeBoxVolZmap( const Frame3d& frBox, const Vector3d& vtDiag, int nZmapId, doub // porto in locale il riferimento (il vettore è già in locale a questo stesso riferimento) Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidBox( frBoxL, vtDiag, dSafeDist) ? 0 : 1) ; + return ( pVZM->AvoidBox( frBoxL, vtDiag, dSafeDist, false) ? 0 : 1) ; } //---------------------------------------------------------------------------- @@ -138,7 +140,7 @@ MyCDeRectPrismoidVolZmap( const Frame3d& frPrismoid, double dBaseLenX, double dB // porto in locale il riferimento (il vettore è già in locale a questo stesso riferimento) Frame3d frPrismoidL = GetFrameLocal( pGeomDB, frPrismoid, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidRectPrismoid( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, dSafeDist) ? 0 : 1) ; + return ( pVZM->AvoidRectPrismoid( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, dSafeDist, false) ? 0 : 1) ; } //---------------------------------------------------------------------------- @@ -211,7 +213,7 @@ MyCDeCylVolZmap( const Frame3d& frCyl, double dR, double dH, int nZmapId, double // porto in locale il riferimento Frame3d frCylL = GetFrameLocal( pGeomDB, frCyl, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidCylinder( frCylL, dR, dH, dSafeDist) ? 0 : 1) ; + return ( pVZM->AvoidCylinder( frCylL, dR, dH, dSafeDist, false) ? 0 : 1) ; } //---------------------------------------------------------------------------- @@ -279,7 +281,7 @@ MyCDeConeVolZmap( const Frame3d& frCone, double dR1, double dR2, double dH, int // porto in locale il riferimento Frame3d frConeL = GetFrameLocal( pGeomDB, frCone, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidConeFrustum( frConeL, dR1, dR2, dH, dSafeDist) ? 0 : 1) ; + return ( pVZM->AvoidConeFrustum( frConeL, dR1, dR2, dH, dSafeDist, false) ? 0 : 1) ; } //---------------------------------------------------------------------------- @@ -348,7 +350,7 @@ MyCDeSpheVolZmap( const Point3d& ptCen, double dRad, int nZmapId, double dSafeDi // porto in locale il centro della sfera Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ; // verifico la collisione - return ( pVZM->AvoidSphere( ptCenL, dRad, dSafeDist) ? 0 : 1) ; + return ( pVZM->AvoidSphere( ptCenL, dRad, dSafeDist, false) ? 0 : 1) ; } //---------------------------------------------------------------------------- @@ -374,3 +376,71 @@ ExeCDeSpheSolid( const Point3d& ptCen, double dR, int nSolidId, double dSafeDist // restituisco risultato return nRes ; } + +//---------------------------------------------------------------------------- +static int +MyCDeClosedSurfTmClosedSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, -1) + // recupero il riferimento della seconda superficie + Frame3d frSurf2 ; + if ( ! pGeomDB->GetGlobFrame( nSurfTm2Id, frSurf2)) + return -1 ; + // recupero la prima superficie in locale alla seconda + SurfLocal Surf1Loc( pGeomDB, nSurfTm1Id, frSurf2) ; + const ISurfTriMesh* pStm1 = GetSurfTriMesh( Surf1Loc) ; + if ( pStm1 == nullptr) + return -1 ; + // recupero la seconda superficie TriMesh + const ISurfTriMesh* pStm2 = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTm2Id)) ; + if ( pStm2 == nullptr) + return -1 ; + // verifico la collisione + return ( CDeClosedSurfTmClosedSurfTm( *pStm1, *pStm2, dSafeDist) ? 1 : 0) ; +} + +//---------------------------------------------------------------------------- +static int +MyCDeClosedSurfTmVolZmap( int nSurfTmId, int nZmapId, double dSafeDist) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, -1) + // recupero il riferimento dello Zmap + Frame3d frZmap ; + if ( ! pGeomDB->GetGlobFrame( nZmapId, frZmap)) + return -1 ; + // recupero la superficie in locale allo Zmap + SurfLocal SurfLoc( pGeomDB, nSurfTmId, frZmap) ; + const ISurfTriMesh* pStm = GetSurfTriMesh( SurfLoc) ; + if ( pStm == nullptr) + return -1 ; + // recupero lo Zmap + const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nZmapId)) ; + if ( pVZM == nullptr) + return -1 ; + // verifico la collisione + return ( pVZM->AvoidSurfTm( *pStm, dSafeDist, false) ? 0 : 1) ; +} + +//---------------------------------------------------------------------------- +int +ExeCDeSolidSolid( int nSolid1Id, int nSolid2Id, double dSafeDist) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + int nRes = -1 ; + if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == SRF_TRIMESH) + nRes = MyCDeClosedSurfTmClosedSurfTm( nSolid1Id, nSolid2Id, dSafeDist) ; + else if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == VOL_ZMAP) + nRes = MyCDeClosedSurfTmVolZmap( nSolid1Id, nSolid2Id, dSafeDist) ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtCDeSolidSolid({" + IdToString( nSolid1Id) + "," + + IdToString( nSolid2Id) + "," + + ToString( dSafeDist) + ")" + + " -- Res=" + ToString( nRes) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return nRes ; +} diff --git a/EgtExecutor.rc b/EgtExecutor.rc index aa7a34a6a0b80ac4c62bf19eac927d05f10a2b11..7b0b79fd6c793d30fc53c28ed74f58f57b311fad 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7>zdnW^-i*QjT29S-`yGOp`YVRxuh)cH~Ol+$UrM5m>XaK delta 81 zcmX>#neo(Q#tpyN7!5c7W^-i*QjT29S-`yGOp`YVRxuh*cH~Ol+$UrM5= 0) + LuaSetParam( L, ( nRes != 0)) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallCDeObjSolid( LuaMgr& luaMgr) @@ -175,5 +197,6 @@ LuaInstallCDeObjSolid( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtCDeCylSolid", LuaCDeCylSolid) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCDeConeSolid", LuaCDeConeSolid) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCDeSpheSolid", LuaCDeSpheSolid) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCDeSolidSolid", LuaCDeSolidSolid) ; return bOk ; } From 3d3900b39a29b27a2c41931fd7f1b0018b7a3b7f Mon Sep 17 00:00:00 2001 From: DarioS Date: Fri, 30 Jun 2023 11:55:16 +0200 Subject: [PATCH 08/17] EgtExecutor 2.5f3 : - dove possibile e sicuro sostituiti dynamic_cast con static_cast. --- EXE_GdbModifyCurve.cpp | 8 ++++---- EgtExecutor.rc | Bin 18890 -> 18890 bytes 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index bbce2d4..9033671 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -292,9 +292,9 @@ ExeChangeClosedCurveStart( int nId, double dU) bOk = bOk && ( pCurve != nullptr) ; // cambio il punto iniziale if ( bOk && pCurve->GetType() == CRV_ARC) - bOk = bOk && dynamic_cast(pCurve)->ChangeStartPoint(dU) ; + bOk = bOk && GetCurveArc( pCurve)->ChangeStartPoint(dU) ; else if ( bOk && pCurve->GetType() == CRV_COMPO) - bOk = bOk && dynamic_cast(pCurve)->ChangeStartPoint(dU) ; + bOk = bOk && GetCurveComposite( pCurve)->ChangeStartPoint(dU) ; else bOk = false ; ExeSetModified() ; @@ -331,9 +331,9 @@ ExeChangeClosedCurveStartPoint( int nId, const Point3d& ptP, int nRefType) bOk = bOk && distPC.GetParamAtMinDistPoint( 0, dPar, nFlag) ; // cambio il punto iniziale if ( bOk && pCurve->GetType() == CRV_ARC) - bOk = bOk && dynamic_cast(pCurve)->ChangeStartPoint(dPar) ; + bOk = bOk && GetCurveArc(pCurve)->ChangeStartPoint(dPar) ; else if ( bOk && pCurve->GetType() == CRV_COMPO) - bOk = bOk && dynamic_cast(pCurve)->ChangeStartPoint(dPar) ; + bOk = bOk && GetCurveComposite( pCurve)->ChangeStartPoint(dPar) ; else bOk = false ; ExeSetModified() ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 7b0b79fd6c793d30fc53c28ed74f58f57b311fad..6eee72644fa65b066b558129e022231bfe73b709 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7>zgoW^-i*QjT29S-`yGOp`YVRxuh+cH~Ol+$UrM5#neo(Q#tpyN7>zdnW^-i*QjT29S-`yGOp`YVRxuh)cH~Ol+$UrM5m>XaK From 90449cad408cdc30049293e65a900437ae12d163 Mon Sep 17 00:00:00 2001 From: DarioS Date: Fri, 7 Jul 2023 17:07:16 +0200 Subject: [PATCH 09/17] EgtExecutor 2.5g1 : - aggiunte funzioni Exe e Lua SurfTmVertexCount, SurfTmGetVertex, SurfTmGetNearestVertex, SurfTmGetAllVertInFacet e SurfTmMoveVertex. --- EXE_GdbGetSurf.cpp | 80 +++++++++++++++++++++++++++++--- EXE_GdbModifySurf.cpp | 47 +++++++++++++++++-- EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_GdbGetSurf.cpp | 104 ++++++++++++++++++++++++++++++++++++++---- LUA_GdbModifySurf.cpp | 25 ++++++++++ 5 files changed, 237 insertions(+), 19 deletions(-) diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index 21997fa..8113edc 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -28,6 +28,7 @@ #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkSurfBezier.h" +#include "/EgtDev/Include/EGkDistPointSurfTm.h" #include "/EgtDev/Include/EGkSurfLocal.h" #include "/EgtDev/Include/EGkStringUtils3d.h" @@ -367,16 +368,16 @@ ExeSurfFrGetZigZagInfill( int nId, int nDestGrpId, double dStep, double dAng, bo //---------------------------------------------------------------------------- int -ExeSurfTmPartCount( int nId) +ExeSurfTmVertexCount( int nId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, -1) + VERIFY_GEOMDB( pGeomDB, 0) // recupero la superficie trimesh const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; if ( pStm == nullptr) - return -1 ; - // recupero il numero di parti - return pStm->GetPartCount() ; + return 0 ; + // recupero il numero di vertici + return pStm->GetVertexCount() ; } //---------------------------------------------------------------------------- @@ -393,6 +394,59 @@ ExeSurfTmFacetCount( int nId) return pStm->GetFacetCount() ; } +//---------------------------------------------------------------------------- +int +ExeSurfTmPartCount( int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, -1) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return -1 ; + // recupero il numero di parti + return pStm->GetPartCount() ; +} + +//----------------------------------------------------------------------------- +bool +ExeSurfTmGetVertex( int nId, int nVert, int nRefId, Point3d& ptVert) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return false ; + // recupero il vertice di indice dato + if ( ! pStm->GetVertex( nVert, ptVert)) + return false ; + // gestione trasformazioni ( eventuali) + return TransformPoint( pGeomDB, nId, nRefId, ptVert) ; +} + +//----------------------------------------------------------------------------- +bool +ExeSurfTmGetNearestVertex( int nId, const Point3d& ptNear, int nRefId, int& nVert, Point3d& ptVert) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return false ; + // porto il punto Near nel riferimento dell'entità + Point3d ptNearL = ptNear ; + if ( ! InvTransformPoint( pGeomDB, nId, nRefId, ptNearL)) + return false ; + // recupero il vertice più vicino della superficie + nVert = GetSurfTmNearestVertex( ptNearL, *pStm) ; + if ( ! pStm->GetVertex( nVert, ptVert)) + return false ; + // gestione trasformazioni ( eventuali) + return TransformPoint( pGeomDB, nId, nRefId, ptVert) ; +} + //---------------------------------------------------------------------------- int ExeSurfTmFacetFromTria( int nId, int nT) @@ -936,6 +990,20 @@ ExeCopySurfTmFacet( int nId, int nFacet, int nDestGrpId) return nFacId ; } +//----------------------------------------------------------------------------- +bool +ExeSurfTmGetAllVertInFacet( int nId, int nFacet, INTVECTOR& vVert) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie TriMesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return false ; + // recupero l'elenco dei vertici nella faccia + return pStm->GetAllVertInFacet( nFacet, vVert) ; +} + //----------------------------------------------------------------------------- bool ExeSurfTmGetFacetBBox( int nId, int nFacet, int nFlag, BBox3d& b3Box) @@ -1344,4 +1412,4 @@ ExeExtractSurfBezierLoops( int nId, int nDestGrpId, int* pnCount) if ( pnCount != nullptr) *pnCount = nCount ; return nFirstId ; -} \ No newline at end of file +} diff --git a/EXE_GdbModifySurf.cpp b/EXE_GdbModifySurf.cpp index d40bd50..f24a13c 100644 --- a/EXE_GdbModifySurf.cpp +++ b/EXE_GdbModifySurf.cpp @@ -410,6 +410,43 @@ ExeSurfFrRotateSimpleNoCollision( int nId1, int nId2, const Point3d& ptCen, doub return ( bOk && CAvSimpleSurfFrMove( *pSfr1, *pSfr2L).Rotate(ptCenL, dAngDeg)) ; } +//------------------------------------------------------------------------------- +bool +ExeSurfTmMoveVertex( int nId, int nVert, const Point3d& ptNewVert, int nRefType, bool bUpdate) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero la superficie + ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pStm != nullptr) ; + // recupero il riferimento in cui è immersa la superficie + Frame3d frStm ; + bOk = bOk && pGeomDB->GetGlobFrame( nId, frStm) ; + // eseguo la modifica + if ( bOk) { + // porto il nuovo vertice nel riferimento della superficie + Point3d ptNewVertL = GetPointLocal( pGeomDB, ptNewVert, nRefType, frStm) ; + // eseguo la modifica + bOk = pStm->MoveVertex( nVert, ptNewVertL) ; + // se richiesto, semplificazione della trimesh + if ( bUpdate) + bOk = bOk && pStm->DoCompacting() ; + } + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmMoveVertex(" + IdToString( nId) + "," + + ToString( nVert) + ",{" + + ToString( ptNewVert) + "}," + + RefTypeToString( nRefType) + "," + + ( bUpdate ? "true" : "false") + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + //------------------------------------------------------------------------------- static int MySurfTmToTriangles( int nId, int& nCount) @@ -468,7 +505,7 @@ ExeSurfTmToTriangles( int nId, int* pnCount) ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtSurfTmToTriangles(" + ToString( nId) + ")" + + string sLua = "EgtSurfTmToTriangles(" + IdToString( nId) + ")" + " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -492,7 +529,7 @@ ExeSurfTmRemoveFacet( int nId, int nFacet) ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtSurfTmRemoveFacet(" + ToString( nId) + "," + + string sLua = "EgtSurfTmRemoveFacet(" + IdToString( nId) + "," + ToString( nFacet) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -515,7 +552,7 @@ ExeSurfTmSwapFacets( int nId, int nFacet1, int nFacet2) ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtSurfTmSwapFacets(" + ToString( nId) + "," + + string sLua = "EgtSurfTmSwapFacets(" + IdToString( nId) + "," + ToString( nFacet1) + "," + ToString( nFacet2) + ")" + " -- Ok=" + ToString( bOk) ; @@ -539,7 +576,7 @@ ExeSurfTmRemovePart( int nId, int nPart) ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtSurfTmRemovePart(" + ToString( nId) + "," + + string sLua = "EgtSurfTmRemovePart(" + IdToString( nId) + "," + ToString( nPart) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -571,7 +608,7 @@ ExeCutSurfTmPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, bool bSave ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtCutSurfTmPlane(" + ToString( nId) + ",{" + + string sLua = "EgtCutSurfTmPlane(" + IdToString( nId) + ",{" + ToString( ptOn) + "},{" + ToString( vtN) + "}," + ( bSaveOnEq ? "true" : "false") + "," + diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 6eee72644fa65b066b558129e022231bfe73b709..1b98ab1695ef6ce72d629899e56cacbe2b4e40ea 100644 GIT binary patch delta 105 zcmX>#neo(Q#tq-tSj`!97z{W6W^-m{P6sj^xfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0Dy8HfB*mh delta 105 zcmX>#neo(Q#tq-tSj`x87>qanW^-m{P6IL=xfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0D<-%hyVZp diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index 43935f4..20f347f 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -270,18 +270,15 @@ LuaSurfFrGetZigZagInfill( lua_State* L) //---------------------------------------------------------------------------- static int -LuaSurfTmPartCount( lua_State* L) +LuaSurfTmVertexCount( lua_State* L) { // 1 parametro : Id int nId ; LuaCheckParam( L, 1, nId) LuaClearStack( L) ; - // recupero il numero di parti della superficie trimesh - int nParts = ExeSurfTmPartCount( nId) ; - if ( nParts >= 0) - LuaSetParam( L, nParts) ; - else - LuaSetParam( L) ; + // recupero il numero di vertici della superficie trimesh + int nNbr = ExeSurfTmVertexCount( nId) ; + LuaSetParam( L, nNbr) ; return 1 ; } @@ -299,6 +296,72 @@ LuaSurfTmFacetCount( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaSurfTmPartCount( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero il numero di parti della superficie trimesh + int nParts = ExeSurfTmPartCount( nId) ; + if ( nParts >= 0) + LuaSetParam( L, nParts) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfTmGetVertex( lua_State* L) +{ + // 2 o 3 parametri : Id, nVert, [, nRefId] + int nId ; + LuaCheckParam( L, 1, nId) + int nVert ; + LuaCheckParam( L, 2, nVert) + int nRefId = nId ; + LuaGetParam( L, 3, nRefId) ; + LuaClearStack( L) ; + // recupero il vertice di indice dato (0-based) + Point3d ptVert ; + bool bOk = ExeSurfTmGetVertex( nId, nVert, nRefId, ptVert) ; + if ( bOk) + LuaSetParam( L, ptVert) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfTmGetNearestVertex( lua_State* L) +{ + // 2 o 3 parametri : Id, ptNear [, nRefId] + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptNear ; + LuaCheckParam( L, 2, ptNear) + int nRefId = nId ; + LuaGetParam( L, 3, nRefId) ; + LuaClearStack( L) ; + // recupero il vertice più vicino della superficie + int nVert ; + Point3d ptVert ; + bool bOk = ExeSurfTmGetNearestVertex( nId, ptNear, nRefId, nVert, ptVert) ; + if ( bOk) { + LuaSetParam( L, nVert) ; + LuaSetParam( L, ptVert) ; + } + else { + LuaSetParam( L) ; + LuaSetParam( L) ; + } + return 2 ; +} + //---------------------------------------------------------------------------- static int LuaSurfTmFacetFromTria( lua_State* L) @@ -319,6 +382,27 @@ LuaSurfTmFacetFromTria( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaSurfTmGetAllVertInFacet( lua_State* L) +{ + // 2 parametri : nId, nFacet + int nId ; + LuaCheckParam( L, 1, nId) + int nFacet ; + LuaCheckParam( L, 2, nFacet) + LuaClearStack( L) ; + // recupero l'elenco dei vertici nella faccia + INTVECTOR vVert ; + bool bOk = ExeSurfTmGetAllVertInFacet( nId, nFacet, vVert) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, vVert) ; + else + LuaSetParam( L) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaSurfTmGetFacetBBox( lua_State* L) @@ -961,9 +1045,13 @@ LuaInstallGdbGetSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrMoveSimpleNoCollision", LuaSurfFrMoveSimpleNoCollision) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrRotateSimpleNoCollision", LuaSurfFrRotateSimpleNoCollision) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfFrZigZagInfill", LuaSurfFrGetZigZagInfill) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPartCount", LuaSurfTmPartCount) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmVertexCount", LuaSurfTmVertexCount) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetCount", LuaSurfTmFacetCount) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPartCount", LuaSurfTmPartCount) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetVertex", LuaSurfTmGetVertex) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetNearestVertex", LuaSurfTmGetNearestVertex) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetFromTria", LuaSurfTmFacetFromTria) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetAllVertInFacet", LuaSurfTmGetAllVertInFacet) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBox", LuaSurfTmGetFacetBBox) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBoxGlob", LuaSurfTmGetFacetBBoxGlob) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBoxRef", LuaSurfTmGetFacetBBoxRef) ; diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp index db04052..d865e4d 100644 --- a/LUA_GdbModifySurf.cpp +++ b/LUA_GdbModifySurf.cpp @@ -141,6 +141,30 @@ LuaSurfFrOffset( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaSurfTmMoveVertex( lua_State* L) +{ + // 3 o 4 o 5 parametri : nId, nVert, ptNewVert [, nRefId] [, bUpdate] + int nId ; + LuaCheckParam( L, 1, nId) + int nVert ; + LuaCheckParam( L, 2, nVert) + Point3d ptNewVert ; + LuaCheckParam( L, 3, ptNewVert) + int nRefType = RTY_DEFAULT ; + bool bUpdate = true ; + if ( LuaGetParam( L, 4, nRefType)) + LuaGetParam( L, 5, bUpdate) ; + else + LuaGetParam( L, 4, bUpdate) ; + LuaClearStack( L) ; + // sposto il vertice di indice dato della trimesh + bool bOk = ExeSurfTmMoveVertex( nId, nVert, ptNewVert, nRefType, bUpdate) ; + LuaSetParam( L, bOk) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaSurfTmToTriangles( lua_State* L) @@ -376,6 +400,7 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrSubtract", LuaSurfFrSubtract) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrIntersect", LuaSurfFrIntersect) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrOffset", LuaSurfFrOffset) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmMoveVertex", LuaSurfTmMoveVertex) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmToTriangles", LuaSurfTmToTriangles) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRemoveFacet", LuaSurfTmRemoveFacet) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSwapFacets", LuaSurfTmSwapFacets) ; From 749830aba9ae9f2b0ab1b0c9ae8fd4751ba9f0ca Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 10 Jul 2023 11:16:59 +0200 Subject: [PATCH 10/17] EgtExecutor : - aggiunto Dump di Stipple (quando presente). --- EXE_GdbObjects.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/EXE_GdbObjects.cpp b/EXE_GdbObjects.cpp index aaeaa78..b5a2f9b 100644 --- a/EXE_GdbObjects.cpp +++ b/EXE_GdbObjects.cpp @@ -594,6 +594,8 @@ ExeGeoObjDump( int nId, string& sDump) sDump = pGeoObj->GetTitle() + " " + ToString( nId) + "\r\n" ; // preparo gli attributi pGeomDB->DumpAttributes( nId, sDump, bMM, "\r\n") ; + // preparo stipple + pGeomDB->DumpStipple( nId, sDump, bMM, "\r\n") ; // preparo TextureData pGeomDB->DumpTextureData( nId, sDump, bMM, "\r\n") ; // preparo UserObj From 382138e6c59047d1d443634a0d3b69b93890a057 Mon Sep 17 00:00:00 2001 From: DarioS Date: Wed, 19 Jul 2023 09:53:40 +0200 Subject: [PATCH 11/17] EgtExecutor : - piccola miglioria. --- EXE_GdbModifyCurve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index 9033671..9fa110e 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -186,7 +186,7 @@ ExeApproxCurve( int nId, int nApprType, double dLinTol) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero la curva - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; + const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; bool bOk = ( pCurve != nullptr) ; // eseguo l'approssimazione PtrOwner pCC( CreateCurveComposite()) ; From 85c4af98ce93caf4453078dd5363cd0e441a1c6f Mon Sep 17 00:00:00 2001 From: DarioS Date: Fri, 28 Jul 2023 11:23:20 +0200 Subject: [PATCH 12/17] EgtExecutor 2.5g3 : - piccole sistemazioni varie. --- EXE_GdbCreate.cpp | 12 ++++++------ EXE_GdbCreateCurve.cpp | 2 +- EXE_GdbGetCurve.cpp | 2 ++ EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_General.cpp | 5 ++++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/EXE_GdbCreate.cpp b/EXE_GdbCreate.cpp index 94ebfc8..0d09256 100644 --- a/EXE_GdbCreate.cpp +++ b/EXE_GdbCreate.cpp @@ -766,17 +766,17 @@ MyCreateAngularDimensionFromLines( int nParentId, INTVECTOR vLineIds, const Poin return false ; if ( abs(( ptDim1 - ptP1L).Len() + ( ptP0L - ptDim1).Len() - ( ptP0L - ptP1L).Len()) < EPS_SMALL || abs(( ptDim1 - ptP1L).Len() + ( ptP0L - ptP1L ).Len() - ( ptDim1 - ptP0L).Len()) < EPS_SMALL) - // ptDim è dal lato di ptP1L - ptP1L = ptP1L ; + // ptDim è dal lato di ptP1L, quindi tengo ptP1L + ; else - // ptDim è dal lato di ptP2L + // ptDim è dal lato di ptP2L ptP1L = ptP2L ; if ( abs(( ptDim2 - ptP3L).Len() + ( ptP0L - ptDim2).Len() - ( ptP0L - ptP3L).Len()) < EPS_SMALL || abs(( ptDim2 - ptP3L).Len() + ( ptP0L - ptP3L).Len() - ( ptDim2 - ptP0L).Len()) < EPS_SMALL) - // ptDim è dal lato di ptP1L - ptP3L = ptP3L ; + // ptDim è dal lato di ptP1L, quindi tengo ptP3L + ; else - // ptDim è dal lato di ptP2L + // ptDim è dal lato di ptP2L ptP3L = ptP4L ; } diff --git a/EXE_GdbCreateCurve.cpp b/EXE_GdbCreateCurve.cpp index 850345c..299c046 100644 --- a/EXE_GdbCreateCurve.cpp +++ b/EXE_GdbCreateCurve.cpp @@ -1948,7 +1948,7 @@ ExeCreateCurveCompoByInterpolation( int nParentId, const PolyLine& PL, int nType bFound ; bFound = PL.GetNextPoint( ptP)) crvByInterp.AddPoint( ptP) ; - PtrOwner pCrvCompo( crvByInterp.GetCurve( nMethod, nType)) ; + PtrOwner pCrvCompo( crvByInterp.GetCurve( nMethod, nCrvType)) ; bOk = bOk && ! IsNull( pCrvCompo) ; // assegno il versore estrusione bOk = bOk && pCrvCompo->SetExtrusion( Z_AX) ; diff --git a/EXE_GdbGetCurve.cpp b/EXE_GdbGetCurve.cpp index 04bbe0b..54b6702 100644 --- a/EXE_GdbGetCurve.cpp +++ b/EXE_GdbGetCurve.cpp @@ -188,6 +188,8 @@ ExeCurveIsACircle( int nId, Point3d& ptCen, Vector3d& vtN, double& dRad, bool& b bCCW = ( pArc->GetAngCenter() > 0) ; return true ; } + else + return false ; } case CRV_COMPO : { ICurveComposite* pCompo = GetCurveComposite( pGObj) ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 1b98ab1695ef6ce72d629899e56cacbe2b4e40ea..a403e49eb9e10375c3de2ec0101f8d221dc5cbf8 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7>zgoW^-i*QjT29S-`yGOp`YVRxuh+cH~Ol+$UrM5#neo(Q#tpyN7!5c7W^-i*QjT29S-`yGOp`YVRxuh*cH~Ol+$UrM5 Date: Fri, 4 Aug 2023 13:22:23 +0200 Subject: [PATCH 13/17] EgtExecutor 2.5h1 : - aggiunta funzione ExeCreateArc2PB e Lua EgtArc2PB (per costruzione arco con 2 punti e bulge). --- EXE_GdbCreateCurve.cpp | 47 +++++++++++++++++++++++++++++++++++------ EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_GdbCreateCurve.cpp | 27 +++++++++++++++++++++++ 3 files changed, 68 insertions(+), 6 deletions(-) diff --git a/EXE_GdbCreateCurve.cpp b/EXE_GdbCreateCurve.cpp index 299c046..b72f951 100644 --- a/EXE_GdbCreateCurve.cpp +++ b/EXE_GdbCreateCurve.cpp @@ -1091,6 +1091,44 @@ ExeCreateArc3P( int nParentId, const Point3d& ptP1, return nId ; } +//------------------------------------------------------------------------------- +int +ExeCreateArc2PB( int nParentId, const Point3d& ptStart, const Point3d& ptEnd, + double dBulge, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // porto in locale i punti, il versore normale e quelloe estrusione + Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ; + Point3d ptEndL = GetPointLocal( pGeomDB, ptEnd, nRefType, frLoc) ; + Vector3d vtNormL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; + Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; + // creo l'arco (in casi particolari retta) + PtrOwner pCrv( bOk ? GetArc2PNB( ptStartL, ptEndL, vtNormL, dBulge) : nullptr) ; + bOk = bOk && ! IsNull( pCrv) ; + // assegno il versore estrusione + bOk = bOk && pCrv->SetExtrusion( vtExtrL) ; + // inserisco l'arco nel DB + int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrv)) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtArc2PB(" + IdToString( nParentId) + ",{" + + ToString( ptStart) + "},{" + + ToString( ptEnd) + "}," + + ToString( dBulge) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nId ; +} + //------------------------------------------------------------------------------- int ExeCreateArc2PD( int nParentId, const Point3d& ptStart, const Point3d& ptEnd, @@ -1099,20 +1137,17 @@ ExeCreateArc2PD( int nParentId, const Point3d& ptStart, const Point3d& ptEnd, IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) nParentId = AdjustId( nParentId) ; - // creo l'arco (in casi particolari retta) - PtrOwner pCrv ; - bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; // porto in locale i punti, il versore iniziale, quello normale e il versore estrusione Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ; Point3d ptEndL = GetPointLocal( pGeomDB, ptEnd, nRefType, frLoc) ; Vector3d vtDirSL = GetVectorLocal( pGeomDB, FromPolar( 1, dDirSDeg), nRefType, frLoc) ; Vector3d vtNormL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; - // setto l'arco - pCrv.Set( GetArc2PVN( ptStartL, ptEndL, vtDirSL, vtNormL)) ; + // creo l'arco (in casi particolari retta) + PtrOwner pCrv( bOk ? GetArc2PVN( ptStartL, ptEndL, vtDirSL, vtNormL) : nullptr) ; bOk = bOk && ! IsNull( pCrv) ; // assegno il versore estrusione bOk = bOk && pCrv->SetExtrusion( vtExtrL) ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index a403e49eb9e10375c3de2ec0101f8d221dc5cbf8..206a4be20563825bc9fdc8f9e267ecbd96866f15 100644 GIT binary patch delta 105 zcmX>#neo(Q#tq-tSS=WI7z{W6W^-m{&HyqTxfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0D>kShyVZp delta 105 zcmX>#neo(Q#tq-tSj`!97>qanW^-m{P6sj^xfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0E4O?kN^Mx diff --git a/LUA_GdbCreateCurve.cpp b/LUA_GdbCreateCurve.cpp index 1550fdd..ec4b9bd 100644 --- a/LUA_GdbCreateCurve.cpp +++ b/LUA_GdbCreateCurve.cpp @@ -425,6 +425,32 @@ LuaCreateArc3P( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateArc2PB( lua_State* L) +{ + // 4 o 5 parametri : ParentId, PtStart, PtEnd, dBulge [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + Point3d ptStart ; + LuaCheckParam( L, 2, ptStart) + Point3d ptEnd ; + LuaCheckParam( L, 3, ptEnd) + double dBulge ; + LuaCheckParam( L, 4, dBulge) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // creo l'arco + int nId = ExeCreateArc2PB( nParentId, ptStart, ptEnd, dBulge, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateArc2PD( lua_State* L) @@ -1057,6 +1083,7 @@ LuaInstallGdbCreateCurve( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtArcC2P", LuaCreateArcC2P) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArcC2PEx", LuaCreateArcC2PEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc3P", LuaCreateArc3P) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PB", LuaCreateArc2PB) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PD", LuaCreateArc2PD) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PDEx", LuaCreateArc2PDEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PV", LuaCreateArc2PV) ; From eedd2068fa390a0851ce40dff571e932a6d5cf38 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 11 Aug 2023 11:29:21 +0200 Subject: [PATCH 14/17] EgtExecutor 2.5h2 : - aggiunta funzione lua EgtPointCurveDistSide. --- EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_GeoDist.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 206a4be20563825bc9fdc8f9e267ecbd96866f15..721dc30d4990ce91c82cd7799ba1d95d626106b5 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7>zdnW^-i*QjT29S-`yGOp`YVRxuh)cH~Ol+$UrM5m>XaK delta 81 zcmX>#neo(Q#tpyN7!5c7W^-i*QjT29S-`yGOp`YVRxuh*cH~Ol+$UrM5 Date: Sun, 27 Aug 2023 18:30:48 +0200 Subject: [PATCH 15/17] EgtExecutor 2.5h3 : - aggiunte funzioni Exe e Lua CopyMachGroup. --- EXE_MachMgr.cpp | 20 ++++++++++++++++++++ EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_MachMgr.cpp | 21 +++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index 28c0fa7..c468ad7 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -245,6 +245,26 @@ ExeAddMachGroup( const string& sName, const string& sMachineName) return nId ; } +//----------------------------------------------------------------------------- +int +ExeCopyMachGroup( const string& sSouName, const string& sName) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL) + // copio la macchinata (gruppo di lavorazione) + int nId = pMachMgr->CopyMachGroup( sSouName, sName) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtCopyMachGroup('" + sSouName + "','" + + sName + "')" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return nId ; +} + //----------------------------------------------------------------------------- bool ExeRemoveMachGroup( int nMGroupId) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 721dc30d4990ce91c82cd7799ba1d95d626106b5..493f687077c6ca67901bc6f247fa4379b0229fe1 100644 GIT binary patch delta 81 zcmX>#neo(Q#tpyN7>zgoW^-i*QjT29S-`yGOp`YVRxuh+cH~Ol+$UrM5#neo(Q#tpyN7>zdnW^-i*QjT29S-`yGOp`YVRxuh)cH~Ol+$UrM5m>XaK diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index 42afb0d..7bf34df 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -227,6 +227,26 @@ LuaAddMachGroup( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCopyMachGroup( lua_State* L) +{ + // 2 parametri : nome del gruppo sorgente, nome del nuovo gruppo + string sSouName ; + LuaCheckParam( L, 1, sSouName) + string sName ; + LuaCheckParam( L, 2, sName) ; + LuaClearStack( L) ; + // copio la macchinata + int nId = ExeCopyMachGroup( sSouName, sName) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaRemoveMachGroup( lua_State* L) @@ -3983,6 +4003,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetPrevMachGroup", LuaGetPrevMachGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachGroupNewName", LuaGetMachGroupNewName) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAddMachGroup", LuaAddMachGroup) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCopyMachGroup", LuaCopyMachGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveMachGroup", LuaRemoveMachGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachGroupName", LuaGetMachGroupName) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachGroupMachineName", LuaGetMachGroupMachineName) ; From 1259955522ff8130b1fb239bc635ae17a497fb4f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 11 Sep 2023 10:44:47 +0200 Subject: [PATCH 16/17] EgtExecutor 2.5i1 : - aggiunta funzione Exe e Lua ProjectCurveOnSurfTm. --- EXE_GdbCreate.cpp | 2 +- EXE_GdbModifyCurve.cpp | 103 ++++++++++++++++++++++++++++++++++++++--- EgtExecutor.rc | Bin 18890 -> 18890 bytes LUA_GdbModifyCurve.cpp | 25 ++++++++++ 4 files changed, 122 insertions(+), 8 deletions(-) diff --git a/EXE_GdbCreate.cpp b/EXE_GdbCreate.cpp index 0d09256..814d1d2 100644 --- a/EXE_GdbCreate.cpp +++ b/EXE_GdbCreate.cpp @@ -131,7 +131,7 @@ ExeCreateGeoVector( int nParentId, const Vector3d& vtV, const Point3d& ptB, int Point3d ptBL = GetPointLocal( pGeomDB, ptB, nRefType, frLoc) ; // creo il vettore PtrOwner pGeoVct( CreateGeoVector3d()) ; - bOk = bOk && !IsNull( pGeoVct) ; + bOk = bOk && ! IsNull( pGeoVct) ; // setto il vettore (con il punto base) bOk = bOk && pGeoVct->Set( vtVL, ptBL) ; // inserisco il vettore nel DB diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index 9fa110e..c3ff401 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -31,12 +31,14 @@ #include "/EgtDev/Include/EGkOffsetCurve.h" #include "/EgtDev/Include/EGkMedialAxis.h" #include "/EgtDev/Include/EGkChainCurves.h" +#include "/EgtDev/Include/EGkProjectCurveSurfTm.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/EGkExtTExt.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkIntervals.h" #include "/EgtDev/Include/EGkPolygon3d.h" +#include "/EgtDev/Include/EGkGeoVector3d.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include @@ -2135,7 +2137,7 @@ bool ExeMergeCurvesInCurveCompo( int nId, double dLinTol, bool bStartEnd) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // recupero la curva composita ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ; bool bOk = ( pCompo != nullptr) ; @@ -2158,7 +2160,7 @@ bool ExeRemoveCurveCompoUndercutOnY( int nId, double dLinTol) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // recupero la curva composita ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ; bool bOk = ( pCompo != nullptr) ; @@ -2180,7 +2182,7 @@ static bool MyChainCurvesInGroup( int nGroupId, const Point3d& ptNear, bool bAllowInvert, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) nGroupId = AdjustId( nGroupId) ; // recupero il riferimento del gruppo Frame3d frGrp ; @@ -2233,11 +2235,11 @@ MyChainCurvesInGroup( int nGroupId, const Point3d& ptNear, bool bAllowInvert, in bool ExeChainCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType) { - bool bOk = MyChainCurvesInGroup(nGroupId, ptNear, true, nRefType) ; + bool bOk = MyChainCurvesInGroup( nGroupId, ptNear, true, nRefType) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtChainCurvesInGroup(" + ToString( nGroupId) + "," + + string sLua = "EgtChainCurvesInGroup(" + ToString( nGroupId) + ",{" + ToString( ptNear) + "}," + RefTypeToString( nRefType) + ")" + " -- Ok=" + ToString( bOk) ; @@ -2250,11 +2252,11 @@ ExeChainCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType) bool ExeReorderCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType) { - bool bOk = MyChainCurvesInGroup(nGroupId, ptNear, false, nRefType) ; + bool bOk = MyChainCurvesInGroup( nGroupId, ptNear, false, nRefType) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtReorderCurvesInGroup(" + ToString( nGroupId) + "," + + string sLua = "EgtReorderCurvesInGroup(" + ToString( nGroupId) + ",{" + ToString( ptNear) + "}," + RefTypeToString( nRefType) + ")" + " -- Ok=" + ToString( bOk) ; @@ -2262,3 +2264,90 @@ ExeReorderCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType) } return bOk ; } + +//------------------------------------------------------------------------------- +static bool +MyProjectCurveOnSurfTm( int nCurveId, int nSurfTmId, const Vector3d& vtDir, int nDestGrpId, double dLinTol, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la curva e il suo riferimento + const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCurveId)) ; + if ( pCrv == nullptr) + return false ; + Frame3d frCrv ; + if ( ! pGeomDB->GetGlobFrame( nCurveId, frCrv)) + return false ; + // recupero la superficie trimesh e il suo riferimento + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTmId)) ; + if ( pStm == nullptr) + return false ; + Frame3d frStm ; + if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frStm)) + return false ; + // recupero il riferimento del gruppo di destinazione + nDestGrpId = AdjustId( nDestGrpId) ; + Frame3d frDest ; + if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) + return false ; + // porto la curva e il vettore nel riferimento della superficie + CurveLocal CrvLoc( pCrv, frCrv, frStm) ; + if ( CrvLoc.Get() == nullptr) + return false ; + Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frCrv) ; + vtDirL.LocToLoc( frCrv, frStm) ; + // eseguo la proiezione + PNT5AXVECTOR vPt5ax ; + if ( ! ProjectCurveOnSurfTm( *CrvLoc.Get(), *pStm, vtDirL, dLinTol, vPt5ax)) + return false ; + // inserisco la composita nel gruppo destinazione + PtrOwner pCompo ; + for ( const auto& Pt5ax : vPt5ax) { + if ( IsNull( pCompo)) { + pCompo.Set( CreateCurveComposite()) ; + if ( IsNull( pCompo)) + return false ; + pCompo->AddPoint( GetLocToLoc( Pt5ax.ptP, frStm, frDest)) ; + } + else + pCompo->AddLine( GetLocToLoc( Pt5ax.ptP, frStm, frDest)) ; + } + int nCompoId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCompo)) ; + if ( nCompoId == GDB_ID_NULL) + return false ; + // aggiungo i versori nel gruppo destinazione + for ( const auto& Pt5ax : vPt5ax) { + PtrOwner pGeoVct( CreateGeoVector3d()) ; + if ( IsNull( pGeoVct)) + return false ; + pGeoVct->Set( 10 * GetLocToLoc( Pt5ax.vtDir, frStm, frDest), GetLocToLoc( Pt5ax.ptP, frStm, frDest)) ; + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoVct)) ; + if ( nNewId == GDB_ID_NULL) + return false ; + pGeomDB->SetInfo( nNewId, "Par", Pt5ax.dPar) ; + pGeomDB->SetInfo( nNewId, "Flag", Pt5ax.nFlag) ; + } + + return true ; +} + +//------------------------------------------------------------------------------- +bool +ExeProjectCurveOnSurfTm( int nCurveId, int nSurfTmId, const Vector3d& vtDir, int nDestGrpId, double dLinTol, int nRefType) +{ + bool bOk = MyProjectCurveOnSurfTm( nCurveId, nSurfTmId, vtDir, nDestGrpId, dLinTol, nRefType) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtProjectCurveOnSurfTm(" + ToString( nCurveId) + "," + + ToString( nSurfTmId) + ",{" + + ToString( vtDir) + "}," + + ToString( nDestGrpId) + "," + + ToString( dLinTol) + "," + + RefTypeToString( nRefType) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; + +} diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 493f687077c6ca67901bc6f247fa4379b0229fe1..be659fe653afff516690261fbda0aef11a4c8707 100644 GIT binary patch delta 105 zcmX>#neo(Q#tq-tSS=ZJ7z{W6W^-m{&IB?XxfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0E5~dkN^Mx delta 105 zcmX>#neo(Q#tq-tSS=WI7>qanW^-m{&HyqTxfZj)#f~#g-XK^35})kImAtu6$O0yJ US`4aQPzqIjgCatGoKlWD0EJ#2m;e9( diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 475eb43..4f35afd 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -944,6 +944,30 @@ LuaReorderCurvesInGroup( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaProjectCurveOnSurfTm( lua_State* L) +{ + // 4, 5 o 6 parametri : nCurveId, nSurfTmId, vtDir, nDestGrpId [, dLinTol [, nRefType]] + int nCurveId ; + LuaCheckParam( L, 1, nCurveId) + int nSurfTmId ; + LuaCheckParam( L, 2, nSurfTmId) + Vector3d vtDir ; + LuaCheckParam( L, 3, vtDir) + int nDestGrpId ; + LuaCheckParam( L, 4, nDestGrpId) + double dLinTol = 0.01 ; + int nRefType = RTY_DEFAULT ; + if ( LuaGetParam( L, 5, dLinTol)) + LuaGetParam( L, 6, nRefType) ; + LuaClearStack( L) ; + // proietto la curva su una trimesh secondo la direzione data + bool bOk = ExeProjectCurveOnSurfTm( nCurveId, nSurfTmId, vtDir, nDestGrpId, dLinTol, nRefType) ; + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbModifyCurve( LuaMgr& luaMgr) @@ -999,5 +1023,6 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveCurveCompoUndercutOnY", LuaRemoveCurveCompoUndercutOnY) ; bOk = bOk && luaMgr.RegisterFunction( "EgtChainCurvesInGroup", LuaChainCurvesInGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtReorderCurvesInGroup", LuaReorderCurvesInGroup) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurfTm", LuaProjectCurveOnSurfTm) ; return bOk ; } From 2794f358050b31daade96043ec20bdc6b7a11569 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 18 Sep 2023 08:14:36 +0200 Subject: [PATCH 17/17] EgtExecutor : - aggiunte funzioni Exe e Lua CreateSurfTmTriangle e CreateSurfTmRectangle - in Copy, CopyGlob, Relocate e RelocateGlob RefId ora accetta anche valori simbolici (layer corrente, ..). --- EXE_GdbCreateSurf.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++- EXE_GdbObjects.cpp | 21 ++++++---- LUA_GdbCreateSurf.cpp | 56 +++++++++++++++++++++++++- 3 files changed, 160 insertions(+), 11 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 0f0e215..07da47d 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -56,8 +56,7 @@ ExeCreateSurfFrRectangle( int nParentId, const Point3d& ptIni, const Point3d& pt if ( ( frEnt.VersZ() * vtZL) < 0) frEnt.PseudoMirror( frEnt.Orig(), frEnt.VersZ()) ; // ricavo le dimensioni della base - Point3d ptCrossI = ptCrossL ; - ptCrossI.ToLoc( frEnt) ; + Point3d ptCrossI = GetToLoc( ptCrossL, frEnt) ; double dWidth = ptCrossI.x ; double dLen = ptCrossI.y ; // creo il rettangolo nel suo riferimento intrinseco @@ -863,6 +862,97 @@ ExeCreateSurfTmSphere( int nParentId, const Point3d& ptOrig, return nNewId ; } +//------------------------------------------------------------------------------- +int +ExeCreateSurfTmTriangle( int nParentId, const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // porto in locale i punti + Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ; + Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ; + Point3d ptP3L = GetPointLocal( pGeomDB, ptP3, nRefType, frLoc) ; + // creo la superficie trimesh + PtrOwner pStm( CreateSurfTriMesh()) ; + bOk = bOk && ! IsNull( pStm) ; + // assegno il triangolo + if ( bOk) { + pStm->Init( 3, 1, 1) ; + int vV[3]{ pStm->AddVertex( ptP1L), + pStm->AddVertex( ptP2L), + pStm->AddVertex( ptP3L)} ; + bOk = ( pStm->AddTriangle( vV) != SVT_NULL) && pStm->AdjustTopology() ; + } + // inserisco la superficie nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmTriangle(" + IdToString( nParentId) + ",{" + + ToString( ptP1) + "},{" + + ToString( ptP2) + "},{" + + ToString( ptP3) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateSurfTmRectangle( int nParentId, const Point3d& ptO, const Point3d& ptL, const Point3d& ptT, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // porto in locale i punti + Point3d ptOL = GetPointLocal( pGeomDB, ptO, nRefType, frLoc) ; + Point3d ptLL = GetPointLocal( pGeomDB, ptL, nRefType, frLoc) ; + Point3d ptTL = GetPointLocal( pGeomDB, ptT, nRefType, frLoc) ; + // modifico il punto trasversale per metterlo perpendicolare al lato Lungo + ptTL -= ParallCompo( ptTL - ptOL, ptLL - ptOL) ; + // calcolo il quarto punto + Point3d ptVL = ptTL + ( ptLL - ptOL) ; + // creo la superficie trimesh + PtrOwner pStm( CreateSurfTriMesh()) ; + bOk = bOk && ! IsNull( pStm) ; + // assegno il triangolo + if ( bOk) { + pStm->Init( 4, 2, 1) ; + int vV[4]{ pStm->AddVertex( ptOL), + pStm->AddVertex( ptLL), + pStm->AddVertex( ptTL), + pStm->AddVertex( ptVL)} ; + int vV1[3]{ vV[0], vV[1], vV[2] } ; + int vV2[3]{ vV[2], vV[1], vV[3] } ; + bOk = ( pStm->AddTriangle( vV1) != SVT_NULL) && ( pStm->AddTriangle( vV2) != SVT_NULL) && pStm->AdjustTopology() ; + } + // inserisco la superficie nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmRectangle(" + IdToString( nParentId) + ",{" + + ToString( ptO) + "},{" + + ToString( ptL) + "},{" + + ToString( ptT) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} + //------------------------------------------------------------------------------- int ExeCreateSurfTmByFlatContour( int nParentId, int nCrvId, double dLinTol) diff --git a/EXE_GdbObjects.cpp b/EXE_GdbObjects.cpp index b5a2f9b..63a8872 100644 --- a/EXE_GdbObjects.cpp +++ b/EXE_GdbObjects.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "EXE.h" #include "EXE_Macro.h" +#include "GeoTools.h" #include "AuxTools.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGkStringUtils3d.h" @@ -254,6 +255,7 @@ ExeCopy( int nSouId, int nRefId, int nSonBeforeAfter) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nRefId = AdjustId( nRefId) ; // eseguo la copia int nNewId = pGeomDB->Copy( nSouId, GDB_ID_NULL, nRefId, nSonBeforeAfter) ; pGeomDB->RemoveInfo( nNewId, GDB_SI_LIST) ; @@ -264,11 +266,11 @@ ExeCopy( int nSouId, int nRefId, int nSonBeforeAfter) string sLua ; if ( nSonBeforeAfter == GDB_LAST_SON) sLua = "EgtCopy(" + ToString( nSouId) + "," + - ToString( nRefId) + ")" + + IdToString( nRefId) + ")" + " -- Id=" + ToString( nNewId) ; else sLua = "EgtCopy(" + ToString( nSouId) + "," + - ToString( nRefId) + "," + + IdToString( nRefId) + "," + InsToString( nSonBeforeAfter) + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -283,6 +285,7 @@ ExeCopyGlob( int nSouId, int nRefId, int nSonBeforeAfter) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nRefId = AdjustId( nRefId) ; // eseguo la copia mantenendo la posizione in globale int nNewId = pGeomDB->CopyGlob( nSouId, GDB_ID_NULL, nRefId, nSonBeforeAfter) ; pGeomDB->RemoveInfo( nNewId, GDB_SI_LIST) ; @@ -293,11 +296,11 @@ ExeCopyGlob( int nSouId, int nRefId, int nSonBeforeAfter) string sLua ; if ( nSonBeforeAfter == GDB_LAST_SON) sLua = "EgtCopyGlob(" + ToString( nSouId) + "," + - ToString( nRefId) + ")" + + IdToString( nRefId) + ")" + " -- Id=" + ToString( nNewId) ; else sLua = "EgtCopyGlob(" + ToString( nSouId) + "," + - ToString( nRefId) + "," + + IdToString( nRefId) + "," + InsToString( nSonBeforeAfter) + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -312,6 +315,7 @@ ExeRelocate( int nSouId, int nRefId, int nSonBeforeAfter) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) + nRefId = AdjustId( nRefId) ; // eseguo la rilocazione bool bOk = pGeomDB->Relocate( nSouId, nRefId, nSonBeforeAfter) ; ExeSetModified() ; @@ -320,11 +324,11 @@ ExeRelocate( int nSouId, int nRefId, int nSonBeforeAfter) string sLua ; if ( nSonBeforeAfter == GDB_LAST_SON) sLua = "EgtRelocate(" + ToString( nSouId) + "," + - ToString( nRefId) + ")" + + IdToString( nRefId) + ")" + " -- Ok=" + ToString( bOk) ; else sLua = "EgtRelocate(" + ToString( nSouId) + "," + - ToString( nRefId) + "," + + IdToString( nRefId) + "," + InsToString( nSonBeforeAfter) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -339,6 +343,7 @@ ExeRelocateGlob( int nSouId, int nRefId, int nSonBeforeAfter) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) + nRefId = AdjustId( nRefId) ; // eseguo la rilocazione mantenendo la posizione in globale bool bOk = pGeomDB->RelocateGlob( nSouId, nRefId, nSonBeforeAfter) ; ExeSetModified() ; @@ -347,11 +352,11 @@ ExeRelocateGlob( int nSouId, int nRefId, int nSonBeforeAfter) string sLua ; if ( nSonBeforeAfter == GDB_LAST_SON) sLua = "EgtRelocateGlob(" + ToString( nSouId) + "," + - ToString( nRefId) + ")" + + IdToString( nRefId) + ")" + " -- Ok=" + ToString( bOk) ; else sLua = "EgtRelocateGlob(" + ToString( nSouId) + "," + - ToString( nRefId) + "," + + IdToString( nRefId) + "," + InsToString( nSonBeforeAfter) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index a449004..f03efd0 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -385,7 +385,7 @@ LuaCreateSurfTmSphere( lua_State* L) else LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; - // creo STM cilindro + // creo STM sfera int nId = ExeCreateSurfTmSphere( nParentId, ptOrig, dRad, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) @@ -395,6 +395,58 @@ LuaCreateSurfTmSphere( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateSurfTmTriangle( lua_State* L) +{ + // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + Point3d PtP1 ; + LuaCheckParam( L, 2, PtP1) + Point3d PtP2 ; + LuaCheckParam( L, 3, PtP2) + Point3d PtP3 ; + LuaCheckParam( L, 4, PtP3) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // creo STM triangolo + int nId = ExeCreateSurfTmTriangle( nParentId, PtP1, PtP2, PtP3, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaCreateSurfTmRectangle( lua_State* L) +{ + // 4 o 5 parametri : ParentId, PtO, PtL, PtT [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + Point3d ptO ; + LuaCheckParam( L, 2, ptO) + Point3d ptL ; + LuaCheckParam( L, 3, ptL) + Point3d ptT ; + LuaCheckParam( L, 4, ptT) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // creo STM rettangolo + int nId = ExeCreateSurfTmRectangle( nParentId, ptO, ptL, ptT, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateSurfTmByFlatContour( lua_State* L) @@ -835,6 +887,8 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCylinder", LuaCreateSurfTmCylinder) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCone", LuaCreateSurfTmCone) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSphere", LuaCreateSurfTmSphere) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTriangle", LuaCreateSurfTmTriangle) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmRectangle", LuaCreateSurfTmRectangle) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByFlatContour", LuaCreateSurfTmByFlatContour) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByRegion", LuaCreateSurfTmByRegion) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByExtrusion", LuaCreateSurfTmByExtrusion) ;