From e0c2b9dacd8bc5d65cbace04960ed0dadea210a4 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 23 Dec 2025 15:36:20 +0100 Subject: [PATCH 01/54] EgtExecutor : - aggiunta funzione exe/lua DuplicateGeomDB. --- EXE_GdbObjects.cpp | 23 +++++++++++++++++++++++ LUA_GdbObjects.cpp | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/EXE_GdbObjects.cpp b/EXE_GdbObjects.cpp index eeed41a..382adad 100644 --- a/EXE_GdbObjects.cpp +++ b/EXE_GdbObjects.cpp @@ -393,6 +393,29 @@ ExeCopyGlobEx( int nSouCtx, int nSouId, int nDestCtx, int nRefId, int nSonBefore return nNewId ; } +//----------------------------------------------------------------------------- +bool +ExeDuplicateGeomDB( int nSouCtx, int nDestCtx, bool bSkipTemp) +{ + // recupero i due GeomDB + IGeomDB* pSouGeomDB = GetGeomDB( nSouCtx) ; + VERIFY_GEOMDB( pSouGeomDB, GDB_ID_NULL) + IGeomDB* pDstGeomDB = GetGeomDB( nDestCtx) ; + VERIFY_GEOMDB( pDstGeomDB, GDB_ID_NULL) + // eseguo la duplicazione del primo GeomDB nel secondo + bool bOk = DuplicateGeomDB( pSouGeomDB, pDstGeomDB, bSkipTemp) ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtDuplicateGeomDB(" + ToString( nSouCtx) + "," + + ToString( nDestCtx) + "," + + ( bSkipTemp ? "true" : "false") + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + //----------------------------------------------------------------------------- bool ExeRelocate( int nSouId, int nRefId, int nSonBeforeAfter) diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp index 442394f..3cc87e6 100644 --- a/LUA_GdbObjects.cpp +++ b/LUA_GdbObjects.cpp @@ -563,6 +563,25 @@ LuaCopyGlobEx( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaDuplicateGeomDB( lua_State* L) +{ + // 2 o 3 parametri : nSouCtx, nDestCtx [, bSkipTemp] + int nSouCtx ; + LuaCheckParam( L, 1, nSouCtx) + int nDestCtx ; + LuaCheckParam( L, 2, nDestCtx) + bool bSkipTemp = false ; + LuaGetParam( L, 3, bSkipTemp) ; + LuaClearStack( L) ; + // eseguo la copia + bool bOk = ExeDuplicateGeomDB( nSouCtx, nDestCtx, bSkipTemp) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaRelocate( lua_State* L) @@ -718,6 +737,7 @@ LuaInstallGdbObjects( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtCopyEx", LuaCopyEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCopyGlob", LuaCopyGlob) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCopyGlobEx", LuaCopyGlobEx) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtDuplicateGeomDB", LuaDuplicateGeomDB) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRelocate", LuaRelocate) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRelocateGlob", LuaRelocateGlob) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGroupSwap", LuaGroupSwap) ; From 116e7c006130e960c4f4ca2a10c412c02303f53f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 2 Jan 2026 12:34:15 +0100 Subject: [PATCH 02/54] EgtExecutor 3.1a1 : - ricompilazione con cambio major version. --- EgtExecutor.rc | Bin 19660 -> 19652 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index f12cb4bd916e122381a2163fa5c15fb06414261e..47af36f586ecc81f6aadaf64fb671f8d0892f84c 100644 GIT binary patch delta 474 zcmX>zlkvz*#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+g6jT!WS3KAI%CmRauPIi#m#b`G9 zzS6|WJGl1&l>+5};^LFNR9;N>la1PZg_n&Hr?Rx(ZABZz6H+2lT<8nC&OC(je! zgKF;PIMD>$W_}kFX2$8p9%(c;ZuXPKW7cyyeoV8VZrglc$)6G7u+3g73JRoz_~wZ& f#f-e5Nbv+mLk>eFI1&uprZHm(AKW~{%Y+F4y6<%c delta 484 zcmX>ylkv<<#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|HJz3DLb#olc z1SWnX1|0@-AU0$Gv5Y7GW>aMai)~hA7iQ)(V$cIh=Kv)fxt=qcPUaS#IC&TMKA;ky z_~eTm;*&c>geKQHa&6wgql4eHxlEHc2o|B3m^`^psD{yWGqd%DoE%`J WByJXT+sKS5Jb9wa!OauAOqc-66ml&9 From b1fcb75e4fd67106de5a37afab447c6df8de64ed Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sun, 4 Jan 2026 20:39:53 +0100 Subject: [PATCH 03/54] EgtExecutor : - aggiunte funzioni di striping per trimming dei termoformati --- EXE_Trimming.cpp | 797 ++++++++++++++++++++++++++++++++++++ EgtExecutor.vcxproj | 2 + EgtExecutor.vcxproj.filters | 6 + LUA.h | 2 + LUA_Base.cpp | 6 +- Lua_Trimming.cpp | 304 ++++++++++++++ 6 files changed, 1116 insertions(+), 1 deletion(-) create mode 100644 EXE_Trimming.cpp create mode 100644 Lua_Trimming.cpp diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp new file mode 100644 index 0000000..c7f3cea --- /dev/null +++ b/EXE_Trimming.cpp @@ -0,0 +1,797 @@ +//---------------------------------------------------------------------------- +// EgalTech 2025-2025 +//---------------------------------------------------------------------------- +// File : EXE_Trimming.cpp Data : 25.10.25 Versione : 2.7j3 +// Funzioni per le lavorazioni di Trimming. +// +// Modifiche : 23.10.25 RE Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "EXE.h" +#include "EXE_Macro.h" +#include "DllExchange.h" +#include "GeoTools.h" +#include "AuxTools.h" +#include "/EgtDev/Include/EgtNumUtils.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/EGkSurfLocal.h" +#include "/EgtDev/Include/EGkCurveComposite.h" +#include "/EgtDev/Include/EGkTrimming.h" +#include "/EgtDev/Include/EGkStmFromTriangleSoup.h" +#include "/EgtDev/Include/EGkDistPointCurve.h" +#include +#include + +using namespace std ; + +static string s_sKey_Sync_Coord = "KeyOldCoord" ; +static string s_sKey_Auto_Trim = "AutoTrim" ; + +// --------------------------------------------------------------------------- +bool +ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, double dShapeAngTol, + double dLinTol, double dEdgeLinTol, double dAngTol, double dAngFaceTol, + const STRVECTOR& vsShapes) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Se non ho geometrie da ricercare, non faccio nulla + if ( vsShapes.empty()) + return true ; + + // Recupero le superfici presenti nel Layer + CISURFPVECTOR vSurfs ; vSurfs.reserve( pGeomDB->GetGroupObjs( nSurfLayerId)) ; + int nId = pGeomDB->GetFirstInGroup( nSurfLayerId) ; + while ( nId != GDB_ID_NULL) { + // Recupero l'entitą + const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ; + if ( pGeoObj != nullptr) { + // Recupero il Tipo + int nType = pGeoObj->GetType() ; + if ( nType == SRF_TRIMESH || nType == SRF_BEZIER) { + // Recupero la superficie + const ISurf* pSurf = GetSurf( pGeoObj) ; + if ( pSurf != nullptr && pSurf->IsValid()) + vSurfs.emplace_back( pSurf) ; + } + } + nId = pGeomDB->GetNext( nId) ; + } + // Se non ho superfici non faccio nulla + if ( vSurfs.empty()) + return false ; + + // Recupero Le Superfici Selezionate, Le Curve e Le Bezier rigate + ISURFPOMATRIX matSelSurfMatrix ; + ICRVCOMPOPOMATRIX matCompoBorders ; + ISURFBEZPOVECTOR vSurfBz ; + bool bOk = GetTrimmingAutoEntities( vSurfs, dShapeLinTol, dShapeAngTol, dLinTol, dEdgeLinTol, dAngTol, dAngFaceTol, vsShapes, + matSelSurfMatrix, matCompoBorders, vSurfBz) ; + + // Per sicurezza verifico che tutte le entitą siano a dimensione corretta + bOk = bOk && ( ssize( matSelSurfMatrix) == ssize( matCompoBorders)) && + ( ssize( matSelSurfMatrix) == ssize( vSurfBz)) ; + + // Per ogni Entitą ricavata inserisco le Geometrie nel Layer + // NB. Ordine di Inserimento : Surf -> Edges -> bezier + // Una anomalia nella serie blocca il flusso corrente e passa al successivo + int nCount = -1 ; + for ( int i = 0 ; bOk && i < int( matSelSurfMatrix.size()) ; ++ i) { + // Verifico che la Superficie sia Valida + bool bOkEntity = true ; + for ( int j = 0 ; bOkEntity && j < ssize( matSelSurfMatrix[i]) ; ++ j) + bOkEntity = ( ! IsNull( matSelSurfMatrix[i][j]) && matSelSurfMatrix[i][j]->IsValid()) ; + if ( ! bOkEntity) + continue ; // anomalia serie livello superfici di selezione + for ( int j = 0 ; bOk && j < ssize( matSelSurfMatrix[i]) ; ++ j) { + int nSurfId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( matSelSurfMatrix[i][j])) ; + bOk = ( ( nSurfId != GDB_ID_NULL) && + ( pGeomDB->SetInfo( nSurfId, s_sKey_Auto_Trim, ToString( ++ nCount)))) ; + } + if ( ! bOk) + break ; // anomalia bloccante + // Verifico che Le Curve di Edges ( Bezier ) siano Valide + for ( int j = 0 ; bOkEntity && j < ssize( matCompoBorders[i]) ; ++ j) + bOkEntity = ( ! IsNull( matCompoBorders[i][j]) && matCompoBorders[i][j]->IsValid()) ; + if ( ! bOkEntity) + continue ; // anomalia serie livello curve di bordo + for ( int j = 0 ; bOk && j < ssize( matCompoBorders[i]) ; ++ j) { + int nCrvId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( matCompoBorders[i][j])) ; + bOk = ( ( nCrvId != GDB_ID_NULL) && + ( pGeomDB->SetInfo( nCrvId, s_sKey_Auto_Trim, ToString( nCount)))) ; + } + if ( ! bOk) + break ; // anomalia bloccante + // Verifico che le Superfici di Bezier rigate siano Valide + bOkEntity = ( ! IsNull( vSurfBz[i]) && vSurfBz[i]->IsValid()) ; + if ( ! bOkEntity) + continue ; // anomalia seria livello Bezier Rigata + int nBzId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vSurfBz[i])) ; + bOk = ( ( nBzId != GDB_ID_NULL) && + ( pGeomDB->SetInfo( nBzId, s_sKey_Auto_Trim, ToString( nCount)))) ; + if ( ! bOk) + break ; // anomali bloccante + } + + ExeSetModified() ; + + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtTrimmingAutoSearch(" + ToString( nParentId) + "," + + ToString( nSurfLayerId) + "," + + ToString( dShapeLinTol) + "," + + ToString( dShapeAngTol) + "," + + ToString( dLinTol) + "," + + ToString( dEdgeLinTol) + "," + + ToString( dAngTol) + "," + + ToString( dAngFaceTol) + "," + + ToString( vsShapes) + ")" + + " -- bOk=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return bOk ; +} + +// --------------------------------------------------------------------------- +bool +ExeTrimmingGetSurfTmFaceAdj( int nSurfId, const INTVECTOR& vTria, const PNTVECTOR& vPts, + double dAngTol, double dSize, double dSizeTol, INTVECTOR& vOtherFaces) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Recupero la superficie TriMesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfId)) ; + bool bOk = ( pStm != nullptr && pStm->IsValid()) ; + + // Verifico che le facce appartengano alla superficie + bOk = bOk && ( ! vTria.empty()) ; + + // Recupero l'insieme dei triangoli + if ( bOk) { + INTVECTOR vOtherTria ; vOtherTria.reserve( pStm->GetTriangleCount()) ; + bOk = GetTrimmingStmAdjTria( pStm, vTria, vPts, dAngTol, dSize, dSizeTol, vOtherTria) ; + // Per ogni triangolo ricavato, recupero la faccia corrispondente + set setFaces ; + for ( const int& nT : vOtherTria) + setFaces.insert( pStm->GetFacetFromTria( nT)) ; + vOtherFaces.assign( setFaces.begin(), setFaces.end()) ; + } + + ExeSetModified() ; + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtTrimmingGetSurfTmFromFaceAdj(" + ToString( nSurfId) + "," + + ToString( vTria) + "," + + ToString( dAngTol) + ")" + + " -- bOk=" + ToString( bOk) + "vOtherFaces=" + ToString( vOtherFaces) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return bOk ; +} + +// --------------------------------------------------------------------------- +int +ExeTrimmingGetSurfTmFromStmFaces( int nParentId, int nSurfId, const INTVECTOR& vFaces) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Recupero il riferimento del gruppo di destinazione + Frame3d frDest ; + if ( ! pGeomDB->GetGlobFrame( nParentId, frDest)) + return GDB_ID_NULL ; + + // Recupero la superficie TriMesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfId)) ; + if ( pStm == nullptr || ! pStm->IsValid()) + return GDB_ID_NULL ; + + // Verifico che le facce appartengano alla superficie + if ( vFaces.empty()) + return CMD_ID_NULL ; + for ( int nF = 0 ; nF < int( vFaces.size()) ; ++ nF) { + double dArea = 0. ; + if ( ! pStm->GetFacetArea( vFaces[nF], dArea)) + return GDB_ID_NULL ; + } + + // Definisco la superficie + StmFromTriangleSoup TriaSoup ; + TriaSoup.Start() ; + for ( int nF = 0 ; nF < int( vFaces.size()) ; ++ nF) { + INTVECTOR vT ; + if ( ! pStm->GetAllTriaInFacet( vFaces[nF], vT)) + return GDB_ID_NULL ; + for ( int nT = 0 ; nT < int( vT.size()) ; ++ nT) { + Triangle3d Tria ; + if ( ! pStm->GetTriangle( vT[nT], Tria) || ! TriaSoup.AddTriangle( Tria)) + return GDB_ID_NULL ; + } + } + TriaSoup.End() ; + PtrOwner pStmTria( TriaSoup.GetSurf()) ; + if ( IsNull( pStmTria) || ! pStmTria->IsValid() || pStmTria->GetTriangleCount() == 0) + return GDB_ID_NULL ; + + // Aggiungo la superficie al DB + int nNewSurfId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmTria)) ; + + ExeSetModified() ; + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "TrimmingGetSurfTmFromStmFaces(" + ToString( nParentId) + "," + + ToString( nSurfId) + "," + + ToString( vFaces) + ")" + + " -- nId=" + ToString( nNewSurfId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return nNewSurfId ; +} + +// --------------------------------------------------------------------------- +bool +ExeTrimmingGetAdjSurfs( const INTVECTOR& vSurfId, const INTVECTOR& vOtherSurfId, double dLinTol, + double dAngTol, double dAngFaceTol, INTVECTOR& vResId) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Recupero le superfici di Riferimento + CISURFPVECTOR vRefSurf ; vRefSurf.reserve( vSurfId.size()) ; + bool bOk = true ; + for ( int i = 0 ; bOk && i < int( vSurfId.size()) ; ++ i) { + const ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( vSurfId[i])) ; + bOk = ( pSurf != nullptr && pSurf->IsValid()) ; + vRefSurf.emplace_back( pSurf) ; + } + + // Recupero le superfici complessive, escludendo eventualmente quelle di riferimento se presenti + CISURFPVECTOR vOtherSurf ; vOtherSurf.reserve( vOtherSurfId.size()) ; + INTVECTOR vIds ; + for ( int i = 0 ; bOk && i < int( vOtherSurfId.size()) ; ++ i) { + if ( find( vSurfId.begin(), vSurfId.end(), vOtherSurfId[i]) == vSurfId.end()) { + const ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( vOtherSurfId[i])) ; + bOk = ( pSurf != nullptr && pSurf->IsValid()) ; + vOtherSurf.emplace_back( pSurf) ; + vIds.push_back( vOtherSurfId[i]) ; + } + } + + // Recupero le facce adiancenti nella tolleranza richiesta + INTVECTOR vMyInds ; + bOk = bOk && GetTrimmingAdjSurfs( vRefSurf, vOtherSurf, dLinTol, dAngTol, dAngFaceTol, vMyInds) ; + if ( bOk) { + for ( const int& myInd : vMyInds) + vResId.push_back( vIds[myInd]) ; + } + + ExeSetModified() ; + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtTrimmingGetAdjSurf(" + ToString( vSurfId) + "," + + ToString( vOtherSurfId) + "," + + ToString( dAngTol) + ")" + + " -- bOk=" + ToString( bOk) + ",vResId=" + ToString( vResId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return bOk ; +} + +// --------------------------------------------------------------------------- +bool +ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, double dAngTol, + int& nFirstId, int& nCount) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Parametri da restituire + nFirstId = GDB_ID_NULL ; + nCount = 0 ; + + // vIds : vettore di { nId = SurfId, nSubId = nSurfFace } + // Controllo che vIds non sia vuoto + bool bOk = ( ! vIds.empty()) ; + // Recupero il riferimento della prima superficie + Frame3d frSurf ; + bOk = bOk && pGeomDB->GetGlobFrame( vIds[0].nId, frSurf) ; + // Recupero il riferimento dei gruppi di destinazione + Frame3d frDest ; + bOk = bOk && pGeomDB->GetGlobFrame( nParentId, frDest) ; + // Recupero gli Id univoci delle superfici selezionate + INTSET setUniqueId ; + for ( const SelData& nIds : vIds) + setUniqueId.insert( nIds.nId) ; + // Recupero le superfici e le porto tutte in locale alla prima + unordered_map uMapPos ; uMapPos.reserve( setUniqueId.size()) ; + SURFLOCALVECTOR vSurfL ; vSurfL.reserve( setUniqueId.size()) ; + CISURFPVECTOR vpSurf ; vpSurf.reserve( setUniqueId.size()) ; + int nSurf = 0 ; + for ( auto nIter = setUniqueId.begin() ; bOk && nIter != setUniqueId.end() ; ++ nIter) { + vSurfL.emplace_back( pGeomDB, *nIter, frSurf) ; + bOk = ( vSurfL.back().Get() != nullptr) ; + vpSurf.emplace_back( vSurfL.back().Get()) ; + uMapPos[*nIter] = nSurf ; + ++ nSurf ; + } + // Recupero il vettore di Selezione associato non pił agli Id delle superficie ma alle loro posizioni nel vettore + vector vFaces ; vFaces.reserve( vIds.size()) ; + for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i) + vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ; + + // Calcolo le curve di Edge grezze ( quindi i tratti lineari) + ICRVCOMPOPOVECTOR vRawEdges ; + bOk = bOk && GetTrimmingRawEdges( vpSurf, vFaces, dLinTol, dAngTol, vRawEdges) && + ( ! vRawEdges.empty()) ; + + // Calcolo le curve di Edge approssimate mediante curve di Bezier + ICRVCOMPOPOVECTOR vBezierEdges ; + bOk = bOk && GetTrimmingBezierEdges( vRawEdges, dLinTol, dAngTol, vBezierEdges) ; + nCount = int( vBezierEdges.size()) ; + if ( bOk) { + // Scorro i gli Edges ottenuti + for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) { + vBezierEdges[nCrv]->ToLoc( frDest) ; + // Inserisco la curva nel DB Geometrico + int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nCrv])) ; + bOk = ( nCurrId != GDB_ID_NULL) ; + if ( nCrv == 0) + nFirstId = nCurrId ; + } + } + + ExeSetModified() ; + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtTrimmingGetBorders(" + IdToString( nParentId) + "," + + ToString( dLinTol) + "," + + ToString( dAngTol) + ")" ; + sLua += " -- bOk=" + ToString( bOk) + + " -- FirstId=" + ToString( nFirstId) + " CurveCount=" + ToString( nCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return bOk ; +} + +// --------------------------------------------------------------------------- +bool +ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLinTol, + double dAngTol, double dThick, Point3d& ptNear, int& nFirstId, int& nCount) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Parametri da restituire + nFirstId = GDB_ID_NULL ; + nCount = 0 ; + + // vIds : vettore di { nId = SurfId, nSubId = nSurfFace } + // Controllo che vIds non sia vuoto + bool bOk = ( ! vIds.empty()) ; + // Recupero il riferimento della prima superficie + Frame3d frSurf ; + bOk = bOk && pGeomDB->GetGlobFrame( vIds[0].nId, frSurf) ; + // Recupero il riferimento dei gruppi di destinazione + Frame3d frDest ; + bOk = bOk && pGeomDB->GetGlobFrame( nParentId, frDest) ; + // Recupero gli Id univoci delle superfici selezionate + INTSET setUniqueId ; + for ( const SelData& nIds : vIds) + setUniqueId.insert( nIds.nId) ; + // Recupero le superfici e le porto tutte in locale alla prima + unordered_map uMapPos ; uMapPos.reserve( setUniqueId.size()) ; + SURFLOCALVECTOR vSurfL ; vSurfL.reserve( setUniqueId.size()) ; + CISURFPVECTOR vpSurf ; vpSurf.reserve( setUniqueId.size()) ; + int nSurf = 0 ; + for ( auto nIter = setUniqueId.begin() ; bOk && nIter != setUniqueId.end() ; ++ nIter) { + vSurfL.emplace_back( pGeomDB, *nIter, frSurf) ; + bOk = ( vSurfL.back().Get() != nullptr) ; + vpSurf.emplace_back( vSurfL.back().Get()) ; + uMapPos[*nIter] = nSurf ; + ++ nSurf ; + } + // Recupero il vettore di Selezione associato non pił agli Id delle superficie ma alle loro posizioni nel vettore + vector vFaces ; vFaces.reserve( vIds.size()) ; + for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i) + vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ; + + // Calcolo le curve di Edge approssimate mediante curve di Bezier + ICRVCOMPOPOVECTOR vBezierEdges ; + bOk = bOk && GetTrimmingFinalBorders( vpSurf, vFaces, dLinTol, dAngTol, dThick, vBezierEdges) ; + if ( bOk) { + // Se non ho un punto di vicinanza, le inserisco tutte + if ( ! ptNear.IsValid()) { + nCount = int( vBezierEdges.size()) ; + // Scorro i gli Edges ottenuti + for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) { + vBezierEdges[nCrv]->ToLoc( frDest) ; + // Inserisco la curva nel DB Geometrico + int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nCrv])) ; + bOk = ( nCurrId != GDB_ID_NULL) ; + if ( nCrv == 0) + nFirstId = nCurrId ; + } + } + // Se ho un punto di vicinanza, cerco la coppia di curve pił vicina + else { + // Se solo una coppia di curve, le inserisco e non ho ambiguitą + if ( int( vBezierEdges.size()) == 2) { + nCount = int( vBezierEdges.size()) ; + // Scorro gli Edges ottenuti + for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) { + vBezierEdges[nCrv]->ToLoc( frDest) ; + // Inserisco la curva nel DB Geometrico + int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nCrv])) ; + bOk = ( nCurrId != GDB_ID_NULL) ; + if ( nCrv == 0) + nFirstId = nCurrId ; + } + } + // altrimenti cerco la coppia pił vicia + else { + double dSqMinDist = INFINITO ; + int nInd = 0 ; + for ( int i = 0 ; i + 1 < int( vBezierEdges.size()) ; i = i + 2) { + double dSqDist = 0., dSqDist1 = 0. ; + if ( DistPointCurve( ptNear, *vBezierEdges[i]).GetSqDist( dSqDist) && + DistPointCurve( ptNear, *vBezierEdges[i + 1]).GetSqDist( dSqDist1)) { + double dCurrMinSqDist = min( dSqDist, dSqDist1) ; + if ( dCurrMinSqDist < dSqMinDist) { + dSqMinDist = dCurrMinSqDist ; + nInd = i ; + } + } + } + vBezierEdges[nInd]->ToLoc( frDest) ; + vBezierEdges[nInd + 1]->ToLoc( frDest) ; + int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nInd])) ; + int nCurrId1 = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nInd + 1])) ; + bOk = ( nCurrId != GDB_ID_NULL && nCurrId1 != GDB_ID_NULL) ; + if ( bOk) { + nFirstId = nCurrId1 ; + nCount = 2 ; + } + } + } + } + + ExeSetModified() ; + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtTrimmingGetBorders(" + IdToString( nParentId) + "," + + ToString( dLinTol) + "," + + ToString( dAngTol) + ")" ; + sLua += " -- bOk=" + ToString( bOk) + + " -- FirstId=" + ToString( nFirstId) + " CurveCount=" + ToString( nCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return bOk ; +} + +// --------------------------------------------------------------------------- +bool +ExeTrimmingGetFinalBorders( int nParentId, const INTVECTOR& vCrvBezierId, double dLinTol, double dAngTol, + const PNTVECTOR& vBrkPts, double dThick, double dThickTol, + int& nFirstId, int& nCount) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Parametri da restituire + nFirstId = GDB_ID_NULL ; + nCount = 0 ; + + // Recupero il riferimento del gruppo di destinazione + Frame3d frDest ; + bool bOk = ( pGeomDB->GetGlobFrame( nParentId, frDest)) ; + + // Recupero le curve di Bordo approssimate come Bezier + ICRVCOMPOPOVECTOR vCompoBezierEdges ; vCompoBezierEdges.reserve( vCrvBezierId.size()) ; + for ( int nCrv = 0 ; bOk && nCrv < int( vCrvBezierId.size()) ; ++ nCrv) { + const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( vCrvBezierId[nCrv])) ; + bOk = ( pCrv != nullptr && pCrv->IsValid()) ; + if ( bOk) { + PtrOwner pCompoRawEdges( ConvertCurveToComposite( pCrv->Clone())) ; + bOk = ( ! IsNull( pCompoRawEdges) && pCompoRawEdges->IsValid() && + vCompoBezierEdges.emplace_back( Release( pCompoRawEdges))) ; + } + } + + // Converto i punti in coppie di punti ( se dispari l'ultimo viene ignorato) + BIPNTVECTOR vBreakingPts ; vBreakingPts.reserve( int( int( vBrkPts.size()) / 2)) ; + for ( int nPt = 0 ; bOk && nPt < int( vBrkPts.size()) - 1 ; nPt += 2) + vBreakingPts.emplace_back( make_pair( vBrkPts[nPt], vBrkPts[nPt+1])) ; + if ( int( vBrkPts.size()) % 2 != 0) + LOG_INFO( GetCmdLogger(), "Warning in EgtExtractSurfFrChunkLoops : Odd number of breaking points") ; + + // Calcolo le curve di Edge + bOk = bOk && GetTrimmingFinalBorders( vCompoBezierEdges, dLinTol, dAngTol, vBreakingPts, dThick, dThickTol) ; + nCount = int( vCompoBezierEdges.size()) ; + if ( bOk) { + // Scorro i gli Edges ottenuti + for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) { + vCompoBezierEdges[nCrv]->ToLoc( frDest) ; + // Inserisco la curva nel DB Geometrico + int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vCompoBezierEdges[nCrv])) ; + bOk = ( nCurrId != GDB_ID_NULL) ; + if ( nCrv == 0) + nFirstId = nCurrId ; + } + ExeSetModified() ; + } + + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtTrimmingGetFinalEdges(" + IdToString( nParentId) + "," + + ToString( vCrvBezierId) + "," + + ToString( dLinTol) + "," + + ToString( dAngTol) + "," ; + sLua += "{" ; + for ( int nP = 0 ; nP < int( vBrkPts.size()) ; ++ nP) { + sLua += "(" + ToString( vBrkPts[nP].x) + ", " + ToString( vBrkPts[nP].y) + ", " + ToString( vBrkPts[nP].z) + ")" + + ( nP != int( vBrkPts.size()) - 1 ? "," : "") ; + } + sLua += "}" ; + sLua += ToString( dThick) + "," + ToString( dThickTol) + ")" ; + sLua += " -- bOk=" + ToString( bOk) + + " -- FirstId=" + ToString( nFirstId) + " CurveCount=" + ToString( nCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return bOk ; +} + +// --------------------------------------------------------------------------- +int +ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, int nEdge2Id, double dLinTol, + const INTVECTOR& vnLineId) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Aggiusto la tolleranza lineare se necessario + double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ; + + // Recupero il riferimento dei gruppi di destinazione + Frame3d frDest ; + bool bOk = pGeomDB->GetGlobFrame( nParentId, frDest) ; + + // Recupero la prima curva + const ICurve* pCrvEdge1 = GetCurve( pGeomDB->GetGeoObj( nEdge1Id)) ; + bOk = bOk && ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid()) ; + + // Recupero la seconda curva + const ICurve* pCrvEdge2 = GetCurve( pGeomDB->GetGeoObj( nEdge2Id)) ; + bOk = bOk && ( pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ; + + // Se ci sono delle superfici di riferimento + CISURFPVECTOR vpSurf ; vpSurf.reserve( vIds.size()) ; + if ( ! vIds.empty()) { + SURFLOCALVECTOR vSurfL ; vSurfL.reserve( vIds.size()) ; + // Recupero il riferimento della prima superficie + Frame3d frSurf ; + bOk = bOk && ( pGeomDB->GetGlobFrame( vIds[0], frSurf)) ; + // Porto le altre nel riferimento della prima + for ( int nSurf = 0 ; bOk && nSurf < int( vIds.size()) ; ++ nSurf) { + vSurfL.emplace_back( pGeomDB, vIds[nSurf], frSurf) ; + if ( vSurfL.back().Get() == nullptr) { + bOk = false ; + break ; + } + vpSurf.emplace_back( vSurfL.back().Get()) ; + } + } + + // Recupero i punti di sincronizzazione ( se presenti) + BIPNTVECTOR vSyncPoints ; vSyncPoints.reserve( pGeomDB->GetGroupObjs( vnLineId.size())) ; + INTVECTOR vIndPriority ; vIndPriority.reserve( vSyncPoints.size()) ; + INTVECTOR vIndVisible ; vIndVisible.reserve( vSyncPoints.size()) ; + for ( int i = 0 ; bOk && i < int( vnLineId.size()) ; ++ i) { + // Recupero la Curva + const ICurve* pLine = GetCurve( pGeomDB->GetGeoObj( vnLineId[i])) ; + bOk = bOk && ( pLine != nullptr && pLine->IsValid()) ; + if ( bOk) { + Point3d ptStart ; pLine->GetStartPoint( ptStart) ; + Point3d ptEnd ; pLine->GetEndPoint( ptEnd) ; + vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ; + // Verifico se la linea č visibile all'utente + int nStatus = GDB_ST_OFF ; + if ( pGeomDB->GetStatus( vnLineId[i], nStatus) && nStatus == GDB_ST_ON) + vIndVisible.emplace_back( int( vSyncPoints.size() - 1)) ; + // Verifico mediante le Info se la curva č stata modificata o aggiunta ( quindi prioritaria) + DBLVECTOR vdOldCoor ; vdOldCoor.reserve( 6) ; + if ( ! pGeomDB->GetInfo( vnLineId[i], s_sKey_Sync_Coord, vdOldCoor) || + int( vdOldCoor.size()) != 6 || + ! AreSamePointApprox( ptStart, Point3d( vdOldCoor[0], vdOldCoor[1], vdOldCoor[2])) || + ! AreSamePointApprox( ptEnd, Point3d( vdOldCoor[3], vdOldCoor[4], vdOldCoor[5]))) + vIndPriority.emplace_back( int( vSyncPoints.size()) - 1) ; + } + } + + // Recupero la superficie Bezier rigata + PtrOwner pSurfBzRuled ; + if ( bOk) { + pSurfBzRuled.Set( GetTrimmingRuledBezier( vpSurf, pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints, vIndPriority, vIndVisible)) ; + bOk = bOk && ( ! IsNull( pSurfBzRuled) && pSurfBzRuled->IsValid()) ; + } + + // Inserisco la curva nel DB Geometrico + int nSurfBzId = GDB_ID_NULL ; + if ( bOk) { + pSurfBzRuled->ToLoc( frDest) ; + nSurfBzId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSurfBzRuled)) ; + bOk = bOk && ( nSurfBzId != GDB_ID_NULL) ; + } + + ExeSetModified() ; + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtTrimmingGetRuledBezier(" + ToString( nParentId) + "," + + ToString( vIds) + "," + + ToString( nEdge1Id) + "," + + ToString( nEdge2Id) + "," + + ToString( dLinTol) + ")" + + " -- bOk=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + // Restituisco il risultato + return nSurfBzId ; +} + +// --------------------------------------------------------------------------- +bool +ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, double dLinTol, + int& nFirstId, int& nCount) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Se necessario aggiusto le tolleranze + double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ; + + // Recupero il riferimento del gruppo di destinazione + Frame3d frDest ; + bool bOk = ( pGeomDB->GetGlobFrame( nParentId, frDest)) ; + + // Recupero le due Curve di bordo + const ICurve* pCrvEdge1 = GetCurve( pGeomDB->GetGeoObj( nEdge1Id)) ; + const ICurve* pCrvEdge2 = GetCurve( pGeomDB->GetGeoObj( nEdge2Id)) ; + bOk = bOk && ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid() && + pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ; + + // Recupero i punti di sincronizzazione + BIPNTVECTOR vSyncPoints ; + bOk = bOk && GetTrimmingSurfBzSyncPoints( pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints) && + ( ! vSyncPoints.empty()) ; + nCount = int( vSyncPoints.size()) ; + + // Inserisco i tratti di sincronizzazione nel DB Geometrico + for ( int nL = 0 ; nL < int( vSyncPoints.size()) ; ++ nL) { + PtrOwner pLine( CreateCurveLine()) ; + if ( ! IsNull( pLine) && pLine->Set( vSyncPoints[nL].first, vSyncPoints[nL].second)) { + int nLineId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ; + if ( nLineId != GDB_ID_NULL) { + if ( nL == 0) + nFirstId = nLineId ; + // Memorizzo come Info le coordinate dei punti ( per tenere traccia in futuro di modifiche) + DBLVECTOR vdCoordInfo = { vSyncPoints[nL].first.x, vSyncPoints[nL].first.y, vSyncPoints[nL].first.z, + vSyncPoints[nL].second.x, vSyncPoints[nL].second.y, vSyncPoints[nL].second.z} ; + pGeomDB->SetInfo( nLineId, s_sKey_Sync_Coord, vdCoordInfo) ; + } + } + } + + ExeSetModified() ; + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtTrimmingGetSurfBzSyncPoints(" + ToString( nParentId) + "," + + ToString( nEdge1Id) + "," + + ToString( nEdge2Id) + "," + + ToString( dLinTol) + "," + + ToString( nFirstId) + "," + + ToString( nCount) + ")" + + " -- bOk=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +ExeTrimmingSkimSyncPoints( int nEdge1Id, int nEdge2Id, const INTVECTOR& vnLineId, double dLinTol, + double dAngTol, int nMaxInvLine) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Se necessario aggiusto le tolleranze + double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ; + double dMyAngTol = Clamp( dAngTol, 1., 45.) ; + int nMyMaxInvLine = Clamp( nMaxInvLine, 1, 100) ; + + // Recupero le due Curve di bordo + const ICurve* pCrvEdge1 = GetCurve( pGeomDB->GetGeoObj( nEdge1Id)) ; + const ICurve* pCrvEdge2 = GetCurve( pGeomDB->GetGeoObj( nEdge2Id)) ; + bool bOk = ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid() && pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ; + + // Definisco il vettore degli Estremi + BIPNTVECTOR vSyncPoints ; vSyncPoints.reserve( vnLineId.size()) ; + for ( int i = 0 ; bOk && i < int( vnLineId.size()) ; ++ i) { + const ICurve* pLine = GetCurve( pGeomDB->GetGeoObj( vnLineId[i])) ; + bOk = ( pLine != nullptr && pLine->IsValid()) ; + if ( bOk) { + Point3d ptStart, ptEnd ; + bOk = ( pLine->GetStartPoint( ptStart) && pLine->GetEndPoint( ptEnd)) ; + if ( bOk) + vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ; + } + } + + // Scelta di Selezione delle linee di sincronizzazione + // 1) In presenza di Spigoli, vengono sempre visualizzate ( Spigolo definito da tolleranza angolare) + // 2) 1 Curva su 'nMyMaxInvLine' viene mostrata altrimenti + int nInvisibleCount = 0 ; + for ( int nL = 0 ; bOk && nL < int( vSyncPoints.size()) ; ++ nL) { + bool bVisible = false ; + Point3d ptUseless = P_INVALID ; + // Recupero gli Estremi e controllo se sono su uno spigolo tra una delle due curve + double dUS = 0. ; + bOk = bOk && pCrvEdge1->GetParamAtPoint( vSyncPoints[nL].first, dUS, dMyLinTol) ; + if ( bOk) { + Vector3d vtPrev, vtAft ; + bOk = pCrvEdge1->GetPointD1D2( dUS, ICurve::FROM_MINUS, ptUseless, &vtPrev) && + pCrvEdge1->GetPointD1D2( dUS, ICurve::FROM_PLUS, ptUseless, &vtAft) ; + if ( bOk) { + vtPrev.Normalize() ; vtAft.Normalize() ; + bVisible = ( vtPrev * vtAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) ; + if ( ! bVisible) { + double dUE = 0. ; + bOk = bOk && pCrvEdge2->GetParamAtPoint( vSyncPoints[nL].second, dUE, dMyLinTol) ; + bOk = pCrvEdge2->GetPointD1D2( dUE, ICurve::FROM_MINUS, ptUseless, &vtPrev) && + pCrvEdge2->GetPointD1D2( dUE, ICurve::FROM_PLUS, ptUseless, &vtAft) ; + if ( bOk) { + vtPrev.Normalize() ; vtAft.Normalize() ; + bVisible = ( vtPrev * vtAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) ; + } + } + } + if ( bOk) { + // Imposto lo Stato + if ( ! bVisible) + ++ nInvisibleCount ; + if ( nInvisibleCount == nMyMaxInvLine) { + bVisible = true ; + nInvisibleCount = 0 ; + } + pGeomDB->SetStatus( vnLineId[nL], bVisible ? GDB_ST_ON : GDB_ST_OFF) ; + } + } + } + + return bOk ; +} diff --git a/EgtExecutor.vcxproj b/EgtExecutor.vcxproj index 044ba37..0a70be6 100644 --- a/EgtExecutor.vcxproj +++ b/EgtExecutor.vcxproj @@ -297,6 +297,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -324,6 +325,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index b1e895f..e214c45 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -407,6 +407,12 @@ File di origine\LUA + + File di origine\LUA + + + File di origine\EXE + File di origine\EXE diff --git a/LUA.h b/LUA.h index 3a56eaf..6a8e333 100644 --- a/LUA.h +++ b/LUA.h @@ -141,3 +141,5 @@ bool LuaInstallRedis( LuaMgr& luaMgr) ; //-------------------------- Base64 ------------------------------------------ bool LuaInstallBase64( LuaMgr& luaMgr) ; +//---------------------------------- Trimming ---------------------------------- +bool LuaInstallTrimming( LuaMgr& luaMgr) ; diff --git a/LUA_Base.cpp b/LUA_Base.cpp index fa1e8d4..e512718 100644 --- a/LUA_Base.cpp +++ b/LUA_Base.cpp @@ -194,7 +194,11 @@ LuaInstallEgtFunctions( LuaMgr& LuaMgr) LOG_ERROR( GetLogger(), "Error in LuaInstallBase64 (LuaInstallEgtFunctions)") return false ; } - + if ( ! LuaInstallTrimming( LuaMgr)) { + LOG_ERROR( GetLogger(), "Error in LuaInstallTrimming (LuaInstallEgtFunctions)") + return false ; + } + return true ; } diff --git a/Lua_Trimming.cpp b/Lua_Trimming.cpp new file mode 100644 index 0000000..60cf332 --- /dev/null +++ b/Lua_Trimming.cpp @@ -0,0 +1,304 @@ +//---------------------------------------------------------------------------- +// EgalTech 2025-2025 +//---------------------------------------------------------------------------- +// File : LUA_Trimming.cpp Data : 23.10.25 Versione : 2.7j3 +// Contenuto : Funzioni per le lavorazioni di Trimming. +// +// Modifiche : 23.10.25 RE Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "LUA.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EGnStringUtils.h" + +using namespace std ; + +// ------------------------------------------------------------------------------ +static int +LuaTrimmingAutoSearch( lua_State* L) +{ + // 9 parametri : nParentId, nSurfLayerId, dShapeLinTol, dShapeAngTol, dLinTol, dEdgeLinTol, dAngTol, dAngFaceTol, vsShapes + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nSurfLayerId ; + LuaCheckParam( L, 2, nSurfLayerId) + double dShapeLinTol ; + LuaCheckParam( L, 3, dShapeLinTol) + double dShapeAngTol ; + LuaCheckParam( L, 4, dShapeAngTol) + double dLinTol ; + LuaCheckParam( L, 5, dLinTol) + double dEdgeLinTol ; + LuaCheckParam( L, 6, dEdgeLinTol) + double dAngTol ; + LuaCheckParam( L, 7, dAngTol) + double dAngFaceTol ; + LuaCheckParam( L, 8, dAngFaceTol) + STRVECTOR vsShapes ; + LuaCheckParam( L, 9, vsShapes) + LuaClearStack( L) ; + // Recupero le lavorazioni di Trimming associate + INTVECTOR vOtherFaces ; + bool bOk = ExeTrimmingAutoSearch( nParentId, nSurfLayerId, dShapeLinTol, dShapeAngTol, dLinTol, + dEdgeLinTol, dAngTol, dAngFaceTol, vsShapes) ; + LuaSetParam( L, bOk) ; + return 1 ; +} + +// ------------------------------------------------------------------------------ +static int +LuaTrimmingGetSurfTmFaceAdj( lua_State* L) +{ + // 6 parametri : nSurfId, vTria, vPts, dAngTol, dSize, dSizeTol + int nSurfId ; + LuaCheckParam( L, 1, nSurfId) + INTVECTOR vTria ; + LuaCheckParam( L, 2, vTria) + PNTVECTOR vPts ; + LuaCheckParam( L, 3, vPts) + double dAngTol ; + LuaCheckParam( L, 4, dAngTol) + double dSize ; + LuaCheckParam( L, 5, dSize) + double dSizeTol ; + LuaCheckParam( L, 6, dSizeTol) + LuaClearStack( L) ; + // Recupero le facce adiacenti in tolleranza angolare + INTVECTOR vOtherFaces ; + bool bOk = ExeTrimmingGetSurfTmFaceAdj( nSurfId, vTria, vPts, dAngTol, dSize, dSizeTol, vOtherFaces) ; + LuaSetParam( L, bOk) ; + if ( bOk) + LuaSetParam( L, vOtherFaces) ; + else + LuaSetParam( L) ; + return 2 ; +} + +// ------------------------------------------------------------------------------ +static int +LuaTrimmingGetSurfTmFromStmFaces( lua_State* L) +{ + // 3 Parametri : nParentId, nSurfId, vFaces + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nSurfId ; + LuaCheckParam( L, 2, nSurfId) + INTVECTOR vFaces ; + LuaCheckParam( L, 3, vFaces) + LuaClearStack( L) ; + int nNewSurfId = ExeTrimmingGetSurfTmFromStmFaces( nParentId, nSurfId, vFaces) ; + LuaSetParam( L, nNewSurfId) ; + return 1 ; +} + +// ------------------------------------------------------------------------------ +static int +LuaTrimmingGetAdjSurfs( lua_State* L) +{ + // 5 parametri : nRefSfrId, vAllSurfId, dLinTol, dAngTol, dAngFaceTol + INTVECTOR vRefSurfId ; + LuaCheckParam( L, 1, vRefSurfId) + INTVECTOR vOtherSurfId ; + LuaCheckParam( L, 2, vOtherSurfId) + double dLinTol ; + LuaCheckParam( L, 3, dLinTol) + double dAngTol ; + LuaCheckParam( L, 4, dAngTol) + double dAngFaceTol ; + LuaCheckParam( L, 5, dAngFaceTol) + LuaClearStack( L) ; + // Calcolo le facce adiacenti per tolleranza + INTVECTOR vOtherSurf ; + bool bOk = ExeTrimmingGetAdjSurfs( vRefSurfId, vOtherSurfId, dLinTol, dAngTol, dAngFaceTol, vOtherSurf) ; + // Restituisco il risultato + LuaSetParam( L, bOk) ; + LuaSetParam( L, vOtherSurf) ; + return 2 ; +} + +// ------------------------------------------------------------------------------- +static int +LuaTrimmingGetBorders( lua_State* L) +{ + // 4 parametri : nParentId, vIds, dLinTol, dAngTol + int nParentId ; + LuaCheckParam( L, 1, nParentId) + SELVECTOR vIds ; + LuaCheckParam( L, 2, vIds) + double dLinTol ; + LuaCheckParam( L, 3, dLinTol) + double dAngTol ; + LuaCheckParam( L, 4, dAngTol) + LuaClearStack( L) ; + // Creo le curve di Edge grezze + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + bool bOk = ExeTrimmingGetBorders( nParentId, vIds, dLinTol, dAngTol, nFirstId, nCount) ; + LuaSetParam( L, bOk) ; + LuaSetParam( L, nFirstId) ; + LuaSetParam( L, nCount) ; + return 3 ; +} + +// ------------------------------------------------------------------------------- +static int +LuaTrimmingGetBordersByNormals( lua_State* L) +{ + // 5 o 6 parametri : nParentId, vIds, dLinTol, dAngTol, dThickness [, ptNear] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + SELVECTOR vIds ; + LuaCheckParam( L, 2, vIds) + double dLinTol ; + LuaCheckParam( L, 3, dLinTol) + double dAngTol ; + LuaCheckParam( L, 4, dAngTol) + double dThickness ; + LuaCheckParam( L, 5, dThickness) + Point3d ptNear = P_INVALID ; + LuaGetParam( L, 6, ptNear) ; + LuaClearStack( L) ; + // Creo le curve di Edge grezze + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + bool bOk = ExeTrimmingGetBordersByNormals( nParentId, vIds, dLinTol, dAngTol, dThickness, ptNear, nFirstId, nCount) ; + LuaSetParam( L, bOk) ; + LuaSetParam( L, nFirstId) ; + LuaSetParam( L, nCount) ; + return 3 ; +} + +// ------------------------------------------------------------------------------- +static int +LuaTrimmingGetFinalBorders( lua_State* L) +{ + // 4 o 5 o 6 o 7 parametri : nParentId, vCrvBezierId, dLinTol, dAngTol [,vBreakingPts] [,dThick] [,dThickTol] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + INTVECTOR vCrvBezierId ; + LuaCheckParam( L, 2, vCrvBezierId) + double dLinTol ; + LuaCheckParam( L, 3, dLinTol) + double dAngTol ; + LuaCheckParam( L, 4, dAngTol) + PNTVECTOR vBreakingPts ; + double dThick = 0., dThickTol = EPS_SMALL ; + int nInd = 5 ; + if ( LuaGetParam( L, nInd, vBreakingPts)) + ++ nInd ; + if ( LuaGetParam( L, nInd, dThick)) { + if ( ! LuaGetParam( L, nInd + 1, dThickTol)) { + LuaClearStack( L) ; + LuaSetParam( L, false) ; + return 1 ; + } + } + LuaClearStack( L) ; + // Creo le curve Edges + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + bool bOk = ExeTrimmingGetFinalBorders( nParentId, vCrvBezierId, dLinTol, dAngTol, vBreakingPts, dThick, dThickTol, + nFirstId, nCount) ; + LuaSetParam( L, bOk) ; + LuaSetParam( L, nFirstId) ; + LuaSetParam( L, nCount) ; + return 3 ; +} + +//------------------------------------------------------------------------------- +static int +LuaTrimmingGetRuledBezier( lua_State* L) +{ + // 5 o 6 parametri : nParentId, vIds, nEdge1Id, nEdge2Id, dLinTol [,vnLineId] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + INTVECTOR vIds ; + LuaCheckParam( L, 2, vIds) ; // serve per orientare la superficie rigata ( Ids delle superfici) + int nEdge1Id ; + LuaCheckParam( L, 3, nEdge1Id) + int nEdge2Id ; + LuaCheckParam( L, 4, nEdge2Id) + double dLinTol ; + LuaCheckParam( L, 5, dLinTol) + INTVECTOR vnLineId ; + LuaGetParam( L, 6, vnLineId) ; + LuaClearStack( L) ; + // Calcolo la superficie di Bezier rigata + int nId = ExeTrimmingGetRuledBezier( nParentId, vIds, nEdge1Id, nEdge2Id, dLinTol, vnLineId) ; + LuaSetParam( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaTrimmingGetSurfBzSyncPoints( lua_State* L) +{ + // 4 parametri : nParentId, nEdge1Id, nEdge2Id, dLinTol + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nEdge1Id ; + LuaCheckParam( L, 2, nEdge1Id) + int nEdge2Id ; + LuaCheckParam( L, 3, nEdge2Id) + double dLinTol ; + LuaCheckParam( L, 4, dLinTol) + LuaClearStack( L) ; + // Inserisco i tratti lineari associati ai punti di sincronizzazione + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + bool bOk = ExeTrimmingGetSurfBzSyncPoints( nParentId, nEdge1Id, nEdge2Id, dLinTol, nFirstId, nCount) ; + LuaSetParam( L, bOk) ; + LuaSetParam( L, nFirstId) ; + LuaSetParam( L, nCount) ; + return 3 ; +} + +// ------------------------------------------------------------------------------ +static int +LuaTrimmingSkimSyncPoints( lua_State* L) +{ + // 5 o 6 parametri : nEdge1Id, nEdge2Id, vnLineId, dLinTol, dAngTol [,nMaxInvLine] + int nEdge1Id ; + LuaCheckParam( L, 1, nEdge1Id) + int nEdge2Id ; + LuaCheckParam( L, 2, nEdge2Id) + INTVECTOR vnLineId ; + LuaCheckParam( L, 3, vnLineId) + double dLinTol ; + LuaCheckParam( L, 4, dLinTol) + double dAngTol ; + LuaCheckParam( L, 5, dAngTol) + int nMaxInvLine = 4 ; + LuaGetParam( L, 6, nMaxInvLine) ; + LuaClearStack( L) ; + // Nascondo/Visualizzo i tratti lineari di sincronizzazione + bool bOk = ExeTrimmingSkimSyncPoints( nEdge1Id, nEdge2Id, vnLineId, dLinTol, dAngTol, nMaxInvLine) ; + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +bool +LuaInstallTrimming( LuaMgr& luaMgr) +{ + bool bOk = ( &luaMgr != nullptr) ; + // --- + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingAutoSearch", LuaTrimmingAutoSearch) ; + // --- + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfTmFaceAdj", LuaTrimmingGetSurfTmFaceAdj) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfTmFromStmFaces", LuaTrimmingGetSurfTmFromStmFaces) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetAdjSurfs", LuaTrimmingGetAdjSurfs) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetBorders", LuaTrimmingGetBorders) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetBordersByNormals", LuaTrimmingGetBordersByNormals) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetFinalBorders", LuaTrimmingGetFinalBorders) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetRuledBezier", LuaTrimmingGetRuledBezier) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfBzSyncPoints", LuaTrimmingGetSurfBzSyncPoints) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingSkimSyncPoints", LuaTrimmingSkimSyncPoints) ; + return bOk ; +} \ No newline at end of file From fb188d566e94b6e7c9523aff8df78051d58294e7 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 7 Jan 2026 09:23:32 +0100 Subject: [PATCH 04/54] EgtExecutor : - piccole correzioni. --- EXE_Trimming.cpp | 43 +++++++++++++++++++++++-------------------- Lua_Trimming.cpp | 5 +++-- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index c7f3cea..ca78893 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -40,7 +40,7 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // Se non ho geometrie da ricercare, non faccio nulla if ( vsShapes.empty()) @@ -147,7 +147,7 @@ ExeTrimmingGetSurfTmFaceAdj( int nSurfId, const INTVECTOR& vTria, const PNTVECTO { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // Recupero la superficie TriMesh const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfId)) ; @@ -248,7 +248,7 @@ ExeTrimmingGetAdjSurfs( const INTVECTOR& vSurfId, const INTVECTOR& vOtherSurfId, { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // Recupero le superfici di Riferimento CISURFPVECTOR vRefSurf ; vRefSurf.reserve( vSurfId.size()) ; @@ -282,9 +282,9 @@ ExeTrimmingGetAdjSurfs( const INTVECTOR& vSurfId, const INTVECTOR& vOtherSurfId, ExeSetModified() ; // Se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtTrimmingGetAdjSurf(" + ToString( vSurfId) + "," + - ToString( vOtherSurfId) + "," + - ToString( dAngTol) + ")" + + string sLua = "EgtTrimmingGetAdjSurfs(" + ToString( vSurfId) + "," + + ToString( vOtherSurfId) + "," + + ToString( dAngTol) + ")" + " -- bOk=" + ToString( bOk) + ",vResId=" + ToString( vResId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -299,7 +299,7 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // Parametri da restituire nFirstId = GDB_ID_NULL ; @@ -331,7 +331,7 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou ++ nSurf ; } // Recupero il vettore di Selezione associato non pił agli Id delle superficie ma alle loro posizioni nel vettore - vector vFaces ; vFaces.reserve( vIds.size()) ; + SELVECTOR vFaces ; vFaces.reserve( vIds.size()) ; for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i) vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ; @@ -377,7 +377,7 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // Parametri da restituire nFirstId = GDB_ID_NULL ; @@ -409,7 +409,7 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi ++ nSurf ; } // Recupero il vettore di Selezione associato non pił agli Id delle superficie ma alle loro posizioni nel vettore - vector vFaces ; vFaces.reserve( vIds.size()) ; + SELVECTOR vFaces ; vFaces.reserve( vIds.size()) ; for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i) vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ; @@ -476,9 +476,9 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi ExeSetModified() ; // Se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtTrimmingGetBorders(" + IdToString( nParentId) + "," + - ToString( dLinTol) + "," + - ToString( dAngTol) + ")" ; + string sLua = "EgtTrimmingGetBordersByNormals(" + IdToString( nParentId) + "," + + ToString( dLinTol) + "," + + ToString( dAngTol) + ")" ; sLua += " -- bOk=" + ToString( bOk) + " -- FirstId=" + ToString( nFirstId) + " CurveCount=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -495,7 +495,7 @@ ExeTrimmingGetFinalBorders( int nParentId, const INTVECTOR& vCrvBezierId, double { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // Parametri da restituire nFirstId = GDB_ID_NULL ; @@ -542,10 +542,10 @@ ExeTrimmingGetFinalBorders( int nParentId, const INTVECTOR& vCrvBezierId, double // Se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtTrimmingGetFinalEdges(" + IdToString( nParentId) + "," + - ToString( vCrvBezierId) + "," + - ToString( dLinTol) + "," + - ToString( dAngTol) + "," ; + string sLua = "EgtTrimmingGetFinalBorders(" + IdToString( nParentId) + "," + + ToString( vCrvBezierId) + "," + + ToString( dLinTol) + "," + + ToString( dAngTol) + "," ; sLua += "{" ; for ( int nP = 0 ; nP < int( vBrkPts.size()) ; ++ nP) { sLua += "(" + ToString( vBrkPts[nP].x) + ", " + ToString( vBrkPts[nP].y) + ", " + ToString( vBrkPts[nP].z) + ")" + @@ -667,7 +667,7 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // Se necessario aggiusto le tolleranze double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ; @@ -727,7 +727,7 @@ ExeTrimmingSkimSyncPoints( int nEdge1Id, int nEdge2Id, const INTVECTOR& vnLineId { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // Se necessario aggiusto le tolleranze double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ; @@ -793,5 +793,8 @@ ExeTrimmingSkimSyncPoints( int nEdge1Id, int nEdge2Id, const INTVECTOR& vnLineId } } + // Se richiesto, salvo il comando Lua equivalente + // ????????????? + return bOk ; } diff --git a/Lua_Trimming.cpp b/Lua_Trimming.cpp index 60cf332..fa2199e 100644 --- a/Lua_Trimming.cpp +++ b/Lua_Trimming.cpp @@ -92,6 +92,7 @@ LuaTrimmingGetSurfTmFromStmFaces( lua_State* L) INTVECTOR vFaces ; LuaCheckParam( L, 3, vFaces) LuaClearStack( L) ; + // Eseguo int nNewSurfId = ExeTrimmingGetSurfTmFromStmFaces( nParentId, nSurfId, vFaces) ; LuaSetParam( L, nNewSurfId) ; return 1 ; @@ -178,7 +179,7 @@ LuaTrimmingGetBordersByNormals( lua_State* L) static int LuaTrimmingGetFinalBorders( lua_State* L) { - // 4 o 5 o 6 o 7 parametri : nParentId, vCrvBezierId, dLinTol, dAngTol [,vBreakingPts] [,dThick] [,dThickTol] + // 4 o 5 o 6 o 7 parametri : nParentId, vCrvBezierId, dLinTol, dAngTol [,vBreakingPts] [,dThick [,dThickTol]] int nParentId ; LuaCheckParam( L, 1, nParentId) INTVECTOR vCrvBezierId ; @@ -188,10 +189,10 @@ LuaTrimmingGetFinalBorders( lua_State* L) double dAngTol ; LuaCheckParam( L, 4, dAngTol) PNTVECTOR vBreakingPts ; - double dThick = 0., dThickTol = EPS_SMALL ; int nInd = 5 ; if ( LuaGetParam( L, nInd, vBreakingPts)) ++ nInd ; + double dThick = 0., dThickTol = EPS_SMALL ; if ( LuaGetParam( L, nInd, dThick)) { if ( ! LuaGetParam( L, nInd + 1, dThickTol)) { LuaClearStack( L) ; From 5a8d472ddfec6b4cfda8666af45f5a41f22f3d2b Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 9 Jan 2026 19:00:36 +0100 Subject: [PATCH 05/54] Executor : - aggiunta funzione lua EraseNonEmptyDirectory. --- LUA_General.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/LUA_General.cpp b/LUA_General.cpp index 59de503..2bb10f9 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -898,6 +898,21 @@ LuaEraseDirectory( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaEraseNonEmptyDirectory( lua_State* L) +{ + // 1 parametro : sDir + string sDir ; + LuaCheckParam( L, 1, sDir) + LuaClearStack( L) ; + // cancello direttorio (deve essere vuoto) + bool bOk = EraseNonEmptyDirectory( sDir) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaTextFileCompare( lua_State* L) @@ -1419,6 +1434,7 @@ LuaInstallGeneral( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtCreateDirectory", LuaCreateDirectory) ; bOk = bOk && luaMgr.RegisterFunction( "EgtEmptyDirectory", LuaEmptyDirectory) ; bOk = bOk && luaMgr.RegisterFunction( "EgtEraseDirectory", LuaEraseDirectory) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtEraseNonEmptyDirectory", LuaEraseNonEmptyDirectory) ; bOk = bOk && luaMgr.RegisterFunction( "EgtTextFileCompare", LuaTextFileCompare) ; bOk = bOk && luaMgr.RegisterFunction( "EgtBinaryFileCompare", LuaBinaryFileCompare) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetStringFromIni", LuaGetStringFromIni) ; From 2aa7669c7b4e0aeacd86d6a9b82af50b6dcf5064 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 15 Jan 2026 11:52:39 +0100 Subject: [PATCH 06/54] EgtExecutor : - aggiunti argomenti alla funzione GetSurfBezierRuledGuided. --- EXE_GdbCreateSurf.cpp | 13 +++++++++++-- LUA_GdbCreateSurf.cpp | 18 ++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 6263180..7e8eaa9 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -2770,7 +2770,8 @@ ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, b //------------------------------------------------------------------------------- int -ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, int nLayGuides, bool bCapEnds, double dLinTol) +ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, int nLayGuides, int nLayNewGuides, + const INTVECTOR& vShown, const INTINTVECTOR& vNewOrEdited, bool bCapEnds, double dLinTol) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -2792,9 +2793,17 @@ ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, int nLayGui vCrv.emplace_back( CrvLocGuide.Get()->Clone()) ; nId = pGeomDB->GetNext( nId) ; } + ICURVEPOVECTOR vNewCrv ; + nId = pGeomDB->GetFirstInGroup( nLayNewGuides) ; + while( nId != GDB_ID_NULL && bOk) { + CurveLocal CrvLocGuide( pGeomDB, nId, frLoc) ; + bOk = bOk && ( CrvLocGuide.Get() != nullptr) ; + vNewCrv.emplace_back( CrvLocGuide.Get()->Clone()) ; + nId = pGeomDB->GetNext( nId) ; + } // calcolo la superficie - PtrOwner pSbz( bOk ? GetSurfBezierRuledGuided( CrvLoc1, CrvLoc2, vCrv, dLinTol) : nullptr) ; + PtrOwner pSbz( bOk ? GetSurfBezierRuledGuided( CrvLoc1, CrvLoc2, vCrv, vNewCrv, vShown, vNewOrEdited, dLinTol) : nullptr) ; bOk = bOk && ! IsNull( pSbz) ; // verifiche per orientamento se con tappi bool bWithCaps = false ; diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 8d6e21d..dce2796 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -1386,7 +1386,7 @@ LuaCreateSurfBzRuled( lua_State* L) static int LuaCreateSurfBzRuledGuided( lua_State* L) { - // 4 o 5 o 6 parametri : ParentId, CrvId1, CrvId2 nLayGuides [, bCapEnds] [, dTol] + // 4 o 5 o 6 parametri : ParentId, CrvId1, CrvId2, nLayGuides, nLayNewGuides, vShown, vNewOrEdited [, bCapEnds] [, dTol] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId1 ; @@ -1395,6 +1395,14 @@ LuaCreateSurfBzRuledGuided( lua_State* L) LuaCheckParam( L, 3, nCrvId2) int nLayGuides ; LuaCheckParam( L, 4, nLayGuides) + int nLayNewGuides ; + LuaCheckParam( L, 5, nLayNewGuides) + INTVECTOR vShown ; + LuaCheckParam( L, 6, vShown) + INTVECTOR vRespectiveOrigCrv ; + LuaCheckParam( L, 7, vRespectiveOrigCrv) + INTVECTOR vNewCrv ; + LuaCheckParam( L, 8, vNewCrv) bool bCapEnds = false ; int nPar = 5 ; if ( LuaGetParam( L, nPar, bCapEnds)) @@ -1402,8 +1410,14 @@ LuaCreateSurfBzRuledGuided( lua_State* L) double dLinTol = LIN_TOL_SRF ; LuaGetParam( L, nPar, dLinTol) ; LuaClearStack( L) ; + // compongo il vettore INTINTVECTOR + INTINTVECTOR vNewOrEdited ; + if( ssize(vRespectiveOrigCrv) != ssize( vNewCrv)) + return 1 ; + for( int i = 0 ; i < ssize(vRespectiveOrigCrv) ; ++i) + vNewOrEdited.emplace_back( vRespectiveOrigCrv[i], vNewCrv[i]) ; // creo una surf bezier come rigata tra le due curve passate, usando le isocurve nel layer nLayIso - int nId = ExeCreateSurfBzRuledGuided( nParentId, nCrvId1, nCrvId2, nLayGuides, bCapEnds, dLinTol) ; + int nId = ExeCreateSurfBzRuledGuided( nParentId, nCrvId1, nCrvId2, nLayGuides, nLayNewGuides, vShown, vNewOrEdited, bCapEnds, dLinTol) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; From 23a46d56cd39bc597a65637ba9bbe46f7d768091 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 15 Jan 2026 11:53:26 +0100 Subject: [PATCH 07/54] EgtExecutor : - aggiunto controllo alla funzione MyCurveCurveInters. --- EXE_GeoInters.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/EXE_GeoInters.cpp b/EXE_GeoInters.cpp index 65bb8c0..2c2d680 100644 --- a/EXE_GeoInters.cpp +++ b/EXE_GeoInters.cpp @@ -1032,6 +1032,9 @@ MyCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int& n CurveLocal Crv1Loc( pGeomDB, nId1, frDest) ; CurveLocal Crv2Loc( pGeomDB, nId2, frDest) ; + if( Crv1Loc.Get() == nullptr || Crv2Loc.Get() == nullptr) + return GDB_ID_NULL ; + // intersezione fra le curve nel piano XY locale IntersCurveCurve intCC( *Crv1Loc, *Crv2Loc, true) ; int nInters = 0 ; From c306967cb228214ca6841e57c499cb3970594a9a Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Mon, 19 Jan 2026 12:33:59 +0100 Subject: [PATCH 08/54] EgtExecutor : - modificata la chiamata alla GetSurfBezierRuledGuided. --- EXE_GdbCreateSurf.cpp | 39 ++++++++++++++++++++++----------------- LUA_GdbCreateSurf.cpp | 24 +++++++++--------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 7e8eaa9..1f1586b 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -2770,8 +2770,8 @@ ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, b //------------------------------------------------------------------------------- int -ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, int nLayGuides, int nLayNewGuides, - const INTVECTOR& vShown, const INTINTVECTOR& vNewOrEdited, bool bCapEnds, double dLinTol) +ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, const BIPNTVECTOR& vGuidesCrv, const INTVECTOR& vShown, + const INTVECTOR& vEdited, const INTVECTOR& vNew, bool bCapEnds, double dLinTol, int nLayGuides) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -2785,25 +2785,30 @@ ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, int nLayGui bOk = bOk && ( CrvLoc1.Get() != nullptr) ; CurveLocal CrvLoc2( pGeomDB, nCrvId2, frLoc) ; bOk = bOk && ( CrvLoc2.Get() != nullptr) ; - ICURVEPOVECTOR vCrv ; - int nId = pGeomDB->GetFirstInGroup( nLayGuides) ; - while( nId != GDB_ID_NULL && bOk) { - CurveLocal CrvLocGuide( pGeomDB, nId, frLoc) ; - bOk = bOk && ( CrvLocGuide.Get() != nullptr) ; - vCrv.emplace_back( CrvLocGuide.Get()->Clone()) ; - nId = pGeomDB->GetNext( nId) ; + BIPNTVECTOR vCrv ; + if( nLayGuides != -1 && vGuidesCrv.empty()) { + int nId = pGeomDB->GetFirstInGroup( nLayGuides) ; + while( nId != GDB_ID_NULL && bOk) { + CurveLocal CrvLocGuide( pGeomDB, nId, frLoc) ; + bOk = bOk && ( CrvLocGuide.Get() != nullptr) ; + const ICurve* pCrv = CrvLocGuide.Get() ; + Point3d ptStart ; pCrv->GetStartPoint( ptStart) ; + ptStart.ToLoc( frLoc) ; + Point3d ptEnd ; pCrv->GetEndPoint( ptEnd) ; + ptEnd.ToLoc( frLoc) ; + vCrv.emplace_back( ptStart, ptEnd) ; + nId = pGeomDB->GetNext( nId) ; + } } - ICURVEPOVECTOR vNewCrv ; - nId = pGeomDB->GetFirstInGroup( nLayNewGuides) ; - while( nId != GDB_ID_NULL && bOk) { - CurveLocal CrvLocGuide( pGeomDB, nId, frLoc) ; - bOk = bOk && ( CrvLocGuide.Get() != nullptr) ; - vNewCrv.emplace_back( CrvLocGuide.Get()->Clone()) ; - nId = pGeomDB->GetNext( nId) ; + else if( ! vGuidesCrv.empty()) { + for( int i = 0 ; i < ssize( vGuidesCrv) ; ++i) + vCrv.emplace_back( GetToLoc( vGuidesCrv[i].first, frLoc), GetToLoc( vGuidesCrv[i].second, frLoc)) ; } + else + return GDB_ID_NULL ; // calcolo la superficie - PtrOwner pSbz( bOk ? GetSurfBezierRuledGuided( CrvLoc1, CrvLoc2, vCrv, vNewCrv, vShown, vNewOrEdited, dLinTol) : nullptr) ; + PtrOwner pSbz( bOk ? GetSurfBezierRuledGuided( CrvLoc1, CrvLoc2, vCrv, vShown, vEdited, vNew, dLinTol) : nullptr) ; bOk = bOk && ! IsNull( pSbz) ; // verifiche per orientamento se con tappi bool bWithCaps = false ; diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index dce2796..2f8cdec 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -1386,7 +1386,7 @@ LuaCreateSurfBzRuled( lua_State* L) static int LuaCreateSurfBzRuledGuided( lua_State* L) { - // 4 o 5 o 6 parametri : ParentId, CrvId1, CrvId2, nLayGuides, nLayNewGuides, vShown, vNewOrEdited [, bCapEnds] [, dTol] + // 7 o 8 o 9 parametri : ParentId, CrvId1, CrvId2, nLayGuides, vShown, vEdited, vNew [, bCapEnds] [, dTol] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId1 ; @@ -1395,14 +1395,12 @@ LuaCreateSurfBzRuledGuided( lua_State* L) LuaCheckParam( L, 3, nCrvId2) int nLayGuides ; LuaCheckParam( L, 4, nLayGuides) - int nLayNewGuides ; - LuaCheckParam( L, 5, nLayNewGuides) INTVECTOR vShown ; - LuaCheckParam( L, 6, vShown) - INTVECTOR vRespectiveOrigCrv ; - LuaCheckParam( L, 7, vRespectiveOrigCrv) - INTVECTOR vNewCrv ; - LuaCheckParam( L, 8, vNewCrv) + LuaCheckParam( L, 5, vShown) + INTVECTOR vEdited ; + LuaCheckParam( L, 6, vEdited) + INTVECTOR vNew ; + LuaCheckParam( L, 7, vNew) bool bCapEnds = false ; int nPar = 5 ; if ( LuaGetParam( L, nPar, bCapEnds)) @@ -1410,14 +1408,10 @@ LuaCreateSurfBzRuledGuided( lua_State* L) double dLinTol = LIN_TOL_SRF ; LuaGetParam( L, nPar, dLinTol) ; LuaClearStack( L) ; - // compongo il vettore INTINTVECTOR - INTINTVECTOR vNewOrEdited ; - if( ssize(vRespectiveOrigCrv) != ssize( vNewCrv)) - return 1 ; - for( int i = 0 ; i < ssize(vRespectiveOrigCrv) ; ++i) - vNewOrEdited.emplace_back( vRespectiveOrigCrv[i], vNewCrv[i]) ; + BIPNTVECTOR vGuides ; + // creo una surf bezier come rigata tra le due curve passate, usando le isocurve nel layer nLayIso - int nId = ExeCreateSurfBzRuledGuided( nParentId, nCrvId1, nCrvId2, nLayGuides, nLayNewGuides, vShown, vNewOrEdited, bCapEnds, dLinTol) ; + int nId = ExeCreateSurfBzRuledGuided( nParentId, nCrvId1, nCrvId2, vGuides, vShown, vEdited, vNew, bCapEnds, dLinTol, nLayGuides) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; From 54a1a882decf46d221579623018f86b77f6ba495 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Tue, 20 Jan 2026 17:30:32 +0100 Subject: [PATCH 09/54] EgtExecutor 3.1a2 : - modifiche e migliorie alla funzioni di Trimming. --- EXE_Trimming.cpp | 105 ++++++++++++++++++++++++++++++++--------------- EgtExecutor.rc | Bin 19652 -> 19652 bytes Lua_Trimming.cpp | 26 ++++++------ 3 files changed, 83 insertions(+), 48 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index ca78893..fb3a810 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -50,7 +50,7 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou CISURFPVECTOR vSurfs ; vSurfs.reserve( pGeomDB->GetGroupObjs( nSurfLayerId)) ; int nId = pGeomDB->GetFirstInGroup( nSurfLayerId) ; while ( nId != GDB_ID_NULL) { - // Recupero l'entitą + // Recupero l'entitĆ  const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ; if ( pGeoObj != nullptr) { // Recupero il Tipo @@ -75,11 +75,11 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou bool bOk = GetTrimmingAutoEntities( vSurfs, dShapeLinTol, dShapeAngTol, dLinTol, dEdgeLinTol, dAngTol, dAngFaceTol, vsShapes, matSelSurfMatrix, matCompoBorders, vSurfBz) ; - // Per sicurezza verifico che tutte le entitą siano a dimensione corretta + // Per sicurezza verifico che tutte le entitĆ  siano a dimensione corretta bOk = bOk && ( ssize( matSelSurfMatrix) == ssize( matCompoBorders)) && ( ssize( matSelSurfMatrix) == ssize( vSurfBz)) ; - // Per ogni Entitą ricavata inserisco le Geometrie nel Layer + // Per ogni EntitĆ  ricavata inserisco le Geometrie nel Layer // NB. Ordine di Inserimento : Surf -> Edges -> bezier // Una anomalia nella serie blocca il flusso corrente e passa al successivo int nCount = -1 ; @@ -141,9 +141,9 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou } // --------------------------------------------------------------------------- -bool -ExeTrimmingGetSurfTmFaceAdj( int nSurfId, const INTVECTOR& vTria, const PNTVECTOR& vPts, - double dAngTol, double dSize, double dSizeTol, INTVECTOR& vOtherFaces) +int +ExeTrimmingGetSurfTmFaceAdj( int nParentId, int nSurfId, const INTVECTOR& vTria, const PNTVECTOR& vPts, + double dAngTol, double dSize, double dSizeTol) { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -156,28 +156,32 @@ ExeTrimmingGetSurfTmFaceAdj( int nSurfId, const INTVECTOR& vTria, const PNTVECTO // Verifico che le facce appartengano alla superficie bOk = bOk && ( ! vTria.empty()) ; - // Recupero l'insieme dei triangoli + // Recupero la superficie formata dai triangoli di adiacenza + int nNewSurfId = GDB_ID_NULL ; if ( bOk) { - INTVECTOR vOtherTria ; vOtherTria.reserve( pStm->GetTriangleCount()) ; - bOk = GetTrimmingStmAdjTria( pStm, vTria, vPts, dAngTol, dSize, dSizeTol, vOtherTria) ; - // Per ogni triangolo ricavato, recupero la faccia corrispondente - set setFaces ; - for ( const int& nT : vOtherTria) - setFaces.insert( pStm->GetFacetFromTria( nT)) ; - vOtherFaces.assign( setFaces.begin(), setFaces.end()) ; + PtrOwner pStmAdjFace( CreateSurfTriMesh()) ; + bOk = ( ! IsNull( pStmAdjFace) && pStmAdjFace->AdjustTopology()) ; + bOk = GetTrimmingStmAdjTria( pStm, vTria, vPts, dAngTol, dSize, dSizeTol, pStmAdjFace) ; + bOk = ( ! IsNull( pStmAdjFace) && pStmAdjFace->IsValid() && pStmAdjFace->GetTriangleCount() > 0) ; + // Inserisco la Superficie nel DB geometrico + if ( bOk) { + nNewSurfId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmAdjFace)) ; + bOk = ( nNewSurfId != GDB_ID_NULL) ; + } } ExeSetModified() ; // Se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtTrimmingGetSurfTmFromFaceAdj(" + ToString( nSurfId) + "," + + string sLua = "EgtTrimmingGetSurfTmFromFaceAdj(" + ToString( nParentId) + "," + + ToString( nSurfId) + "," + ToString( vTria) + "," + ToString( dAngTol) + ")" + - " -- bOk=" + ToString( bOk) + "vOtherFaces=" + ToString( vOtherFaces) ; + " nNewSurfId=" + ToString( nNewSurfId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - return bOk ; + return nNewSurfId ; } // --------------------------------------------------------------------------- @@ -330,7 +334,7 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou uMapPos[*nIter] = nSurf ; ++ nSurf ; } - // Recupero il vettore di Selezione associato non pił agli Id delle superficie ma alle loro posizioni nel vettore + // Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore SELVECTOR vFaces ; vFaces.reserve( vIds.size()) ; for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i) vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ; @@ -408,7 +412,7 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi uMapPos[*nIter] = nSurf ; ++ nSurf ; } - // Recupero il vettore di Selezione associato non pił agli Id delle superficie ma alle loro posizioni nel vettore + // Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore SELVECTOR vFaces ; vFaces.reserve( vIds.size()) ; for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i) vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ; @@ -430,9 +434,9 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi nFirstId = nCurrId ; } } - // Se ho un punto di vicinanza, cerco la coppia di curve pił vicina + // Se ho un punto di vicinanza, cerco la coppia di curve più vicina else { - // Se solo una coppia di curve, le inserisco e non ho ambiguitą + // Se solo una coppia di curve, le inserisco e non ho ambiguitĆ  if ( int( vBezierEdges.size()) == 2) { nCount = int( vBezierEdges.size()) ; // Scorro gli Edges ottenuti @@ -445,7 +449,7 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi nFirstId = nCurrId ; } } - // altrimenti cerco la coppia pił vicia + // altrimenti cerco la coppia più vicia else { double dSqMinDist = INFINITO ; int nInd = 0 ; @@ -605,34 +609,58 @@ ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, i // Recupero i punti di sincronizzazione ( se presenti) BIPNTVECTOR vSyncPoints ; vSyncPoints.reserve( pGeomDB->GetGroupObjs( vnLineId.size())) ; - INTVECTOR vIndPriority ; vIndPriority.reserve( vSyncPoints.size()) ; - INTVECTOR vIndVisible ; vIndVisible.reserve( vSyncPoints.size()) ; - for ( int i = 0 ; bOk && i < int( vnLineId.size()) ; ++ i) { + INTVECTOR vnShown ; vnShown.reserve( vSyncPoints.size()) ; + INTVECTOR vnEdited ; vnEdited.reserve( vSyncPoints.size()) ; + INTVECTOR vnNew ; vnNew.reserve( vSyncPoints.size()) ; + for ( int i = 0 ; bOk && i < ssize( vnLineId) ; ++ i) { // Recupero la Curva const ICurve* pLine = GetCurve( pGeomDB->GetGeoObj( vnLineId[i])) ; bOk = bOk && ( pLine != nullptr && pLine->IsValid()) ; if ( bOk) { + // Recupero gli Estremi Point3d ptStart ; pLine->GetStartPoint( ptStart) ; Point3d ptEnd ; pLine->GetEndPoint( ptEnd) ; + // Mi assicuro che gli estremi siano sulle curve di Bordo e orientati correttamente ( nel caso inverto) + double dSqDistS1 = INFINITO ; + if ( ! DistPointCurve( ptStart, *pCrvEdge1).GetSqDist( dSqDistS1)) + continue ; + if ( dSqDistS1 < dLinTol * dLinTol) { + double dSqDistE2 = INFINITO ; + if ( ! DistPointCurve( ptEnd, *pCrvEdge2).GetSqDist( dSqDistE2) || + dSqDistE2 > dLinTol * dLinTol) + continue ; + } + else { + double dSqDistS2 = INFINITO ; + if ( ! DistPointCurve( ptStart, *pCrvEdge2).GetSqDist( dSqDistS2) || + dSqDistS2 > dLinTol * dLinTol) + continue ; + double dSqDistE1 = INFINITO ; + if ( ! DistPointCurve( ptEnd, *pCrvEdge1).GetSqDist( dSqDistE1) || + dSqDistE1 > dLinTol * dLinTol) + continue ; + swap( ptStart, ptEnd) ; + } vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ; - // Verifico se la linea č visibile all'utente + // Verifico se la linea ĆØ visibile all'utente int nStatus = GDB_ST_OFF ; if ( pGeomDB->GetStatus( vnLineId[i], nStatus) && nStatus == GDB_ST_ON) - vIndVisible.emplace_back( int( vSyncPoints.size() - 1)) ; - // Verifico mediante le Info se la curva č stata modificata o aggiunta ( quindi prioritaria) + vnShown.emplace_back( ssize( vSyncPoints) - 1) ; + // Verifico mediante le Info se la curva ĆØ stata modificata o aggiunta DBLVECTOR vdOldCoor ; vdOldCoor.reserve( 6) ; if ( ! pGeomDB->GetInfo( vnLineId[i], s_sKey_Sync_Coord, vdOldCoor) || - int( vdOldCoor.size()) != 6 || - ! AreSamePointApprox( ptStart, Point3d( vdOldCoor[0], vdOldCoor[1], vdOldCoor[2])) || - ! AreSamePointApprox( ptEnd, Point3d( vdOldCoor[3], vdOldCoor[4], vdOldCoor[5]))) - vIndPriority.emplace_back( int( vSyncPoints.size()) - 1) ; + int( vdOldCoor.size()) != 6) + vnNew.emplace_back( ssize( vSyncPoints) - 1) ; + else if ( ! AreSamePointApprox( ptStart, Point3d( vdOldCoor[0], vdOldCoor[1], vdOldCoor[2])) || + ! AreSamePointApprox( ptEnd, Point3d( vdOldCoor[3], vdOldCoor[4], vdOldCoor[5]))) + vnEdited.emplace_back( ssize( vSyncPoints) - 1) ; } } // Recupero la superficie Bezier rigata PtrOwner pSurfBzRuled ; if ( bOk) { - pSurfBzRuled.Set( GetTrimmingRuledBezier( vpSurf, pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints, vIndPriority, vIndVisible)) ; + pSurfBzRuled.Set( GetTrimmingRuledBezier( vpSurf, pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints, vnShown, vnEdited, vnNew)) ; bOk = bOk && ( ! IsNull( pSurfBzRuled) && pSurfBzRuled->IsValid()) ; } @@ -794,7 +822,16 @@ ExeTrimmingSkimSyncPoints( int nEdge1Id, int nEdge2Id, const INTVECTOR& vnLineId } // Se richiesto, salvo il comando Lua equivalente - // ????????????? + if ( IsCmdLog()) { + string sLua = "EgtTrimmingGetSurfBzSyncPoints(" + ToString( nEdge1Id) + "," + + ToString( nEdge2Id) + "," + + ToString( vnLineId) + "," + + ToString( dLinTol) + "," + + ToString( dAngTol) + "," + + ToString( nMaxInvLine) + ")" + + " -- bOk=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } return bOk ; } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 47af36f586ecc81f6aadaf64fb671f8d0892f84c..0dcc65eb86321a195f015c289b40b0f4f4ffe747 100644 GIT binary patch delta 225 zcmX>ylkvz*#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|HJz3DLb#olc z941Di&A-`PnSqoe*K!sx?>N)s4T4pSMw1=6k~jAW*?>e(i-FY$N+HxVD8kglDRC$f oYw_lZF2#(3`CylMf?bvabW!4FLAQ;}n8K4Mx*Xg*!OMgR0F3ZDZ~y=R delta 252 zcmX>ylkvz*#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+g Date: Wed, 21 Jan 2026 18:28:33 +0100 Subject: [PATCH 10/54] EgtExecutor : - in Trimming semplificazione delle funzioni per le curve di sincronizzazione. --- EXE_Trimming.cpp | 213 +++++++++++++++++++++-------------------------- Lua_Trimming.cpp | 35 ++------ 2 files changed, 103 insertions(+), 145 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index fb3a810..7c35ed8 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -29,7 +29,6 @@ using namespace std ; -static string s_sKey_Sync_Coord = "KeyOldCoord" ; static string s_sKey_Auto_Trim = "AutoTrim" ; // --------------------------------------------------------------------------- @@ -609,9 +608,6 @@ ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, i // Recupero i punti di sincronizzazione ( se presenti) BIPNTVECTOR vSyncPoints ; vSyncPoints.reserve( pGeomDB->GetGroupObjs( vnLineId.size())) ; - INTVECTOR vnShown ; vnShown.reserve( vSyncPoints.size()) ; - INTVECTOR vnEdited ; vnEdited.reserve( vSyncPoints.size()) ; - INTVECTOR vnNew ; vnNew.reserve( vSyncPoints.size()) ; for ( int i = 0 ; bOk && i < ssize( vnLineId) ; ++ i) { // Recupero la Curva const ICurve* pLine = GetCurve( pGeomDB->GetGeoObj( vnLineId[i])) ; @@ -642,25 +638,13 @@ ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, i swap( ptStart, ptEnd) ; } vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ; - // Verifico se la linea ĆØ visibile all'utente - int nStatus = GDB_ST_OFF ; - if ( pGeomDB->GetStatus( vnLineId[i], nStatus) && nStatus == GDB_ST_ON) - vnShown.emplace_back( ssize( vSyncPoints) - 1) ; - // Verifico mediante le Info se la curva ĆØ stata modificata o aggiunta - DBLVECTOR vdOldCoor ; vdOldCoor.reserve( 6) ; - if ( ! pGeomDB->GetInfo( vnLineId[i], s_sKey_Sync_Coord, vdOldCoor) || - int( vdOldCoor.size()) != 6) - vnNew.emplace_back( ssize( vSyncPoints) - 1) ; - else if ( ! AreSamePointApprox( ptStart, Point3d( vdOldCoor[0], vdOldCoor[1], vdOldCoor[2])) || - ! AreSamePointApprox( ptEnd, Point3d( vdOldCoor[3], vdOldCoor[4], vdOldCoor[5]))) - vnEdited.emplace_back( ssize( vSyncPoints) - 1) ; } } // Recupero la superficie Bezier rigata PtrOwner pSurfBzRuled ; if ( bOk) { - pSurfBzRuled.Set( GetTrimmingRuledBezier( vpSurf, pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints, vnShown, vnEdited, vnNew)) ; + pSurfBzRuled.Set( GetTrimmingRuledBezier( vpSurf, pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints)) ; bOk = bOk && ( ! IsNull( pSurfBzRuled) && pSurfBzRuled->IsValid()) ; } @@ -691,14 +675,24 @@ ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, i // --------------------------------------------------------------------------- bool ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, double dLinTol, + double dAngTol, int nLineNbr, bool bShowOnCorners, int& nFirstId, int& nCount) { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) + // Imposto i parametri di ritorno + nFirstId = GDB_ID_NULL ; + nCount = 0 ; + + // Se non devo visualizzare alcuna linea, non faccio nulla + if ( nLineNbr <= 0 && ! bShowOnCorners) + return true ; + // Se necessario aggiusto le tolleranze double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ; + double dMyAngTol = Clamp( dAngTol, EPS_ANG_SMALL, ANG_RIGHT) ; // Recupero il riferimento del gruppo di destinazione Frame3d frDest ; @@ -714,20 +708,91 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl BIPNTVECTOR vSyncPoints ; bOk = bOk && GetTrimmingSurfBzSyncPoints( pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints) && ( ! vSyncPoints.empty()) ; - nCount = int( vSyncPoints.size()) ; + int nToTSyncLines = ssize( vSyncPoints) ; - // Inserisco i tratti di sincronizzazione nel DB Geometrico - for ( int nL = 0 ; nL < int( vSyncPoints.size()) ; ++ nL) { - PtrOwner pLine( CreateCurveLine()) ; - if ( ! IsNull( pLine) && pLine->Set( vSyncPoints[nL].first, vSyncPoints[nL].second)) { - int nLineId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ; - if ( nLineId != GDB_ID_NULL) { - if ( nL == 0) - nFirstId = nLineId ; - // Memorizzo come Info le coordinate dei punti ( per tenere traccia in futuro di modifiche) - DBLVECTOR vdCoordInfo = { vSyncPoints[nL].first.x, vSyncPoints[nL].first.y, vSyncPoints[nL].first.z, - vSyncPoints[nL].second.x, vSyncPoints[nL].second.y, vSyncPoints[nL].second.z} ; - pGeomDB->SetInfo( nLineId, s_sKey_Sync_Coord, vdCoordInfo) ; + if ( bOk) { + // Se devo visualizzarne più di quante sono, allora le visualizzo tutte + if ( nLineNbr >= nToTSyncLines) { + for ( int nL = 0 ; bOk && nL < nToTSyncLines ; ++ nL) { + PtrOwner pLine( CreateCurveLine()) ; + bOk = ( ! IsNull( pLine) && pLine->Set( vSyncPoints[nL].first, vSyncPoints[nL].second)) ; + if ( bOk) { + int nLineId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ; + bOk = ( nLineId != GDB_ID_NULL) ; + if ( bOk && nL == 0) + nFirstId = nLineId ; + } + } + nCount = nToTSyncLines ; + } + // Altrimenti devo scremare le curve + else { + // Se voglio visualizzare i Corner + INTSET setInds ; + if ( bShowOnCorners) { + for ( int nL = 0 ; bOk && nL < nToTSyncLines ; ++ nL) { + // Controllo se su uno spigolo della curva + double dU = 0. ; + Vector3d vtTanPrev, vtTanAft ; + Point3d ptUseless ; + bOk = ( pCrvEdge1->GetParamAtPoint( vSyncPoints[nL].first, dU, dMyLinTol) && + pCrvEdge1->GetPointD1D2( dU, ICurve::FROM_MINUS, ptUseless, &vtTanPrev) && + pCrvEdge1->GetPointD1D2( dU, ICurve::FROM_PLUS, ptUseless, &vtTanAft)) ; + if ( ! bOk) + break ; + vtTanPrev.Normalize() ; + vtTanAft.Normalize() ; + if ( vtTanPrev * vtTanAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) { + setInds.insert( nL) ; + continue ; + } + bOk = ( pCrvEdge2->GetParamAtPoint( vSyncPoints[nL].second, dU, dMyLinTol) && + pCrvEdge2->GetPointD1D2( dU, ICurve::FROM_MINUS, ptUseless, &vtTanPrev) && + pCrvEdge2->GetPointD1D2( dU, ICurve::FROM_PLUS, ptUseless, &vtTanAft)) ; + if ( ! bOk) + break ; + vtTanPrev.Normalize() ; + vtTanAft.Normalize() ; + if ( vtTanPrev * vtTanAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) { + setInds.insert( nL) ; + continue ; + } + } + } + // Se devo mostrare alcune Linee -> Algoritmo di Pick_Bresenham + if ( bOk && nLineNbr > 0) { + if ( nLineNbr == 1) + setInds.insert( 0) ; + else { + int nDx = nToTSyncLines - 1 ; + int nDy = nLineNbr - 1 ; + int nErr = 0 ; + int nX = 0 ; + for ( int i = 0 ; i <= nDy ; ++ i) { + setInds.insert( nX) ; + nErr += nDx ; + while ( nErr >= nDy) { + nX += 1 ; + nErr -= nDy ; + } + } + } + } + + // Visualizzo i segmenti lineare di sincronizzazione per ogni indice ricavato + bool bFirst = true ; + for ( auto Iter = setInds.begin() ; bOk && Iter != setInds.end() ; ++ Iter) { + PtrOwner pLine( CreateCurveLine()) ; + bOk = ( ! IsNull( pLine) && pLine->Set( vSyncPoints[*Iter].first, vSyncPoints[*Iter].second)) ; + if ( bOk) { + int nLineId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ; + bOk = ( nLineId != GDB_ID_NULL) ; + if ( bFirst) { + nFirstId = nLineId ; + bFirst = false ; + } + ++ nCount ; + } } } } @@ -747,91 +812,3 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl return bOk ; } - -//---------------------------------------------------------------------------- -bool -ExeTrimmingSkimSyncPoints( int nEdge1Id, int nEdge2Id, const INTVECTOR& vnLineId, double dLinTol, - double dAngTol, int nMaxInvLine) -{ - // Verifica database geometrico - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - - // Se necessario aggiusto le tolleranze - double dMyLinTol = Clamp( dLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ; - double dMyAngTol = Clamp( dAngTol, 1., 45.) ; - int nMyMaxInvLine = Clamp( nMaxInvLine, 1, 100) ; - - // Recupero le due Curve di bordo - const ICurve* pCrvEdge1 = GetCurve( pGeomDB->GetGeoObj( nEdge1Id)) ; - const ICurve* pCrvEdge2 = GetCurve( pGeomDB->GetGeoObj( nEdge2Id)) ; - bool bOk = ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid() && pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ; - - // Definisco il vettore degli Estremi - BIPNTVECTOR vSyncPoints ; vSyncPoints.reserve( vnLineId.size()) ; - for ( int i = 0 ; bOk && i < int( vnLineId.size()) ; ++ i) { - const ICurve* pLine = GetCurve( pGeomDB->GetGeoObj( vnLineId[i])) ; - bOk = ( pLine != nullptr && pLine->IsValid()) ; - if ( bOk) { - Point3d ptStart, ptEnd ; - bOk = ( pLine->GetStartPoint( ptStart) && pLine->GetEndPoint( ptEnd)) ; - if ( bOk) - vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ; - } - } - - // Scelta di Selezione delle linee di sincronizzazione - // 1) In presenza di Spigoli, vengono sempre visualizzate ( Spigolo definito da tolleranza angolare) - // 2) 1 Curva su 'nMyMaxInvLine' viene mostrata altrimenti - int nInvisibleCount = 0 ; - for ( int nL = 0 ; bOk && nL < int( vSyncPoints.size()) ; ++ nL) { - bool bVisible = false ; - Point3d ptUseless = P_INVALID ; - // Recupero gli Estremi e controllo se sono su uno spigolo tra una delle due curve - double dUS = 0. ; - bOk = bOk && pCrvEdge1->GetParamAtPoint( vSyncPoints[nL].first, dUS, dMyLinTol) ; - if ( bOk) { - Vector3d vtPrev, vtAft ; - bOk = pCrvEdge1->GetPointD1D2( dUS, ICurve::FROM_MINUS, ptUseless, &vtPrev) && - pCrvEdge1->GetPointD1D2( dUS, ICurve::FROM_PLUS, ptUseless, &vtAft) ; - if ( bOk) { - vtPrev.Normalize() ; vtAft.Normalize() ; - bVisible = ( vtPrev * vtAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) ; - if ( ! bVisible) { - double dUE = 0. ; - bOk = bOk && pCrvEdge2->GetParamAtPoint( vSyncPoints[nL].second, dUE, dMyLinTol) ; - bOk = pCrvEdge2->GetPointD1D2( dUE, ICurve::FROM_MINUS, ptUseless, &vtPrev) && - pCrvEdge2->GetPointD1D2( dUE, ICurve::FROM_PLUS, ptUseless, &vtAft) ; - if ( bOk) { - vtPrev.Normalize() ; vtAft.Normalize() ; - bVisible = ( vtPrev * vtAft < cos( ( dMyAngTol + EPS_ANG_SMALL) * DEGTORAD)) ; - } - } - } - if ( bOk) { - // Imposto lo Stato - if ( ! bVisible) - ++ nInvisibleCount ; - if ( nInvisibleCount == nMyMaxInvLine) { - bVisible = true ; - nInvisibleCount = 0 ; - } - pGeomDB->SetStatus( vnLineId[nL], bVisible ? GDB_ST_ON : GDB_ST_OFF) ; - } - } - } - - // Se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtTrimmingGetSurfBzSyncPoints(" + ToString( nEdge1Id) + "," + - ToString( nEdge2Id) + "," + - ToString( vnLineId) + "," + - ToString( dLinTol) + "," + - ToString( dAngTol) + "," + - ToString( nMaxInvLine) + ")" + - " -- bOk=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - - return bOk ; -} diff --git a/Lua_Trimming.cpp b/Lua_Trimming.cpp index 7e7ded8..75275a0 100644 --- a/Lua_Trimming.cpp +++ b/Lua_Trimming.cpp @@ -238,7 +238,7 @@ LuaTrimmingGetRuledBezier( lua_State* L) static int LuaTrimmingGetSurfBzSyncPoints( lua_State* L) { - // 4 parametri : nParentId, nEdge1Id, nEdge2Id, dLinTol + // 7 parametri : nParentId, nEdge1Id, nEdge2Id, dLinTol, dAngTol, nLinesNbr, bShowOnCorners int nParentId ; LuaCheckParam( L, 1, nParentId) int nEdge1Id ; @@ -247,41 +247,23 @@ LuaTrimmingGetSurfBzSyncPoints( lua_State* L) LuaCheckParam( L, 3, nEdge2Id) double dLinTol ; LuaCheckParam( L, 4, dLinTol) + double dAngTol ; + LuaCheckParam( L, 5, dAngTol) + int nLineNbr ; + LuaCheckParam( L, 6, nLineNbr) + bool bShowOnCorners ; + LuaCheckParam( L, 7, bShowOnCorners) LuaClearStack( L) ; // Inserisco i tratti lineari associati ai punti di sincronizzazione int nFirstId = GDB_ID_NULL ; int nCount = 0 ; - bool bOk = ExeTrimmingGetSurfBzSyncPoints( nParentId, nEdge1Id, nEdge2Id, dLinTol, nFirstId, nCount) ; + bool bOk = ExeTrimmingGetSurfBzSyncPoints( nParentId, nEdge1Id, nEdge2Id, dLinTol, dAngTol, nLineNbr, bShowOnCorners, nFirstId, nCount) ; LuaSetParam( L, bOk) ; LuaSetParam( L, nFirstId) ; LuaSetParam( L, nCount) ; return 3 ; } -// ------------------------------------------------------------------------------ -static int -LuaTrimmingSkimSyncPoints( lua_State* L) -{ - // 5 o 6 parametri : nEdge1Id, nEdge2Id, vnLineId, dLinTol, dAngTol [,nMaxInvLine] - int nEdge1Id ; - LuaCheckParam( L, 1, nEdge1Id) - int nEdge2Id ; - LuaCheckParam( L, 2, nEdge2Id) - INTVECTOR vnLineId ; - LuaCheckParam( L, 3, vnLineId) - double dLinTol ; - LuaCheckParam( L, 4, dLinTol) - double dAngTol ; - LuaCheckParam( L, 5, dAngTol) - int nMaxInvLine = 4 ; - LuaGetParam( L, 6, nMaxInvLine) ; - LuaClearStack( L) ; - // Nascondo/Visualizzo i tratti lineari di sincronizzazione - bool bOk = ExeTrimmingSkimSyncPoints( nEdge1Id, nEdge2Id, vnLineId, dLinTol, dAngTol, nMaxInvLine) ; - LuaSetParam( L, bOk) ; - return 1 ; -} - //------------------------------------------------------------------------------- bool LuaInstallTrimming( LuaMgr& luaMgr) @@ -298,6 +280,5 @@ LuaInstallTrimming( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetFinalBorders", LuaTrimmingGetFinalBorders) ; bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetRuledBezier", LuaTrimmingGetRuledBezier) ; bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfBzSyncPoints", LuaTrimmingGetSurfBzSyncPoints) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingSkimSyncPoints", LuaTrimmingSkimSyncPoints) ; return bOk ; } \ No newline at end of file From ab3681e2099936fd61c4823f88aa85dfde73be7c Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 22 Jan 2026 11:22:59 +0100 Subject: [PATCH 11/54] EgtExecutor : - modifica alla funzione GetSurfBezierRuledGuided. --- EXE_GdbCreateSurf.cpp | 5 ++--- LUA_GdbCreateSurf.cpp | 10 ++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 1f1586b..6818b3c 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -2770,8 +2770,7 @@ ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, b //------------------------------------------------------------------------------- int -ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, const BIPNTVECTOR& vGuidesCrv, const INTVECTOR& vShown, - const INTVECTOR& vEdited, const INTVECTOR& vNew, bool bCapEnds, double dLinTol, int nLayGuides) +ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, const BIPNTVECTOR& vGuidesCrv, bool bCapEnds, double dLinTol, int nLayGuides) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -2808,7 +2807,7 @@ ExeCreateSurfBzRuledGuided( int nParentId, int nCrvId1, int nCrvId2, const BIPNT return GDB_ID_NULL ; // calcolo la superficie - PtrOwner pSbz( bOk ? GetSurfBezierRuledGuided( CrvLoc1, CrvLoc2, vCrv, vShown, vEdited, vNew, dLinTol) : nullptr) ; + PtrOwner pSbz( bOk ? GetSurfBezierRuledGuided( CrvLoc1, CrvLoc2, vCrv, dLinTol) : nullptr) ; bOk = bOk && ! IsNull( pSbz) ; // verifiche per orientamento se con tappi bool bWithCaps = false ; diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 2f8cdec..4484b51 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -1386,7 +1386,7 @@ LuaCreateSurfBzRuled( lua_State* L) static int LuaCreateSurfBzRuledGuided( lua_State* L) { - // 7 o 8 o 9 parametri : ParentId, CrvId1, CrvId2, nLayGuides, vShown, vEdited, vNew [, bCapEnds] [, dTol] + // 4 o 5 o 6 parametri : ParentId, CrvId1, CrvId2, nLayGuides [, bCapEnds] [, dTol] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId1 ; @@ -1395,12 +1395,6 @@ LuaCreateSurfBzRuledGuided( lua_State* L) LuaCheckParam( L, 3, nCrvId2) int nLayGuides ; LuaCheckParam( L, 4, nLayGuides) - INTVECTOR vShown ; - LuaCheckParam( L, 5, vShown) - INTVECTOR vEdited ; - LuaCheckParam( L, 6, vEdited) - INTVECTOR vNew ; - LuaCheckParam( L, 7, vNew) bool bCapEnds = false ; int nPar = 5 ; if ( LuaGetParam( L, nPar, bCapEnds)) @@ -1411,7 +1405,7 @@ LuaCreateSurfBzRuledGuided( lua_State* L) BIPNTVECTOR vGuides ; // creo una surf bezier come rigata tra le due curve passate, usando le isocurve nel layer nLayIso - int nId = ExeCreateSurfBzRuledGuided( nParentId, nCrvId1, nCrvId2, vGuides, vShown, vEdited, vNew, bCapEnds, dLinTol, nLayGuides) ; + int nId = ExeCreateSurfBzRuledGuided( nParentId, nCrvId1, nCrvId2, vGuides, bCapEnds, dLinTol, nLayGuides) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetParam( L, nId) ; From f2dc3876b0ebb64e0d83d67df86b50719edc1d29 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Thu, 22 Jan 2026 19:25:01 +0100 Subject: [PATCH 12/54] EgtExecutor : - in Trimming piccola miglioria nella scelta delle curve di sincronizzazione da visualizzare. --- EXE_Trimming.cpp | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index 7c35ed8..f034488 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -704,6 +704,9 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl bOk = bOk && ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid() && pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ; + // Verifico che le curve siano entrambe Aperte o entrambe Chiuse + bOk = bOk && ( pCrvEdge1->IsClosed() == pCrvEdge2->IsClosed()) ; + // Recupero i punti di sincronizzazione BIPNTVECTOR vSyncPoints ; bOk = bOk && GetTrimmingSurfBzSyncPoints( pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints) && @@ -761,20 +764,32 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl } // Se devo mostrare alcune Linee -> Algoritmo di Pick_Bresenham if ( bOk && nLineNbr > 0) { - if ( nLineNbr == 1) - setInds.insert( 0) ; - else { - int nDx = nToTSyncLines - 1 ; - int nDy = nLineNbr - 1 ; - int nErr = 0 ; - int nX = 0 ; - for ( int i = 0 ; i <= nDy ; ++ i) { - setInds.insert( nX) ; - nErr += nDx ; - while ( nErr >= nDy) { - nX += 1 ; - nErr -= nDy ; + bool bBothOpen = ( ! pCrvEdge1->IsClosed() && ! pCrvEdge2->IsClosed()) ; + bool bBothClosed = ( ! bBothOpen) ; + int nLastIdx = nToTSyncLines - 1 ; + if ( bBothClosed) { + int nLine = nLineNbr ; + if ( nLine == 1) + setInds.insert( 0) ; + else { + int nMaxIndex = nToTSyncLines - 2 ; + for ( int i = 0 ; i < nLine ; ++ i) { + double dT = double( i) / double( nLine) ; + int nIdx = int( 0.5 + dT * nMaxIndex) ; + setInds.insert( nIdx) ; } + setInds.erase( nLastIdx) ; + } + } + else { + int nInternal = nLineNbr ; + setInds.insert( 0) ; + setInds.insert( nLastIdx) ; + int nMaxIndex = nLastIdx ; + for ( int i = 0; i < nInternal ; ++ i) { + double dT = double( i + 1) / double( nInternal + 1) ; + int nIdx = int( 0.5 + dT * nMaxIndex) ; + setInds.insert( nIdx) ; } } } From e68153fb70bc753da0811008de6976ff6b1209e1 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 23 Jan 2026 10:22:02 +0100 Subject: [PATCH 13/54] =?UTF-8?q?EgtExecutor=20:=20-=20a=20Exe=20e=20lua?= =?UTF-8?q?=20TestSurfaceSurface=20aggiunto=20il=20parametro=20opzionale?= =?UTF-8?q?=20bTestEnclusion=20per=20segnalare=20collisione=20anche=20quan?= =?UTF-8?q?do=20una=20delle=20due=20=C3=A8=20chiusa=20(ovvero=20racchiude?= =?UTF-8?q?=20un=20volume)=20e=20contiene=20l'altra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EXE_TestObjSurface.cpp | 17 +++++++++-------- LUA_TestObjSurface.cpp | 6 ++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/EXE_TestObjSurface.cpp b/EXE_TestObjSurface.cpp index 6389c34..195518f 100644 --- a/EXE_TestObjSurface.cpp +++ b/EXE_TestObjSurface.cpp @@ -242,7 +242,7 @@ MyTestSpheSurfTm( const Point3d& ptCen, double dR, int nSurfTmId, double dSafeDi return -1 ; // porto in locale alla superficie il centro della sfera Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frSurf) ; - // verifico l'a collisione'interferenza + // verifico l'interferenza return ( TestSpheSurfTm( ptCenL, dR, *pStm, dSafeDist) ? 1 : 0) ; } @@ -271,7 +271,7 @@ ExeTestSpheSurface( const Point3d& ptCen, double dR, int nSurfId, double dSafeDi //---------------------------------------------------------------------------- static int -MyTestSurfTmSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist) +MyTestSurfTmSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist, bool bTestEnclosion) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, -1) @@ -288,26 +288,27 @@ MyTestSurfTmSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist) const ISurfTriMesh* pStm2 = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTm2Id)) ; if ( pStm2 == nullptr) return -1 ; - // verifico l'a collisione'interferenza - return ( TestSurfTmSurfTm( *pStm1, *pStm2, dSafeDist) ? 1 : 0) ; + // verifico l'interferenza + return ( TestSurfTmSurfTm( *pStm1, *pStm2, dSafeDist, bTestEnclosion) ? 1 : 0) ; } //---------------------------------------------------------------------------- int -ExeTestSurfaceSurface( int nSurf1Id, int nSurf2Id, double dSafeDist) +ExeTestSurfaceSurface( int nSurf1Id, int nSurf2Id, double dSafeDist, bool bTestEnclosion) { IGeomDB* pGeomDB = GetCurrGeomDB() ; int nRes = -1 ; if ( pGeomDB != nullptr) { if ( pGeomDB->GetGeoType( nSurf1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSurf2Id) == SRF_TRIMESH) - nRes = MyTestSurfTmSurfTm( nSurf1Id, nSurf2Id, dSafeDist) ; - // č da aggiungere il test con le superfici di Bezier + nRes = MyTestSurfTmSurfTm( nSurf1Id, nSurf2Id, dSafeDist, bTestEnclosion) ; + // č da aggiungere il test con le superfici di Bezier } // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtTestSurfaceSurface({" + IdToString( nSurf1Id) + "," + IdToString( nSurf2Id) + "," + - ToString( dSafeDist) + ")" + + ToString( dSafeDist) + "," + + ( bTestEnclosion ? "true" : "false") + ")" + " -- Res=" + ToString( nRes) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/LUA_TestObjSurface.cpp b/LUA_TestObjSurface.cpp index d8b8148..623487a 100644 --- a/LUA_TestObjSurface.cpp +++ b/LUA_TestObjSurface.cpp @@ -169,16 +169,18 @@ LuaTestSpheSurface( lua_State* L) static int LuaTestSurfaceSurface( lua_State* L) { - // 3 parametri : nSurf1Id, nSurf2Id, dSafeDist + // 3 o 4 parametri : nSurf1Id, nSurf2Id, dSafeDist [, bTestEnclusion] int nSurf1Id ; LuaCheckParam( L, 1, nSurf1Id) int nSurf2Id ; LuaCheckParam( L, 2, nSurf2Id) double dSafeDist ; LuaCheckParam( L, 3, dSafeDist) + bool bTestEnclusion = false ; + LuaGetParam( L, 4, bTestEnclusion) ; LuaClearStack( L) ; // eseguo verifica di interferenza - int nRes = ExeTestSurfaceSurface( nSurf1Id, nSurf2Id, dSafeDist) ; + int nRes = ExeTestSurfaceSurface( nSurf1Id, nSurf2Id, dSafeDist, bTestEnclusion) ; // restituisco il risultato if ( nRes >= 0) LuaSetParam( L, ( nRes != 0)) ; From 7cf368e51893a0d379250f2a787e629fd6516da9 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 26 Jan 2026 18:04:19 +0100 Subject: [PATCH 14/54] EgtExecutor : - in Trimming piccole migliorie/correzioni. --- EXE_Trimming.cpp | 19 +++++++++++++------ Lua_Trimming.cpp | 28 ++++++++++++++++++---------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index f034488..5220647 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -297,8 +297,8 @@ ExeTrimmingGetAdjSurfs( const INTVECTOR& vSurfId, const INTVECTOR& vOtherSurfId, // --------------------------------------------------------------------------- bool -ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, double dAngTol, - int& nFirstId, int& nCount) +ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dSurfLinTol, double dSurfAngTol, + double dLinTol, double dAngTol, int& nFirstId, int& nCount) { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -340,7 +340,7 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou // Calcolo le curve di Edge grezze ( quindi i tratti lineari) ICRVCOMPOPOVECTOR vRawEdges ; - bOk = bOk && GetTrimmingRawEdges( vpSurf, vFaces, dLinTol, dAngTol, vRawEdges) && + bOk = bOk && GetTrimmingRawEdges( vpSurf, vFaces, dSurfLinTol, dSurfAngTol, vRawEdges) && ( ! vRawEdges.empty()) ; // Calcolo le curve di Edge approssimate mediante curve di Bezier @@ -363,6 +363,8 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou // Se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtTrimmingGetBorders(" + IdToString( nParentId) + "," + + ToString( dSurfLinTol) + "," + + ToString( dSurfAngTol) + "," + ToString( dLinTol) + "," + ToString( dAngTol) + ")" ; sLua += " -- bOk=" + ToString( bOk) + @@ -375,8 +377,9 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou // --------------------------------------------------------------------------- bool -ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLinTol, - double dAngTol, double dThick, Point3d& ptNear, int& nFirstId, int& nCount) +ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dSurfLinTol, + double dSurfAngTol, double dLinTol, double dAngTol, double dThick, + Point3d& ptNear, int& nFirstId, int& nCount) { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -418,7 +421,7 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi // Calcolo le curve di Edge approssimate mediante curve di Bezier ICRVCOMPOPOVECTOR vBezierEdges ; - bOk = bOk && GetTrimmingFinalBorders( vpSurf, vFaces, dLinTol, dAngTol, dThick, vBezierEdges) ; + bOk = bOk && GetTrimmingFinalBorders( vpSurf, vFaces, dSurfLinTol, dSurfAngTol, dLinTol, dAngTol, dThick, vBezierEdges) ; if ( bOk) { // Se non ho un punto di vicinanza, le inserisco tutte if ( ! ptNear.IsValid()) { @@ -716,7 +719,11 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl if ( bOk) { // Se devo visualizzarne più di quante sono, allora le visualizzo tutte if ( nLineNbr >= nToTSyncLines) { + bool bAllClosed = ( pCrvEdge1->IsClosed() && pCrvEdge2->IsClosed()) ; for ( int nL = 0 ; bOk && nL < nToTSyncLines ; ++ nL) { + // Se ho due curve chiuse, non ripeto l'ultimo tratto di Sync + if ( bAllClosed && nL == nToTSyncLines - 1) + continue ; PtrOwner pLine( CreateCurveLine()) ; bOk = ( ! IsNull( pLine) && pLine->Set( vSyncPoints[nL].first, vSyncPoints[nL].second)) ; if ( bOk) { diff --git a/Lua_Trimming.cpp b/Lua_Trimming.cpp index 75275a0..e63ddd1 100644 --- a/Lua_Trimming.cpp +++ b/Lua_Trimming.cpp @@ -125,20 +125,24 @@ LuaTrimmingGetAdjSurfs( lua_State* L) static int LuaTrimmingGetBorders( lua_State* L) { - // 4 parametri : nParentId, vIds, dLinTol, dAngTol + // 6 parametri : nParentId, vIds, dSurfLinTol, dSurfAngTol, dLinTol, dAngTol int nParentId ; LuaCheckParam( L, 1, nParentId) SELVECTOR vIds ; LuaCheckParam( L, 2, vIds) + double dSurfLinTol ; + LuaCheckParam( L, 3, dSurfLinTol) ; + double dSurfAngTol ; + LuaCheckParam( L, 4, dSurfAngTol) ; double dLinTol ; - LuaCheckParam( L, 3, dLinTol) + LuaCheckParam( L, 5, dLinTol) double dAngTol ; - LuaCheckParam( L, 4, dAngTol) + LuaCheckParam( L, 6, dAngTol) LuaClearStack( L) ; // Creo le curve di Edge grezze int nFirstId = GDB_ID_NULL ; int nCount = 0 ; - bool bOk = ExeTrimmingGetBorders( nParentId, vIds, dLinTol, dAngTol, nFirstId, nCount) ; + bool bOk = ExeTrimmingGetBorders( nParentId, vIds, dSurfLinTol, dSurfAngTol, dLinTol, dAngTol, nFirstId, nCount) ; LuaSetParam( L, bOk) ; LuaSetParam( L, nFirstId) ; LuaSetParam( L, nCount) ; @@ -149,24 +153,28 @@ LuaTrimmingGetBorders( lua_State* L) static int LuaTrimmingGetBordersByNormals( lua_State* L) { - // 5 o 6 parametri : nParentId, vIds, dLinTol, dAngTol, dThickness [, ptNear] + // 7 o 8 parametri : nParentId, vIds, dLinTol, dAngTol, dThickness [, ptNear] int nParentId ; LuaCheckParam( L, 1, nParentId) SELVECTOR vIds ; LuaCheckParam( L, 2, vIds) + double dSurfLinTol ; + LuaCheckParam( L, 3, dSurfLinTol) ; + double dSurfAngTol ; + LuaCheckParam( L, 4, dSurfAngTol) ; double dLinTol ; - LuaCheckParam( L, 3, dLinTol) + LuaCheckParam( L, 5, dLinTol) double dAngTol ; - LuaCheckParam( L, 4, dAngTol) + LuaCheckParam( L, 6, dAngTol) double dThickness ; - LuaCheckParam( L, 5, dThickness) + LuaCheckParam( L, 7, dThickness) Point3d ptNear = P_INVALID ; - LuaGetParam( L, 6, ptNear) ; + LuaGetParam( L, 8, ptNear) ; LuaClearStack( L) ; // Creo le curve di Edge grezze int nFirstId = GDB_ID_NULL ; int nCount = 0 ; - bool bOk = ExeTrimmingGetBordersByNormals( nParentId, vIds, dLinTol, dAngTol, dThickness, ptNear, nFirstId, nCount) ; + bool bOk = ExeTrimmingGetBordersByNormals( nParentId, vIds, dSurfLinTol, dSurfAngTol, dLinTol, dAngTol, dThickness, ptNear, nFirstId, nCount) ; LuaSetParam( L, bOk) ; LuaSetParam( L, nFirstId) ; LuaSetParam( L, nCount) ; From d6c79cbf78ef187614e741bc3dac5009027e4be8 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 2 Feb 2026 10:32:05 +0100 Subject: [PATCH 15/54] EgtExecutor 3.1a3 : - aggiunto a funzioni lua EgtCurveCompoSetTempProp e EgtCurveCompoSetTempParam il parametro opzionale indice (default 0). --- EgtExecutor.rc | Bin 19652 -> 19652 bytes LUA_GdbModifyCurve.cpp | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 0dcc65eb86321a195f015c289b40b0f4f4ffe747..3d2f9991536e151a3d09fc944d736b51184dfc27 100644 GIT binary patch delta 252 zcmX>ylkvz*#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+gylkvz*#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|HJz3DLb#olc z941Di&A-`PnSqoe*K!sx?>N)s4T4pSMw1=6k~jAW*?>e(i-FY$N+HxVD8kglDRC$f oYw_lZF2#(3`CylMf?bvabW!4FLAQ;}n8K4Mx*Xg*!OMgR0F3ZDZ~y=R diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 274c433..8f4edd1 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -933,16 +933,18 @@ LuaRemoveCurveCompoUndercutOnY( lua_State* L) static int LuaCurveCompoSetTempProp( lua_State* L) { - // 3 parametri : Id, nCrv, nProp + // 3 parametri : Id, nCrv, nProp [, nPropInd] int nId ; LuaCheckParam( L, 1, nId) int nCrv ; LuaCheckParam( L, 2, nCrv) int nProp ; LuaCheckParam( L, 3, nProp) + int nPropInd = 0 ; + LuaGetParam( L, 4, nPropInd) ; LuaClearStack( L) ; // imposto sulla curva della composita la proprietą temporanea - bool bOk = ExeCurveCompoSetTempProp( nId, nCrv, nProp) ; + bool bOk = ExeCurveCompoSetTempProp( nId, nCrv, nProp, nPropInd) ; LuaSetParam( L, bOk) ; return 1 ; } @@ -951,16 +953,18 @@ LuaCurveCompoSetTempProp( lua_State* L) static int LuaCurveCompoSetTempParam( lua_State* L) { - // 3 parametri : Id, nCrv, dParam + // 3 parametri : Id, nCrv, dParam [, nParamInd] int nId ; LuaCheckParam( L, 1, nId) int nCrv ; LuaCheckParam( L, 2, nCrv) double dParam ; LuaCheckParam( L, 3, dParam) + int nParamInd = 0 ; + LuaGetParam( L, 4, nParamInd) ; LuaClearStack( L) ; // imposto sulla curva della composita il parametro temporaneo - bool bOk = ExeCurveCompoSetTempParam( nId, nCrv, dParam) ; + bool bOk = ExeCurveCompoSetTempParam( nId, nCrv, dParam, nParamInd) ; LuaSetParam( L, bOk) ; return 1 ; } From 039f261f0cd21f27cd2c17ba13696fb83f1f8f99 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Tue, 3 Feb 2026 17:20:21 +0100 Subject: [PATCH 16/54] EgtExecutor 3.1a4 : - in Trimming aggiunte le funzioni per riconoscimento di fori e asole - in Trimming pulizia del codice. --- EXE_Trimming.cpp | 232 ++++++++++++++++++++--------------------------- EgtExecutor.rc | Bin 19652 -> 19652 bytes Lua_Trimming.cpp | 92 ++++++++----------- 3 files changed, 136 insertions(+), 188 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index 5220647..a94fd40 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -29,28 +29,30 @@ using namespace std ; -static string s_sKey_Auto_Trim = "AutoTrim" ; - // --------------------------------------------------------------------------- bool -ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, double dShapeAngTol, - double dLinTol, double dEdgeLinTol, double dAngTol, double dAngFaceTol, - const STRVECTOR& vsShapes) +ExeTrimmingGetHoleBorder( int nParentId, const INTVECTOR& vSurfIds, const INTVECTOR& vOtherSurfIds, + double dSurfLinTol, double dSurfAngTol, double dEdgeLinTol, double dEdgeAngTol, + double dEdgeThick, int& nFirstId, int& nCount) { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) + // Inizializzo i valori di ritorno + nFirstId = GDB_ID_NULL ; + nCount = 0 ; + // Se non ho geometrie da ricercare, non faccio nulla - if ( vsShapes.empty()) + if ( vSurfIds.empty()) return true ; - // Recupero le superfici presenti nel Layer - CISURFPVECTOR vSurfs ; vSurfs.reserve( pGeomDB->GetGroupObjs( nSurfLayerId)) ; - int nId = pGeomDB->GetFirstInGroup( nSurfLayerId) ; - while ( nId != GDB_ID_NULL) { + // Recupero le superfici da cui estrarre i bordi + CISURFPVECTOR vpSurfs ; vpSurfs.reserve( vSurfIds.size()) ; + for ( int i = 0 ; i < ssize( vSurfIds) ; ++ i) { + int nSurfId = vSurfIds[i] ; // Recupero l'entitĆ  - const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ; + const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nSurfId) ; if ( pGeoObj != nullptr) { // Recupero il Tipo int nType = pGeoObj->GetType() ; @@ -58,81 +60,89 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou // Recupero la superficie const ISurf* pSurf = GetSurf( pGeoObj) ; if ( pSurf != nullptr && pSurf->IsValid()) - vSurfs.emplace_back( pSurf) ; + vpSurfs.emplace_back( pSurf) ; } } - nId = pGeomDB->GetNext( nId) ; } // Se non ho superfici non faccio nulla - if ( vSurfs.empty()) + if ( vpSurfs.empty()) return false ; - // Recupero Le Superfici Selezionate, Le Curve e Le Bezier rigate - ISURFPOMATRIX matSelSurfMatrix ; - ICRVCOMPOPOMATRIX matCompoBorders ; - ISURFBEZPOVECTOR vSurfBz ; - bool bOk = GetTrimmingAutoEntities( vSurfs, dShapeLinTol, dShapeAngTol, dLinTol, dEdgeLinTol, dAngTol, dAngFaceTol, vsShapes, - matSelSurfMatrix, matCompoBorders, vSurfBz) ; - - // Per sicurezza verifico che tutte le entitĆ  siano a dimensione corretta - bOk = bOk && ( ssize( matSelSurfMatrix) == ssize( matCompoBorders)) && - ( ssize( matSelSurfMatrix) == ssize( vSurfBz)) ; - - // Per ogni EntitĆ  ricavata inserisco le Geometrie nel Layer - // NB. Ordine di Inserimento : Surf -> Edges -> bezier - // Una anomalia nella serie blocca il flusso corrente e passa al successivo - int nCount = -1 ; - for ( int i = 0 ; bOk && i < int( matSelSurfMatrix.size()) ; ++ i) { - // Verifico che la Superficie sia Valida - bool bOkEntity = true ; - for ( int j = 0 ; bOkEntity && j < ssize( matSelSurfMatrix[i]) ; ++ j) - bOkEntity = ( ! IsNull( matSelSurfMatrix[i][j]) && matSelSurfMatrix[i][j]->IsValid()) ; - if ( ! bOkEntity) - continue ; // anomalia serie livello superfici di selezione - for ( int j = 0 ; bOk && j < ssize( matSelSurfMatrix[i]) ; ++ j) { - int nSurfId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( matSelSurfMatrix[i][j])) ; - bOk = ( ( nSurfId != GDB_ID_NULL) && - ( pGeomDB->SetInfo( nSurfId, s_sKey_Auto_Trim, ToString( ++ nCount)))) ; + // Calcolo il Centroide delle superfici complessive + Point3d ptRef = P_INVALID ; + if ( ! vOtherSurfIds.empty()) { + int nToTSurf = 0 ; + for ( const int& nOtherSurfId : vOtherSurfIds) { + // Recupero l'entitĆ  + const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nOtherSurfId) ; + if ( pGeoObj != nullptr) { + // Recupero il Tipo + int nType = pGeoObj->GetType() ; + if ( nType == SRF_TRIMESH || nType == SRF_BEZIER) { + // Recupero la superficie + const ISurf* pSurf = GetSurf( pGeoObj) ; + if ( pSurf != nullptr && pSurf->IsValid()) { + // Recupero il Centroide + Point3d ptCentroid ; + pSurf->GetCentroid( ptCentroid) ; + if ( ! ptRef.IsValid()) + ptRef = ptCentroid ; + else + ptRef += ptCentroid ; + ++ nToTSurf ; + } + } + } } - if ( ! bOk) - break ; // anomalia bloccante - // Verifico che Le Curve di Edges ( Bezier ) siano Valide - for ( int j = 0 ; bOkEntity && j < ssize( matCompoBorders[i]) ; ++ j) - bOkEntity = ( ! IsNull( matCompoBorders[i][j]) && matCompoBorders[i][j]->IsValid()) ; - if ( ! bOkEntity) - continue ; // anomalia serie livello curve di bordo - for ( int j = 0 ; bOk && j < ssize( matCompoBorders[i]) ; ++ j) { - int nCrvId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( matCompoBorders[i][j])) ; - bOk = ( ( nCrvId != GDB_ID_NULL) && - ( pGeomDB->SetInfo( nCrvId, s_sKey_Auto_Trim, ToString( nCount)))) ; + if ( nToTSurf > 0) { + for ( const ISurf* pSurf : vpSurfs) { + Point3d ptCentroid ; + pSurf->GetCentroid( ptCentroid) ; + if ( ! ptRef.IsValid()) + ptRef = ptCentroid ; + else + ptRef += ptCentroid ; + ++ nToTSurf ; + } + ptRef /= nToTSurf ; + } + } + + // Recupero i Bordi per fori ed asole + ICRVCOMPOPOVECTOR vHoleBorders ; + bool bOk = GetTrimmingHoleBorders( vpSurfs, ptRef, dSurfLinTol, dSurfAngTol, dEdgeLinTol, dEdgeAngTol, + dEdgeThick, vHoleBorders) ; + if ( bOk) { + // Inserisco le curve nel DB e imposto i parametri di ritorno + bool bFirst = true ; + for ( int i = 0 ; bOk && i < ssize( vHoleBorders) ; ++ i) { + // Verifico che sia valida + if ( ! IsNull( vHoleBorders[i]) && vHoleBorders[i]->IsValid()) { + int nCrvId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vHoleBorders[i])) ; + bOk = ( nCrvId != GDB_ID_NULL) ; + if ( bOk) { + ++ nCount ; + if ( bFirst) { + nFirstId = nCrvId ; + bFirst = false ; + } + } + } } - if ( ! bOk) - break ; // anomalia bloccante - // Verifico che le Superfici di Bezier rigate siano Valide - bOkEntity = ( ! IsNull( vSurfBz[i]) && vSurfBz[i]->IsValid()) ; - if ( ! bOkEntity) - continue ; // anomalia seria livello Bezier Rigata - int nBzId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vSurfBz[i])) ; - bOk = ( ( nBzId != GDB_ID_NULL) && - ( pGeomDB->SetInfo( nBzId, s_sKey_Auto_Trim, ToString( nCount)))) ; - if ( ! bOk) - break ; // anomali bloccante } ExeSetModified() ; - // Se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtTrimmingAutoSearch(" + ToString( nParentId) + "," + - ToString( nSurfLayerId) + "," + - ToString( dShapeLinTol) + "," + - ToString( dShapeAngTol) + "," + - ToString( dLinTol) + "," + - ToString( dEdgeLinTol) + "," + - ToString( dAngTol) + "," + - ToString( dAngFaceTol) + "," + - ToString( vsShapes) + ")" + - " -- bOk=" + ToString( bOk) ; + string sLua = "EgtTrimmingGetHoleBorder(" + ToString( nParentId) + "," + + ToString( vSurfIds) + "," + + ToString( dSurfLinTol) + "," + + ToString( dSurfAngTol) + "," + + ToString( dEdgeLinTol) + "," + + ToString( dEdgeAngTol) + "," + + ToString( dEdgeThick) + ")" + + " bOk=" + ToString( bOk) + + " nNewSurfId=" + ToString( nFirstId) + ", nCount= " + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -141,7 +151,7 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou // --------------------------------------------------------------------------- int -ExeTrimmingGetSurfTmFaceAdj( int nParentId, int nSurfId, const INTVECTOR& vTria, const PNTVECTOR& vPts, +ExeTrimmingGetSurfTmFaceAdj( int nParentId, int nSurfId, int nTria, const Point3d& ptTria, double dAngTol, double dSize, double dSizeTol) { // Verifica database geometrico @@ -152,15 +162,12 @@ ExeTrimmingGetSurfTmFaceAdj( int nParentId, int nSurfId, const INTVECTOR& vTria, const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfId)) ; bool bOk = ( pStm != nullptr && pStm->IsValid()) ; - // Verifico che le facce appartengano alla superficie - bOk = bOk && ( ! vTria.empty()) ; - // Recupero la superficie formata dai triangoli di adiacenza int nNewSurfId = GDB_ID_NULL ; if ( bOk) { PtrOwner pStmAdjFace( CreateSurfTriMesh()) ; bOk = ( ! IsNull( pStmAdjFace) && pStmAdjFace->AdjustTopology()) ; - bOk = GetTrimmingStmAdjTria( pStm, vTria, vPts, dAngTol, dSize, dSizeTol, pStmAdjFace) ; + bOk = GetTrimmingStmAdjTria( pStm, nTria, ptTria, dAngTol, dSize, dSizeTol, pStmAdjFace) ; bOk = ( ! IsNull( pStmAdjFace) && pStmAdjFace->IsValid() && pStmAdjFace->GetTriangleCount() > 0) ; // Inserisco la Superficie nel DB geometrico if ( bOk) { @@ -174,7 +181,10 @@ ExeTrimmingGetSurfTmFaceAdj( int nParentId, int nSurfId, const INTVECTOR& vTria, if ( IsCmdLog()) { string sLua = "EgtTrimmingGetSurfTmFromFaceAdj(" + ToString( nParentId) + "," + ToString( nSurfId) + "," + - ToString( vTria) + "," + + ToString( nTria) + "," + + "{ " + ToString( ptTria.x) + "," + + ToString( ptTria.y) + "," + + ToString( ptTria.z) + "}," + ToString( dAngTol) + ")" + " nNewSurfId=" + ToString( nNewSurfId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -379,7 +389,7 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dSurfLinTol, bool ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dSurfLinTol, double dSurfAngTol, double dLinTol, double dAngTol, double dThick, - Point3d& ptNear, int& nFirstId, int& nCount) + int& nFirstId, int& nCount) { // Verifica database geometrico IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -423,59 +433,15 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dSu ICRVCOMPOPOVECTOR vBezierEdges ; bOk = bOk && GetTrimmingFinalBorders( vpSurf, vFaces, dSurfLinTol, dSurfAngTol, dLinTol, dAngTol, dThick, vBezierEdges) ; if ( bOk) { - // Se non ho un punto di vicinanza, le inserisco tutte - if ( ! ptNear.IsValid()) { - nCount = int( vBezierEdges.size()) ; - // Scorro i gli Edges ottenuti - for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) { - vBezierEdges[nCrv]->ToLoc( frDest) ; - // Inserisco la curva nel DB Geometrico - int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nCrv])) ; - bOk = ( nCurrId != GDB_ID_NULL) ; - if ( nCrv == 0) - nFirstId = nCurrId ; - } - } - // Se ho un punto di vicinanza, cerco la coppia di curve più vicina - else { - // Se solo una coppia di curve, le inserisco e non ho ambiguitĆ  - if ( int( vBezierEdges.size()) == 2) { - nCount = int( vBezierEdges.size()) ; - // Scorro gli Edges ottenuti - for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) { - vBezierEdges[nCrv]->ToLoc( frDest) ; - // Inserisco la curva nel DB Geometrico - int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nCrv])) ; - bOk = ( nCurrId != GDB_ID_NULL) ; - if ( nCrv == 0) - nFirstId = nCurrId ; - } - } - // altrimenti cerco la coppia più vicia - else { - double dSqMinDist = INFINITO ; - int nInd = 0 ; - for ( int i = 0 ; i + 1 < int( vBezierEdges.size()) ; i = i + 2) { - double dSqDist = 0., dSqDist1 = 0. ; - if ( DistPointCurve( ptNear, *vBezierEdges[i]).GetSqDist( dSqDist) && - DistPointCurve( ptNear, *vBezierEdges[i + 1]).GetSqDist( dSqDist1)) { - double dCurrMinSqDist = min( dSqDist, dSqDist1) ; - if ( dCurrMinSqDist < dSqMinDist) { - dSqMinDist = dCurrMinSqDist ; - nInd = i ; - } - } - } - vBezierEdges[nInd]->ToLoc( frDest) ; - vBezierEdges[nInd + 1]->ToLoc( frDest) ; - int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nInd])) ; - int nCurrId1 = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nInd + 1])) ; - bOk = ( nCurrId != GDB_ID_NULL && nCurrId1 != GDB_ID_NULL) ; - if ( bOk) { - nFirstId = nCurrId1 ; - nCount = 2 ; - } - } + nCount = int( vBezierEdges.size()) ; + // Scorro i gli Edges ottenuti + for ( int nCrv = 0 ; bOk && nCrv < nCount ; ++ nCrv) { + vBezierEdges[nCrv]->ToLoc( frDest) ; + // Inserisco la curva nel DB Geometrico + int nCurrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( vBezierEdges[nCrv])) ; + bOk = ( nCurrId != GDB_ID_NULL) ; + if ( nCrv == 0) + nFirstId = nCurrId ; } } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 3d2f9991536e151a3d09fc944d736b51184dfc27..f9952db49c1a3ea3d9ba0c5db95caa245b031329 100644 GIT binary patch delta 225 zcmX>ylkvz*#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|HJz3DLb#olc z941DS&A-`PnSqoe*K!sx?>N)s4T4pSCX*exk~jAW*?>e(i-FY$N+HxVD8kglDRC$f oYw_lZF2#(3`CylMf?bvabW!4FLAQ;}n8K4Mx*Xg*!OMgR0F`(;fB*mh delta 252 zcmX>ylkvz*#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+g Date: Tue, 3 Feb 2026 17:46:42 +0100 Subject: [PATCH 17/54] EgtExecutor : - aggiunta funzione exe/lua GetClEntFeed. --- EXE_MachMgr.cpp | 10 ++++++++++ LUA_MachMgr.cpp | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index 59566fd..7ef0287 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -3090,6 +3090,16 @@ ExeGetClEntIndex( int nEntId, int& nIndex) return pMachMgr->GetClEntIndex( nEntId, nIndex) ; } +//----------------------------------------------------------------------------- +bool +ExeGetClEntFeed( int nEntId, double& dFeed) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) + // recupero la feed + return pMachMgr->GetClEntFeed( nEntId, dFeed) ; +} + //----------------------------------------------------------------------------- bool ExeGetClEntAxesStatus( int nEntId, int& nStatus) diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index 455b1d6..704d215 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -3233,6 +3233,25 @@ LuaGetClEntIndex( lua_State* L) return 1 ; } +//----------------------------------------------------------------------------- +static int +LuaGetClEntFeed( lua_State* L) +{ + // 1 parametro : nEntId + int nEntId ; + LuaGetParam( L, 1, nEntId) ; + LuaClearStack( L) ; + // recupero la feed + double dFeed ; + bool bOk = ExeGetClEntFeed( nEntId, dFeed) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, dFeed) ; + else + LuaSetParam( L) ; + return 1 ; +} + //----------------------------------------------------------------------------- static int LuaGetClEntAxesStatus( lua_State* L) @@ -4629,6 +4648,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntMove", LuaGetClEntMove) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntFlag", LuaGetClEntFlag) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntIndex", LuaGetClEntIndex) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntFeed", LuaGetClEntFeed) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesStatus", LuaGetClEntAxesStatus) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesMask", LuaGetClEntAxesMask) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesVal", LuaGetClEntAxesVal) ; From 50dcd97857a4bd65b36a0396f15e7b5bd58dff95 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 9 Feb 2026 08:25:27 +0100 Subject: [PATCH 18/54] EgtExecutor : - aggiunte info in ProjectCurveOnSurf - piccolo aggiustamento per ricavere curve di sincro da trimming. --- EXE_GdbModifyCurve.cpp | 2 ++ EXE_Trimming.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index e436511..3168f5e 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -2510,6 +2510,8 @@ MyProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, int nDestGrpId, pGeomDB->SetInfo( nNewId, "Ind", nInd ++) ; pGeomDB->SetInfo( nNewId, "Par", Pt5ax.dPar) ; pGeomDB->SetInfo( nNewId, "Flag", Pt5ax.nFlag) ; + pGeomDB->SetInfo( nNewId, "DirU", Pt5ax.vtDirU) ; + pGeomDB->SetInfo( nNewId, "DirV", Pt5ax.vtDirV) ; } return true ; diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index a94fd40..05ca190 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -711,7 +711,7 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl double dU = 0. ; Vector3d vtTanPrev, vtTanAft ; Point3d ptUseless ; - bOk = ( pCrvEdge1->GetParamAtPoint( vSyncPoints[nL].first, dU, dMyLinTol) && + bOk = ( pCrvEdge1->GetParamAtPoint( vSyncPoints[nL].first, dU, 5 * dMyLinTol) && pCrvEdge1->GetPointD1D2( dU, ICurve::FROM_MINUS, ptUseless, &vtTanPrev) && pCrvEdge1->GetPointD1D2( dU, ICurve::FROM_PLUS, ptUseless, &vtTanAft)) ; if ( ! bOk) @@ -722,7 +722,7 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl setInds.insert( nL) ; continue ; } - bOk = ( pCrvEdge2->GetParamAtPoint( vSyncPoints[nL].second, dU, dMyLinTol) && + bOk = ( pCrvEdge2->GetParamAtPoint( vSyncPoints[nL].second, dU, 5 * dMyLinTol) && pCrvEdge2->GetPointD1D2( dU, ICurve::FROM_MINUS, ptUseless, &vtTanPrev) && pCrvEdge2->GetPointD1D2( dU, ICurve::FROM_PLUS, ptUseless, &vtTanAft)) ; if ( ! bOk) From d55f02a7b28181d52919813241fecb5589e6305f Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 9 Feb 2026 14:52:30 +0100 Subject: [PATCH 19/54] EgtExecutor : - in Trimming migliorata la funzione per il calcolo delle curve di sincronizzazione. --- EXE_Trimming.cpp | 64 +++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index 05ca190..863ae27 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -682,32 +682,28 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl ( ! vSyncPoints.empty()) ; int nToTSyncLines = ssize( vSyncPoints) ; + // Ogni punto di sincronizzazione deve avere gli estremi sulle curve di Bordo + for ( int i = 0 ; bOk && i < ssize( vSyncPoints) ; ++ i) { + double dSqDistStart = INFINITO, dSqDistEnd = INFINITO ; + bOk = ( DistPointCurve( vSyncPoints[i].first, *pCrvEdge1).GetSqDist( dSqDistStart) && + dSqDistStart < ( 5. * dMyLinTol) * ( 5. * dMyLinTol) && + DistPointCurve( vSyncPoints[i].second, *pCrvEdge2).GetSqDist( dSqDistEnd) && + dSqDistEnd < ( 5. * dMyLinTol) * ( 5. * dMyLinTol)) ; + } + if ( bOk) { - // Se devo visualizzarne più di quante sono, allora le visualizzo tutte + INTSET setInds ; + // Se devo visualizzare più linee di quante ne ho ricavate, allora le devo visualizzare tutte if ( nLineNbr >= nToTSyncLines) { - bool bAllClosed = ( pCrvEdge1->IsClosed() && pCrvEdge2->IsClosed()) ; - for ( int nL = 0 ; bOk && nL < nToTSyncLines ; ++ nL) { - // Se ho due curve chiuse, non ripeto l'ultimo tratto di Sync - if ( bAllClosed && nL == nToTSyncLines - 1) - continue ; - PtrOwner pLine( CreateCurveLine()) ; - bOk = ( ! IsNull( pLine) && pLine->Set( vSyncPoints[nL].first, vSyncPoints[nL].second)) ; - if ( bOk) { - int nLineId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ; - bOk = ( nLineId != GDB_ID_NULL) ; - if ( bOk && nL == 0) - nFirstId = nLineId ; - } - } - nCount = nToTSyncLines ; + for ( int i = 0 ; i < nToTSyncLines ; ++ i) + setInds.insert( i) ; } - // Altrimenti devo scremare le curve + // Altrimenti else { - // Se voglio visualizzare i Corner - INTSET setInds ; + // Se voglio visualizzare gli Spigoli if ( bShowOnCorners) { for ( int nL = 0 ; bOk && nL < nToTSyncLines ; ++ nL) { - // Controllo se su uno spigolo della curva + // Controllo se punto su spigolo della curva double dU = 0. ; Vector3d vtTanPrev, vtTanAft ; Point3d ptUseless ; @@ -735,7 +731,7 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl } } } - // Se devo mostrare alcune Linee -> Algoritmo di Pick_Bresenham + // Se devo mostrare alcune Linee if ( bOk && nLineNbr > 0) { bool bBothOpen = ( ! pCrvEdge1->IsClosed() && ! pCrvEdge2->IsClosed()) ; bool bBothClosed = ( ! bBothOpen) ; @@ -766,21 +762,21 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl } } } + } - // Visualizzo i segmenti lineare di sincronizzazione per ogni indice ricavato - bool bFirst = true ; - for ( auto Iter = setInds.begin() ; bOk && Iter != setInds.end() ; ++ Iter) { - PtrOwner pLine( CreateCurveLine()) ; - bOk = ( ! IsNull( pLine) && pLine->Set( vSyncPoints[*Iter].first, vSyncPoints[*Iter].second)) ; - if ( bOk) { - int nLineId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ; - bOk = ( nLineId != GDB_ID_NULL) ; - if ( bFirst) { - nFirstId = nLineId ; - bFirst = false ; - } - ++ nCount ; + // Visualizzo i segmenti lineari di sincronizzazione per ogni indice ricavato + bool bFirst = true ; + for ( auto Iter = setInds.begin() ; bOk && Iter != setInds.end() ; ++ Iter) { + PtrOwner pLine( CreateCurveLine()) ; + bOk = ( ! IsNull( pLine) && pLine->Set( vSyncPoints[*Iter].first, vSyncPoints[*Iter].second)) ; + if ( bOk) { + int nLineId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pLine)) ; + bOk = ( nLineId != GDB_ID_NULL) ; + if ( bFirst) { + nFirstId = nLineId ; + bFirst = false ; } + ++ nCount ; } } } From 7bb53a0e3f3427c7ffc0b1efed8ae280b603b147 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Tue, 10 Feb 2026 15:44:43 +0100 Subject: [PATCH 20/54] EgtExecutor : - ripristinata tollerenza corretta. --- EXE_Trimming.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index 863ae27..08bbb4b 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -686,9 +686,9 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl for ( int i = 0 ; bOk && i < ssize( vSyncPoints) ; ++ i) { double dSqDistStart = INFINITO, dSqDistEnd = INFINITO ; bOk = ( DistPointCurve( vSyncPoints[i].first, *pCrvEdge1).GetSqDist( dSqDistStart) && - dSqDistStart < ( 5. * dMyLinTol) * ( 5. * dMyLinTol) && + dSqDistStart < dMyLinTol * dMyLinTol && DistPointCurve( vSyncPoints[i].second, *pCrvEdge2).GetSqDist( dSqDistEnd) && - dSqDistEnd < ( 5. * dMyLinTol) * ( 5. * dMyLinTol)) ; + dSqDistEnd < dMyLinTol * dMyLinTol) ; } if ( bOk) { @@ -707,7 +707,7 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl double dU = 0. ; Vector3d vtTanPrev, vtTanAft ; Point3d ptUseless ; - bOk = ( pCrvEdge1->GetParamAtPoint( vSyncPoints[nL].first, dU, 5 * dMyLinTol) && + bOk = ( pCrvEdge1->GetParamAtPoint( vSyncPoints[nL].first, dU, dMyLinTol) && pCrvEdge1->GetPointD1D2( dU, ICurve::FROM_MINUS, ptUseless, &vtTanPrev) && pCrvEdge1->GetPointD1D2( dU, ICurve::FROM_PLUS, ptUseless, &vtTanAft)) ; if ( ! bOk) @@ -718,7 +718,7 @@ ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, doubl setInds.insert( nL) ; continue ; } - bOk = ( pCrvEdge2->GetParamAtPoint( vSyncPoints[nL].second, dU, 5 * dMyLinTol) && + bOk = ( pCrvEdge2->GetParamAtPoint( vSyncPoints[nL].second, dU, dMyLinTol) && pCrvEdge2->GetPointD1D2( dU, ICurve::FROM_MINUS, ptUseless, &vtTanPrev) && pCrvEdge2->GetPointD1D2( dU, ICurve::FROM_PLUS, ptUseless, &vtTanAft)) ; if ( ! bOk) From 09dd6cc2f75dfcaa9e93819d13ff47b90cdc94e3 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 11 Feb 2026 16:46:25 +0100 Subject: [PATCH 21/54] =?UTF-8?q?EgtExecutor=20:=20-=20aggiunta=20possibil?= =?UTF-8?q?it=C3=A0=20di=20approsimare=20con=20curve=20di=20bezier.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EXE_GdbModifyCurve.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index 3168f5e..ec67214 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -208,7 +208,7 @@ ExeApproxCurve( int nId, int nApprType, double dLinTol, double dMaxSegmLen) // eliminazione di small Z bOk = bOk && pCC->RemoveSmallDefects( 0.5 * dLinTol, ANG_TOL_STD_DEG) ; } - else { // con bi-archi + else if ( nApprType == APP_ARCS) { // con bi-archi PolyArc PA ; double dLinFea = LIN_FEA_STD ; double dAngTol = ANG_TOL_STD_DEG ; @@ -223,6 +223,11 @@ ExeApproxCurve( int nId, int nApprType, double dLinTol, double dMaxSegmLen) // merge di archi identici di biarchi bOk = bOk && pCC->MergeCurves( 0.5 * dLinTol, ANG_TOL_STD_DEG) ; } + else if ( nApprType == APP_CUBIC_BEZIER) { + PtrOwner pCrv( ApproxCurveWithBezier( pCurve, dLinTol)) ; + bOk = bOk && ! IsNull( pCrv) ; + bOk = bOk && pCC->AddCurve( pCrv) ; + } // copio estrusione e spessore Vector3d vtExtr ; if ( bOk && pCurve->GetExtrusion( vtExtr)) From 9d611b80a8c0a66210f6ed7a0f1fc6c63816202d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 19 Feb 2026 10:02:17 +0100 Subject: [PATCH 22/54] EgtExecutor 3.1b1 : - correzioni a recupero nome da nota NcName di Gruppo di Lavoro per generazione e stima. --- EXE_MachMgr.cpp | 12 ++++++++---- EgtExecutor.rc | Bin 19652 -> 19652 bytes 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index 7ef0287..86337f3 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -3272,12 +3272,14 @@ ExeGenerate( const string& sCncFile, const string& sInfo) ReplaceString( sDir, "/", "\\") ; // recupero il nome string sNcName ; - if ( ! ExeGetInfo( ExeGetCurrMachGroup(), GDL_NC_NAME, sNcName)) { + if ( ExeGetInfo( ExeGetCurrMachGroup(), GDL_NC_NAME, sNcName)) + sNcName = GetFileName( sNcName) ; + else { string sCurrMachDir ; pMachMgr->GetCurrMachineDir( sCurrMachDir) ; string sCurrMachName ; pMachMgr->GetCurrMachineName( sCurrMachName) ; string sCurrMachIni = sCurrMachDir + "\\" + sCurrMachName + ".ini" ; string sExt = GetPrivateProfileStringUtf8( "PartProgram", "Extension", ".cnc", sCurrMachIni.c_str()) ; - sNcName = ChangeFileExtension( GetFileTitleEgt( sProjPath), sExt) ; + sNcName = ChangeFileExtension( GetFileName( sProjPath), sExt) ; } // creo la path completa sMyCncFile = sDir + "\\" + sNcName ; @@ -3304,8 +3306,10 @@ ExeEstimate( const string& sEstFile, const string& sInfo) ReplaceString( sDir, "/", "\\") ; // recupero il nome string sEstName ; - if ( ! ExeGetInfo( ExeGetCurrMachGroup(), GDL_NC_NAME, sEstName)) - sEstName = GetFileTitleEgt( sProjPath) ; + if ( ExeGetInfo( ExeGetCurrMachGroup(), GDL_NC_NAME, sEstName)) + sEstName = GetFileName( sEstName) ; + else + sEstName = GetFileName( sProjPath) ; sEstName = ChangeFileExtension( sEstName, ".html") ; // creo la path completa sMyEstFile = sDir + "\\" + sEstName ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index f9952db49c1a3ea3d9ba0c5db95caa245b031329..2906d677eb77995917016ea791254dc899231ff8 100644 GIT binary patch delta 276 zcmX>ylkvz*#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+g>CICZGNJ{_! delta 249 zcmX>ylkvz*#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|HJz3DLb#olc z3?^1X1|0^I&A-{4nVA!T3`efTEO4>oOp`YVR)EAOJ8~s&?h~?r$(qnp+u~MHcxaZW)#c^yVw)#;vAq$6E_RGZDht2o;=az;N}TlCQJZ>q&;{5 From e9f38149ac293fd47c173026976b60eca87bef81 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 19 Feb 2026 16:01:21 +0100 Subject: [PATCH 23/54] EgtExecutor : - piccola correzione. --- EXE_GdbModifyCurve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index ec67214..7ca9129 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -226,7 +226,7 @@ ExeApproxCurve( int nId, int nApprType, double dLinTol, double dMaxSegmLen) else if ( nApprType == APP_CUBIC_BEZIER) { PtrOwner pCrv( ApproxCurveWithBezier( pCurve, dLinTol)) ; bOk = bOk && ! IsNull( pCrv) ; - bOk = bOk && pCC->AddCurve( pCrv) ; + bOk = bOk && pCC->AddCurve( Release( pCrv)) ; } // copio estrusione e spessore Vector3d vtExtr ; From 5723c92e0916bb79a406618fda3cc9925f599a57 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 20 Feb 2026 16:51:40 +0100 Subject: [PATCH 24/54] EgtExecutor 3.1b2 : - in Trimming aggiunte funzioni per interpolazione curve di sincronizzazione - in LUA_GENERAL aggiunto il dialogo di tipo Brush/ColorPicker. --- EXE_Trimming.cpp | 70 ++++++++ EgtExecutor.rc | Bin 19652 -> 19652 bytes LUA_General.cpp | 425 +++++++++++++++++++++++++++++++++-------------- Lua_Trimming.cpp | 32 ++++ 4 files changed, 406 insertions(+), 121 deletions(-) diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index 08bbb4b..c6fe70d 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -641,6 +641,76 @@ ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, i return nSurfBzId ; } +// --------------------------------------------------------------------------- +bool +ExeTrimmingInterpolateSyncLines( int nParentId, int nSync1Id, int nSync2Id, int nBorder1Id, + int nBorder2Id, double dEdgeLinTol, double dEdgeAngTol, + int& nFirstId, int& nCount) +{ + // Verifica database geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + + // Reset parametri di ritorno + nFirstId = GDB_ID_NULL ; + nCount = 0 ; + + // Aggiusto la tolleranza lineare e angolare se necessario + double dMyEdgeLinTol = Clamp( dEdgeLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ; + double dMyEdgeAngTol = Clamp( dEdgeAngTol, EPS_ANG_SMALL, 60.) ; + + // recupero le due curve di sincronizzazione + const ICurve* pSync1 = GetCurve( pGeomDB->GetGeoObj( nSync1Id)) ; + const ICurve* pSync2 = GetCurve( pGeomDB->GetGeoObj( nSync2Id)) ; + bool bOk = ( pSync1 != nullptr && pSync1->IsValid() && + pSync2 != nullptr && pSync2->IsValid()) ; + + // Recupero le due curve di bordo + const ICurve* pCrvEdge1 = GetCurve( pGeomDB->GetGeoObj( nBorder1Id)) ; + const ICurve* pCrvEdge2 = GetCurve( pGeomDB->GetGeoObj( nBorder2Id)) ; + bOk = bOk && ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid()) ; + bOk = bOk && ( pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ; + + // Calcolo le Curve di sincornizzazione Interpolate + BIPNTVECTOR vSyncPoints ; + bOk = bOk && GetTrimmingSyncInterpolation( pCrvEdge1, pCrvEdge2, pSync1, pSync2, dMyEdgeLinTol, + dMyEdgeAngTol, vSyncPoints) ; + if ( bOk && ! vSyncPoints.empty()) { + // Inserisco le curve di sincronizzazione nel DB + // [orientate da pCrvEdge1 a pCrvEdge2] + for ( int i = 0 ; bOk && i < ssize( vSyncPoints) ; ++ i) { + PtrOwner pSyncLine( CreateCurveLine()) ; + bOk = ( ! IsNull( pSyncLine) && pSyncLine->Set( vSyncPoints[i].first, vSyncPoints[i].second)) ; + if ( bOk) { + if ( pCrvEdge1->IsPointOn( vSyncPoints[i].second, dMyEdgeLinTol)) + pSyncLine->Invert() ; + int nSyncId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSyncLine)) ; + bOk = ( nSyncId != CMD_ID_NULL) ; + if ( i == 0) + nFirstId = nSyncId ; + } + } + nCount = ssize( vSyncPoints) ; + } + + ExeSetModified() ; + // Se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtTrimmingInterpolateSyncLines(" + ToString( nParentId) + "," + + ToString( nSync1Id) + "," + + ToString( nSync2Id) + "," + + ToString( nBorder1Id) + "," + + ToString( nBorder2Id) + "," + + ToString( dEdgeLinTol) + "," + + ToString( dEdgeAngTol) + ")" + + " -- bOk=" + ToString( bOk) + + " -- nFirstId=" + ToString( nFirstId) + " nCount=" + ToString( nCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + + return bOk ; +} + // --------------------------------------------------------------------------- bool ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, double dLinTol, diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 2906d677eb77995917016ea791254dc899231ff8..992894ce5496cc20d8e28f06c3afe9d0a068f5f9 100644 GIT binary patch delta 225 zcmX>ylkvz*#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|HJz3DLb#olc z941Di&A-`PnSqoe*K!sx?>N)s4T4pSMw1=6k~jAW*?>e(i-FY$N+HxVD8kglDRC$f oYw_lZF2#(3`CylMf?bvabW!4FLAQ;}n8K4Mx*Xg*!OMgR0F3ZDZ~y=R delta 252 zcmX>ylkvz*#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+g(c))) { + bOk = false; + break ; + } + } + if ( bOk) { + try { + unsigned long hex = stoul( sVal, nullptr, 16) ; + BYTE r = ( hex >> 16) & 0xFF ; + BYTE g = ( hex >> 8) & 0xFF ; + BYTE b = hex & 0xFF ; + g_selectedColor[i] = RGB( r, g, b) ; + } catch (...) {} + } + } + } + + // nascondo qualsiasi tipo di componente ( per sicurezza) + HWND hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT1 + i) ; + if ( hwndEdit) + ShowWindow( hwndEdit, SW_HIDE) ; + HWND hwndCombo = GetDlgItem( hwndDlg, IDC_COMBO1 + i) ; + if ( hwndCombo) + ShowWindow( hwndCombo, SW_HIDE) ; + HWND hwndChk = GetDlgItem( hwndDlg, IDC_CHECK1 + i) ; + if ( hwndChk) + ShowWindow( hwndChk, SW_HIDE) ; + + // margini per dimensione del rettangolo preview pickColor + const int MARGIN_RIGHT = 8 ; // spazio tra preview e bordo destro dialog + const int PREVIEW_HEIGHT = 20 ; // altezza del rettangolo + const int PREVIEW_MIN_WIDTH = 40 ; // larghezza minima + + // ottieni o crea la static preview (allargata fino al bordo destro del dialog) + HWND hwndPreview = GetDlgItem( hwndDlg, IDC_STATIC_PREVIEW + i) ; + RECT rcLabel ; + HWND hwndLabel = GetDlgItem( hwndDlg, IDC_TEXT1 + i) ; + RECT rcClient ; GetClientRect( hwndDlg, &rcClient) ; // coordinate client del dialog + if ( hwndLabel && GetWindowRect( hwndLabel, &rcLabel)) { + // converti rcLabel in coordinate client + POINT ptLabel = { rcLabel.right, rcLabel.top } ; + ScreenToClient( hwndDlg, &ptLabel) ; + int x = ptLabel.x + 8 ; // distanza dal label + int y = ptLabel.y ; + int width = rcClient.right - x - MARGIN_RIGHT ; + if ( width < PREVIEW_MIN_WIDTH) + width = PREVIEW_MIN_WIDTH ; + if ( ! hwndPreview) { + hwndPreview = CreateWindowEx( + 0, L"STATIC", NULL, + WS_CHILD | WS_VISIBLE | SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER, + x, y, width, PREVIEW_HEIGHT, + hwndDlg, ( HMENU)( IDC_STATIC_PREVIEW + i), + GetModuleHandle( NULL), NULL) ; + } + else { + // aggiornamento posizione e dimensione se gią esiste + LONG_PTR style = GetWindowLongPtr( hwndPreview, GWL_STYLE) ; + style |= SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER ; + style &= ~SS_OWNERDRAW ; + SetWindowLongPtr( hwndPreview, GWL_STYLE, style) ; + SetWindowPos( hwndPreview, HWND_TOP, x, y, width, PREVIEW_HEIGHT, SWP_SHOWWINDOW | SWP_FRAMECHANGED) ; + } + // pulizia e aggiornamento brush colori + SetWindowText( hwndPreview, L"") ; + if ( g_hColorBrush[i]) { + DeleteObject( g_hColorBrush[i]) ; + g_hColorBrush[i] = NULL ; + } + g_hColorBrush[i] = CreateSolidBrush( g_selectedColor[i]) ; + // ridisegno + InvalidateRect( hwndPreview, NULL, TRUE) ; + UpdateWindow( hwndPreview) ; + } + // pulizia elementi testuali + if ( hwndPreview) + SetWindowText( hwndPreview, L"") ; + if ( g_hColorBrush[i]) { + DeleteObject( g_hColorBrush[i]) ; + g_hColorBrush[i] = NULL ; + } + // creazione brush di colori + g_hColorBrush[i] = CreateSolidBrush( g_selectedColor[i]) ; + if ( hwndPreview) { + SetWindowPos( hwndPreview, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) ; + InvalidateRect( hwndPreview, NULL, TRUE) ; + UpdateWindow( hwndPreview) ; + } + s_nType[i] = CTRL_COLOR ; + } + else { + SetDlgItemText( hwndDlg, IDC_EDIT1 + i, stringtoW( s_sEdit[i])) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; + s_nType[i] = CTRL_EDIT ; } - ComboBox_SetCurSel( hwndCBox, nSel) ; - ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ; - ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; - s_nType[i] = CTRL_COMBO ; } else { - SetDlgItemText( hwndDlg, IDC_EDIT1 + i, stringtoW( s_sEdit[i])) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_TEXT1 + i), SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ; ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; - s_nType[i] = CTRL_EDIT ; + ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_PREVIEW + i), SW_HIDE) ; + s_nType[i] = CTRL_NONE ; } } - else { - ShowWindow( GetDlgItem( hwndDlg, IDC_TEXT1 + i), SW_HIDE) ; - ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ; - ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; - ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; - s_nType[i] = CTRL_NONE ; + break ; + case WM_CTLCOLORSTATIC : + { + HDC hdcStatic = ( HDC)wParam ; + HWND hwndCtrl = ( HWND)lParam ; + int ctrlId = GetDlgCtrlID( hwndCtrl) ; + if ( ctrlId >= IDC_STATIC_PREVIEW && ctrlId < IDC_STATIC_PREVIEW + MAX_CTRLS) { + int idx = ctrlId - IDC_STATIC_PREVIEW ; + if ( g_hColorBrush[idx] == NULL) + g_hColorBrush[idx] = CreateSolidBrush( g_selectedColor[idx]) ; + SetBkMode( hdcStatic, OPAQUE) ; + SetBkColor( hdcStatic, g_selectedColor[idx]) ; + return ( INT_PTR)g_hColorBrush[idx] ; + } + } + case WM_COMMAND : { + int id = LOWORD( wParam) ; + int code = HIWORD( wParam) ; + // comando di Preview per brush di colori mediante click del mouse + if ( code == STN_CLICKED && id >= IDC_STATIC_PREVIEW && id < IDC_STATIC_PREVIEW + MAX_CTRLS) { + int idx = id - IDC_STATIC_PREVIEW ; + HWND hwndPreview = GetDlgItem( hwndDlg, IDC_STATIC_PREVIEW + idx) ; + if ( ! hwndPreview) + return TRUE ; + // apertura ChooseColor (usa hwndDlg come owner) + CHOOSECOLOR cc = {} ; + cc.lStructSize = sizeof( cc) ; + cc.hwndOwner = hwndDlg ; + cc.lpCustColors = g_customColors ; + cc.rgbResult = g_selectedColor[idx] ; + cc.Flags = CC_FULLOPEN | CC_RGBINIT ; + if ( ChooseColor( &cc)) { + g_selectedColor[idx] = cc.rgbResult ; + if ( g_hColorBrush[idx]) { + DeleteObject( g_hColorBrush[idx]) ; + g_hColorBrush[idx] = NULL ; + } + g_hColorBrush[idx] = CreateSolidBrush( g_selectedColor[idx]) ; + InvalidateRect(hwndPreview, NULL, TRUE) ; + UpdateWindow( hwndPreview) ; + } + return TRUE ; + } + + switch ( LOWORD( wParam)) { + case IDOK : + for ( int i = 0 ; i < s_nCtrls ; ++ i) { + AtoWEX<128> wsEdit( "") ; + s_sEdit[i] = "" ; + switch ( s_nType[i]) { + case CTRL_CHECK : + s_sEdit[i] = ( IsDlgButtonChecked( hwndDlg, IDC_CHECK1 + i) == BST_CHECKED ? "1" : "0") ; + break ; + case CTRL_COMBO : + if ( GetDlgItemText( hwndDlg, IDC_COMBO1 + i, LPWSTR( wsEdit), 128) > 0) + s_sEdit[i] = wstrztoA( wsEdit) ; + break ; + case CTRL_EDIT : + if ( GetDlgItemText( hwndDlg, IDC_EDIT1 + i, LPWSTR( wsEdit), 128) > 0) + s_sEdit[i] = wstrztoA( wsEdit) ; + break ; + case CTRL_COLOR : + { + COLORREF col = g_selectedColor[i] ; + BYTE r = GetRValue( col), g = GetGValue( col), b = GetBValue( col) ; + char buf[16] ; + sprintf_s( buf, sizeof( buf), "#%02X%02X%02X", r, g, b) ; + s_sEdit[i] = buf ; + break ; + } + } + } + [[fallthrough]] ; + case IDCANCEL : { + // pulizia brush colori + for ( int i = 0 ; i < MAX_CTRLS ; ++ i) { + if ( g_hColorBrush[i]) { + DeleteObject( g_hColorBrush[i]) ; + g_hColorBrush[i] = NULL ; + } + } + EndDialog( hwndDlg, wParam) ; + return TRUE ; + } } } - break ; - case WM_COMMAND : - switch ( LOWORD( wParam)) { - case IDOK : - for ( int i = 0 ; i < s_nCtrls ; ++ i) { - AtoWEX<128> wsEdit( "") ; - s_sEdit[i] = "" ; - switch ( s_nType[i]) { - case CTRL_CHECK : - s_sEdit[i] = ( IsDlgButtonChecked( hwndDlg, IDC_CHECK1 + i) == BST_CHECKED ? "1" : "0") ; - break ; - case CTRL_COMBO : - if ( GetDlgItemText( hwndDlg, IDC_COMBO1 + i, LPWSTR( wsEdit), 128) > 0) - s_sEdit[i] = wstrztoA( wsEdit) ; - break ; - case CTRL_EDIT : - if ( GetDlgItemText( hwndDlg, IDC_EDIT1 + i, LPWSTR( wsEdit), 128) > 0) - s_sEdit[i] = wstrztoA( wsEdit) ; - break ; - } - } - [[fallthrough]] ; - case IDCANCEL : - EndDialog( hwndDlg, wParam) ; - return TRUE ; - } - } - return FALSE ; -} + } + return FALSE ; +} //------------------------------------------------------------------------------- static int diff --git a/Lua_Trimming.cpp b/Lua_Trimming.cpp index 5c1c769..88214e3 100644 --- a/Lua_Trimming.cpp +++ b/Lua_Trimming.cpp @@ -222,6 +222,37 @@ LuaTrimmingGetRuledBezier( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaTrimmingInterpolateSyncLines( lua_State* L) +{ + // 7 parametri : nParentId, nFirstSyncId, nSecondSyncId, nBorder1Id, nBorder2Id, dEdgeLinTol, dEdgeAngTol + int nParentId ; + LuaCheckParam( L, 1, nParentId) ; + int nSync1Id ; + LuaCheckParam( L, 2, nSync1Id) ; + int nSync2Id ; + LuaCheckParam( L, 3, nSync2Id) ; + int nBorder1Id ; + LuaCheckParam( L, 4, nBorder1Id) ; + int nBorder2Id ; + LuaCheckParam( L, 5, nBorder2Id) ; + double dEdgeLinTol ; + LuaCheckParam( L, 6, dEdgeLinTol) ; + double dEdgeAngTol ; + LuaCheckParam( L, 7, dEdgeAngTol) ; + LuaClearStack( L) ; + // Interpolo le curve di sincronizzazione + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + bool bOk = ExeTrimmingInterpolateSyncLines( nParentId, nSync1Id, nSync2Id, nBorder1Id, + nBorder2Id, dEdgeLinTol, dEdgeAngTol, nFirstId, nCount) ; + LuaSetParam( L, bOk) ; + LuaSetParam( L, nFirstId) ; + LuaSetParam( L, nCount) ; + return 3 ; +} + //------------------------------------------------------------------------------- static int LuaTrimmingGetSurfBzSyncPoints( lua_State* L) @@ -269,6 +300,7 @@ LuaInstallTrimming( LuaMgr& luaMgr) // --- Recupero Surf Bezier Ruled bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetRuledBezier", LuaTrimmingGetRuledBezier) ; // --- Recupero linee di sincronizzazione + bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingInterpolateSyncLines", LuaTrimmingInterpolateSyncLines) ; bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfBzSyncPoints", LuaTrimmingGetSurfBzSyncPoints) ; return bOk ; } \ No newline at end of file From 9611421fbcea8f8f435a977fdd98e4e968e98130 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Mon, 23 Feb 2026 09:47:41 +0100 Subject: [PATCH 25/54] EgtExecutor : - aggiunto flag alla funzione EgtSurfBezierLeaves. --- EXE_GdbCreateSurf.cpp | 4 ++-- LUA_GdbCreateSurf.cpp | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 6818b3c..79015a1 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -2038,7 +2038,7 @@ ExeCreateSurfBezierRational( int nParentId, int nDegU, int nDegV, int nSpanU, in //------------------------------------------------------------------------------- int -ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight, bool bShowTrim, int* pnCount) +ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight, bool bShowTrim, bool bRefined, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -2049,7 +2049,7 @@ ExeCreateSurfBezierLeaves( int nParentId, int nSurfBzId, int nTextHeight, bool b return GDB_ID_NULL ; // disegno le foglie vector> vLeaves ; - pSurfBez->GetLeaves( vLeaves) ; + pSurfBez->GetLeaves( vLeaves, bRefined) ; double dFactor = 1 ; int nFirstId = GDB_ID_NULL ; int nCount = 0 ; diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 4484b51..1fa9578 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -1051,21 +1051,27 @@ LuaCreateSurfBezierRational( lua_State* L) static int LuaCreateSurfBezierLeaves( lua_State* L) { - // 2, 3 o 4 parametri : ParentId, nId [, nTextHeight] [, bShowTrim] + // 2, 3 o 4 parametri : ParentId, nId [, nTextHeight] [, bShowTrim] [, bRefined] int nParentId ; LuaCheckParam( L, 1, nParentId) int nSurfBzId ; LuaCheckParam( L, 2, nSurfBzId) int nTextHeight = 50 ; bool bShowTrim = false ; - if ( LuaGetParam( L, 3, nTextHeight)) - LuaGetParam( L, 4, bShowTrim) ; - else + bool bRefined = false ; + // testo pił due booleani o solo due booleani + if ( LuaGetParam( L, 3, nTextHeight)) { + if ( LuaGetParam( L, 4, bShowTrim)) + LuaGetParam( L, 5, bRefined) ; + } + else { LuaGetParam( L, 3, bShowTrim) ; + LuaGetParam( L, 4, bRefined) ; + } LuaClearStack( L) ; // creo la superficie int nCount = 0 ; - int nId = ExeCreateSurfBezierLeaves( nParentId, nSurfBzId, nTextHeight, bShowTrim, &nCount) ; + int nId = ExeCreateSurfBezierLeaves( nParentId, nSurfBzId, nTextHeight, bShowTrim, bRefined, &nCount) ; // restituisco il risultato if ( nId != GDB_ID_NULL) { LuaSetParam( L, nId) ; From 71009205b590b9fe6ccd37a9bd14b94dbe91db22 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 23 Feb 2026 15:53:39 +0100 Subject: [PATCH 26/54] EgtExecutor : - in LUA_GENERAL migliorato e corretto il dialogo di tipo Brush/ColorPicker. --- LUA_General.cpp | 84 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 26 deletions(-) diff --git a/LUA_General.cpp b/LUA_General.cpp index b060571..047db07 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -30,6 +30,7 @@ #include "/EgtDev/Include/EgtIniFile.h" #include "/EgtDev/Include/EgtNumUtils.h" #include "/EgtDev/Include/EgtStringConverter.h" +#include #include #include @@ -1224,15 +1225,18 @@ static int s_nType[MAX_CTRLS] ; #ifndef IDC_STATIC_PREVIEW #define IDC_STATIC_PREVIEW 41000 #endif +static COLORREF s_CustomColors[16] = {0} ; // 16 colori BLACK +static bool s_bCustomColorsInit = false ; // flag di inizializzazione colori +static const string s_CustomColorIniSection = "Scene" ; // [Scene] +static const string s_CustomColorIniKey = "CustomColors" ; // [Scene]->CustomCulors=... //------------------------------------------------------------------------------- BOOL CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { // variabili static locali per mantenere lo stato tra chiamate static per selezione colori - COLORREF g_customColors[16] = {0} ; - static HBRUSH g_hColorBrush[MAX_CTRLS] = {0} ; - static COLORREF g_selectedColor[MAX_CTRLS] = {0} ; + static HBRUSH g_hColorBrush[MAX_CTRLS] = {0} ; // BLACK + static COLORREF g_selectedColor[MAX_CTRLS] = {0} ; // BLACK switch ( message) { case WM_INITDIALOG : @@ -1332,30 +1336,43 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam } else if ( s_sEdit[i].find( "CP:") == 0) { string sVal = s_sEdit[i].substr( 3) ; - // recupero eventuale colore di default - if ( ! sVal.empty()) { - // rimuovo eventuale carattere di "#" - if ( sVal[0] == '#') - sVal.erase( 0, 1) ; - // il colore di base deve essere composto da esattamente 6 caratteri - if ( sVal.size() == 6) { - bool bOk = true ; - for ( char c : sVal) { - if ( ! isxdigit( static_cast(c))) { - bOk = false; - break ; - } - } - if ( bOk) { + // aggiungo Alpha, in questo caso sempre 100 + sVal += ",100" ; + Color CColor ; + if ( ! FromString( sVal, CColor)) + CColor = INVISIBLE ; + try { + double dRed = double( CColor.GetRed()) ; + double dGreen = double( CColor.GetGreen()) ; + double dBlue = double( CColor.GetBlue()) ; + BYTE byteRed = static_cast( Clamp( dRed * 255. + .5, 0., 255.)) ; + BYTE byteGreen = static_cast( Clamp( dGreen * 255. + .5, 0., 255.)) ; + BYTE byteBlue = static_cast( Clamp( dBlue * 255. + .5, 0., 255.)) ; + g_selectedColor[i] = RGB( byteRed, byteGreen, byteBlue) ; + } catch (...) {} + + // recupero i valori dei colori personalizzati dal file .ini + if ( ! s_bCustomColorsInit) { + // recupero il file Ini + string sIniFile = ExeGetIniFile() ; + if ( ! sIniFile.empty()) { + string sCustomVals = GetPrivateProfileStringUtf8( + string{s_CustomColorIniSection}.c_str(), + string{s_CustomColorIniKey}.c_str(), + string{""}.c_str(), sIniFile.c_str()) ; + STRVECTOR vsWinColors ; Tokenize( sCustomVals, ",", vsWinColors) ; + for ( int i = 0 ; i < min( 16, int( vsWinColors.size())) ; ++ i) { try { - unsigned long hex = stoul( sVal, nullptr, 16) ; - BYTE r = ( hex >> 16) & 0xFF ; - BYTE g = ( hex >> 8) & 0xFF ; - BYTE b = hex & 0xFF ; - g_selectedColor[i] = RGB( r, g, b) ; - } catch (...) {} + uint32_t uWinCol = static_cast( stoul( vsWinColors[i])) ; + unsigned int unR = uWinCol & 0xFF ; + unsigned int unG = ( uWinCol >> 8) & 0xFF ; + unsigned int unB = ( uWinCol >> 16) & 0xFF ; + s_CustomColors[i] = RGB( unR, unG, unB) ; + } + catch (...) {} } } + s_bCustomColorsInit = true ; } // nascondo qualsiasi tipo di componente ( per sicurezza) @@ -1475,11 +1492,26 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam CHOOSECOLOR cc = {} ; cc.lStructSize = sizeof( cc) ; cc.hwndOwner = hwndDlg ; - cc.lpCustColors = g_customColors ; + cc.lpCustColors = s_CustomColors ; cc.rgbResult = g_selectedColor[idx] ; cc.Flags = CC_FULLOPEN | CC_RGBINIT ; if ( ChooseColor( &cc)) { g_selectedColor[idx] = cc.rgbResult ; + // salvo nel file Ini i nuovi colori personalizzati + string sIniFile = ExeGetIniFile() ; + if ( ! sIniFile.empty()) { + ostringstream ss ; + for ( int i = 0 ; i < 16 ; ++ i) { + if ( i > 0) + ss << "," ; + ss << static_cast( s_CustomColors[i]) ; + } + string sVal = ss.str() ; + WritePrivateProfileStringUtf8( + s_CustomColorIniSection.c_str(), + s_CustomColorIniKey.c_str(), + sVal.c_str(), sIniFile.c_str()) ; + } if ( g_hColorBrush[idx]) { DeleteObject( g_hColorBrush[idx]) ; g_hColorBrush[idx] = NULL ; @@ -1513,7 +1545,7 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam COLORREF col = g_selectedColor[i] ; BYTE r = GetRValue( col), g = GetGValue( col), b = GetBValue( col) ; char buf[16] ; - sprintf_s( buf, sizeof( buf), "#%02X%02X%02X", r, g, b) ; + sprintf_s( buf, sizeof( buf), "%u,%u,%u", r, g, b) ; s_sEdit[i] = buf ; break ; } From 0da179802910615aedf85321c84f76dc8e398ee7 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 24 Feb 2026 08:42:06 +0100 Subject: [PATCH 27/54] EgtExecutor : - piccole modifiche a scelta colore per dialogo lua. --- LUA_General.cpp | 174 ++++++++++++++++-------------------------------- resource.h | 10 ++- 2 files changed, 65 insertions(+), 119 deletions(-) diff --git a/LUA_General.cpp b/LUA_General.cpp index 047db07..5735f6c 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -1220,23 +1220,18 @@ static string s_sCaption ; static string s_sText[MAX_CTRLS] ; static string s_sEdit[MAX_CTRLS] ; static int s_nType[MAX_CTRLS] ; - -// preview statica per la selezione del colore -#ifndef IDC_STATIC_PREVIEW - #define IDC_STATIC_PREVIEW 41000 -#endif -static COLORREF s_CustomColors[16] = {0} ; // 16 colori BLACK +static COLORREF s_CustomColors[16] = {12632256} ; // 16 colori GRAY static bool s_bCustomColorsInit = false ; // flag di inizializzazione colori -static const string s_CustomColorIniSection = "Scene" ; // [Scene] -static const string s_CustomColorIniKey = "CustomColors" ; // [Scene]->CustomCulors=... +const char* SEC_SCENE = "Scene" ; +const char* KEY_CUSTOMCOLORS = "CustomColors" ; //------------------------------------------------------------------------------- BOOL CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { - // variabili static locali per mantenere lo stato tra chiamate static per selezione colori - static HBRUSH g_hColorBrush[MAX_CTRLS] = {0} ; // BLACK - static COLORREF g_selectedColor[MAX_CTRLS] = {0} ; // BLACK + // variabili static locali per mantenere lo stato tra chiamate per selezione colori + static COLORREF selectedColor[MAX_CTRLS] = {0} ; // BLACK + static HBRUSH hColorBrush[MAX_CTRLS] = {NULL} ; // non definito switch ( message) { case WM_INITDIALOG : @@ -1245,12 +1240,10 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam COLORREF defaultColor = RGB( 255, 0, 0) ; // inizializzazione colori e brush for ( int i = 0 ; i < MAX_CTRLS ; ++ i) { - if ( g_hColorBrush[i]) { - DeleteObject( g_hColorBrush[i]) ; - g_hColorBrush[i] = NULL ; - } - g_selectedColor[i] = defaultColor ; - g_hColorBrush[i] = CreateSolidBrush( g_selectedColor[i]) ; + selectedColor[i] = defaultColor ; + if ( hColorBrush[i] != NULL) + DeleteObject( hColorBrush[i]) ; + hColorBrush[i] = CreateSolidBrush( selectedColor[i]) ; } // dati del dialogo HWND hwndOwner = GetParent( hwndDlg) ; @@ -1336,55 +1329,36 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam } else if ( s_sEdit[i].find( "CP:") == 0) { string sVal = s_sEdit[i].substr( 3) ; - // aggiungo Alpha, in questo caso sempre 100 - sVal += ",100" ; Color CColor ; if ( ! FromString( sVal, CColor)) CColor = INVISIBLE ; - try { - double dRed = double( CColor.GetRed()) ; - double dGreen = double( CColor.GetGreen()) ; - double dBlue = double( CColor.GetBlue()) ; - BYTE byteRed = static_cast( Clamp( dRed * 255. + .5, 0., 255.)) ; - BYTE byteGreen = static_cast( Clamp( dGreen * 255. + .5, 0., 255.)) ; - BYTE byteBlue = static_cast( Clamp( dBlue * 255. + .5, 0., 255.)) ; - g_selectedColor[i] = RGB( byteRed, byteGreen, byteBlue) ; - } catch (...) {} - + selectedColor[i] = RGB( CColor.GetIntRed(), CColor.GetIntGreen(), CColor.GetIntBlue()) ; + if ( hColorBrush[i] != NULL) + DeleteObject( hColorBrush[i]) ; + hColorBrush[i] = CreateSolidBrush( selectedColor[i]) ; // recupero i valori dei colori personalizzati dal file .ini if ( ! s_bCustomColorsInit) { // recupero il file Ini string sIniFile = ExeGetIniFile() ; if ( ! sIniFile.empty()) { - string sCustomVals = GetPrivateProfileStringUtf8( - string{s_CustomColorIniSection}.c_str(), - string{s_CustomColorIniKey}.c_str(), - string{""}.c_str(), sIniFile.c_str()) ; + string sCustomVals = GetPrivateProfileStringUtf8( SEC_SCENE, KEY_CUSTOMCOLORS, "", sIniFile.c_str()) ; STRVECTOR vsWinColors ; Tokenize( sCustomVals, ",", vsWinColors) ; - for ( int i = 0 ; i < min( 16, int( vsWinColors.size())) ; ++ i) { - try { - uint32_t uWinCol = static_cast( stoul( vsWinColors[i])) ; - unsigned int unR = uWinCol & 0xFF ; - unsigned int unG = ( uWinCol >> 8) & 0xFF ; - unsigned int unB = ( uWinCol >> 16) & 0xFF ; - s_CustomColors[i] = RGB( unR, unG, unB) ; + for ( int j = 0 ; j < ssize( vsWinColors) && j < 16 ; ++ j) { + unsigned int unVal ; + if ( FromString( vsWinColors[j], unVal)) { + unsigned int unR = unVal & 0xFF ; + unsigned int unG = ( unVal >> 8) & 0xFF ; + unsigned int unB = ( unVal >> 16) & 0xFF ; + s_CustomColors[j] = RGB( unR, unG, unB) ; } - catch (...) {} } } s_bCustomColorsInit = true ; } - // nascondo qualsiasi tipo di componente ( per sicurezza) - HWND hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT1 + i) ; - if ( hwndEdit) - ShowWindow( hwndEdit, SW_HIDE) ; - HWND hwndCombo = GetDlgItem( hwndDlg, IDC_COMBO1 + i) ; - if ( hwndCombo) - ShowWindow( hwndCombo, SW_HIDE) ; - HWND hwndChk = GetDlgItem( hwndDlg, IDC_CHECK1 + i) ; - if ( hwndChk) - ShowWindow( hwndChk, SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; + ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; // margini per dimensione del rettangolo preview pickColor const int MARGIN_RIGHT = 8 ; // spazio tra preview e bordo destro dialog @@ -1392,7 +1366,7 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam const int PREVIEW_MIN_WIDTH = 40 ; // larghezza minima // ottieni o crea la static preview (allargata fino al bordo destro del dialog) - HWND hwndPreview = GetDlgItem( hwndDlg, IDC_STATIC_PREVIEW + i) ; + HWND hwndPreview = NULL ; RECT rcLabel ; HWND hwndLabel = GetDlgItem( hwndDlg, IDC_TEXT1 + i) ; RECT rcClient ; GetClientRect( hwndDlg, &rcClient) ; // coordinate client del dialog @@ -1405,43 +1379,15 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam int width = rcClient.right - x - MARGIN_RIGHT ; if ( width < PREVIEW_MIN_WIDTH) width = PREVIEW_MIN_WIDTH ; - if ( ! hwndPreview) { - hwndPreview = CreateWindowEx( - 0, L"STATIC", NULL, - WS_CHILD | WS_VISIBLE | SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER, - x, y, width, PREVIEW_HEIGHT, - hwndDlg, ( HMENU)( IDC_STATIC_PREVIEW + i), - GetModuleHandle( NULL), NULL) ; - } - else { - // aggiornamento posizione e dimensione se gią esiste - LONG_PTR style = GetWindowLongPtr( hwndPreview, GWL_STYLE) ; - style |= SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER ; - style &= ~SS_OWNERDRAW ; - SetWindowLongPtr( hwndPreview, GWL_STYLE, style) ; - SetWindowPos( hwndPreview, HWND_TOP, x, y, width, PREVIEW_HEIGHT, SWP_SHOWWINDOW | SWP_FRAMECHANGED) ; - } - // pulizia e aggiornamento brush colori - SetWindowText( hwndPreview, L"") ; - if ( g_hColorBrush[i]) { - DeleteObject( g_hColorBrush[i]) ; - g_hColorBrush[i] = NULL ; - } - g_hColorBrush[i] = CreateSolidBrush( g_selectedColor[i]) ; - // ridisegno - InvalidateRect( hwndPreview, NULL, TRUE) ; - UpdateWindow( hwndPreview) ; + hwndPreview = CreateWindowEx( 0, L"STATIC", NULL, + WS_CHILD | WS_VISIBLE | SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER, + x, y, width, PREVIEW_HEIGHT, + hwndDlg, ( HMENU)( IDC_COLOR1 + i), + GetModuleHandle( NULL), NULL) ; } // pulizia elementi testuali - if ( hwndPreview) - SetWindowText( hwndPreview, L"") ; - if ( g_hColorBrush[i]) { - DeleteObject( g_hColorBrush[i]) ; - g_hColorBrush[i] = NULL ; - } - // creazione brush di colori - g_hColorBrush[i] = CreateSolidBrush( g_selectedColor[i]) ; if ( hwndPreview) { + SetWindowText( hwndPreview, L"") ; SetWindowPos( hwndPreview, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) ; InvalidateRect( hwndPreview, NULL, TRUE) ; UpdateWindow( hwndPreview) ; @@ -1460,7 +1406,6 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ; ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ; ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ; - ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_PREVIEW + i), SW_HIDE) ; s_nType[i] = CTRL_NONE ; } } @@ -1470,22 +1415,23 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam HDC hdcStatic = ( HDC)wParam ; HWND hwndCtrl = ( HWND)lParam ; int ctrlId = GetDlgCtrlID( hwndCtrl) ; - if ( ctrlId >= IDC_STATIC_PREVIEW && ctrlId < IDC_STATIC_PREVIEW + MAX_CTRLS) { - int idx = ctrlId - IDC_STATIC_PREVIEW ; - if ( g_hColorBrush[idx] == NULL) - g_hColorBrush[idx] = CreateSolidBrush( g_selectedColor[idx]) ; + if ( ctrlId >= IDC_COLOR1 && ctrlId <= IDC_COLOR8) { + int idx = ctrlId - IDC_COLOR1 ; + if ( hColorBrush[idx] == NULL) + hColorBrush[idx] = CreateSolidBrush( selectedColor[idx]) ; SetBkMode( hdcStatic, OPAQUE) ; - SetBkColor( hdcStatic, g_selectedColor[idx]) ; - return ( INT_PTR)g_hColorBrush[idx] ; + SetBkColor( hdcStatic, selectedColor[idx]) ; + return ( INT_PTR)hColorBrush[idx] ; } } + break ; case WM_COMMAND : { int id = LOWORD( wParam) ; int code = HIWORD( wParam) ; // comando di Preview per brush di colori mediante click del mouse - if ( code == STN_CLICKED && id >= IDC_STATIC_PREVIEW && id < IDC_STATIC_PREVIEW + MAX_CTRLS) { - int idx = id - IDC_STATIC_PREVIEW ; - HWND hwndPreview = GetDlgItem( hwndDlg, IDC_STATIC_PREVIEW + idx) ; + if ( code == STN_CLICKED && id >= IDC_COLOR1 && id <= IDC_COLOR8) { + int idx = id - IDC_COLOR1 ; + HWND hwndPreview = GetDlgItem( hwndDlg, IDC_COLOR1 + idx) ; if ( ! hwndPreview) return TRUE ; // apertura ChooseColor (usa hwndDlg come owner) @@ -1493,30 +1439,22 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam cc.lStructSize = sizeof( cc) ; cc.hwndOwner = hwndDlg ; cc.lpCustColors = s_CustomColors ; - cc.rgbResult = g_selectedColor[idx] ; + cc.rgbResult = selectedColor[idx] ; cc.Flags = CC_FULLOPEN | CC_RGBINIT ; if ( ChooseColor( &cc)) { - g_selectedColor[idx] = cc.rgbResult ; + selectedColor[idx] = cc.rgbResult ; // salvo nel file Ini i nuovi colori personalizzati string sIniFile = ExeGetIniFile() ; if ( ! sIniFile.empty()) { - ostringstream ss ; - for ( int i = 0 ; i < 16 ; ++ i) { - if ( i > 0) - ss << "," ; - ss << static_cast( s_CustomColors[i]) ; - } - string sVal = ss.str() ; - WritePrivateProfileStringUtf8( - s_CustomColorIniSection.c_str(), - s_CustomColorIniKey.c_str(), - sVal.c_str(), sIniFile.c_str()) ; + string sOut = "" ; + for ( int j = 0 ; j < ssize( s_CustomColors) && j < 16 ; ++ j) + sOut += ToString( ( unsigned int)s_CustomColors[j]) + "," ; + sOut.pop_back() ; + WritePrivateProfileStringUtf8( SEC_SCENE, KEY_CUSTOMCOLORS, sOut.c_str(), sIniFile.c_str()) ; } - if ( g_hColorBrush[idx]) { - DeleteObject( g_hColorBrush[idx]) ; - g_hColorBrush[idx] = NULL ; - } - g_hColorBrush[idx] = CreateSolidBrush( g_selectedColor[idx]) ; + if ( hColorBrush[idx] != NULL) + DeleteObject( hColorBrush[idx]) ; + hColorBrush[idx] = CreateSolidBrush( selectedColor[idx]) ; InvalidateRect(hwndPreview, NULL, TRUE) ; UpdateWindow( hwndPreview) ; } @@ -1542,7 +1480,7 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam break ; case CTRL_COLOR : { - COLORREF col = g_selectedColor[i] ; + COLORREF col = selectedColor[i] ; BYTE r = GetRValue( col), g = GetGValue( col), b = GetBValue( col) ; char buf[16] ; sprintf_s( buf, sizeof( buf), "%u,%u,%u", r, g, b) ; @@ -1555,9 +1493,9 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam case IDCANCEL : { // pulizia brush colori for ( int i = 0 ; i < MAX_CTRLS ; ++ i) { - if ( g_hColorBrush[i]) { - DeleteObject( g_hColorBrush[i]) ; - g_hColorBrush[i] = NULL ; + if ( hColorBrush[i] != NULL) { + DeleteObject( hColorBrush[i]) ; + hColorBrush[i] = NULL ; } } EndDialog( hwndDlg, wParam) ; diff --git a/resource.h b/resource.h index 3c69bdc..8891cf6 100644 --- a/resource.h +++ b/resource.h @@ -37,7 +37,15 @@ #define IDC_CHECK6 1036 #define IDC_CHECK7 1037 #define IDC_CHECK8 1038 -#define IDC_PICTURE1 1041 +#define IDC_COLOR1 1041 +#define IDC_COLOR2 1042 +#define IDC_COLOR3 1043 +#define IDC_COLOR4 1044 +#define IDC_COLOR5 1045 +#define IDC_COLOR6 1046 +#define IDC_COLOR7 1047 +#define IDC_COLOR8 1048 +#define IDC_PICTURE1 1101 // Next default values for new objects // From 6356d670349fcb1e27778940dac70352440a0cb1 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 3 Mar 2026 18:34:50 +0100 Subject: [PATCH 28/54] EgtExecutor 3.1c1 : - aggiunta funzione ExeChangePreviewMachiningToolShow. --- EXE_MachMgr.cpp | 10 ++++++++++ EgtExecutor.rc | Bin 19652 -> 19652 bytes 2 files changed, 10 insertions(+) diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index 86337f3..30d67e7 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -2748,6 +2748,16 @@ ExeUpdateMachining( bool bPostApply) return bOk ; } +//----------------------------------------------------------------------------- +bool +ExeChangePreviewMachiningToolShow( int nLookFlag) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) + // impostazione tipo visualizzazione anteprima utensile su lavorazione + return pMachMgr->ChangePreviewMachiningToolShow( nLookFlag) ; +} + //----------------------------------------------------------------------------- bool ExePreparePreviewMachiningTool( void) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 992894ce5496cc20d8e28f06c3afe9d0a068f5f9..335235dbe92e0d167f266061e16215ed43eec3d4 100644 GIT binary patch delta 276 zcmX>ylkvz*#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+g>CICoylkvz*#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|HJz3DLb#olc z3?^111|0^Y&A-{4nVFM-3`efTEO4>oOp`YVR)EAOJ8~s&?h~?r$(qnp+u~MHcxaZW)#c^yVw)#;vAq$6E_RGZDht2o;=az;N}TlCQJZ-C_Qih From bc167e88324382714f27f2e97f99e7ed269494c2 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 4 Mar 2026 14:49:15 +0100 Subject: [PATCH 29/54] EgtExecutor : - aggiunta funzione per richiedere i parametri di un punto di una bezier. --- EXE_GdbGetSurf.cpp | 33 +++++++++++++++++++++++++++++++++ LUA_GdbGetSurf.cpp | 20 ++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index 5cda347..ac52675 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -21,6 +21,7 @@ #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EGkGeoPoint3d.h" +#include "/EgtDev/Include/EGkGeoVector3d.h" #include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveBezier.h" #include "/EgtDev/Include/EGkCurveComposite.h" @@ -1657,6 +1658,38 @@ ExeSurfBezierGetCurveV( int nSurfId, double dU, int nDestGrpId) return nNewId ; } +//---------------------------------------------------------------------------- +bool +ExeSurfBezParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nDestGrpId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero la superficie di Bezier + const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ; + if ( pSbz == nullptr) + return false ; + Point3d ptParam, ptBez ; + bool bOk = pSbz->UnprojectPoint( ptOnSurf, ptParam, P_INVALID) ; + Vector3d vtNorm, vtDerU, vtDerV ; + pSbz->GetPointNrmD1D2( ptParam.x, ptParam.y, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptBez, vtNorm, &vtDerU, &vtDerV) ; + if ( ! AreSamePointEpsilon( ptBez, ptOnSurf, 100 * EPS_SMALL)) + return false ; + PtrOwner vtGeoNorm( CreateGeoVector3d()) ; vtGeoNorm->Set( vtNorm, ptOnSurf) ; + int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoNorm)) ; + INTVECTOR vIds ; vIds.push_back( nId) ; + ExeSetColor( vIds, Color(255,0,0), false) ; + PtrOwner vtGeoDerU( CreateGeoVector3d()) ; vtGeoDerU->Set( vtDerU, ptOnSurf) ; + nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoDerU)) ; + vIds.clear() ; vIds.push_back( nId) ; + ExeSetColor( vIds, Color(0,128,192), false) ; + PtrOwner vtGeoDerV( CreateGeoVector3d()) ; vtGeoDerV->Set( vtDerV, ptOnSurf) ; + nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoDerV)) ; + vIds.clear() ; vIds.push_back( nId) ; + ExeSetColor( vIds, Color(255,128,0), false) ; + + return bOk ; +} + //---------------------------------------------------------------------------- bool ExeSurfBezierGetInfo( int nSurfId, int& nDegU, int& nDegV, int& nSpanU, int& nSpanV, bool& bIsRat, bool& bTrimmed) diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index 9dd7459..7d3c78f 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -1140,6 +1140,25 @@ LuaSurfBezierGetCurveV( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaSurfBezParamsFromPoint( lua_State* L) +{ + // 3 parametri : nSurfId, ptOnSurf, nDestGrp + int nSurfId ; + LuaCheckParam( L, 1, nSurfId) + Point3d ptOnSurf ; + LuaCheckParam( L, 2, ptOnSurf) + int nDestGrp ; + LuaCheckParam( L, 3, nDestGrp) + LuaClearStack( L) ; + // recupero la curva + bool bOk = ExeSurfBezParamsFromPoint( nSurfId, ptOnSurf, nDestGrp) ; + LuaSetParam( L) ; + + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaSurfBezierGetInfo( lua_State* L) @@ -1312,6 +1331,7 @@ LuaInstallGdbGetSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetPointNrmD1", LuaSurfBezierGetPointNrmD1) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetCurveU", LuaSurfBezierGetCurveU) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetCurveV", LuaSurfBezierGetCurveV) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezParamsFromPoint", LuaSurfBezParamsFromPoint) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetInfo", LuaSurfBezierGetInfo) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetControlCurveU", LuaSurfBezierGetControlCurveU) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetControlCurveV", LuaSurfBezierGetControlCurveV) ; From dc759d5eb3690dc0f38d4520d26f8f10035dfe8d Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 4 Mar 2026 15:43:16 +0100 Subject: [PATCH 30/54] EgtExecutor : - aggiunta funzione per ottenere part e shell di una faccia di una trimesh. --- EXE_GdbGetSurf.cpp | 14 ++++++++++++++ LUA_GdbGetSurf.cpp | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index ac52675..72905cd 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -374,6 +374,20 @@ ExeSurfTmPartCount( int nId) return pStm->GetPartCount() ; } +//---------------------------------------------------------------------------- +bool +ExeSurfTmGetPartAndShellFromFacet( int nIdSurfTm, int nIdFacet, int& nPart, int& nShell) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, -1) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nIdSurfTm)) ; + if ( pStm == nullptr) + return false ; + // recupero la parte e la shell a cui appartiene la faccia passata + return pStm->GetPartAndShellFromFacet( nIdFacet, nPart, nShell) ; +} + //----------------------------------------------------------------------------- bool ExeSurfTmGetVertex( int nId, int nVert, int nRefId, Point3d& ptVert) diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index 7d3c78f..f710511 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -301,6 +301,27 @@ LuaSurfTmPartCount( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaSurfTmGetPartAndShellFromFacet( lua_State* L) +{ + // 2 parametri : Id SurfTm, Id Facet + int nIdSurfTm ; + LuaCheckParam( L, 1, nIdSurfTm) + int nIdFacet ; + LuaCheckParam( L, 1, nIdFacet) + LuaClearStack( L) ; + // recupero il numero di parti della superficie trimesh + int nPart = - 1 ; + int nShell = - 1 ; + ExeSurfTmGetPartAndShellFromFacet( nIdSurfTm, nIdFacet, nPart, nShell) ; + if ( nPart >= 0) + LuaSetParam( L, nPart) ; + else + LuaSetParam( L) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaSurfTmGetVertex( lua_State* L) @@ -1299,6 +1320,7 @@ LuaInstallGdbGetSurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmVertexCount", LuaSurfTmVertexCount) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetCount", LuaSurfTmFacetCount) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPartCount", LuaSurfTmPartCount) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetPartAndShellFromFacet", LuaSurfTmGetPartAndShellFromFacet) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetVertex", LuaSurfTmGetVertex) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetNearestVertex", LuaSurfTmGetNearestVertex) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTriangleNormVersor", LuaSurfTmTriangleNormVersor) ; From 4925444552d9f397942e91f116786d3444476ac4 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 4 Mar 2026 15:48:22 +0100 Subject: [PATCH 31/54] EgtExecutor : - piccola correzione. --- LUA_GdbGetSurf.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index f710511..66f81fc 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -315,11 +315,9 @@ LuaSurfTmGetPartAndShellFromFacet( lua_State* L) int nPart = - 1 ; int nShell = - 1 ; ExeSurfTmGetPartAndShellFromFacet( nIdSurfTm, nIdFacet, nPart, nShell) ; - if ( nPart >= 0) - LuaSetParam( L, nPart) ; - else - LuaSetParam( L) ; - return 1 ; + LuaSetParam( L, nPart) ; + LuaSetParam( L, nShell) ; + return 2 ; } //---------------------------------------------------------------------------- From 6056ac41cd3838e42af70cbff5723a7734c05ad9 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 4 Mar 2026 16:04:26 +0100 Subject: [PATCH 32/54] EgtExecutor : - piccola correzione. --- LUA_GdbGetSurf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index 66f81fc..d77a43a 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -309,7 +309,7 @@ LuaSurfTmGetPartAndShellFromFacet( lua_State* L) int nIdSurfTm ; LuaCheckParam( L, 1, nIdSurfTm) int nIdFacet ; - LuaCheckParam( L, 1, nIdFacet) + LuaCheckParam( L, 2, nIdFacet) LuaClearStack( L) ; // recupero il numero di parti della superficie trimesh int nPart = - 1 ; From fec60b2ea7c7348f67af0b494524b8eabafce9c7 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 5 Mar 2026 10:47:42 +0100 Subject: [PATCH 33/54] EgtExecutor 3.1c2 : - cambio versione. --- EgtExecutor.rc | Bin 19652 -> 19652 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 335235dbe92e0d167f266061e16215ed43eec3d4..b609a91d36a2bd0bec812eb714fc11358996bdc0 100644 GIT binary patch delta 225 zcmX>ylkvz*#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|HJz3DLb#olc z941Di&A-`PnSqoe*K!sx?>N)s4T4pSMw1=6k~jAW*?>e(i-FY$N+HxVD8kglDRC$f oYw_lZF2#(3`CylMf?bvabW!4FLAQ;}n8K4Mx*Xg*!OMgR0F3ZDZ~y=R delta 252 zcmX>ylkvz*#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+g Date: Tue, 10 Mar 2026 10:01:56 +0100 Subject: [PATCH 34/54] EgtExecutor 3.1c3 : - piccola miglioria nel concatenamento delle curve nelle intersezioni con piano per gestire meglio i tratti di lunghezza inferiore alla tolleranza. --- EXE_GdbGetSurf.cpp | 2 +- EXE_GeoInters.cpp | 55 +++++++++++++++++++++++++++++++-------------- EgtExecutor.rc | Bin 19652 -> 19652 bytes 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index 72905cd..59054c2 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -379,7 +379,7 @@ bool ExeSurfTmGetPartAndShellFromFacet( int nIdSurfTm, int nIdFacet, int& nPart, int& nShell) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, -1) + VERIFY_GEOMDB( pGeomDB, false) // recupero la superficie trimesh const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nIdSurfTm)) ; if ( pStm == nullptr) diff --git a/EXE_GeoInters.cpp b/EXE_GeoInters.cpp index 2c2d680..7204882 100644 --- a/EXE_GeoInters.cpp +++ b/EXE_GeoInters.cpp @@ -71,7 +71,7 @@ MyLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, const int nId, con if ( ! CrvLoc->GetLocalBBox( b3Crv)) return false ; b3Crv.Expand( 100 * EPS_SMALL) ; - // definisco la linea (punto e direzione sono giļæ½ nel riferimento di calcolo) + // definisco la linea (punto e direzione sono giĆ  nel riferimento di calcolo) double dLen = 2 * floor( b3Crv.MaxDistFromPoint( ptP)) ; double dOffs = -dLen / 2 ; PtrOwner pLine( CreateCurveLine()) ; @@ -161,7 +161,7 @@ ExeLineBoxInters( const Point3d& ptP, const Vector3d& vtDir, const BBox3d& b3Box " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return bOk ; } @@ -217,7 +217,7 @@ ExeLineSurfTmInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRe " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return bOk ; } @@ -272,7 +272,7 @@ ExeLineSurfBzInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRe " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return bOk ; } @@ -359,15 +359,27 @@ MyAddPlaneIntersResultToGeomDB( IGeomDB* pGeomDB, const PNTVECTOR& vPnt, const B } // Inserisco le curve nel DB (dopo averle concatenate) ChainCurves chainC ; - chainC.Init( false, dToler, int( vBpt.size())) ; + chainC.Init( false, dToler, int( vBpt.size())) ; + DBLVECTOR vdLen ; vdLen.reserve( vBpt.size()) ; for ( int i = 0 ; i < int( vBpt.size()) ; ++ i) { Vector3d vtDir = vBpt[i].second - vBpt[i].first ; + vdLen.emplace_back( vtDir.Len()) ; vtDir.Normalize() ; if ( ! chainC.AddCurve( i + 1, vBpt[i].first, vtDir, vBpt[i].second, vtDir)) return GDB_ID_NULL ; } + // recupero i percorsi concatenati + // il punto di inizio viene scelto come lo start di un tratto più lungo della tolleranza in modo da evitare casi problematici + // del chain in cui percorsi formati da tratti di lunghezza inferiore alla tolleranza vengono individuati erroneamente come chiusi + // interrompendo il loro concatenamento con le altre curve Point3d ptNear = ( vBpt.empty() ? ORIG : vBpt[0].first) ; + for ( int i = 0 ; i < int( vdLen.size()) ; ++ i) { + if ( vdLen[i] > 2 * dToler) { + ptNear = vBpt[i].first ; + break ; + } + } INTVECTOR vId ; while ( chainC.GetChainFromNear( ptNear, false, vId)) { // creo una curva composita @@ -390,6 +402,8 @@ MyAddPlaneIntersResultToGeomDB( IGeomDB* pGeomDB, const PNTVECTOR& vPnt, const B pLine->Set( ptStart, ptEnd) && pCrvCompo->AddCurve( Release( pLine), true, dToler)) ; ptNear = ( bAdded ? ptEnd : ptStart) ; + // rendo invalida la sua lunghezza per non ritrovarlo come tratto iniziale del percorso successivo + vdLen[nInd] = -1 ; } // se lunghezza curva inferiore a 5 volte la tolleranza, la ignoro double dCrvLen ; @@ -421,6 +435,13 @@ MyAddPlaneIntersResultToGeomDB( IGeomDB* pGeomDB, const PNTVECTOR& vPnt, const B if ( nFirstId == GDB_ID_NULL) nFirstId = nNewId ; ++ nCrvCount ; + // scelgo il nuovo punto di inizio + for ( int i = 0 ; i < int( vdLen.size()) ; ++ i) { + if ( vdLen[i] > 2 * dToler) { + ptNear = vBpt[i].first ; + break ; + } + } } // Inserisco i triangoli nel DB (dopo averli uniti in una superficie trimesh) StmFromTriangleSoup StmFts ; @@ -546,7 +567,7 @@ MyPlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, con EPS_SMALL, nPntCount, nCrvCount, nTmp) ; nCount = nPntCount + nCrvCount ; - // restituisco l'identificativo della prima entitļæ½ creata + // restituisco l'identificativo della prima entitĆ  creata return nFirstId ; } @@ -575,7 +596,7 @@ ExePlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, co LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } @@ -746,7 +767,7 @@ MyPlaneBoxInters( const Point3d& ptOn, const Vector3d& vtN, const BBox3d& b3Box, nFirstId = nNewId ; ++ nSrfCount ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } @@ -779,7 +800,7 @@ ExePlaneBoxInters( const Point3d& ptOn, const Vector3d& vtN, const BBox3d& b3Box ", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } @@ -818,7 +839,7 @@ MyPlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDes // inserisco il risultato dell'intersezione nel DB int nFirstId = MyAddPlaneIntersResultToGeomDB( pGeomDB, vPnt, vBpt, vTria, frSurf, frDest, nId, nDestGrpId, plPlane.GetVersN(), dToler, nPntCount, nCrvCount, nSrfCount) ; - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } @@ -852,7 +873,7 @@ ExePlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDe ", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } @@ -941,7 +962,7 @@ ExeParPlanesSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, const DBLVEC LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } @@ -1010,7 +1031,7 @@ ExePlaneVolZmapInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nD " -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } @@ -1117,7 +1138,7 @@ ExeCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int* LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } @@ -1377,7 +1398,7 @@ MySurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, double dToler, const ISurfTriMesh* pStm2L = GetSurfTriMesh( Surf2Loc) ; if ( pStm2L == nullptr) return GDB_ID_NULL ; - // eseguo l'intersezione (giļæ½ espressa nel riferimento destinazione) + // eseguo l'intersezione (giĆ  espressa nel riferimento destinazione) PNTVECTOR vPnt ; BIPNTVECTOR vBpt ; TRIA3DVECTOR vTria ; @@ -1433,7 +1454,7 @@ MySurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, double dToler, nFirstId = nNewId ; ++ nSrfCount ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } @@ -1465,7 +1486,7 @@ ExeSurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, double dToler, ", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della prima nuova entitļæ½ + // restituisco l'identificativo della prima nuova entitĆ  return nFirstId ; } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index b609a91d36a2bd0bec812eb714fc11358996bdc0..430b1ae59eb4f2edf2d0d2bc39e2dd2f1d137bcd 100644 GIT binary patch delta 97 zcmX>ylkvz*#tq-t7>zf7XLDs{G@k4zsJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlCl(Mt{PR$>E delta 97 zcmX>ylkvz*#tq-t7>zc6XLDs{G@9%vsJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlCl(Mt{O)(#J From 7af8d0ae4187075225f3841c27c7d0f2bba0c445 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Tue, 10 Mar 2026 17:35:08 +0100 Subject: [PATCH 35/54] EgtExecutor : - modificata funzione ExeSurfBezParamsFromPoint. --- EXE_GdbGetSurf.cpp | 58 ++++++++++++++++++++++++++++++++-------------- LUA_GdbGetSurf.cpp | 10 +++++--- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index 59054c2..eb61253 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -1674,7 +1674,7 @@ ExeSurfBezierGetCurveV( int nSurfId, double dU, int nDestGrpId) //---------------------------------------------------------------------------- bool -ExeSurfBezParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nDestGrpId) +ExeSurfBezParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nDestGrpId, Point3d& ptParam) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -1682,24 +1682,46 @@ ExeSurfBezParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nDestGrpId) const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ; if ( pSbz == nullptr) return false ; - Point3d ptParam, ptBez ; + Point3d ptBez ; bool bOk = pSbz->UnprojectPoint( ptOnSurf, ptParam, P_INVALID) ; - Vector3d vtNorm, vtDerU, vtDerV ; - pSbz->GetPointNrmD1D2( ptParam.x, ptParam.y, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptBez, vtNorm, &vtDerU, &vtDerV) ; - if ( ! AreSamePointEpsilon( ptBez, ptOnSurf, 100 * EPS_SMALL)) - return false ; - PtrOwner vtGeoNorm( CreateGeoVector3d()) ; vtGeoNorm->Set( vtNorm, ptOnSurf) ; - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoNorm)) ; - INTVECTOR vIds ; vIds.push_back( nId) ; - ExeSetColor( vIds, Color(255,0,0), false) ; - PtrOwner vtGeoDerU( CreateGeoVector3d()) ; vtGeoDerU->Set( vtDerU, ptOnSurf) ; - nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoDerU)) ; - vIds.clear() ; vIds.push_back( nId) ; - ExeSetColor( vIds, Color(0,128,192), false) ; - PtrOwner vtGeoDerV( CreateGeoVector3d()) ; vtGeoDerV->Set( vtDerV, ptOnSurf) ; - nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoDerV)) ; - vIds.clear() ; vIds.push_back( nId) ; - ExeSetColor( vIds, Color(255,128,0), false) ; + if ( ! bOk) { + ptParam = P_INVALID ; + return bOk ; + } + + if ( nDestGrpId != GDB_ID_NULL) { + Vector3d vtNorm, vtDerU, vtDerV ; + pSbz->GetPointNrmD1D2( ptParam.x, ptParam.y, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptBez, vtNorm, &vtDerU, &vtDerV) ; + + PtrOwner ptChosen( CreateGeoPoint3d()) ; + ptChosen->Set( ptOnSurf) ; + int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( ptChosen)) ; + INTVECTOR vIds ; vIds.push_back( nId) ; + ExeSetColor( vIds, Color(255,0,128), false) ; + PtrOwner ptRefined( CreateGeoPoint3d()) ; + + //// punto reale sulla superficie + //ptRefined->Set( ptBez) ; + //nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( ptRefined)) ; + //vIds.clear() ; vIds.push_back( nId) ; + //ExeSetColor( vIds, Color(128,0,255), false) ; + //if ( ! AreSamePointEpsilon( ptBez, ptOnSurf, 100 * EPS_SMALL)) { + //// i due punti possono essere distanti fino alla tolleranza usata per triangolare la superficie + //return false ; + //} + PtrOwner vtGeoNorm( CreateGeoVector3d()) ; vtGeoNorm->Set( vtNorm, ptOnSurf) ; + nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoNorm)) ; + vIds.push_back( nId) ; + ExeSetColor( vIds, Color(255,0,0), false) ; + PtrOwner vtGeoDerU( CreateGeoVector3d()) ; vtGeoDerU->Set( vtDerU, ptOnSurf) ; + nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoDerU)) ; + vIds.clear() ; vIds.push_back( nId) ; + ExeSetColor( vIds, Color(0,128,192), false) ; + PtrOwner vtGeoDerV( CreateGeoVector3d()) ; vtGeoDerV->Set( vtDerV, ptOnSurf) ; + nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoDerV)) ; + vIds.clear() ; vIds.push_back( nId) ; + ExeSetColor( vIds, Color(255,128,0), false) ; + } return bOk ; } diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index d77a43a..f22e676 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -1171,9 +1171,13 @@ LuaSurfBezParamsFromPoint( lua_State* L) int nDestGrp ; LuaCheckParam( L, 3, nDestGrp) LuaClearStack( L) ; - // recupero la curva - bool bOk = ExeSurfBezParamsFromPoint( nSurfId, ptOnSurf, nDestGrp) ; - LuaSetParam( L) ; + // recupero le coordinate parametriche del punto + Point3d ptParam = P_INVALID ; + bool bOk = ExeSurfBezParamsFromPoint( nSurfId, ptOnSurf, nDestGrp, ptParam) ; + if ( bOk) + LuaSetParam( L, ptParam) ; + else + LuaSetParam( L) ; return 1 ; } From 2687fd90dc3269db816354ead229ba805717206a Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Thu, 12 Mar 2026 18:12:21 +0100 Subject: [PATCH 36/54] EgtExecutor : - cambio restituzione valori per ExeSurfBezParamsFromPoint. --- EXE_GdbGetSurf.cpp | 14 +++++++------- LUA_GdbGetSurf.cpp | 11 +++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index eb61253..29dd83e 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -1674,7 +1674,7 @@ ExeSurfBezierGetCurveV( int nSurfId, double dU, int nDestGrpId) //---------------------------------------------------------------------------- bool -ExeSurfBezParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nDestGrpId, Point3d& ptParam) +ExeSurfBezParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nDestGrpId, double& dU, double& dV) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -1682,12 +1682,12 @@ ExeSurfBezParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nDestGrpId, const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ; if ( pSbz == nullptr) return false ; + Point3d ptParam ; Point3d ptBez ; - bool bOk = pSbz->UnprojectPoint( ptOnSurf, ptParam, P_INVALID) ; - if ( ! bOk) { - ptParam = P_INVALID ; - return bOk ; - } + if ( ! pSbz->UnprojectPoint( ptOnSurf, ptParam, P_INVALID)) + return false ; + dU = ptParam.x ; + dV = ptParam.y ; if ( nDestGrpId != GDB_ID_NULL) { Vector3d vtNorm, vtDerU, vtDerV ; @@ -1723,7 +1723,7 @@ ExeSurfBezParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nDestGrpId, ExeSetColor( vIds, Color(255,128,0), false) ; } - return bOk ; + return true ; } //---------------------------------------------------------------------------- diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index f22e676..4096a17 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -1172,10 +1172,13 @@ LuaSurfBezParamsFromPoint( lua_State* L) LuaCheckParam( L, 3, nDestGrp) LuaClearStack( L) ; // recupero le coordinate parametriche del punto - Point3d ptParam = P_INVALID ; - bool bOk = ExeSurfBezParamsFromPoint( nSurfId, ptOnSurf, nDestGrp, ptParam) ; - if ( bOk) - LuaSetParam( L, ptParam) ; + double dU = - 1 ; + double dV = - 1 ; + bool bOk = ExeSurfBezParamsFromPoint( nSurfId, ptOnSurf, nDestGrp, dU, dV) ; + if ( bOk) { + LuaSetParam( L, dU) ; + LuaSetParam( L, dV) ; + } else LuaSetParam( L) ; From e1b2c93f22154b5ebf81bd61fb3bcb63e924c8d5 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Fri, 13 Mar 2026 09:14:07 +0100 Subject: [PATCH 37/54] EgtExecutor : - piccola correzione. --- LUA_GdbGetSurf.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index 4096a17..83414d4 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -1179,10 +1179,12 @@ LuaSurfBezParamsFromPoint( lua_State* L) LuaSetParam( L, dU) ; LuaSetParam( L, dV) ; } - else + else { LuaSetParam( L) ; + LuaSetParam( L) ; + } - return 1 ; + return 2 ; } //---------------------------------------------------------------------------- From 7412a3085ffa16da88e5cbc14b3b8d16dd747cb9 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 13 Mar 2026 13:33:46 +0100 Subject: [PATCH 38/54] EgtExecutor : - la funzione Exe/Lua SurfBezierParamsFromPoint ora restituisce solo i valori dei parametri U e V che corrispondono al punto - piccole migliorie. --- EXE_GdbGetPocketing.cpp | 2 +- EXE_GdbGetSurf.cpp | 66 ++++++++--------------------------------- EXE_GeoInters.cpp | 22 +++++++------- EXE_Trimming.cpp | 4 +-- LUA_GdbGetSurf.cpp | 14 +++++---- 5 files changed, 34 insertions(+), 74 deletions(-) diff --git a/EXE_GdbGetPocketing.cpp b/EXE_GdbGetPocketing.cpp index 01e42a9..a5ad798 100644 --- a/EXE_GdbGetPocketing.cpp +++ b/EXE_GdbGetPocketing.cpp @@ -23,7 +23,7 @@ using namespace std ; //---------------------------------------------------------------------------- bool -ExePocketing( const int nId, double dRad, double dStep, double dAngle, int nType, bool bSmooth, int nDestGrpId, +ExePocketing( int nId, double dRad, double dStep, double dAngle, int nType, bool bSmooth, int nDestGrpId, int& nFirstId, int& nCrvCount) { // database geometrico diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index 29dd83e..0af254a 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -48,9 +48,6 @@ ExeSurfArea( int nId, double& dArea) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - // verifico il parametro - if ( &dArea == nullptr) - return false ; // recupero la superficie ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ; // ne restituisco l'area @@ -75,9 +72,6 @@ ExeSurfVolume( int nId, double& dVol) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - // verifico il parametro - if ( &dVol == nullptr) - return false ; // recupero la superficie ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ; // ne restituisco l'eventuale volume (se ĆØ chiusa) @@ -106,9 +100,6 @@ ExeSurfFrGrossArea( int nId, double& dArea) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - // verifico il parametro - if ( &dArea == nullptr) - return false ; // recupero la Regione const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ; // ne restituisco l'area senza eventuali buchi @@ -220,9 +211,6 @@ ExeSurfFrChunkMaxOffset( int nId, int nChunk, double& dMaxOffset) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - // verifico il parametro - if ( &dMaxOffset == nullptr) - return false ; // recupero la Regione const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ; return ( pSfr != nullptr && pSfr->GetChunkMaxOffset( nChunk, dMaxOffset)) ; @@ -1587,7 +1575,7 @@ ExeSurfBezierGetPointNrmD1( int nSurfId, double dU, double dV, int nUsd, int nVs } //---------------------------------------------------------------------------- -int +static int MySurfBezierGetCurveUV( int nSurfId, bool bIsU, double dPar, int nDestGrpId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -1674,55 +1662,25 @@ ExeSurfBezierGetCurveV( int nSurfId, double dU, int nDestGrpId) //---------------------------------------------------------------------------- bool -ExeSurfBezParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nDestGrpId, double& dU, double& dV) +ExeSurfBezierParamsFromPoint( int nSurfId, const Point3d& ptOnSurf, int nRefId, double& dU, double& dV) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // recupero la superficie di Bezier const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ; if ( pSbz == nullptr) return false ; + // porto il punto Near nel riferimento dell'entitĆ  + Point3d ptOnSurfL = ptOnSurf ; + if ( ! InvTransformPoint( pGeomDB, nSurfId, nRefId, ptOnSurfL)) + return false ; + // determino i parametri corrispondenti al punto Point3d ptParam ; - Point3d ptBez ; - if ( ! pSbz->UnprojectPoint( ptOnSurf, ptParam, P_INVALID)) + if ( ! pSbz->UnprojectPoint( ptOnSurfL, ptParam, P_INVALID)) return false ; dU = ptParam.x ; dV = ptParam.y ; - if ( nDestGrpId != GDB_ID_NULL) { - Vector3d vtNorm, vtDerU, vtDerV ; - pSbz->GetPointNrmD1D2( ptParam.x, ptParam.y, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptBez, vtNorm, &vtDerU, &vtDerV) ; - - PtrOwner ptChosen( CreateGeoPoint3d()) ; - ptChosen->Set( ptOnSurf) ; - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( ptChosen)) ; - INTVECTOR vIds ; vIds.push_back( nId) ; - ExeSetColor( vIds, Color(255,0,128), false) ; - PtrOwner ptRefined( CreateGeoPoint3d()) ; - - //// punto reale sulla superficie - //ptRefined->Set( ptBez) ; - //nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( ptRefined)) ; - //vIds.clear() ; vIds.push_back( nId) ; - //ExeSetColor( vIds, Color(128,0,255), false) ; - //if ( ! AreSamePointEpsilon( ptBez, ptOnSurf, 100 * EPS_SMALL)) { - //// i due punti possono essere distanti fino alla tolleranza usata per triangolare la superficie - //return false ; - //} - PtrOwner vtGeoNorm( CreateGeoVector3d()) ; vtGeoNorm->Set( vtNorm, ptOnSurf) ; - nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoNorm)) ; - vIds.push_back( nId) ; - ExeSetColor( vIds, Color(255,0,0), false) ; - PtrOwner vtGeoDerU( CreateGeoVector3d()) ; vtGeoDerU->Set( vtDerU, ptOnSurf) ; - nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoDerU)) ; - vIds.clear() ; vIds.push_back( nId) ; - ExeSetColor( vIds, Color(0,128,192), false) ; - PtrOwner vtGeoDerV( CreateGeoVector3d()) ; vtGeoDerV->Set( vtDerV, ptOnSurf) ; - nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vtGeoDerV)) ; - vIds.clear() ; vIds.push_back( nId) ; - ExeSetColor( vIds, Color(255,128,0), false) ; - } - return true ; } @@ -1855,7 +1813,7 @@ ExeExtractSurfBezierLoops( int nId, int nDestGrpId, int* pnCount) // recupero la superficie di Bezier const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nId)) ; bool bOk = ( pSbz != nullptr) ; - if( ! bOk) + if ( ! bOk) return GDB_ID_NULL ; // recupero il riferimento della superficie Frame3d frSurf ; @@ -1905,7 +1863,7 @@ int ExeShowSurfBezierControlPoints( int nSrfId, int nDestGrpId, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero la superficie di bezier IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nSrfId) ; if ( pGeoObj->GetType() != SRF_BEZIER) @@ -1939,4 +1897,4 @@ ExeShowSurfBezierControlPoints( int nSrfId, int nDestGrpId, int* pnCount) if ( pnCount != nullptr) *pnCount = nCount ; return nFirstId ; -} \ No newline at end of file +} diff --git a/EXE_GeoInters.cpp b/EXE_GeoInters.cpp index 7204882..e1d1c97 100644 --- a/EXE_GeoInters.cpp +++ b/EXE_GeoInters.cpp @@ -47,8 +47,8 @@ using namespace std ; //------------------------------------------------------------------------------- -bool -MyLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, const int nId, const int nRefType, +static bool +MyLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType, INTDBLVECTOR& vInters) { vInters.clear() ; @@ -127,7 +127,7 @@ MyLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, const int nId, con //------------------------------------------------------------------------------- bool -ExeLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, const int nId, const int nRefType, +ExeLineCurveInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType, INTDBLVECTOR& vInters) { // eseguo @@ -475,8 +475,8 @@ MyAddPlaneIntersResultToGeomDB( IGeomDB* pGeomDB, const PNTVECTOR& vPnt, const B } //------------------------------------------------------------------------------- -int -MyPlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, const int nDestGrpId, const int nRefType, int& nCount) +static int +MyPlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDestGrpId, int nRefType, int& nCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -573,7 +573,7 @@ MyPlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, con //------------------------------------------------------------------------------- int -ExePlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, const int nId, const int nDestGrpId, const int nRefType, int* pnCount) +ExePlaneCurveInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDestGrpId, int nRefType, int* pnCount) { // eseguo int nCount{ 0} ; @@ -1036,8 +1036,8 @@ ExePlaneVolZmapInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nD } //------------------------------------------------------------------------------- -int -MyCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int& nPntCount, int& nCrvCount, bool bOnly3D) +static int +MyCurveCurveInters( int nId1, int nId2, int nDestGrpId, int& nPntCount, int& nCrvCount, bool bOnly3D) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -1116,7 +1116,7 @@ MyCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int& n //------------------------------------------------------------------------------- int -ExeCurveCurveInters( const int nId1, const int nId2, const int nDestGrpId, int* pnPntCount, int* pnCrvCount, bool bOnly3D) +ExeCurveCurveInters( int nId1, int nId2, int nDestGrpId, int* pnPntCount, int* pnCrvCount, bool bOnly3D) { // eseguo int nPntCount{ 0}, nCrvCount{ 0} ; @@ -1161,7 +1161,7 @@ GetCurveSurfTmIntersType( int nFlag) //------------------------------------------------------------------------------- static int -MyCurveSurfTmInters( const int nCrvId, const int nId2, const int nDestGrpId, int& nPntCount, int& nCrvCount) +MyCurveSurfTmInters( int nCrvId, int nId2, int nDestGrpId, int& nPntCount, int& nCrvCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -1243,7 +1243,7 @@ MyCurveSurfTmInters( const int nCrvId, const int nId2, const int nDestGrpId, int //------------------------------------------------------------------------------- int -ExeCurveSurfTmInters( const int nCrvId, const int nStmId, const int nDestGrpId, int* pnPntCount, int* pnCrvCount) +ExeCurveSurfTmInters( int nCrvId, int nStmId, int nDestGrpId, int* pnPntCount, int* pnCrvCount) { // eseguo int nPntCount{ 0}, nCrvCount{ 0} ; diff --git a/EXE_Trimming.cpp b/EXE_Trimming.cpp index c6fe70d..0614d14 100644 --- a/EXE_Trimming.cpp +++ b/EXE_Trimming.cpp @@ -72,7 +72,7 @@ ExeTrimmingGetHoleBorder( int nParentId, const INTVECTOR& vSurfIds, const INTVEC Point3d ptRef = P_INVALID ; if ( ! vOtherSurfIds.empty()) { int nToTSurf = 0 ; - for ( const int& nOtherSurfId : vOtherSurfIds) { + for ( int nOtherSurfId : vOtherSurfIds) { // Recupero l'entitĆ  const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nOtherSurfId) ; if ( pGeoObj != nullptr) { @@ -288,7 +288,7 @@ ExeTrimmingGetAdjSurfs( const INTVECTOR& vSurfId, const INTVECTOR& vOtherSurfId, INTVECTOR vMyInds ; bOk = bOk && GetTrimmingAdjSurfs( vRefSurf, vOtherSurf, dLinTol, dAngTol, dAngFaceTol, vMyInds) ; if ( bOk) { - for ( const int& myInd : vMyInds) + for ( int myInd : vMyInds) vResId.push_back( vIds[myInd]) ; } diff --git a/LUA_GdbGetSurf.cpp b/LUA_GdbGetSurf.cpp index 4096a17..df261e3 100644 --- a/LUA_GdbGetSurf.cpp +++ b/LUA_GdbGetSurf.cpp @@ -1163,26 +1163,28 @@ LuaSurfBezierGetCurveV( lua_State* L) static int LuaSurfBezParamsFromPoint( lua_State* L) { - // 3 parametri : nSurfId, ptOnSurf, nDestGrp + // 2 o 3 parametri : nSurfId, ptOnSurf [, nRefId] int nSurfId ; LuaCheckParam( L, 1, nSurfId) Point3d ptOnSurf ; LuaCheckParam( L, 2, ptOnSurf) - int nDestGrp ; - LuaCheckParam( L, 3, nDestGrp) + int nRefId = nSurfId ; + LuaGetParam( L, 3, nRefId) ; LuaClearStack( L) ; // recupero le coordinate parametriche del punto double dU = - 1 ; double dV = - 1 ; - bool bOk = ExeSurfBezParamsFromPoint( nSurfId, ptOnSurf, nDestGrp, dU, dV) ; + bool bOk = ExeSurfBezierParamsFromPoint( nSurfId, ptOnSurf, nRefId, dU, dV) ; if ( bOk) { LuaSetParam( L, dU) ; LuaSetParam( L, dV) ; } - else + else { LuaSetParam( L) ; + LuaSetParam( L) ; + } - return 1 ; + return 2 ; } //---------------------------------------------------------------------------- From 6b6fd884a06cfa688ac58800e5adf98921c1ea00 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Wed, 18 Mar 2026 15:56:28 +0100 Subject: [PATCH 39/54] =?UTF-8?q?EgtExecutor=203.1c4=20:=20-=20in=20MachMg?= =?UTF-8?q?r=20aggiunte=20funzioni=20per=20ottenere=20vTDir,=20vCDir=20e?= =?UTF-8?q?=20vADir=20per=20entit=C3=A0=20CamData.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EXE_MachMgr.cpp | 30 ++++++++++++++++++++ EgtExecutor.rc | Bin 19652 -> 19652 bytes LUA_MachMgr.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 94 insertions(+), 7 deletions(-) diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index 30d67e7..507a370 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -3140,6 +3140,36 @@ ExeGetClEntAxesVal( int nEntId, DBLVECTOR& vAxes) return pMachMgr->GetClEntAxesVal( nEntId, vAxes) ; } +//----------------------------------------------------------------------------- +bool +ExeGetClEntTDir( int nEntId, Vector3d& vTDir) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) ; + // recupero vTDir + return pMachMgr->GetClEntTDir( nEntId, vTDir) ; +} + +//----------------------------------------------------------------------------- +bool +ExeGetClEntCDir( int nEntId, Vector3d& vtCDir) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) ; + // recupero CDir + return pMachMgr->GetClEntCDir( nEntId, vtCDir) ; +} + +//----------------------------------------------------------------------------- +bool +ExeGetClEntADir( int nEntId, Vector3d& vADir) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) ; + // recupero ADir + return pMachMgr->GetClEntADir( nEntId, vADir) ; +} + //----------------------------------------------------------------------------- // Simulazione //----------------------------------------------------------------------------- diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 430b1ae59eb4f2edf2d0d2bc39e2dd2f1d137bcd..a7c0e5ee9b899c818a679d83a31f45a2602e02e6 100644 GIT binary patch delta 97 zcmX>ylkvz*#tq-t7)>^RXLDs{G@0xusJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlCl(Mt{P-!29 delta 97 zcmX>ylkvz*#tq-t7>zf7XLDs{G@k4zsJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlCl(Mt{PR$>E diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index 704d215..133a0d9 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -1462,7 +1462,7 @@ LuaTdbIsCurrToolModified( lua_State* L) { // nessun parametro LuaClearStack( L) ; - // verifico se l'utensile corrente č stato modificato + // verifico se l'utensile corrente ļæ½ stato modificato bool bOk = ExeTdbIsCurrToolModified() ; LuaSetParam( L, bOk) ; return 1 ; @@ -2037,7 +2037,7 @@ LuaMdbIsCurrMachiningModified( lua_State* L) { // nessun parametro LuaClearStack( L) ; - // verifico se la lavorazione corrente č stata modificata + // verifico se la lavorazione corrente ļæ½ stata modificata bool bOk = ExeMdbIsCurrMachiningModified() ; LuaSetParam( L, bOk) ; return 1 ; @@ -3309,6 +3309,60 @@ LuaGetClEntAxesVal( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaGetClEntTDir( lua_State* L) +{ + // 1 parametro : nEntId + int nEntId ; + LuaGetParam( L, 1, nEntId) ; + LuaClearStack( L) ; + // recupero vTDir + Vector3d vTDir ; + bool bOk = ExeGetClEntTDir( nEntId, vTDir) ; + if ( bOk) + LuaSetParam( L, vTDir) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetClEntCDir( lua_State* L) +{ + // 1 parametro : nEntId + int nEntId ; + LuaGetParam( L, 1, nEntId) ; + LuaClearStack( L) ; + // recupero vCDir + Vector3d vCDir ; + bool bOk = ExeGetClEntCDir( nEntId, vCDir) ; + if ( bOk) + LuaSetParam( L, vCDir) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetClEntADir( lua_State* L) +{ + // 1 parametro : nEntId + int nEntId ; + LuaGetParam( L, 1, nEntId) ; + LuaClearStack( L) ; + // recupero vADir + Vector3d vADir ; + bool bOk = ExeGetClEntADir( nEntId, vADir) ; + if ( bOk) + LuaSetParam( L, vADir) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- // Simulation //------------------------------------------------------------------------------- @@ -3492,7 +3546,7 @@ LuaSimGetMoveInfo( lua_State* L) { // nessun parametro LuaClearStack( L) ; - // recupero tipo e veolcitą del movimento corrente + // recupero tipo e veolcitļæ½ del movimento corrente int nGmove ; double dFeed ; bool bOk = ExeSimGetMoveInfo( nGmove, dFeed) ; @@ -3800,7 +3854,7 @@ LuaGetCalcPositions( lua_State* L) // restituisco il risultato if ( bOk) { LuaSetParam( L, bOk) ; - LuaSetParam( L, 0) ; // assegnato per compatibilitą + LuaSetParam( L, 0) ; // assegnato per compatibilitļæ½ LuaSetParam( L, dX) ; LuaSetParam( L, dY) ; LuaSetParam( L, dZ) ; @@ -4647,11 +4701,14 @@ LuaInstallMachMgr( LuaMgr& luaMgr) // CL Entities Interrogations bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntMove", LuaGetClEntMove) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntFlag", LuaGetClEntFlag) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntIndex", LuaGetClEntIndex) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntFeed", LuaGetClEntFeed) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntIndex", LuaGetClEntIndex) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntFeed", LuaGetClEntFeed) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesStatus", LuaGetClEntAxesStatus) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesMask", LuaGetClEntAxesMask) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesVal", LuaGetClEntAxesVal) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntAxesVal", LuaGetClEntAxesVal) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntTDir", LuaGetClEntTDir) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntCDir", LuaGetClEntCDir) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetClEntADir", LuaGetClEntADir) ; // Simulation bOk = bOk && luaMgr.RegisterFunction( "EgtSimInit", LuaSimInit) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSimStart", LuaSimStart) ; From 0699f7ffd135045c54affd6c3b84c1a89215cb6c Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Thu, 19 Mar 2026 18:43:11 +0100 Subject: [PATCH 40/54] EgtExecutor : - aggiunta funzione EraseFins per gli Zmap. --- EXE_GdbCreateVol.cpp | 24 +++++++++++++++++++++++- LUA_GdbModifyVol.cpp | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/EXE_GdbCreateVol.cpp b/EXE_GdbCreateVol.cpp index fdebb51..8c81f32 100644 --- a/EXE_GdbCreateVol.cpp +++ b/EXE_GdbCreateVol.cpp @@ -225,7 +225,7 @@ bool ExeUniformVolZmap( int nVolZmapId, double dToler, bool bExtensionFirst, int nToolNum) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // recupero lo Zmap IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ; bool bOk = ( pVZM != nullptr) ; @@ -244,3 +244,25 @@ ExeUniformVolZmap( int nVolZmapId, double dToler, bool bExtensionFirst, int nToo } return bOk ; } + +//-------------------------------------------------------------------------------- +bool +ExeVolZMapEraseFins( int nVolZMapId, const Vector3d& vtDir, double dThick) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) ; + // Recupero lo ZMap + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZMapId)) ; + bool bOk = ( pVZM != nullptr) ; + // Aggiorno lo ZMap mediante rimozione delle alette + bOk = bOk && pVZM->EraseFins( vtDir, dThick) ; + // Se richiesto salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZMapEraseFins(" + ToString( nVolZMapId) + "," + + ToString( vtDir) + "," + + ToString( dThick) + ")" + " -- bOk =" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; +} diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index f12d443..98eb838 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -437,6 +437,24 @@ LuaVolZmapOffset( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaVolZmapEraseFins( lua_State* L) +{ + // 3 parametri : Id, vtDir, dThick + int nId ; + LuaCheckParam( L, 1, nId) ; + Vector3d vtDir ; + LuaCheckParam( L, 2, vtDir) ; + double dThick ; + LuaCheckParam( L, 3, dThick) ; + LuaClearStack( L) ; + // Eseguo la rimozione delle alette + bool bOk = ExeVolZMapEraseFins( nId, vtDir, dThick) ; + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbModifyVol( LuaMgr& luaMgr) @@ -460,5 +478,6 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtUpdateVolZmapByAddingSurfTm", LuaUpdateVolZmapByAddingSurfTm ) ; bOk = bOk && luaMgr.RegisterFunction( "EgtUniformVolZmap", LuaUniformVolZmap) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapOffset", LuaVolZmapOffset) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapEraseFins", LuaVolZmapEraseFins) ; return bOk ; } \ No newline at end of file From 5314a1926bb2f674809a61eea5979d534cf91ad9 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 19 Mar 2026 19:31:36 +0100 Subject: [PATCH 41/54] EgtExecutor : - cambio nome di funzione exe/lua da EraseFins in RemoveFins - cambio nome di funzione exe/lua da UniformVolZmap a VolZmapMakeUniform. --- EXE_GdbCreateVol.cpp | 78 -------------------------------------------- EXE_GdbModifyVol.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++ LUA_GdbModifyVol.cpp | 12 +++---- 3 files changed, 84 insertions(+), 84 deletions(-) diff --git a/EXE_GdbCreateVol.cpp b/EXE_GdbCreateVol.cpp index 8c81f32..a61cec5 100644 --- a/EXE_GdbCreateVol.cpp +++ b/EXE_GdbCreateVol.cpp @@ -188,81 +188,3 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe // restituisco l'identificativo della nuova entitĆ  return nNewId ; } - -//------------------------------------------------------------------------------- -bool -ExeUpdateVolZmapByAddingSurfTm( int nVolZmapId, int nStmId) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero lo Zmap - IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ; - bool bOk = ( pVZM != nullptr) ; - // recupero la trimesh - PtrOwner pStm( CloneSurfTriMesh( pGeomDB->GetGeoObj( nStmId))) ; - bOk = bOk && !IsNull( pStm) ; - // recupero il frame dello Zmap e della Trimesh - Frame3d frZmap, frStm ; - bOk = bOk && pGeomDB->GetGlobFrame( nVolZmapId, frZmap) && - pGeomDB->GetGlobFrame( nStmId, frStm) ; - // porto la Stm nel frame dello Zmap - bOk = bOk && pStm->LocToLoc( frStm, frZmap) ; - // aggiorno lo Zmap con la nuova superficie - bOk = bOk && pVZM->AddSurfTm( pStm) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtUpdateVolZmapByAddingSurfTm(" + ToString( nVolZmapId) + "," + - ToString( nStmId) + ")" - " -- bOk =" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - return bOk ; -} - -//------------------------------------------------------------------------------- -bool -ExeUniformVolZmap( int nVolZmapId, double dToler, bool bExtensionFirst, int nToolNum) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero lo Zmap - IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ; - bool bOk = ( pVZM != nullptr) ; - // aggiorno lo Zmap - dToler = max( dToler, EPS_SMALL) ; - bOk = bOk && pVZM->MakeUniform( dToler, bExtensionFirst, nToolNum) ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtUniformVolZmap(" + ToString( nVolZmapId) + "," + - ToString( dToler) + "," + - ( bExtensionFirst ? "true" : "false") + - ToString( nToolNum) + ")" - " -- bOk =" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - return bOk ; -} - -//-------------------------------------------------------------------------------- -bool -ExeVolZMapEraseFins( int nVolZMapId, const Vector3d& vtDir, double dThick) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) ; - // Recupero lo ZMap - IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZMapId)) ; - bool bOk = ( pVZM != nullptr) ; - // Aggiorno lo ZMap mediante rimozione delle alette - bOk = bOk && pVZM->EraseFins( vtDir, dThick) ; - // Se richiesto salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtVolZMapEraseFins(" + ToString( nVolZMapId) + "," + - ToString( vtDir) + "," + - ToString( dThick) + ")" - " -- bOk =" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - return bOk ; -} diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index eddf97d..422be63 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -561,3 +561,81 @@ ExeVolZMapOffset( int nId, double dDist, int nType) } return bOk ; } + +//------------------------------------------------------------------------------- +bool +ExeUpdateVolZmapByAddingSurfTm( int nVolZmapId, int nStmId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero lo Zmap + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ; + bool bOk = ( pVZM != nullptr) ; + // recupero la trimesh + PtrOwner pStm( CloneSurfTriMesh( pGeomDB->GetGeoObj( nStmId))) ; + bOk = bOk && !IsNull( pStm) ; + // recupero il frame dello Zmap e della Trimesh + Frame3d frZmap, frStm ; + bOk = bOk && pGeomDB->GetGlobFrame( nVolZmapId, frZmap) && + pGeomDB->GetGlobFrame( nStmId, frStm) ; + // porto la Stm nel frame dello Zmap + bOk = bOk && pStm->LocToLoc( frStm, frZmap) ; + // aggiorno lo Zmap con la nuova superficie + bOk = bOk && pVZM->AddSurfTm( pStm) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtUpdateVolZmapByAddingSurfTm(" + ToString( nVolZmapId) + "," + + ToString( nStmId) + ")" + " -- bOk =" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; +} + +//------------------------------------------------------------------------------- +bool +ExeVolZmapMakeUniform( int nVolZmapId, double dToler, bool bExtensionFirst, int nToolNum) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero lo Zmap + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ; + bool bOk = ( pVZM != nullptr) ; + // aggiorno lo Zmap + dToler = max( dToler, EPS_SMALL) ; + bOk = bOk && pVZM->MakeUniform( dToler, bExtensionFirst, nToolNum) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapMakeUniform(" + ToString( nVolZmapId) + "," + + ToString( dToler) + "," + + ( bExtensionFirst ? "true" : "false") + + ToString( nToolNum) + ")" + " -- bOk =" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; +} + +//-------------------------------------------------------------------------------- +bool +ExeVolZMapRemoveFins( int nVolZMapId, const Vector3d& vtDir, double dThick) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) ; + // Recupero lo ZMap + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZMapId)) ; + bool bOk = ( pVZM != nullptr) ; + // Aggiorno lo ZMap mediante rimozione delle alette + bOk = bOk && pVZM->RemoveFins( vtDir, dThick) ; + // Se richiesto salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZMapRemoveFins(" + ToString( nVolZMapId) + "," + + ToString( vtDir) + "," + + ToString( dThick) + ")" + " -- bOk =" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return bOk ; +} diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index 98eb838..c484120 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -402,7 +402,7 @@ LuaUpdateVolZmapByAddingSurfTm( lua_State* L) //------------------------------------------------------------------------------- static int -LuaUniformVolZmap( lua_State* L) +LuaVolZmapMakeUniform( lua_State* L) { // 2 o 3 o 4 parametri : nVolZmapId, dToler [, bExtensionFirst] [, nToolNum] int nVolZmapId ; @@ -414,7 +414,7 @@ LuaUniformVolZmap( lua_State* L) int nToolNum = 0 ; LuaGetParam( L, 4, nToolNum) ; LuaClearStack( L) ; - bool bOk = ExeUniformVolZmap( nVolZmapId, dToler, bExtensionFirst, nToolNum) ; + bool bOk = ExeVolZmapMakeUniform( nVolZmapId, dToler, bExtensionFirst, nToolNum) ; LuaSetParam( L, bOk) ; return 1 ; } @@ -439,7 +439,7 @@ LuaVolZmapOffset( lua_State* L) //------------------------------------------------------------------------------- static int -LuaVolZmapEraseFins( lua_State* L) +LuaVolZmapRemoveFins( lua_State* L) { // 3 parametri : Id, vtDir, dThick int nId ; @@ -450,7 +450,7 @@ LuaVolZmapEraseFins( lua_State* L) LuaCheckParam( L, 3, dThick) ; LuaClearStack( L) ; // Eseguo la rimozione delle alette - bool bOk = ExeVolZMapEraseFins( nId, vtDir, dThick) ; + bool bOk = ExeVolZMapRemoveFins( nId, vtDir, dThick) ; LuaSetParam( L, bOk) ; return 1 ; } @@ -476,8 +476,8 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCutVolZmapPlane", LuaCutVolZmapPlane) ; bOk = bOk && luaMgr.RegisterFunction( "EgtUpdateVolZmapByAddingSurfTm", LuaUpdateVolZmapByAddingSurfTm ) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtUniformVolZmap", LuaUniformVolZmap) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMakeUniform", LuaVolZmapMakeUniform) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapOffset", LuaVolZmapOffset) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapEraseFins", LuaVolZmapEraseFins) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapRemoveFins", LuaVolZmapRemoveFins) ; return bOk ; } \ No newline at end of file From 4b8f8ee87e4d37e338eabc63b75a8559a8e073e4 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 20 Mar 2026 09:02:56 +0100 Subject: [PATCH 42/54] EgtExecutor : - aggiunto parametro nRefType a funzione VolZMapRemoveFins. --- EXE_GdbModifyVol.cpp | 12 +++++++++--- LUA_GdbModifyVol.cpp | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index 422be63..3866ea2 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -620,20 +620,26 @@ ExeVolZmapMakeUniform( int nVolZmapId, double dToler, bool bExtensionFirst, int //-------------------------------------------------------------------------------- bool -ExeVolZMapRemoveFins( int nVolZMapId, const Vector3d& vtDir, double dThick) +ExeVolZMapRemoveFins( int nVolZMapId, const Vector3d& vtDir, double dThick, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) ; // Recupero lo ZMap IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZMapId)) ; bool bOk = ( pVZM != nullptr) ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGlobFrame( nVolZMapId, frLoc) ; + // porto in locale la normale al piano + Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frLoc) ; // Aggiorno lo ZMap mediante rimozione delle alette - bOk = bOk && pVZM->RemoveFins( vtDir, dThick) ; + bOk = bOk && pVZM->RemoveFins( vtDirL, dThick) ; // Se richiesto salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtVolZMapRemoveFins(" + ToString( nVolZMapId) + "," + ToString( vtDir) + "," + - ToString( dThick) + ")" + ToString( dThick) + "," + + RefTypeToString( nRefType) + ")" + " -- bOk =" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index c484120..3ea1e93 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -448,9 +448,11 @@ LuaVolZmapRemoveFins( lua_State* L) LuaCheckParam( L, 2, vtDir) ; double dThick ; LuaCheckParam( L, 3, dThick) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 4, nRefType) ; LuaClearStack( L) ; // Eseguo la rimozione delle alette - bool bOk = ExeVolZMapRemoveFins( nId, vtDir, dThick) ; + bool bOk = ExeVolZMapRemoveFins( nId, vtDir, dThick, nRefType) ; LuaSetParam( L, bOk) ; return 1 ; } From bdd0e89b7806290309d3840811570a832f492581 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 23 Mar 2026 08:25:59 +0100 Subject: [PATCH 43/54] EgtExecutor : - piccole modifiche estetiche. --- EXE_NstPartNesting.cpp | 71 ++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index 6e8e86f..ccfe026 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -802,7 +802,7 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& // Eseguo verifiche // regioni dei pezzi - for ( size_t i = 0 ; i < vReg.size() ; ++ i) { + for ( int i = 0 ; i < ssize( vReg) ; ++ i) { // verifico con le regioni degli altri pezzi (sempre regioni standard) for ( int nOthRegId : vOthReg) { if ( ExeSurfFrChunkSimpleClassify( vReg[i], 0, nOthRegId, 0) != REGC_OUT) @@ -816,9 +816,9 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& } } // regioni sotto dei pezzi - for ( size_t i = 0 ; i < vDwnReg.size() ; ++ i) { + for ( int i = 0 ; i < ssize( vDwnReg) ; ++ i) { // verifico con le regioni sotto degli altri pezzi - for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) { if ( vDwnReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nDwnRegId = ( vDwnReg[i] != GDB_ID_NULL ? vDwnReg[i] : vReg[i]) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; @@ -827,7 +827,7 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& } } // e con le regioni sotto dei tagli degli altri pezzi - for ( size_t j = 0 ; j < vOthDwnCutReg.size() ; ++ j) { + for ( int j = 0 ; j < ssize( vOthDwnCutReg) ; ++ j) { if ( vDwnReg[i] != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { int nDwnRegId = ( vDwnReg[i] != GDB_ID_NULL ? vDwnReg[i] : vReg[i]) ; int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; @@ -839,16 +839,16 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& // regioni delle lavorazioni dei pezzi for ( int nCutRegId : vCutReg) { // le confronto con le regioni degli altri pezzi - for ( size_t j = 0 ; j < vOthReg.size() ; ++ j) { + for ( int j = 0 ; j < ssize( vOthReg) ; ++ j) { int nOthUpRegId = (( vOthUpReg[j] == GDB_ID_NULL) ? vOthReg[j] : vOthUpReg[j]) ; if ( ExeSurfFrChunkSimpleClassify( nCutRegId, 0, nOthUpRegId, 0) != REGC_OUT) return false ; } } // regioni sotto delle lavorazioni dei pezzi - for ( size_t i = 0 ; i < vDwnCutReg.size() ; ++ i) { + for ( int i = 0 ; i < ssize( vDwnCutReg) ; ++ i) { // le confronto con le regioni sotto degli altri pezzi - for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) { if ( vDwnCutReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nDwnCutRegId = ( vDwnCutReg[i] != GDB_ID_NULL ? vDwnCutReg[i] : vCutReg[i]) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; @@ -1170,23 +1170,27 @@ MySurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero la prima superficie FlatRegion ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ; - bool bOk = ( pSfr1 != nullptr) ; + if ( pSfr1 == nullptr) + return false ; // recupero il riferimento della superficie Frame3d frSurf1 ; - bOk = bOk && pGeomDB->GetGlobFrame( nId1, frSurf1) ; + if ( ! pGeomDB->GetGlobFrame( nId1, frSurf1)) + return false ; // recupero la seconda superficie FlatRegion const ISurfFlatRegion* pSfr2 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId2)) ; - bOk = bOk && ( pSfr2 != nullptr) ; + if ( pSfr2 == nullptr) + return false ; // recupero il riferimento della superficie Frame3d frSurf2 ; - bOk = bOk && pGeomDB->GetGlobFrame( nId2, frSurf2) ; + if ( ! pGeomDB->GetGlobFrame( nId2, frSurf2)) + return false ; // se riferimenti diversi, porto una copia della seconda nel riferimento della prima const ISurfFlatRegion* pSfr2L = pSfr2 ; PtrOwner pTmp ; if ( ! AreSameFrame( frSurf1, frSurf2)) { pTmp.Set( pSfr2->Clone()) ; - bOk = bOk && ! IsNull( pTmp) ; - bOk = bOk && pTmp->LocToLoc( frSurf2, frSurf1) ; + if ( IsNull( pTmp) || ! pTmp->LocToLoc( frSurf2, frSurf1)) + return false ; pSfr2L = pTmp ; } // porto in locale alla prima superficie il versore di movimento @@ -1194,18 +1198,17 @@ MySurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double vtDirL.ToLoc( frSurf1) ; // calcolo massima lunghezza di traslazione della prima regione senza semplice collisione con la seconda CAvSimpleSurfFrMove ScdSfrMove( *pSfr1, *pSfr2L) ; - bOk = bOk && ScdSfrMove.Translate( vtDirL, dLen) ; - if ( bOk) { - scInfo = ScdSfrMove.GetSCollInfo() ; - if ( scInfo.nType != SCI_NONE) { - scInfo.ptP1.ToGlob( frSurf1) ; - scInfo.vtDirM.ToGlob( frSurf1) ; - scInfo.vtDirF.ToGlob( frSurf1) ; - } - if ( scInfo.nType == SCI_LINE_LINE) - scInfo.ptP2.ToGlob( frSurf1) ; + if ( ! ScdSfrMove.Translate( vtDirL, dLen)) + return false ; + scInfo = ScdSfrMove.GetSCollInfo() ; + if ( scInfo.nType != SCI_NONE) { + scInfo.ptP1.ToGlob( frSurf1) ; + scInfo.vtDirM.ToGlob( frSurf1) ; + scInfo.vtDirF.ToGlob( frSurf1) ; } - return bOk ; + if ( scInfo.nType == SCI_LINE_LINE) + scInfo.ptP2.ToGlob( frSurf1) ; + return true ; } //---------------------------------------------------------------------------- @@ -1340,7 +1343,7 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster } } // la confronto con le regioni in basso degli altri pezzi - for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) { if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; @@ -1349,7 +1352,7 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster } } // e con le regioni in basso dei tagli degli altri pezzi - for ( size_t j = 0 ; j < vOthDwnCutReg.size() ; ++ j) { + for ( int j = 0 ; j < ssize( vOthDwnCutReg) ; ++ j) { if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; @@ -1366,7 +1369,7 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster } // le confronto con le regioni degli altri pezzi for ( int nCrId : vCrId) { - for ( size_t k = 0 ; k < vOthReg.size() ; ++ k) { + for ( int k = 0 ; k < ssize( vOthReg) ; ++ k) { int nOthRegId = ( vOthUpReg[k] == GDB_ID_NULL ? vOthReg[k] : vOthUpReg[k]) ; MySurfFrMoveSimpleNoCollision( nCrId, nOthRegId, vtDir, dLen, scInfoCurr) ; dPrevLen = UpdateCollId( dLen, dPrevLen, nCrId, nOthRegId, true, false, scInfoCurr) ; @@ -1380,8 +1383,8 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster break ; } // le confronto con le regioni in basso degli altri pezzi - for ( size_t j = 0 ; j < vDwnCrId.size() ; ++ j) { - for ( size_t k = 0 ; k < vOthDwnReg.size() ; ++ k) { + for ( int j = 0 ; j < ssize( vDwnCrId) ; ++ j) { + for ( int k = 0 ; k < ssize( vOthDwnReg) ; ++ k) { if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) { int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ; int nOthDwnRegId = ( vOthDwnReg[k] != GDB_ID_NULL ? vOthDwnReg[k] : vOthReg[k]) ; @@ -1591,7 +1594,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus } } // la confronto con le regioni in basso degli altri pezzi - for ( size_t j = 0 ; j < vOthDwnReg.size() ; ++ j) { + for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) { if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; @@ -1599,7 +1602,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus } } // e con le regioni in basso dei tagli degli altri pezzi - for ( size_t j = 0 ; j < vOthDwnCutReg.size() ; ++ j) { + for ( int j = 0 ; j < ssize( vOthDwnCutReg) ; ++ j) { if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; @@ -1615,7 +1618,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus } // le confronto con le regioni degli altri pezzi for ( int nCrId : vCrId) { - for ( size_t k = 0 ; k < vOthReg.size() ; ++ k) { + for ( int k = 0 ; k < ssize( vOthReg) ; ++ k) { int nOthRegId = ( vOthUpReg[k] == GDB_ID_NULL ? vOthReg[k] : vOthUpReg[k]) ; ExeSurfFrRotateSimpleNoCollision( nCrId, nOthRegId, ptCen, dAng, RTY_GLOB) ; } @@ -1628,8 +1631,8 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus break ; } // le confronto con le regioni in basso degli altri pezzi - for ( size_t j = 0 ; j < vDwnCrId.size() ; ++ j) { - for ( size_t k = 0 ; k < vOthDwnReg.size() ; ++ k) { + for ( int j = 0 ; j < ssize( vDwnCrId) ; ++ j) { + for ( int k = 0 ; k < ssize( vOthDwnReg) ; ++ k) { if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) { int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ; int nOthDwnRegId = ( vOthDwnReg[k] != GDB_ID_NULL ? vOthDwnReg[k] : vOthReg[k]) ; From 4a34b2e45dc551a948e7e83e0c9b6cdc88455368 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Tue, 24 Mar 2026 16:01:43 +0100 Subject: [PATCH 44/54] EgtExecutor 3.1c5 : - aggiunto controllo sulla dimensione alle funzioni di creazione ZMap per versioni a 32Bit. --- EXE_GdbCreateVol.cpp | 44 +++++++++++++++++++++++++++++++++++++++---- EgtExecutor.rc | Bin 19652 -> 19652 bytes 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/EXE_GdbCreateVol.cpp b/EXE_GdbCreateVol.cpp index a61cec5..e70e203 100644 --- a/EXE_GdbCreateVol.cpp +++ b/EXE_GdbCreateVol.cpp @@ -45,7 +45,16 @@ ExeCreateVolZmap( int nParentId, const Point3d& ptIni, double dDimX, double dDim // creo lo Zmap nel suo riferimento intrinseco PtrOwner pVZM( CreateVolZmap()) ; bOk = bOk && ! IsNull( pVZM) ; - bOk = bOk && pVZM->Create( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex) ; + if ( bOk) { + int nError = 0 ; + bOk = pVZM->Create( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex, &nError) ; + if ( ! bOk) { + if ( nError == 1) + ExeOutLog( "EgtVolZmapBox too big for a 32-bit system") ; + else + ExeOutLog( "EgtVolZmapBox error number : " + ToString( nError)) ; + } + } // lo porto nel riferimento locale bOk = bOk && pVZM->ToGlob( frBox) ; // inserisco lo Zmap nel DB @@ -88,7 +97,16 @@ int ExeCreateVolZmapEmpty( int nParentId, const Point3d& ptIni, double dDimX, do // creo lo Zmap nel suo riferimento intrinseco PtrOwner pVZM( CreateVolZmap()) ; bOk = bOk && ! IsNull( pVZM) ; - bOk = bOk && pVZM->CreateEmpty( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex) ; + if ( bOk) { + int nError = 0 ; + bOk = pVZM->CreateEmpty( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex, &nError) ; + if ( ! bOk) { + if ( nError == 1) + ExeOutLog( "EgtVolZmapEmpty too big for a 32-bit system") ; + else + ExeOutLog( "EgtVolZmapEmpty error number : " + ToString( nError)) ; + } + } // lo porto nel riferimento locale bOk = bOk && pVZM->ToGlob( frBox) ; // inserisco lo Zmap nel DB @@ -130,7 +148,16 @@ ExeCreateVolZmapByRegionExtrusion( int nParentId, int nSfrId, double dDimZ, doub // creo lo Zmap nel suo riferimento intrinseco PtrOwner pVZM( CreateVolZmap()) ; bOk = bOk && ! IsNull( pVZM) ; - bOk = bOk && pVZM->CreateFromFlatRegion( *pSfr, dDimZ, dPrec, bTriDex) ; + if ( bOk) { + int nError = 0 ; + bOk = pVZM->CreateFromFlatRegion( *pSfr, dDimZ, dPrec, bTriDex, &nError) ; + if ( ! bOk) { + if ( nError == 1) + ExeOutLog( "EgtVolZmapByRegionExtrusion too big for a 32-bit system") ; + else + ExeOutLog( "EgtVolZmapByRegionExtrusion error number : " + ToString( nError)) ; + } + } // lo porto nel riferimento di destinazione bOk = bOk && pVZM->LocToLoc( frSfr, frDest) ; // inserisco lo Zmap nel DB @@ -169,7 +196,16 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe // creo lo Zmap nel suo riferimento intrinseco PtrOwner pVZM( CreateVolZmap()) ; bOk = bOk && ! IsNull( pVZM) ; - bOk = bOk && pVZM->CreateFromTriMesh( *pStm, dPrec, bTriDex, dExtraBox) ; + if ( bOk) { + int nError = 0 ; + bOk = pVZM->CreateFromTriMesh( *pStm, dPrec, bTriDex, dExtraBox, &nError) ; + if ( ! bOk) { + if ( nError == 1) + ExeOutLog( "EgtVolZmapFromSurfTm too big for a 32-bit system") ; + else + ExeOutLog( "EgtVolZmapFromSurfTm error number : " + ToString( nError)) ; + } + } // lo porto nel riferimento di destinazione bOk = bOk && pVZM->LocToLoc( frStm, frDest) ; // inserisco lo Zmap nel DB diff --git a/EgtExecutor.rc b/EgtExecutor.rc index a7c0e5ee9b899c818a679d83a31f45a2602e02e6..edd62f3895393077d3171cae6d988eed35da59dc 100644 GIT binary patch delta 97 zcmX>ylkvz*#tq-t7)>{SXLDs{G@a}ysJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlCl(Mt{QUxE4 delta 97 zcmX>ylkvz*#tq-t7)>^RXLDs{G@0xusJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlCl(Mt{P-!29 From 1141af30d7de19efa6c4d351a557e7bbe8be5486 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 25 Mar 2026 16:48:10 +0100 Subject: [PATCH 45/54] =?UTF-8?q?EgtExecutor=20:=20-=20aggiunta=20funzione?= =?UTF-8?q?=20lua=20EgtGetCalcAnglesEx=20per=20calcolo=20assi=20rotanti=20?= =?UTF-8?q?in=20centri=20di=20lavoro=20con=20pi=C3=B9=20di=20due=20assi=20?= =?UTF-8?q?-=20funzione=20lua=20EgtVerifyOutstroke=20estesa=20per=20accett?= =?UTF-8?q?are=20fino=20a=204=20assi=20rotanti.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EXE_MachMgr.cpp | 10 ++++++++++ LUA_MachMgr.cpp | 49 +++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index 507a370..c656da0 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -3647,6 +3647,16 @@ ExeVerifyOutstroke( double dX, double dY, double dZ, double dAngA, double dAngB, return pMachMgr->VerifyOutstroke( dX, dY, dZ, dAngA, dAngB, nStat) ; } +//----------------------------------------------------------------------------- +bool +ExeVerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, int& nStat) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) + // verifica l'extracorsa degli assi + return pMachMgr->VerifyOutstroke( dX, dY, dZ, vAng, true, nStat) ; +} + //----------------------------------------------------------------------------- bool ExeGetOutstrokeInfo( string& sInfo) diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index 133a0d9..2c26121 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -3832,11 +3832,38 @@ LuaGetCalcAngles( lua_State* L) } } +//------------------------------------------------------------------------------- +static int +LuaGetCalcAnglesEx( lua_State* L) +{ + // 1 o 2 parametri : vtDirT, vtDirA + Vector3d vtDirT ; + LuaCheckParam( L, 1, vtDirT) + Vector3d vtDirA ; + LuaGetParam( L, 2, vtDirA) ; + LuaClearStack( L) ; + // calcolo gli angoli macchina dalle direzioni fresa e ausiliaria + int nStat ; DBLVECTOR vAng1, vAng2 ; + bool bOk = ExeGetCalcAngles( vtDirT, vtDirA, nStat, vAng1, vAng2) ; + // restituisco il risultato + if ( bOk) { + LuaSetParam( L, bOk) ; + LuaSetParam( L, nStat) ; + LuaSetParam( L, vAng1) ; + LuaSetParam( L, vAng2) ; + return 4 ; + } + else { + LuaSetParam( L, bOk) ; + return 1 ; + } +} + //------------------------------------------------------------------------------- static int LuaGetCalcPositions( lua_State* L) { - // da 2 a 5 parametri : ptP, dAngA [, dAngB] [, dAngC] [, dAngD] + // da 1 a 5 parametri : ptP [, dAngR1] [, dAngR2] [, dAngR3] [, dAngR4] Point3d ptP ; LuaCheckParam( L, 1, ptP) DBLVECTOR vAng ; @@ -3854,7 +3881,7 @@ LuaGetCalcPositions( lua_State* L) // restituisco il risultato if ( bOk) { LuaSetParam( L, bOk) ; - LuaSetParam( L, 0) ; // assegnato per compatibilitļæ½ + LuaSetParam( L, 0) ; // assegnato per compatibilitĆ  LuaSetParam( L, dX) ; LuaSetParam( L, dY) ; LuaSetParam( L, dZ) ; @@ -3982,21 +4009,26 @@ LuaGetCalcAuxDirFromAngles( lua_State* L) static int LuaVerifyOutstroke( lua_State* L) { - // 5 parametri : dX, dY, dZ, dAngA, dAngB + // 3 o 4 o 5 o 6 o 7 parametri : dX, dY, dZ [, dAngR1] [, dAngR2] [, dAngR3] [, dAngR4] double dX ; LuaCheckParam( L, 1, dX) double dY ; LuaCheckParam( L, 2, dY) double dZ ; LuaCheckParam( L, 3, dZ) - double dAngA ; - LuaCheckParam( L, 4, dAngA) - double dAngB ; - LuaCheckParam( L, 5, dAngB) + DBLVECTOR vAng ; + int i ; + for ( i = 4 ; i <= 7 ; ++ i) { + double dAng ; + if ( LuaGetParam( L, i, dAng)) + vAng.emplace_back( dAng) ; + else + break ; + } LuaClearStack( L) ; // imposto la tavola corrente per il calcolo int nStat ; - bool bOk = ExeVerifyOutstroke( dX, dY, dZ, dAngA, dAngB, nStat) ; + bool bOk = ExeVerifyOutstroke( dX, dY, dZ, vAng, nStat) ; // restituisco il risultato if ( bOk) { LuaSetParam( L, ( nStat == 0)) ; @@ -4754,6 +4786,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetAllCurrAxesNames", LuaGetAllCurrAxesNames) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetRotAxisBlocked", LuaGetRotAxisBlocked) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcAngles", LuaGetCalcAngles) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcAnglesEx", LuaGetCalcAnglesEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcPositions", LuaGetCalcPositions) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetRobotAngles", LuaGetRobotAngles) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcTipFromPositions", LuaGetCalcTipFromPositions) ; From d87b349788bddf01a98a58b271cd51b1f7466046 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 27 Mar 2026 18:43:36 +0100 Subject: [PATCH 46/54] EgtExecutor (Nst_SurfFr) : - primo commit per CAv tra Regioni Piane con loop interni e Interferenza tra Regioni Piane. --- EXE_GdbGetSurf.cpp | 40 ++++++ EXE_NstMachining.cpp | 12 +- EXE_NstPartNesting.cpp | 288 +++++++++++++++++++++++++++++++---------- 3 files changed, 263 insertions(+), 77 deletions(-) diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index 0af254a..204b904 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -249,6 +249,46 @@ ExeSurfFrChunkSimpleClassify( int nId1, int nChunk1, int nId2, int nChunk2, doub return nRes ; } +//---------------------------------------------------------------------------- +// Resultati restituiti : REGC_NULL ( errore), REGC_OUT ( Chunks esterni), REGC_INTERS ( Chunk che si intersecano) +int +ExeSurfFlatRegionInterference( int nId1, int nChunk1, int nId2, int nChunk2, double dToler) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la prima superficie FlatRegion + ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ; + bool bOk = ( pSfr1 != nullptr) ; + // recupero il riferimento della superficie + Frame3d frSurf1 ; + bOk = bOk && pGeomDB->GetGlobFrame( nId1, frSurf1) ; + // recupero la seconda superficie FlatRegion + const ISurfFlatRegion* pSfr2 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId2)) ; + bOk = bOk && ( pSfr2 != nullptr) ; + // recupero il riferimento della superficie + Frame3d frSurf2 ; + bOk = bOk && pGeomDB->GetGlobFrame( nId2, frSurf2) ; + // se riferimenti diversi, porto una copia della seconda nel riferimento della prima + const ISurfFlatRegion* pSfr2L = pSfr2 ; + PtrOwner pTmp ; + if ( bOk && ( abs( dToler) > EPS_SMALL || ! AreSameFrame( frSurf1, frSurf2))) { + pTmp.Set( pSfr2->Clone()) ; + bOk = ( ! IsNull( pTmp)) ; + bOk = bOk && pTmp->LocToLoc( frSurf2, frSurf1) ; + pTmp->Offset( - abs( dToler), ICurve::OFF_FILLET) ; + pSfr2L = pTmp ; + } + // verifico interferenza del Chunk della prima regione rispetto a quello della seconda + int nRes = REGC_NULL ; + if ( bOk) { + bool bInterference = false ; + bOk = pSfr1->CheckChunkInterference( nChunk1, *pSfr2L, nChunk2, bInterference) ; + if ( bOk) + nRes = ( bInterference ? REGC_INTERS : REGC_OUT) ; + } + return nRes ; +} + //---------------------------------------------------------------------------- bool ExeSurfFrChunkCenter( int nId, int nChunk, int nRefId, Point3d& ptCen, Vector3d& vtN) diff --git a/EXE_NstMachining.cpp b/EXE_NstMachining.cpp index 44883af..be9fcc2 100644 --- a/EXE_NstMachining.cpp +++ b/EXE_NstMachining.cpp @@ -143,7 +143,7 @@ ExeVerifyMachining( int nMchId, int& nResult) // confronto la regione di attacco della lavorazione con le regioni degli altri pezzi for ( int nMchRegId : vMchLiReg) { for ( int nOthRegId : vOthReg) { - if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) nResult |= FMI_LI ; } } @@ -152,7 +152,7 @@ ExeVerifyMachining( int nMchId, int& nResult) if ( vMchDwnLiReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nMchRegId = ( ( vMchDwnLiReg[i] != GDB_ID_NULL) ? vMchDwnLiReg[i] : vMchLiReg[i]) ; int nOthRegId = ( ( vOthDwnReg[j] != GDB_ID_NULL) ? vOthDwnReg[j] : vOthReg[j]) ; - if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) nResult |= FMI_LI ; } } @@ -160,7 +160,7 @@ ExeVerifyMachining( int nMchId, int& nResult) // confronto la regione ridotta della lavorazione con le regioni degli altri pezzi for ( int nMchRegId : vMchRReg) { for ( int nOthRegId : vOthReg) { - if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) nResult |= FMI_RM ; } } @@ -169,7 +169,7 @@ ExeVerifyMachining( int nMchId, int& nResult) if ( vMchDwnRReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nMchRegId = ( ( vMchDwnRReg[i] != GDB_ID_NULL) ? vMchDwnRReg[i] : vMchRReg[i]) ; int nOthRegId = ( ( vOthDwnReg[j] != GDB_ID_NULL) ? vOthDwnReg[j] : vOthReg[j]) ; - if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) nResult |= FMI_RM ; } } @@ -177,7 +177,7 @@ ExeVerifyMachining( int nMchId, int& nResult) // confronto la regione di uscita della lavorazione con le regioni degli altri pezzi for ( int nMchRegId : vMchLoReg) { for ( int nOthRegId : vOthReg) { - if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) nResult |= FMI_LO ; } } @@ -186,7 +186,7 @@ ExeVerifyMachining( int nMchId, int& nResult) if ( vMchDwnLoReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nMchRegId = ( ( vMchDwnLoReg[i] != GDB_ID_NULL) ? vMchDwnLoReg[i] : vMchLoReg[i]) ; int nOthRegId = ( ( vOthDwnReg[j] != GDB_ID_NULL) ? vOthDwnReg[j] : vOthReg[j]) ; - if ( ExeSurfFrChunkSimpleClassify( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nOthRegId, 0, nMchRegId, 0, VERIF_TOLER) != REGC_OUT) nResult |= FMI_LO ; } } diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index ccfe026..154a518 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -24,6 +24,7 @@ #include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkCAvSimpleSurfFrMove.h" +#include "/EgtDev/Include/EGkCAvSurfFrMove.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EMkMachiningGeoConst.h" #include "/EgtDev/Include/EGkIntervals.h" @@ -32,6 +33,7 @@ using namespace std ; //---------------------------------------------------------------------------- +// collisioni semplici struct SCollInfoEx : public SCollInfo { int nIdM ; // identificativo della regione mobile @@ -43,7 +45,22 @@ struct SCollInfoEx : public SCollInfo nIdF( GDB_ID_NULL), bIsCutF( false) {} SCollInfoEx( const SCollInfo& Sou) : SCollInfo( Sou), nIdM( GDB_ID_NULL), bIsCutM( false), nIdF( GDB_ID_NULL), bIsCutF( false) {} -} ; +} ; + +//---------------------------------------------------------------------------- +// collisioni +struct CollInfoEx : public CollInfo +{ + int nIdM ; // identificativo della regione mobile + bool bIsCutM ; // flag di regione o pezzo di taglio + int nIdF ; // identificativo della regione fissa + bool bIsCutF ; // flag di regione di pezzo o di taglio + // costruttori + CollInfoEx() : CollInfo(), nIdM( GDB_ID_NULL), bIsCutM( false), + nIdF( GDB_ID_NULL), bIsCutF( false) {} + CollInfoEx( const CollInfo& Sou) : CollInfo( Sou), nIdM( GDB_ID_NULL), bIsCutM( false), + nIdF( GDB_ID_NULL), bIsCutF( false) {} +} ; //---------------------------------------------------------------------------- static const double SPESS = 100 ; @@ -710,7 +727,7 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& // box delle regioni dei pezzi rispetto al box dell'esterno if ( ! b3Region.EnclosesXY( b3RegCluster)) return false ; - // regioni dei pezzi rispetto alla regione dell'esterno + // regioni dei pezzi rispetto alla regione dell'esterno (controllo semplice) for ( int nRegId : vReg) { if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nBoxId, 0) != REGC_OUT) return false ; @@ -721,7 +738,7 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& return false ; } - // Verifico con l'eventuale regione di riferimento + // Verifico con l'eventuale regione di riferimento (controllo semplice) // recupero la regione int nRefReg = pGeomDB->GetFirstNameInGroup( nGroupId, NST_REFERENCE_REG) ; if ( pGeomDB->ExistsInfo( nRefReg, KEY_NST_OFF)) @@ -749,17 +766,17 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& vDmgReg.emplace_back( nId) ; nId = pGeomDB->GetNextName( nId, NST_DAMAGED_REG) ; } - // regioni dei pezzi rispetto alle regioni delle aree danneggiate + // regioni dei pezzi rispetto alle regioni delle aree danneggiate (controllo completo) for ( int nRegId : vReg) { for ( int nDmgRegId : vDmgReg) { - if ( ExeSurfFrChunkSimpleClassify( nRegId, 0, nDmgRegId, 0) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nRegId, 0, nDmgRegId, 0) != REGC_OUT) return false ; } } for ( int nDwnRegId : vDwnReg) { if ( nDwnRegId != GDB_ID_NULL) { for ( int nDmgRegId : vDmgReg) { - if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nDmgRegId, 0) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nDwnRegId, 0, nDmgRegId, 0) != REGC_OUT) return false ; } } @@ -800,29 +817,30 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& nId2 = ( bInRoot ? ExeGetNextPart( nId2, true) : ExeGetNextGroup( nId2)) ; } - // Eseguo verifiche + // Eseguo verifiche (controllo completo) // regioni dei pezzi for ( int i = 0 ; i < ssize( vReg) ; ++ i) { - // verifico con le regioni degli altri pezzi (sempre regioni standard) + // verifico con le regioni degli altri pezzi for ( int nOthRegId : vOthReg) { - if ( ExeSurfFrChunkSimpleClassify( vReg[i], 0, nOthRegId, 0) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( vReg[i], 0, nOthRegId, 0) != REGC_OUT) return false ; } // e con le regioni dei tagli degli altri pezzi (se esistono le regioni up devo usarle) - int nRegUpId = ((vUpReg[i] == GDB_ID_NULL) ? vReg[i] : vUpReg[i]) ; + int nRegUpId = ( ( vUpReg[i] == GDB_ID_NULL) ? vReg[i] : vUpReg[i]) ; for ( int nOthCutRegId : vOthCutReg) { - if ( ExeSurfFrChunkSimpleClassify( nRegUpId, 0, nOthCutRegId, 0) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nRegUpId, 0, nOthCutRegId, 0) != REGC_OUT) return false ; } } - // regioni sotto dei pezzi + + // regioni sotto dei pezzi (controllo completo) for ( int i = 0 ; i < ssize( vDwnReg) ; ++ i) { // verifico con le regioni sotto degli altri pezzi for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) { if ( vDwnReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nDwnRegId = ( vDwnReg[i] != GDB_ID_NULL ? vDwnReg[i] : vReg[i]) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; - if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nOthDwnRegId, 0) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nDwnRegId, 0, nOthDwnRegId, 0) != REGC_OUT) return false ; } } @@ -831,28 +849,30 @@ MyVerifyPartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, const BBox3d& if ( vDwnReg[i] != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { int nDwnRegId = ( vDwnReg[i] != GDB_ID_NULL ? vDwnReg[i] : vReg[i]) ; int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; - if ( ExeSurfFrChunkSimpleClassify( nDwnRegId, 0, nOthDwnCutRegId, 0) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nDwnRegId, 0, nOthDwnCutRegId, 0) != REGC_OUT) return false ; } } } + // regioni delle lavorazioni dei pezzi for ( int nCutRegId : vCutReg) { - // le confronto con le regioni degli altri pezzi + // le confronto con le regioni degli altri pezzi (controllo completo) for ( int j = 0 ; j < ssize( vOthReg) ; ++ j) { - int nOthUpRegId = (( vOthUpReg[j] == GDB_ID_NULL) ? vOthReg[j] : vOthUpReg[j]) ; - if ( ExeSurfFrChunkSimpleClassify( nCutRegId, 0, nOthUpRegId, 0) != REGC_OUT) + int nOthUpRegId = ( ( vOthUpReg[j] == GDB_ID_NULL) ? vOthReg[j] : vOthUpReg[j]) ; + if ( ExeSurfFlatRegionInterference( nCutRegId, 0, nOthUpRegId, 0) != REGC_OUT) return false ; } } + // regioni sotto delle lavorazioni dei pezzi for ( int i = 0 ; i < ssize( vDwnCutReg) ; ++ i) { - // le confronto con le regioni sotto degli altri pezzi + // le confronto con le regioni sotto degli altri pezzi (controllo completo) for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) { if ( vDwnCutReg[i] != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nDwnCutRegId = ( vDwnCutReg[i] != GDB_ID_NULL ? vDwnCutReg[i] : vCutReg[i]) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; - if ( ExeSurfFrChunkSimpleClassify( nDwnCutRegId, 0, nOthDwnRegId, 0) != REGC_OUT) + if ( ExeSurfFlatRegionInterference( nDwnCutRegId, 0, nOthDwnRegId, 0) != REGC_OUT) return false ; } } @@ -1135,6 +1155,8 @@ ExePackPartCluster( const INTVECTOR& vIds, bool bReducedCut, bool bBottomUp) //---------------------------------------------------------------------------- static SCollInfoEx s_scInfo ; static SCollInfoEx s_scInfoSaved ; +static CollInfoEx s_cInfo ; +static CollInfoEx s_cInfoSaved ; //---------------------------------------------------------------------------- static double @@ -1163,6 +1185,33 @@ UpdateCollId( double dLen, double dPrevLen, int nId1, int nId2, bool bIsCut1, bo } //---------------------------------------------------------------------------- +static double +UpdateCollId( double dLen, double dPrevLen, int nId1, int nId2, bool bIsCut1, bool bIsCut2, const CollInfo& cInfoCurr) +{ + if ( abs( dLen - dPrevLen) < EPS_SMALL) { + if ( cInfoCurr.nType == CI_PNT_LINE || cInfoCurr.nType == CI_LINE_LINE) { + s_cInfo = cInfoCurr ; + s_cInfo.nIdM = nId1 ; + s_cInfo.nIdF = nId2 ; + s_cInfo.bIsCutM = bIsCut1 ; + s_cInfo.bIsCutF = bIsCut2 ; + } + return dPrevLen ; + } + else if ( dLen < dPrevLen) { + s_cInfo = cInfoCurr ; + s_cInfo.nIdM = nId1 ; + s_cInfo.nIdF = nId2 ; + s_cInfo.bIsCutM = bIsCut1 ; + s_cInfo.bIsCutF = bIsCut2 ; + return dLen ; + } + else + return dPrevLen ; +} + +//---------------------------------------------------------------------------- +// Collisione semplice static bool MySurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double& dLen, SCollInfo& scInfo) { @@ -1212,11 +1261,63 @@ MySurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double } //---------------------------------------------------------------------------- +// Collisione completa +static bool +MySurfFrMoveNoCollision( int nId1, int nId2, const Vector3d& vtDir, double& dLen, CollInfo& cInfo) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero la prima superficie FlatRegion + ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ; + if ( pSfr1 == nullptr) + return false ; + // recupero il riferimento della superficie + Frame3d frSurf1 ; + if ( ! pGeomDB->GetGlobFrame( nId1, frSurf1)) + return false ; + // recupero la seconda superficie FlatRegion + const ISurfFlatRegion* pSfr2 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId2)) ; + if ( pSfr2 == nullptr) + return false ; + // recupero il riferimento della superficie + Frame3d frSurf2 ; + if ( ! pGeomDB->GetGlobFrame( nId2, frSurf2)) + return false ; + // se riferimenti diversi, porto una copia della seconda nel riferimento della prima + const ISurfFlatRegion* pSfr2L = pSfr2 ; + PtrOwner pTmp ; + if ( ! AreSameFrame( frSurf1, frSurf2)) { + pTmp.Set( pSfr2->Clone()) ; + if ( IsNull( pTmp) || ! pTmp->LocToLoc( frSurf2, frSurf1)) + return false ; + pSfr2L = pTmp ; + } + // porto in locale alla prima superficie il versore di movimento + Vector3d vtDirL = vtDir ; + vtDirL.ToLoc( frSurf1) ; + // calcolo massima lunghezza di traslazione della prima regione senza collisione con la seconda + CAvSurfFrMove cdSfrMove( *pSfr1, *pSfr2L) ; + if ( ! cdSfrMove.Translate( vtDirL, dLen)) + return false ; + cInfo = cdSfrMove.GetCollInfo() ; + if ( cInfo.nType != CI_NONE) { + cInfo.ptP1.ToGlob( frSurf1) ; + cInfo.vtDirM.ToGlob( frSurf1) ; + cInfo.vtDirF.ToGlob( frSurf1) ; + } + if ( cInfo.nType == CI_LINE_LINE) + cInfo.ptP2.ToGlob( frSurf1) ; + return true ; +} + +//---------------------------------------------------------------------------- +// Traslazione con CAvSurfFr static bool MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster, bool bReducedCut, Vector3d& vtMove) { // Reset info di collisione - s_scInfo.nType = SCI_NONE ; + s_scInfo.nType = SCI_NONE ; // semplice + s_cInfo.nType = CI_NONE ; // completa // Vettore movimento nel piano XY globale Vector3d vtMoveXY( vtMove.x, vtMove.y, 0) ; @@ -1288,7 +1389,8 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster Vector3d vtDir = ( dLen > EPS_SMALL ? vtMoveXY / dLen : V_NULL) ; for ( auto nTrueId : vTrueIds) { // info di collisione correnti - SCollInfo scInfoCurr ; + SCollInfo scInfoCurr ; // semplice + CollInfo cInfoCurr ; // completa // ----------------------------------------- // recupero regione del pezzo int nRegId = GetFlatPartRegion( pGeomDB, nTrueId) ; @@ -1296,68 +1398,68 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster bOk = false ; break ; } - // la confronto con il box + // la confronto con il box (collisione semplice) MySurfFrMoveSimpleNoCollision( nRegId, nBoxId, vtDir, dLen, scInfoCurr) ; dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nBoxId, false, false, scInfoCurr) ; - // la confronto con la regione di riferimento + // la confronto con la regione di riferimento (collisione semplice) if ( nRefReg != GDB_ID_NULL) { MySurfFrMoveSimpleNoCollision( nRegId, nRefReg, vtDir, dLen, scInfoCurr) ; dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nRefReg, false, false, scInfoCurr) ; } - // la confronto con le aree danneggiate + // la confronto con le aree danneggiate (collisione completa) for ( int nDmgRegId : vDmgReg) { - MySurfFrMoveSimpleNoCollision( nRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ; + MySurfFrMoveNoCollision( nRegId, nDmgRegId, vtDir, dLen, cInfoCurr) ; dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nDmgRegId, false, false, scInfoCurr) ; } - // la confronto con le regioni degli altri pezzi + // la confronto con le regioni degli altri pezzi (collisione completa) for ( int nOthRegId : vOthReg) { - MySurfFrMoveSimpleNoCollision( nRegId, nOthRegId, vtDir, dLen, scInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nOthRegId, false, false, scInfoCurr) ; + MySurfFrMoveNoCollision( nRegId, nOthRegId, vtDir, dLen, cInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nOthRegId, false, false, cInfoCurr) ; } // e con le regioni dei tagli degli altri pezzi - // recupero regione in alto del pezzo + // recupero regione in alto del pezzo (collisione completa) int nUpRegId = GetFlatPartUpRegion( pGeomDB, nTrueId) ; int nTestRegId = (( nUpRegId == GDB_ID_NULL) ? nRegId : nUpRegId) ; for ( int nOthCutRegId : vOthCutReg) { - MySurfFrMoveSimpleNoCollision( nTestRegId, nOthCutRegId, vtDir, dLen, scInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nTestRegId, nOthCutRegId, false, true, scInfoCurr) ; + MySurfFrMoveNoCollision( nTestRegId, nOthCutRegId, vtDir, dLen, cInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTestRegId, nOthCutRegId, false, true, cInfoCurr) ; } // ----------------------------------------- // recupero regione in basso del pezzo int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nTrueId) ; - // la confronto con il box + // la confronto con il box (collisone semplice) if ( nDwnRegId != GDB_ID_NULL) { MySurfFrMoveSimpleNoCollision( nDwnRegId, nBoxId, vtDir, dLen, scInfoCurr) ; dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nBoxId, false, false, scInfoCurr) ; } - // la confronto con la regione di riferimento + // la confronto con la regione di riferimento (collisione completa) if ( nDwnRegId != GDB_ID_NULL && nRefReg != GDB_ID_NULL) { - MySurfFrMoveSimpleNoCollision( nDwnRegId, nRefReg, vtDir, dLen, scInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nRefReg, false, false, scInfoCurr) ; + MySurfFrMoveNoCollision( nDwnRegId, nRefReg, vtDir, dLen, cInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nRefReg, false, false, cInfoCurr) ; } - // la confronto con le aree danneggiate + // la confronto con le aree danneggiate (collisione completa) if ( nDwnRegId != GDB_ID_NULL) { for ( int nDmgRegId : vDmgReg) { - MySurfFrMoveSimpleNoCollision( nDwnRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nDmgRegId, false, false, scInfoCurr) ; + MySurfFrMoveNoCollision( nDwnRegId, nDmgRegId, vtDir, dLen, cInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nDmgRegId, false, false, cInfoCurr) ; } } - // la confronto con le regioni in basso degli altri pezzi + // la confronto con le regioni in basso degli altri pezzi (collisione completa) for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) { if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; - MySurfFrMoveSimpleNoCollision( nTmpDwnRegId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnRegId, false, false, scInfoCurr) ; + MySurfFrMoveNoCollision( nTmpDwnRegId, nOthDwnRegId, vtDir, dLen, cInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnRegId, false, false, cInfoCurr) ; } } - // e con le regioni in basso dei tagli degli altri pezzi + // e con le regioni in basso dei tagli degli altri pezzi (collisione completa) for ( int j = 0 ; j < ssize( vOthDwnCutReg) ; ++ j) { if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; - MySurfFrMoveSimpleNoCollision( nTmpDwnRegId, nOthDwnCutRegId, vtDir, dLen, scInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnCutRegId, false, true, scInfoCurr) ; + MySurfFrMoveNoCollision( nTmpDwnRegId, nOthDwnCutRegId, vtDir, dLen, cInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnCutRegId, false, true, cInfoCurr) ; } } // ----------------------------------------- @@ -1367,12 +1469,12 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster bOk = false ; break ; } - // le confronto con le regioni degli altri pezzi + // le confronto con le regioni degli altri pezzi (collisione completa) for ( int nCrId : vCrId) { for ( int k = 0 ; k < ssize( vOthReg) ; ++ k) { int nOthRegId = ( vOthUpReg[k] == GDB_ID_NULL ? vOthReg[k] : vOthUpReg[k]) ; - MySurfFrMoveSimpleNoCollision( nCrId, nOthRegId, vtDir, dLen, scInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nCrId, nOthRegId, true, false, scInfoCurr) ; + MySurfFrMoveNoCollision( nCrId, nOthRegId, vtDir, dLen, cInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nCrId, nOthRegId, true, false, cInfoCurr) ; } } // ----------------------------------------- @@ -1382,14 +1484,14 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster bOk = false ; break ; } - // le confronto con le regioni in basso degli altri pezzi + // le confronto con le regioni in basso degli altri pezzi (collisione completa) for ( int j = 0 ; j < ssize( vDwnCrId) ; ++ j) { for ( int k = 0 ; k < ssize( vOthDwnReg) ; ++ k) { if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) { int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ; int nOthDwnRegId = ( vOthDwnReg[k] != GDB_ID_NULL ? vOthDwnReg[k] : vOthReg[k]) ; - MySurfFrMoveSimpleNoCollision( nTmpDwnCrId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnCrId, nOthDwnRegId, true, false, scInfoCurr) ; + MySurfFrMoveNoCollision( nTmpDwnCrId, nOthDwnRegId, vtDir, dLen, cInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnCrId, nOthDwnRegId, true, false, cInfoCurr) ; } } } @@ -1467,7 +1569,7 @@ ExeMovePartCluster( const INTVECTOR& vIds, bool bReducedCut, Vector3d& vtMove) vtMove = vtM ; return true ; } - // altrimenti, riprovo con tagli standard + // altrimenti, riprovo con tagli standard else { // annullo il movimento for ( int nId : vTrueIds) @@ -1478,13 +1580,57 @@ ExeMovePartCluster( const INTVECTOR& vIds, bool bReducedCut, Vector3d& vtMove) } } + //---------------------------------------------------------------------------- +static bool +MySurfFrRotateNoCollision( int nId1, int nId2, const Point3d& ptCen, double& dAngDeg, CollInfo& cInfo) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero la prima superficie FlatRegion + ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ; + if ( pSfr1 == nullptr) + return false ; + // recupero il riferimento della superficie + Frame3d frSurf1 ; + if ( ! pGeomDB->GetGlobFrame( nId1, frSurf1)) + return false ; + // recupero la seconda superficie FlatRegion + const ISurfFlatRegion* pSfr2 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId2)) ; + if ( pSfr2 == nullptr) + return false ; + // recupero il riferimento della superficie + Frame3d frSurf2 ; + if ( ! pGeomDB->GetGlobFrame( nId2, frSurf2)) + return false ; + // se riferimenti diversi, porto una copia della seconda nel riferimento della prima + const ISurfFlatRegion* pSfr2L = pSfr2 ; + PtrOwner pTmp ; + if ( ! AreSameFrame( frSurf1, frSurf2)) { + pTmp.Set( pSfr2->Clone()) ; + if ( IsNull( pTmp) || ! pTmp->LocToLoc( frSurf2, frSurf1)) + return false ; + pSfr2L = pTmp ; + } + // porto in locale alla prima superficie il punto di rotazione + Point3d ptCenL = ptCen ; + ptCenL.ToLoc( frSurf1) ; + // calcolo massima lunghezza di traslazione della prima regione senza collisione con la seconda + CAvSurfFrMove cdSfrMove( *pSfr1, *pSfr2L) ; + if ( ! cdSfrMove.Rotate( ptCenL, dAngDeg)) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +// Rotazione con CAvSurfFr bool MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Cluster, bool bReducedCut, const Point3d& ptCen, double& dRotAngDeg) { // Reset info di collisione - s_scInfo.nType = SCI_NONE ; + s_scInfo.nType = SCI_NONE ; // semplice + s_cInfo.nType = CI_NONE ; // completa // Rotazione nel piano XY globale @@ -1556,21 +1702,21 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus bOk = false ; break ; } - // la confronto con il box + // la confronto con il box (collisione semplice) ExeSurfFrRotateSimpleNoCollision( nRegId, nBoxId, ptCen, dAng, RTY_GLOB) ; - // la confronto con la regione di riferimento + // la confronto con la regione di riferimento (collisione semplice) if ( nRefReg != GDB_ID_NULL) { ExeSurfFrRotateSimpleNoCollision( nRegId, nRefReg, ptCen, dAng, RTY_GLOB) ; } - // la confronto con le aree danneggiate + // la confronto con le aree danneggiate (collisione completa) for ( int nDmgRegId : vDmgReg) { - ExeSurfFrRotateSimpleNoCollision( nRegId, nDmgRegId, ptCen, dAng, RTY_GLOB) ; + MySurfFrRotateNoCollision( nRegId, nDmgRegId, ptCen, dAng, s_cInfo) ; } - // la confronto con le regioni degli altri pezzi + // la confronto con le regioni degli altri pezzi (collisione completa) for ( int nOthRegId : vOthReg) { - ExeSurfFrRotateSimpleNoCollision( nRegId, nOthRegId, ptCen, dAng, RTY_GLOB) ; + MySurfFrRotateNoCollision( nRegId, nOthRegId, ptCen, dAng, s_cInfo) ; } - // e con le regioni dei tagli degli altri pezzi + // e con le regioni dei tagli degli altri pezzi (collisione completa) // recupero regione in alto del pezzo int nUpRegId = GetFlatPartUpRegion( pGeomDB, nTrueId) ; int nTestRegId = (( nUpRegId == GDB_ID_NULL) ? nRegId : nUpRegId) ; @@ -1580,33 +1726,33 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus // ----------------------------------------- // recupero regione in basso del pezzo int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nTrueId) ; - // la confronto con il box + // la confronto con il box (collisione semplice) if ( nDwnRegId != GDB_ID_NULL) ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nBoxId, ptCen, dAng, RTY_GLOB) ; - // la confronto con la regione di riferimento + // la confronto con la regione di riferimento (collisione semplice) if ( nRefReg != GDB_ID_NULL) { ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nRefReg, ptCen, dAng, RTY_GLOB) ; } - // la confronto con le aree danneggiate + // la confronto con le aree danneggiate (collisione completa) if ( nDwnRegId != GDB_ID_NULL) { for ( int nDmgRegId : vDmgReg) { - ExeSurfFrRotateSimpleNoCollision( nDwnRegId, nDmgRegId, ptCen, dAng, RTY_GLOB) ; + MySurfFrRotateNoCollision( nDwnRegId, nDmgRegId, ptCen, dAng, s_cInfo) ; } } - // la confronto con le regioni in basso degli altri pezzi + // la confronto con le regioni in basso degli altri pezzi (collisione completa) for ( int j = 0 ; j < ssize( vOthDwnReg) ; ++ j) { if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; - ExeSurfFrRotateSimpleNoCollision( nTmpDwnRegId, nOthDwnRegId, ptCen, dAng, RTY_GLOB) ; + MySurfFrRotateNoCollision( nTmpDwnRegId, nOthDwnRegId, ptCen, dAng, s_cInfo) ; } } - // e con le regioni in basso dei tagli degli altri pezzi + // e con le regioni in basso dei tagli degli altri pezzi (collisione completa) for ( int j = 0 ; j < ssize( vOthDwnCutReg) ; ++ j) { if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; - ExeSurfFrRotateSimpleNoCollision( nTmpDwnRegId, nOthDwnCutRegId, ptCen, dAng, RTY_GLOB) ; + MySurfFrRotateNoCollision( nTmpDwnRegId, nOthDwnCutRegId, ptCen, dAng, s_cInfo) ; } } // ----------------------------------------- @@ -1616,11 +1762,11 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus bOk = false ; break ; } - // le confronto con le regioni degli altri pezzi + // le confronto con le regioni degli altri pezzi (collisione completa) for ( int nCrId : vCrId) { for ( int k = 0 ; k < ssize( vOthReg) ; ++ k) { int nOthRegId = ( vOthUpReg[k] == GDB_ID_NULL ? vOthReg[k] : vOthUpReg[k]) ; - ExeSurfFrRotateSimpleNoCollision( nCrId, nOthRegId, ptCen, dAng, RTY_GLOB) ; + MySurfFrRotateNoCollision( nCrId, nOthRegId, ptCen, dAng, s_cInfo) ; } } // ----------------------------------------- @@ -1630,13 +1776,13 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus bOk = false ; break ; } - // le confronto con le regioni in basso degli altri pezzi + // le confronto con le regioni in basso degli altri pezzi (collisione completa) for ( int j = 0 ; j < ssize( vDwnCrId) ; ++ j) { for ( int k = 0 ; k < ssize( vOthDwnReg) ; ++ k) { if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) { int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ; int nOthDwnRegId = ( vOthDwnReg[k] != GDB_ID_NULL ? vOthDwnReg[k] : vOthReg[k]) ; - ExeSurfFrRotateSimpleNoCollision( nTmpDwnCrId, nOthDwnRegId, ptCen, dAng, RTY_GLOB) ; + MySurfFrRotateNoCollision( nTmpDwnCrId, nOthDwnRegId, ptCen, dAng, s_cInfo) ; } } } From 6c2437831da6ad736696450455059f6290616266 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Mon, 30 Mar 2026 18:17:52 +0200 Subject: [PATCH 47/54] EgtExecutor (Nst_SurfFr) : - aggiunti controlli aggiuntivi per collisioni. --- EXE_NstPartNesting.cpp | 112 ++++++++++++----------------------------- 1 file changed, 33 insertions(+), 79 deletions(-) diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index 154a518..7e2bde8 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -47,21 +47,6 @@ struct SCollInfoEx : public SCollInfo nIdF( GDB_ID_NULL), bIsCutF( false) {} } ; -//---------------------------------------------------------------------------- -// collisioni -struct CollInfoEx : public CollInfo -{ - int nIdM ; // identificativo della regione mobile - bool bIsCutM ; // flag di regione o pezzo di taglio - int nIdF ; // identificativo della regione fissa - bool bIsCutF ; // flag di regione di pezzo o di taglio - // costruttori - CollInfoEx() : CollInfo(), nIdM( GDB_ID_NULL), bIsCutM( false), - nIdF( GDB_ID_NULL), bIsCutF( false) {} - CollInfoEx( const CollInfo& Sou) : CollInfo( Sou), nIdM( GDB_ID_NULL), bIsCutM( false), - nIdF( GDB_ID_NULL), bIsCutF( false) {} -} ; - //---------------------------------------------------------------------------- static const double SPESS = 100 ; static const int BBF_PART_MY_FLAG = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_DIM ; @@ -1155,8 +1140,6 @@ ExePackPartCluster( const INTVECTOR& vIds, bool bReducedCut, bool bBottomUp) //---------------------------------------------------------------------------- static SCollInfoEx s_scInfo ; static SCollInfoEx s_scInfoSaved ; -static CollInfoEx s_cInfo ; -static CollInfoEx s_cInfoSaved ; //---------------------------------------------------------------------------- static double @@ -1184,32 +1167,6 @@ UpdateCollId( double dLen, double dPrevLen, int nId1, int nId2, bool bIsCut1, bo return dPrevLen ; } -//---------------------------------------------------------------------------- -static double -UpdateCollId( double dLen, double dPrevLen, int nId1, int nId2, bool bIsCut1, bool bIsCut2, const CollInfo& cInfoCurr) -{ - if ( abs( dLen - dPrevLen) < EPS_SMALL) { - if ( cInfoCurr.nType == CI_PNT_LINE || cInfoCurr.nType == CI_LINE_LINE) { - s_cInfo = cInfoCurr ; - s_cInfo.nIdM = nId1 ; - s_cInfo.nIdF = nId2 ; - s_cInfo.bIsCutM = bIsCut1 ; - s_cInfo.bIsCutF = bIsCut2 ; - } - return dPrevLen ; - } - else if ( dLen < dPrevLen) { - s_cInfo = cInfoCurr ; - s_cInfo.nIdM = nId1 ; - s_cInfo.nIdF = nId2 ; - s_cInfo.bIsCutM = bIsCut1 ; - s_cInfo.bIsCutF = bIsCut2 ; - return dLen ; - } - else - return dPrevLen ; -} - //---------------------------------------------------------------------------- // Collisione semplice static bool @@ -1263,7 +1220,7 @@ MySurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double //---------------------------------------------------------------------------- // Collisione completa static bool -MySurfFrMoveNoCollision( int nId1, int nId2, const Vector3d& vtDir, double& dLen, CollInfo& cInfo) +MySurfFrMoveNoCollision( int nId1, int nId2, const Vector3d& vtDir, double& dLen, SCollInfo& cInfo) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -1300,12 +1257,12 @@ MySurfFrMoveNoCollision( int nId1, int nId2, const Vector3d& vtDir, double& dLen if ( ! cdSfrMove.Translate( vtDirL, dLen)) return false ; cInfo = cdSfrMove.GetCollInfo() ; - if ( cInfo.nType != CI_NONE) { + if ( cInfo.nType != SCI_NONE) { cInfo.ptP1.ToGlob( frSurf1) ; cInfo.vtDirM.ToGlob( frSurf1) ; cInfo.vtDirF.ToGlob( frSurf1) ; } - if ( cInfo.nType == CI_LINE_LINE) + if ( cInfo.nType == SCI_LINE_LINE) cInfo.ptP2.ToGlob( frSurf1) ; return true ; } @@ -1316,8 +1273,7 @@ static bool MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster, bool bReducedCut, Vector3d& vtMove) { // Reset info di collisione - s_scInfo.nType = SCI_NONE ; // semplice - s_cInfo.nType = CI_NONE ; // completa + s_scInfo.nType = SCI_NONE ; // Vettore movimento nel piano XY globale Vector3d vtMoveXY( vtMove.x, vtMove.y, 0) ; @@ -1389,8 +1345,7 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster Vector3d vtDir = ( dLen > EPS_SMALL ? vtMoveXY / dLen : V_NULL) ; for ( auto nTrueId : vTrueIds) { // info di collisione correnti - SCollInfo scInfoCurr ; // semplice - CollInfo cInfoCurr ; // completa + SCollInfo scInfoCurr ; // ----------------------------------------- // recupero regione del pezzo int nRegId = GetFlatPartRegion( pGeomDB, nTrueId) ; @@ -1408,21 +1363,21 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster } // la confronto con le aree danneggiate (collisione completa) for ( int nDmgRegId : vDmgReg) { - MySurfFrMoveNoCollision( nRegId, nDmgRegId, vtDir, dLen, cInfoCurr) ; + MySurfFrMoveNoCollision( nRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ; dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nDmgRegId, false, false, scInfoCurr) ; } // la confronto con le regioni degli altri pezzi (collisione completa) for ( int nOthRegId : vOthReg) { - MySurfFrMoveNoCollision( nRegId, nOthRegId, vtDir, dLen, cInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nOthRegId, false, false, cInfoCurr) ; + MySurfFrMoveNoCollision( nRegId, nOthRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nRegId, nOthRegId, false, false, scInfoCurr) ; } // e con le regioni dei tagli degli altri pezzi // recupero regione in alto del pezzo (collisione completa) int nUpRegId = GetFlatPartUpRegion( pGeomDB, nTrueId) ; int nTestRegId = (( nUpRegId == GDB_ID_NULL) ? nRegId : nUpRegId) ; for ( int nOthCutRegId : vOthCutReg) { - MySurfFrMoveNoCollision( nTestRegId, nOthCutRegId, vtDir, dLen, cInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nTestRegId, nOthCutRegId, false, true, cInfoCurr) ; + MySurfFrMoveNoCollision( nTestRegId, nOthCutRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTestRegId, nOthCutRegId, false, true, scInfoCurr) ; } // ----------------------------------------- // recupero regione in basso del pezzo @@ -1434,14 +1389,14 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster } // la confronto con la regione di riferimento (collisione completa) if ( nDwnRegId != GDB_ID_NULL && nRefReg != GDB_ID_NULL) { - MySurfFrMoveNoCollision( nDwnRegId, nRefReg, vtDir, dLen, cInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nRefReg, false, false, cInfoCurr) ; + MySurfFrMoveNoCollision( nDwnRegId, nRefReg, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nRefReg, false, false, scInfoCurr) ; } // la confronto con le aree danneggiate (collisione completa) if ( nDwnRegId != GDB_ID_NULL) { for ( int nDmgRegId : vDmgReg) { - MySurfFrMoveNoCollision( nDwnRegId, nDmgRegId, vtDir, dLen, cInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nDmgRegId, false, false, cInfoCurr) ; + MySurfFrMoveNoCollision( nDwnRegId, nDmgRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nDwnRegId, nDmgRegId, false, false, scInfoCurr) ; } } // la confronto con le regioni in basso degli altri pezzi (collisione completa) @@ -1449,8 +1404,8 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; - MySurfFrMoveNoCollision( nTmpDwnRegId, nOthDwnRegId, vtDir, dLen, cInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnRegId, false, false, cInfoCurr) ; + MySurfFrMoveNoCollision( nTmpDwnRegId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnRegId, false, false, scInfoCurr) ; } } // e con le regioni in basso dei tagli degli altri pezzi (collisione completa) @@ -1458,8 +1413,8 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; - MySurfFrMoveNoCollision( nTmpDwnRegId, nOthDwnCutRegId, vtDir, dLen, cInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnCutRegId, false, true, cInfoCurr) ; + MySurfFrMoveNoCollision( nTmpDwnRegId, nOthDwnCutRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnRegId, nOthDwnCutRegId, false, true, scInfoCurr) ; } } // ----------------------------------------- @@ -1473,8 +1428,8 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster for ( int nCrId : vCrId) { for ( int k = 0 ; k < ssize( vOthReg) ; ++ k) { int nOthRegId = ( vOthUpReg[k] == GDB_ID_NULL ? vOthReg[k] : vOthUpReg[k]) ; - MySurfFrMoveNoCollision( nCrId, nOthRegId, vtDir, dLen, cInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nCrId, nOthRegId, true, false, cInfoCurr) ; + MySurfFrMoveNoCollision( nCrId, nOthRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nCrId, nOthRegId, true, false, scInfoCurr) ; } } // ----------------------------------------- @@ -1490,8 +1445,8 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) { int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ; int nOthDwnRegId = ( vOthDwnReg[k] != GDB_ID_NULL ? vOthDwnReg[k] : vOthReg[k]) ; - MySurfFrMoveNoCollision( nTmpDwnCrId, nOthDwnRegId, vtDir, dLen, cInfoCurr) ; - dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnCrId, nOthDwnRegId, true, false, cInfoCurr) ; + MySurfFrMoveNoCollision( nTmpDwnCrId, nOthDwnRegId, vtDir, dLen, scInfoCurr) ; + dPrevLen = UpdateCollId( dLen, dPrevLen, nTmpDwnCrId, nOthDwnRegId, true, false, scInfoCurr) ; } } } @@ -1583,7 +1538,7 @@ ExeMovePartCluster( const INTVECTOR& vIds, bool bReducedCut, Vector3d& vtMove) //---------------------------------------------------------------------------- static bool -MySurfFrRotateNoCollision( int nId1, int nId2, const Point3d& ptCen, double& dAngDeg, CollInfo& cInfo) +MySurfFrRotateNoCollision( int nId1, int nId2, const Point3d& ptCen, double& dAngDeg, SCollInfo& cInfo) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -1629,8 +1584,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus const Point3d& ptCen, double& dRotAngDeg) { // Reset info di collisione - s_scInfo.nType = SCI_NONE ; // semplice - s_cInfo.nType = CI_NONE ; // completa + s_scInfo.nType = SCI_NONE ; // Rotazione nel piano XY globale @@ -1710,11 +1664,11 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus } // la confronto con le aree danneggiate (collisione completa) for ( int nDmgRegId : vDmgReg) { - MySurfFrRotateNoCollision( nRegId, nDmgRegId, ptCen, dAng, s_cInfo) ; + MySurfFrRotateNoCollision( nRegId, nDmgRegId, ptCen, dAng, s_scInfo) ; } // la confronto con le regioni degli altri pezzi (collisione completa) for ( int nOthRegId : vOthReg) { - MySurfFrRotateNoCollision( nRegId, nOthRegId, ptCen, dAng, s_cInfo) ; + MySurfFrRotateNoCollision( nRegId, nOthRegId, ptCen, dAng, s_scInfo) ; } // e con le regioni dei tagli degli altri pezzi (collisione completa) // recupero regione in alto del pezzo @@ -1736,7 +1690,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus // la confronto con le aree danneggiate (collisione completa) if ( nDwnRegId != GDB_ID_NULL) { for ( int nDmgRegId : vDmgReg) { - MySurfFrRotateNoCollision( nDwnRegId, nDmgRegId, ptCen, dAng, s_cInfo) ; + MySurfFrRotateNoCollision( nDwnRegId, nDmgRegId, ptCen, dAng, s_scInfo) ; } } // la confronto con le regioni in basso degli altri pezzi (collisione completa) @@ -1744,7 +1698,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus if ( nDwnRegId != GDB_ID_NULL || vOthDwnReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnRegId = ( vOthDwnReg[j] != GDB_ID_NULL ? vOthDwnReg[j] : vOthReg[j]) ; - MySurfFrRotateNoCollision( nTmpDwnRegId, nOthDwnRegId, ptCen, dAng, s_cInfo) ; + MySurfFrRotateNoCollision( nTmpDwnRegId, nOthDwnRegId, ptCen, dAng, s_scInfo) ; } } // e con le regioni in basso dei tagli degli altri pezzi (collisione completa) @@ -1752,7 +1706,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus if ( nDwnRegId != GDB_ID_NULL || vOthDwnCutReg[j] != GDB_ID_NULL) { int nTmpDwnRegId = ( nDwnRegId != GDB_ID_NULL ? nDwnRegId : nRegId) ; int nOthDwnCutRegId = ( vOthDwnCutReg[j] != GDB_ID_NULL ? vOthDwnCutReg[j] : vOthCutReg[j]) ; - MySurfFrRotateNoCollision( nTmpDwnRegId, nOthDwnCutRegId, ptCen, dAng, s_cInfo) ; + MySurfFrRotateNoCollision( nTmpDwnRegId, nOthDwnCutRegId, ptCen, dAng, s_scInfo) ; } } // ----------------------------------------- @@ -1766,7 +1720,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus for ( int nCrId : vCrId) { for ( int k = 0 ; k < ssize( vOthReg) ; ++ k) { int nOthRegId = ( vOthUpReg[k] == GDB_ID_NULL ? vOthReg[k] : vOthUpReg[k]) ; - MySurfFrRotateNoCollision( nCrId, nOthRegId, ptCen, dAng, s_cInfo) ; + MySurfFrRotateNoCollision( nCrId, nOthRegId, ptCen, dAng, s_scInfo) ; } } // ----------------------------------------- @@ -1782,7 +1736,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus if ( vDwnCrId[j] != GDB_ID_NULL || vOthDwnReg[k] != GDB_ID_NULL) { int nTmpDwnCrId = ( vDwnCrId[j] != GDB_ID_NULL ? vDwnCrId[j] : vCrId[j]) ; int nOthDwnRegId = ( vOthDwnReg[k] != GDB_ID_NULL ? vOthDwnReg[k] : vOthReg[k]) ; - MySurfFrRotateNoCollision( nTmpDwnCrId, nOthDwnRegId, ptCen, dAng, s_cInfo) ; + MySurfFrRotateNoCollision( nTmpDwnCrId, nOthDwnRegId, ptCen, dAng, s_scInfo) ; } } } @@ -1835,7 +1789,7 @@ GetObstacleTangent( Vector3d& vtTang) //---------------------------------------------------------------------------- static bool -GetMovingTangent( Vector3d& vtTang) +GetMovingTangent( Vector3d& vtTang) { if ( s_scInfo.nType != SCI_LINE_PNT && s_scInfo.nType != SCI_LINE_LINE) return false ; @@ -1882,7 +1836,7 @@ ExeAlignPartClusterOnCollision( const INTVECTOR& vIds, bool bReducedCut, bool& b Point3d ptCntL = s_scInfo.ptP1 ; ptCntL.ToLoc( frSfr) ; // cerco le direzioni tangenti prima e dopo il punto di contatto sulle parti mobili - PtrOwner pCrv( pSfr->GetLoop( s_scInfo.nChunkM, 0)) ; + PtrOwner pCrv( pSfr->GetLoop( s_scInfo.nChunkM, s_scInfo.nLoopM)) ; if ( IsNull( pCrv)) return false ; double dU ; From 1d9ecd9b7874511eb24965b857a7d7b21dc9b8b3 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Tue, 31 Mar 2026 13:22:51 +0200 Subject: [PATCH 48/54] EgtExecutor (Nst_SurfFr) : - migliorata la collisione e l'allineamento per Regioni Piane. --- EXE_Nst.h | 20 ++--- EXE_NstCreateFlatParts.cpp | 21 ++--- EXE_NstPartNesting.cpp | 168 +++++++++++++++++++++++++++++-------- 3 files changed, 153 insertions(+), 56 deletions(-) diff --git a/EXE_Nst.h b/EXE_Nst.h index ae672e5..f05bb46 100644 --- a/EXE_Nst.h +++ b/EXE_Nst.h @@ -16,13 +16,13 @@ class IGeomDB ; //---------------------------------------------------------------------------- -int GetFlatPartRegion( IGeomDB* pGeomDB, int nId) ; -int GetFlatPartUpRegion( IGeomDB* pGeomDB, int nId) ; -int GetFlatPartDownRegion( IGeomDB* pGeomDB, int nId) ; -bool GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) ; -bool GetFlatPartDownCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) ; -bool GetFlatPartInterpartGap(IGeomDB* pGeomDB, int nId, double& dGap); -int GetFlatPartFromRegion( IGeomDB* pGeomDB, int nId) ; -int GetFlatPartFromCut( IGeomDB* pGeomDB, int nId) ; -int GetGeometryFromCut( IGeomDB* pGeomDB, IMachMgr* pMachMgr, int nId) ; -bool GetFlatPartApproxContour( IGeomDB* pGeomDB, int nId, PolyLine& PL) ; +int GetFlatPartRegion( IGeomDB* pGeomDB, int nId) ; +int GetFlatPartUpRegion( IGeomDB* pGeomDB, int nId) ; +int GetFlatPartDownRegion( IGeomDB* pGeomDB, int nId) ; +bool GetFlatPartCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) ; +bool GetFlatPartDownCutRegions( IGeomDB* pGeomDB, int nId, bool bReduced, INTVECTOR& vCrId) ; +bool GetFlatPartInterpartGap(IGeomDB* pGeomDB, int nId, double& dGap); +int GetFlatPartFromRegion( IGeomDB* pGeomDB, int nId) ; +int GetFlatPartFromCut( IGeomDB* pGeomDB, int nId) ; +INTVECTOR GetGeometryFromCut( IGeomDB* pGeomDB, IMachMgr* pMachMgr, int nId) ; +bool GetFlatPartApproxContour( IGeomDB* pGeomDB, int nId, PolyLine& PL) ; diff --git a/EXE_NstCreateFlatParts.cpp b/EXE_NstCreateFlatParts.cpp index 9101b0c..0f57d10 100644 --- a/EXE_NstCreateFlatParts.cpp +++ b/EXE_NstCreateFlatParts.cpp @@ -2184,24 +2184,25 @@ GetFlatPartFromCut( IGeomDB* pGeomDB, int nId) } //---------------------------------------------------------------------------- -int +INTVECTOR GetGeometryFromCut( IGeomDB* pGeomDB, IMachMgr* pMachMgr, int nId) { + INTVECTOR vnIds ; if ( pGeomDB == nullptr || pMachMgr == nullptr) - return GDB_ID_NULL ; + return vnIds ; // verifico appartenga ad una lavorazione int nMchId ; if ( ! pGeomDB->GetInfo( pGeomDB->GetParentId( pGeomDB->GetParentId( nId)), "MId", nMchId)) - return GDB_ID_NULL ; + return vnIds ; // recupero la geometria di applicazione della lavorazione (deve essere una sola) if ( ! pMachMgr->SetCurrMachining( nMchId)) - return GDB_ID_NULL ; - SELVECTOR vIds ; - pMachMgr->GetMachiningGeometry( vIds) ; - if ( vIds.size() == 1) - return vIds[0].nId ; - else - return GDB_ID_NULL ; + return vnIds ; + SELVECTOR vSelIds ; + pMachMgr->GetMachiningGeometry( vSelIds) ; + vnIds.reserve( vSelIds.size()) ; + for ( const SelData& mySelData : vSelIds) + vnIds.emplace_back( mySelData.nId) ; + return vnIds ; } //---------------------------------------------------------------------------- diff --git a/EXE_NstPartNesting.cpp b/EXE_NstPartNesting.cpp index 7e2bde8..00067a2 100644 --- a/EXE_NstPartNesting.cpp +++ b/EXE_NstPartNesting.cpp @@ -22,6 +22,7 @@ #include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkDistPointCurve.h" +#include "/EgtDev/Include/EGkDistPointLine.h" #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkCAvSimpleSurfFrMove.h" #include "/EgtDev/Include/EGkCAvSurfFrMove.h" @@ -94,7 +95,7 @@ ExeCreateOutRegion( int nParentId, double dXmin, double dYmin, double dXmax, dou dYmax < dYmin + GAP + 2 * EPS_SMALL) return false ; - // se gią esiste, posso uscire + // se giĆ  esiste, posso uscire int nBoxId = pGeomDB->GetFirstNameInGroup( nParentId, NST_SHEET_OUTREG) ; if ( nBoxId != GDB_ID_NULL) return true ; @@ -151,7 +152,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - // se gią esiste, posso uscire + // se giĆ  esiste, posso uscire int nBoxId = pGeomDB->GetFirstNameInGroup( nParentId, NST_SHEET_OUTREG) ; if ( nBoxId != GDB_ID_NULL) return true ; @@ -189,7 +190,7 @@ ExeCreateOutRegion( int nParentId, int nOutCrvId) BBox3d b3Box ; pCompo->GetLocalBBox( b3Box) ; b3Box.Expand( SPESS, SPESS, 0) ; - // determino il punto pił vicino al massimo del box e lo faccio diventare il nuovo inizio + // determino il punto più vicino al massimo del box e lo faccio diventare il nuovo inizio int nFlag ; double dU ; DistPointCurve distPC( b3Box.GetMax(), *pCompo) ; @@ -252,7 +253,7 @@ ExeCreateReferenceRegion( int nParentId, int nOutCrvId, bool bBottomUp) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - // se gią esiste, posso uscire + // se giĆ  esiste, posso uscire int nRegId = pGeomDB->GetFirstNameInGroup( nParentId, NST_REFERENCE_REG) ; if ( nRegId != GDB_ID_NULL) return true ; @@ -285,7 +286,7 @@ ExeCreateReferenceRegion( int nParentId, int nOutCrvId, bool bBottomUp) // ne ricavo il bbox BBox3d b3Box ; PL.GetLocalBBox( b3Box) ; - // cerco i punti pił vicini ai quattro vertici (0=BL, 1=BR, 2=TR, 3=TL) + // cerco i punti più vicini ai quattro vertici (0=BL, 1=BR, 2=TR, 3=TL) double dU[4] = { -1, -1, -1, -1} ; double dMinSqDist[4] = { SQ_INFINITO, SQ_INFINITO, SQ_INFINITO, SQ_INFINITO} ; Point3d ptVert[4] ; @@ -393,7 +394,7 @@ ExeCreateDamagedRegion( int nParentId, int nDmgCrvId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - // verifico se esiste gią la regione associata + // verifico se esiste giĆ  la regione associata int nRegId = pGeomDB->GetFirstNameInGroup( nParentId, NST_DAMAGED_REG) ; while ( nRegId != GDB_ID_NULL) { // recupero l'indice della curva di origine @@ -1036,14 +1037,14 @@ ExePackPartCluster( const INTVECTOR& vIds, bool bReducedCut, bool bBottomUp) double dRegClDimY = b3RegCluster.GetMax().y - b3RegCluster.GetMin().y ; Point3d ptOrig = b3RegCluster.GetMin() ; - // Determino punto pił in basso a sinistra del cluster + // Determino punto più in basso a sinistra del cluster Point3d ptBL = b3RegCluster.GetMax() ; double dDimBottom = 0 ; for ( int nId : vTrueIds) { // recupero l'approssimazione lineare del contorno del pezzo ( in globale) PolyLine PL ; if ( GetFlatPartApproxContour( pGeomDB, nId, PL)) { - // cerco il punto pił in basso a sinistra + // cerco il punto più in basso a sinistra Point3d ptP ; bool bFound = PL.GetFirstPoint( ptP) ; while ( bFound) { @@ -1479,7 +1480,7 @@ MyMovePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d b3Cluster } } - // Se movimento risultante nullo, non faccio alcunché + // Se movimento risultante nullo, non faccio alcunchĆ© vtMoveXY = vtDir * dLen ; if ( vtMoveXY.IsSmall()) return true ; @@ -1746,7 +1747,7 @@ MyRotatePartCluster( IGeomDB* pGeomDB, const INTVECTOR& vTrueIds, BBox3d& b3Clus if ( ! bOk) return false ; - // Se movimento risultante nullo, non faccio alcunché + // Se movimento risultante nullo, non faccio alcunchĆ© dRotAngDeg = dAng ; if ( abs( dAng) < EPS_ANG_SMALL) return true ; @@ -1863,7 +1864,7 @@ ExeAlignPartClusterOnCollision( const INTVECTOR& vIds, bool bReducedCut, bool& b string sOut = "vtTp=(" + ToString( vtTp) + ") vtTn=(" + ToString( vtTn) + ")" ; LOG_INFO( GetLogger(), sOut.c_str()) ; } - // ruoto dalla parte dell'angolo pił piccolo (componente pił grande) + // ruoto dalla parte dell'angolo più piccolo (componente più grande) double dRotAngDeg = ( abs( vtTp * s_scInfo.vtDirF) > abs( vtTn * s_scInfo.vtDirF)) ? 90 : - 90 ; // provo a ruotare sul punto di collisione in senso orario Point3d ptCen = s_scInfo.ptP1 ; @@ -1887,6 +1888,7 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d // cerco i due tagli in collisione int nCutM = GDB_ID_NULL ; int nGeoM = GDB_ID_NULL ; + INTVECTOR vnGeoM, vnGeoF ; Point3d ptStartM, ptEndM ; Vector3d vtDirM ; Frame3d frGeoM ; @@ -1895,13 +1897,38 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d Point3d ptStartF, ptEndF ; Vector3d vtDirF ; Frame3d frGeoF ; - // se mobile č gią un taglio, ne ricavo i dati + // se mobile ĆØ giĆ  un taglio, ne ricavo i dati if ( s_scInfo.bIsCutM) { + if ( s_scInfo.nIdM == GDB_ID_NULL) + return false ; nCutM = s_scInfo.nIdM ; - nGeoM = GetGeometryFromCut( pGeomDB, pMachMgr, nCutM) ; - ICurveLine* pLineM = GetCurveLine( pGeomDB->GetGeoObj( nGeoM)) ; - if ( nCutM == GDB_ID_NULL || nGeoM == GDB_ID_NULL || - pLineM == nullptr || ! pGeomDB->GetGlobFrame( nGeoM, frGeoM)) + vnGeoM = GetGeometryFromCut( pGeomDB, pMachMgr, nCutM) ; + if ( vnGeoM.empty()) + return false ; + ICurveLine* pLineM = nullptr ; + // se ho un solo taglio, allora ĆØ quello + if ( ssize( vnGeoM) == 1) { + pLineM = GetCurveLine( pGeomDB->GetGeoObj( vnGeoM[0])) ; + nGeoM = vnGeoM[0] ; + } + // se più tagli, cerco quello più vicino alla linea corrente + else { + double dMinSqDist = INFINITO ; + for ( int i = 0 ; i < ssize( vnGeoM) ; ++ i) { + Frame3d frCurrGeoM ; + ICurveLine* pCurrLineM = GetCurveLine( pGeomDB->GetGeoObj( vnGeoM[i])) ; + if ( pCurrLineM == nullptr || ! pGeomDB->GetGlobFrame( vnGeoM[i], frCurrGeoM)) + return false ; + double dCurrSqDist ; + DistPointLine( GetToLoc( s_scInfo.ptP1, frCurrGeoM), *pCurrLineM).GetSqDist( dCurrSqDist) ; + if ( dCurrSqDist < dMinSqDist) { + dMinSqDist = dCurrSqDist ; + pLineM = pCurrLineM ; + nGeoM = vnGeoM[i] ; + } + } + } + if ( pLineM == nullptr || ! pGeomDB->GetGlobFrame( nGeoM, frGeoM)) return false ; ptStartM = pLineM->GetStart() ; ptStartM.ToGlob( frGeoM) ; @@ -1910,13 +1937,36 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d vtDirM = ptEndM - ptStartM ; vtDirM.Normalize() ; } - // se fisso č gią un taglio, ne ricavo i dati + // se fisso ĆØ giĆ  un taglio, ne ricavo i dati if ( s_scInfo.bIsCutF) { + if ( s_scInfo.nChunkF == GDB_ID_NULL) + return false ; nCutF = s_scInfo.nIdF ; - nGeoF = GetGeometryFromCut( pGeomDB, pMachMgr, nCutF) ; + vnGeoF = GetGeometryFromCut( pGeomDB, pMachMgr, nCutF) ; ICurveLine* pLineF = GetCurveLine( pGeomDB->GetGeoObj( nGeoF)) ; - if ( nCutF == GDB_ID_NULL || nGeoF == GDB_ID_NULL || - pLineF == nullptr || ! pGeomDB->GetGlobFrame( nGeoF, frGeoF)) + // se ho un solo taglio, allora ĆØ quello + if ( ssize( vnGeoF) == 1) { + pLineF = GetCurveLine( pGeomDB->GetGeoObj( vnGeoF[0])) ; + nGeoF = vnGeoF[0] ; + } + // se più tagli, cerco quello più vicino alla linea corrente + else { + double dMinSqDist = INFINITO ; + for ( int i = 0 ; i < ssize( vnGeoF) ; ++ i) { + Frame3d frCurrGeoF ; + ICurveLine* pCurrLineF = GetCurveLine( pGeomDB->GetGeoObj( vnGeoF[i])) ; + if ( pCurrLineF == nullptr || ! pGeomDB->GetGlobFrame( vnGeoF[i], frCurrGeoF)) + return false ; + double dCurrSqDist ; + DistPointLine( GetToLoc( s_scInfo.ptP1, frCurrGeoF), *pCurrLineF).GetSqDist( dCurrSqDist) ; + if ( dCurrSqDist < dMinSqDist) { + dMinSqDist = dCurrSqDist ; + pLineF = pCurrLineF ; + nGeoF = vnGeoF[i] ; + } + } + } + if ( pLineF == nullptr || ! pGeomDB->GetGlobFrame( nGeoF, frGeoF)) return false ; ptStartF = pLineF->GetStart() ; ptStartF.ToGlob( frGeoF) ; @@ -1941,8 +1991,31 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d BBox3d b3Temp ; pGeomDB->GetGlobalBBox( nId, b3Temp) ; if ( b3Temp.OverlapsXY( b3CutM)) { - int nGeom = GetGeometryFromCut( pGeomDB, pMachMgr, nId) ; - ICurveLine* pLine = GetCurveLine( pGeomDB->GetGeoObj( nGeom)) ; + int nGeom = GDB_ID_NULL ; + INTVECTOR vnGeom = GetGeometryFromCut( pGeomDB, pMachMgr, nId) ; + ICurveLine* pLine = nullptr ; + // se ho un solo taglio, allora ĆØ quello + if ( ssize( vnGeom) == 1) { + pLine = GetCurveLine( pGeomDB->GetGeoObj( vnGeom[0])) ; + nGeom = vnGeom[0] ; + } + // se ho più tagli, cerco quello più vicino alla linea corrente + else { + double dMinSqDist = INFINITO ; + for ( int i = 0 ; i < ssize( vnGeom) ; ++ i) { + Frame3d frCurrGeo ; + ICurveLine* pCurrLine = GetCurveLine( pGeomDB->GetGeoObj( vnGeom[i])) ; + if ( pCurrLine == nullptr || ! pGeomDB->GetGlobFrame( vnGeom[i], frCurrGeo)) + return false ; + double dCurrSqDist ; + DistPointLine( GetToLoc( s_scInfo.ptP1, frCurrGeo), *pCurrLine).GetSqDist( dCurrSqDist) ; + if ( dCurrSqDist < dMinSqDist) { + dMinSqDist = dCurrSqDist ; + pLine = pCurrLine ; + nGeom = vnGeom[i] ; + } + } + } if ( nGeom == GDB_ID_NULL || pLine == nullptr || ! pGeomDB->GetGlobFrame( nGeom, frGeoF)) continue ; ptStartF = pLine->GetStart() ; @@ -1975,8 +2048,31 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d BBox3d b3Temp ; pGeomDB->GetGlobalBBox( nId, b3Temp) ; if ( b3Temp.OverlapsXY( b3CutF)) { - int nGeom = GetGeometryFromCut( pGeomDB, pMachMgr, nId) ; - ICurveLine* pLine = GetCurveLine( pGeomDB->GetGeoObj( nGeom)) ; + int nGeom = GDB_ID_NULL ; + INTVECTOR vnGeom = GetGeometryFromCut( pGeomDB, pMachMgr, nId) ; + ICurveLine* pLine = nullptr ; + // se ho un solo taglio, allora ĆØ quello + if ( ssize( vnGeom) == 1) { + pLine = GetCurveLine( pGeomDB->GetGeoObj( vnGeom[0])) ; + nGeom = vnGeom[0] ; + } + // se ho più tagli, cerco quello più vicino alla linea corrente + else { + double dMinSqDist = INFINITO ; + for ( int i = 0 ; i < ssize( vnGeom) ; ++ i) { + Frame3d frCurrGeo ; + ICurveLine* pCurrLine = GetCurveLine( pGeomDB->GetGeoObj( vnGeom[0])) ; + if ( pCurrLine == nullptr || ! pGeomDB->GetGlobFrame( vnGeom[i], frCurrGeo)) + return false ; + double dCurrSqDist ; + DistPointLine( GetToLoc( s_scInfo.ptP1, frCurrGeo), *pCurrLine).GetSqDist( dCurrSqDist) ; + if ( dCurrSqDist < dMinSqDist) { + dMinSqDist = dCurrSqDist ; + pLine = pCurrLine ; + nGeom = vnGeom[i] ; + } + } + } if ( nGeom == GDB_ID_NULL || pLine == nullptr || ! pGeomDB->GetGlobFrame( nGeom, frGeoM)) continue ; ptStartM = pLine->GetStart() ; @@ -2053,9 +2149,9 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d dMoveMn = CrossXY( ptStartF - ptEndM, vtDirFp) / dDenom ; } } - // pareggio la parte pił vicina, se almeno una sotto soglia + // pareggio la parte più vicina, se almeno una sotto soglia if ( abs( dMoveMp) < dMaxMove || abs( dMoveMn) < dMaxMove) { - // calcolo movimento necessario, se nullo gią a posto + // calcolo movimento necessario, se nullo giĆ  a posto Vector3d vtMove = (( abs( dMoveMp) < abs( dMoveMn)) ? dMoveMp : dMoveMn) * vtDirF ; if ( vtMove.IsSmall()) { bMoved = false ; @@ -2080,7 +2176,7 @@ ExeMoveToSnapPointOnCollision( const INTVECTOR& vIds, bool bReducedCut, double d pGeomDB->GetRefBBox( nCutM, frCutF, b3CutM) ; double dStartDelta = b3CutF.GetMin().x - b3CutM.GetMin().x ; double dEndDelta = b3CutF.GetMax().x - b3CutM.GetMax().x ; - // pareggio la parte pił vicina, se sotto soglia + // pareggio la parte più vicina, se sotto soglia if ( abs( dStartDelta) > dMaxMove && abs( dEndDelta) > dMaxMove) return false ; Vector3d vtMove = (( abs( dStartDelta) < abs( dEndDelta)) ? dStartDelta : dEndDelta) * vtDirF ; @@ -2182,7 +2278,7 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut, // Avvio nesting automatico ExeAutoNestStart() ; - // Modalitą ghigliottina incompatibile con tagli completi + // ModalitĆ  ghigliottina incompatibile con tagli completi if ( ! bReducedCut) bGuillotineMode = false ; @@ -2205,11 +2301,11 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut, nDamId = pGeomDB->GetNextName( nDamId, NST_DAMAGED_REG) ; } - // Modalitą ghigliottina incompatibile con pannelli non rettangolari + // ModalitĆ  ghigliottina incompatibile con pannelli non rettangolari if ( ! bIsRect) bGuillotineMode = false ; - // Assegno le aree occupate dai pezzi gią nestati + // Assegno le aree occupate dai pezzi giĆ  nestati bool bPartAlreadyNested = false ; BBox3d b3Sheet ; pGeomDB->GetGlobalBBox( nRefReg, b3Sheet) ; @@ -2235,18 +2331,18 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut, GetFlatPartDownCutRegions( pGeomDB, nId, bReducedCut, vCutReg) ; for ( int nRegId : vCutReg) ExeAutoNestAddDefectToSheet( nSheetId, nRegId) ; - // dichiaro ci sono pezzi gią nestati + // dichiaro ci sono pezzi giĆ  nestati bPartAlreadyNested = true ; } } nId = ( bInRoot ? ExeGetNextPart( nId, true) : ExeGetNextGroup( nId)) ; } - // Pezzi gią nestati incompatibili con ghigliottina + // Pezzi giĆ  nestati incompatibili con ghigliottina if ( bPartAlreadyNested) bGuillotineMode = false ; - // Se richiesta modalitą ghigliottina + // Se richiesta modalitĆ  ghigliottina if ( bGuillotineMode) { // cerco il gap necessario tra le parti double dGap = 0 ; @@ -2256,7 +2352,7 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut, if ( GetFlatPartInterpartGap( pGeomDB, nPartId, dCurrGap) && dCurrGap > dGap) dGap = dCurrGap ; } - // se non trovato disabilito richiesta modalitą ghigliottina + // se non trovato disabilito richiesta modalitĆ  ghigliottina if ( dGap < EPS_SMALL) bGuillotineMode = false ; // altrimenti lo imposto @@ -2264,7 +2360,7 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut, ExeAutoNestSetInterpartGap( dGap) ; } - // Se richiesto e abilitato, imposto modalitą ghigliottina + // Se richiesto e abilitato, imposto modalitĆ  ghigliottina if ( bGuillotineMode) ExeAutoNestSetGuillotineMode() ; @@ -2280,7 +2376,7 @@ ExeAutomaticPackParts( INTVECTOR& vIds, bool bMinimizeOnXvsY, bool bReducedCut, int nDwnRegId = GetFlatPartDownRegion( pGeomDB, nPartId) ; if ( nDwnRegId != GDB_ID_NULL) ExeAutoNestAddAnotherOutlineToPart( nPartId, nDwnRegId) ; - // se non č ghigliottina imposto le regioni dei tagli (con ghigliottina si usa il gap) + // se non ĆØ ghigliottina imposto le regioni dei tagli (con ghigliottina si usa il gap) if ( ! bGuillotineMode) { // recupero regioni dei tagli del pezzo INTVECTOR vCutReg ; From c33cbe7b9fe5303797bb6fa08ea78ada5bb54adf Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Tue, 31 Mar 2026 14:24:05 +0200 Subject: [PATCH 49/54] EgtExecutor 3.1c6 : - In Nesting aggiunto controllo e gestione di collisioni con i loop interni delle regioni piane - in nesting aggiunte funzioni per interferenza tra regioni piane - aggiunto controllo per allineamento e riposizionamento nel caso di lavorazioni con Waterjet. --- EgtExecutor.rc | Bin 19652 -> 19652 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index edd62f3895393077d3171cae6d988eed35da59dc..504683bdd8f223e98c9b6f05442c378ae071a855 100644 GIT binary patch delta 97 zcmX>ylkvz*#tq-t7|k|+XLDs{G@I-wsJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlCl(Mt{Q=uP~ delta 97 zcmX>ylkvz*#tq-t7)>{SXLDs{G@a}ysJl6ftBM6Ia-3=M8o?@v=;SOev&~&XHXxbf TVsN!qQV6v*ipXlCl(Mt{QUxE4 From 41790f7d57ec2af927e1fc86a79437bae3a34160 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Tue, 31 Mar 2026 15:01:56 +0200 Subject: [PATCH 50/54] EgtExecutor : - aggiunto controllo. --- EXE_GdbGetSurf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXE_GdbGetSurf.cpp b/EXE_GdbGetSurf.cpp index 0af254a..15a54ad 100644 --- a/EXE_GdbGetSurf.cpp +++ b/EXE_GdbGetSurf.cpp @@ -1866,7 +1866,7 @@ ExeShowSurfBezierControlPoints( int nSrfId, int nDestGrpId, int* pnCount) VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero la superficie di bezier IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nSrfId) ; - if ( pGeoObj->GetType() != SRF_BEZIER) + if ( pGeoObj == nullptr || pGeoObj->GetType() != SRF_BEZIER) return GDB_ID_NULL ; // recupero il riferimento della superficie Frame3d frSurf ; From 1abcac8aa409170f3b4b1155f4a0e2173f73e6d8 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Tue, 31 Mar 2026 19:02:17 +0200 Subject: [PATCH 51/54] EgtExecutor : - In ExePocketing aggiunti parametri per lucidatura. --- EXE_GdbGetPocketing.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EXE_GdbGetPocketing.cpp b/EXE_GdbGetPocketing.cpp index a5ad798..60b803b 100644 --- a/EXE_GdbGetPocketing.cpp +++ b/EXE_GdbGetPocketing.cpp @@ -59,7 +59,8 @@ ExePocketing( int nId, double dRad, double dStep, double dAngle, int nType, bool // eseguo Pocketing ICRVCOMPOPOVECTOR vCrvCompoRes ; - bool bOk = CalcPocketing( pSfr, dRad, 0, dStep, dAngle, 5., nType, bSmooth, true, false, false, false, true, P_INVALID, nullptr, false, dStep, INFINITO, 0, vCrvCompoRes) ; + bool bOk = CalcPocketing( pSfr, dRad, 0, dStep, dAngle, 5., nType, bSmooth, true, false, false, false, true, P_INVALID, nullptr, false, + dStep, 0, INFINITO, 0, 0, INFINITO, false, 0., 0., vCrvCompoRes) ; nFirstId = GDB_ID_NULL ; nCrvCount = int( vCrvCompoRes.size()) ; if ( bOk && nCrvCount > 0) { From e9f368a85f18ad00ca49bb6ca7e399025011a424 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 8 Apr 2026 19:30:11 +0200 Subject: [PATCH 52/54] EgtExecutor 3.1d1 : - aggiunta funzione Exe/lua Redraw - aggiunte funzioni Exe/lua SurfTmGetSmoothAng e VolZmapGetShowEdges. --- EXE_GdbModifySurf.cpp | 23 ++++++++++++++++++++++- EXE_GdbModifyVol.cpp | 17 +++++++++++++++++ EXE_Scene.cpp | 15 +++++++++++++++ EgtExecutor.rc | Bin 19652 -> 19652 bytes LUA_GdbModifySurf.cpp | 23 +++++++++++++++++++++-- LUA_GdbModifyVol.cpp | 20 ++++++++++++++++++++ LUA_Scene.cpp | 16 +++++++++++++++- 7 files changed, 110 insertions(+), 4 deletions(-) diff --git a/EXE_GdbModifySurf.cpp b/EXE_GdbModifySurf.cpp index 1859831..0d378ba 100644 --- a/EXE_GdbModifySurf.cpp +++ b/EXE_GdbModifySurf.cpp @@ -1185,7 +1185,10 @@ ExeSurfTmGetShowEdges( int nId, bool& bShow) ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; bool bOk = ( pStm != nullptr) ; // recupero lo stato di visualizzazione degli spigoli vivi - bShow = ( bOk && pStm->GetShowEdges()) ; + if ( bOk) + bShow = pStm->GetShowEdges() ; + else + bShow = false ; return bOk ; } @@ -1199,6 +1202,7 @@ ExeSurfTmSetSmoothAng( int nId, double dAngDeg) ISurfTriMesh* pSrfTm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; if ( pSrfTm == nullptr) return false ; + // imposto l'angolo discriminante degli spigoli vivi pSrfTm->SetSmoothAngle( dAngDeg) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente @@ -1210,6 +1214,23 @@ ExeSurfTmSetSmoothAng( int nId, double dAngDeg) return true ; } +//---------------------------------------------------------------------------- +bool +ExeSurfTmGetSmoothAng( int nId, double& dAngDeg) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie trimesh + ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pStm != nullptr) ; + // recupero l'angolo discriminante degli spigoli vivi + if ( bOk) + dAngDeg = pStm->GetSmoothAngle() ; + else + dAngDeg = 0 ; + return bOk ; +} + //---------------------------------------------------------------------------- static double GetStmOffsPrec( double dOffs, double dLinTol) diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index 3866ea2..32b30da 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -142,6 +142,23 @@ ExeVolZmapSetShowEdges( int nId, bool bShow) return bOk ; } +//---------------------------------------------------------------------------- +bool +ExeVolZmapGetShowEdges( int nId, bool& bShow) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero lo Zmap + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pVZM != nullptr) ; + // leggo lo stato di visualizzazione degli spigoli vivi + if ( bOk) + bShow = pVZM->GetShowEdges() ; + else + bShow = false ; + return bOk ; +} + //------------------------------------------------------------------------------- bool ExeRemoveVolZmapPart( int nId, int nPart) diff --git a/EXE_Scene.cpp b/EXE_Scene.cpp index be755fc..00d0a18 100644 --- a/EXE_Scene.cpp +++ b/EXE_Scene.cpp @@ -267,6 +267,21 @@ ExeDraw( void) return true ; } +//----------------------------------------------------------------------------- +bool +ExeRedraw( void) +{ + // se interfaccia disabilitata, esco subito + if ( ! ExeGetEnableUI()) + return true ; + + IEGrScene* pScene = GetCurrScene() ; + VERIFY_SCENE( pScene, false) + // forzo ridisegno + pScene->RedrawWindow() ; + return true ; +} + //----------------------------------------------------------------------------- bool ExeSelect( int nWinX, int nWinY, int nSelW, int nSelH, int* pnSel) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 504683bdd8f223e98c9b6f05442c378ae071a855..a75731ea9b237d250285c6aa132e54e77746b30d 100644 GIT binary patch delta 276 zcmX>ylkvz*#trM3wOtwV7}6PX7%~}(88R3Y7&I6{fg+g>CIC&jNLv5^ delta 249 zcmX>ylkvz*#trM3)jb*V7}6PX7*ZLEfmne-gCUrqgdq`#Gl9HNpll|HJz3DLb#olc z3?^1%1|0^o&A-{4nVFM;3`efTEO4>oOp`YVR)EAOJ8~s&?h~?r$(qnp+u~MHcxaZW)#c^yVw)#;vAq$6E_RGZDht2o;=az;N}TlCQJa9Bt4h_ diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp index a775a48..ee3bbe0 100644 --- a/LUA_GdbModifySurf.cpp +++ b/LUA_GdbModifySurf.cpp @@ -565,7 +565,7 @@ LuaSurfTmGetShowEdges( lua_State* L) static int LuaSurfTmSetSmoothAng( lua_State* L) { - // 2 parametri : nId, nCutterId + // 2 parametri : nId, dAngDeg int nId ; LuaCheckParam( L, 1, nId) double dAngDeg ; @@ -577,6 +577,24 @@ LuaSurfTmSetSmoothAng( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaSurfTmGetSmoothAng( lua_State* L) +{ + // 1 parametro : nId + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero lo smooth angle della superficie + double dAngDeg ; + bool bOk = ExeSurfTmGetSmoothAng( nId, dAngDeg) ; + if ( bOk) + LuaSetParam( L, dAngDeg) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaSurfTmOffset( lua_State* L) @@ -664,7 +682,7 @@ LuaSurfBzTrim( lua_State* L) bool LuaInstallGdbModifySurf( LuaMgr& luaMgr) { - bool bOk = ( &luaMgr != nullptr) ; + bool bOk = true ; bOk = bOk && luaMgr.RegisterFunction( "EgtInvertSurf", LuaInvertSurf) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeSurf", LuaExplodeSurf) ; bOk = bOk && luaMgr.RegisterFunction( "EgtApproxSurf", LuaApproxSurf) ; @@ -694,6 +712,7 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSetShowEdges", LuaSurfTmSetShowEdges) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetShowEdges", LuaSurfTmGetShowEdges) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSetSmoothAng", LuaSurfTmSetSmoothAng) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetSmoothAng", LuaSurfTmGetSmoothAng) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmOffset", LuaSurfTmOffset) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmThickeningOffset", LuaSurfTmThickeningOffset) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfBzPlane", LuaCutSurfBzPlane) ; diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index 3ea1e93..3c543d5 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -73,6 +73,25 @@ LuaVolZmapSetShowEdges( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaVolZmapGetShowEdges( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // imposto flag visualizzazione spigoli vivi + bool bShow ; + bool bOk = ExeVolZmapGetShowEdges( nId, bShow) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, bShow) ; + else + LuaSetParam( L) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaRemoveVolZmapPart( lua_State* L) @@ -465,6 +484,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeVolume", LuaExplodeVolume) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapChangeResolution", LuaVolZmapChangeResolution) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetShowEdges", LuaVolZmapSetShowEdges) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetShowEdges", LuaVolZmapGetShowEdges) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveVolZmapPart", LuaRemoveVolZmapPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetStdTool", LuaVolZmapSetStdTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetAdvTool", LuaVolZmapSetAdvTool) ; diff --git a/LUA_Scene.cpp b/LUA_Scene.cpp index ddd759f..cabe7de 100644 --- a/LUA_Scene.cpp +++ b/LUA_Scene.cpp @@ -73,6 +73,19 @@ LuaDraw( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaRedraw( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // forzo ridisegno + bool bOk = ExeRedraw() ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaSetShowMode( lua_State* L) @@ -378,10 +391,11 @@ LuaSetShowSurfBezierTol( lua_State* L) bool LuaInstallScene( LuaMgr& luaMgr) { - bool bOk = ( &luaMgr != nullptr) ; + bool bOk = true ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetBackground", LuaSetBackground) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetBackground", LuaGetBackground) ; bOk = bOk && luaMgr.RegisterFunction( "EgtDraw", LuaDraw) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtRedraw", LuaRedraw) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetShowMode", LuaSetShowMode) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetShowCurveDirection", LuaSetShowCurveDirection) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetShowTriaAdv", LuaSetShowTriaAdv) ; From cfcb8449236f86ab179828d671f4c91f56e32090 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 15 Apr 2026 08:56:43 +0200 Subject: [PATCH 53/54] EgtExecutor 3.1d2 : - nelle funzioni exe e lua di proiezione di curve su superfici aggiunto paramtetro bFromVsTo. --- EXE_GdbModifyCurve.cpp | 24 +++++++++++++----------- EgtExecutor.rc | Bin 19652 -> 19652 bytes LUA_GdbModifyCurve.cpp | 20 ++++++++++++-------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index 7ca9129..7e6d475 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -2545,7 +2545,7 @@ ExeProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, int nDestGrpId, //------------------------------------------------------------------------------- static bool MyProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId, - double dLinTol, double dMaxSegmLen, bool bDirFromProj, int nRefType) + double dLinTol, double dMaxSegmLen, bool bDirFromProj, bool bFromVsTo, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) @@ -2587,7 +2587,7 @@ MyProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d bool bSharpEdges = ( ! bDirFromProj) ; // eseguo la proiezione PNT5AXVECTOR vPt5ax ; - if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, vtProjL, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) + if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, vtProjL, dLinTol, dMaxSegmLen, bSharpEdges, bFromVsTo, vPt5ax)) return false ; // inserisco la composita nel gruppo destinazione PtrOwner pCompo ; @@ -2626,9 +2626,9 @@ MyProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d //------------------------------------------------------------------------------- bool ExeProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId, - double dLinTol, double dMaxSegmLen, bool bDirFromProj, int nRefType) + double dLinTol, double dMaxSegmLen, bool bDirFromProj, bool bFromVsTo, int nRefType) { - bool bOk = MyProjectCurveOnSurfDir( nCurveId, vnSurfId, vtProj, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ; + bool bOk = MyProjectCurveOnSurfDir( nCurveId, vnSurfId, vtProj, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, bFromVsTo, nRefType) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -2639,6 +2639,7 @@ ExeProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3 ToString( dLinTol) + "," + ToString( dMaxSegmLen) + "," + ( bDirFromProj ? "true" : "false") + "," + + ( bFromVsTo ? "true" : "false") + "," + RefTypeToString( nRefType) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -2649,7 +2650,7 @@ ExeProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3 //------------------------------------------------------------------------------- static bool MyProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, int nDestGrpId, - double dLinTol, double dMaxSegmLen, bool bDirFromGuide) + double dLinTol, double dMaxSegmLen, bool bDirFromGuide, bool bFromVsTo) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) @@ -2710,14 +2711,14 @@ MyProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, if ( pGdeLoc == nullptr) return false ; pGdeLoc->LocToLoc( frGde, frSurf) ; - if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) + if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, bFromVsTo, vPt5ax)) return false ; } else if ( pGdeCrv != nullptr) { CurveLocal GdeLoc( pGdeCrv, frGde, frSurf) ; if ( GdeLoc.Get() == nullptr) return false ; - if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *GdeLoc.Get(), dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) + if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *GdeLoc.Get(), dLinTol, dMaxSegmLen, bSharpEdges, bFromVsTo, vPt5ax)) return false ; } else { // pGdeStm != nullptr @@ -2725,7 +2726,7 @@ MyProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, const ISurf* pGdeLoc = GetSurf( GdeLoc.Get()) ; if ( pGdeLoc == nullptr) return false ; - if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) + if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, bFromVsTo, vPt5ax)) return false ; } // inserisco la composita nel gruppo destinazione @@ -2765,9 +2766,9 @@ MyProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, //------------------------------------------------------------------------------- bool ExeProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, int nDestGrpId, - double dLinTol, double dMaxSegmLen, bool bDirFromGuide) + double dLinTol, double dMaxSegmLen, bool bDirFromGuide, bool bFromVsTo) { - bool bOk = MyProjectCurveOnSurfExt( nCurveId, vnSurfId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide) ; + bool bOk = MyProjectCurveOnSurfExt( nCurveId, vnSurfId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide, bFromVsTo) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -2777,7 +2778,8 @@ ExeProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, ToString( nDestGrpId) + "," + ToString( dLinTol) + "," + ToString( dMaxSegmLen) + "," + - ( bDirFromGuide ? "true" : "false") + ")" + + ( bDirFromGuide ? "true" : "false") + "," + + ( bFromVsTo ? "true" : "false") + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index a75731ea9b237d250285c6aa132e54e77746b30d..3e70ad624b57a972ff2123579c16d81feba7444b 100644 GIT binary patch delta 81 zcmX>ylkvz*#tpyN7>zdnW^-i*QjT29S-`yGOp`YVRxuh)cH~Ol+$UrM5ylkvz*#tpyN7!5c7W^-i*QjT29S-`yGOp`YVRxuh*cH~Ol+$UrM5 Date: Fri, 17 Apr 2026 13:23:56 +0200 Subject: [PATCH 54/54] EgtExecutor . - aggiunto controllo. --- EXE_GdbGetCurve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXE_GdbGetCurve.cpp b/EXE_GdbGetCurve.cpp index 75ec980..1a27922 100644 --- a/EXE_GdbGetCurve.cpp +++ b/EXE_GdbGetCurve.cpp @@ -760,7 +760,7 @@ ExeShowCurveBezierControlPoints( int nCrvId, int nDestGrpId, int* pnCount) VERIFY_GEOMDB( pGeomDB, false) // recupero la curva di Bezier IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nCrvId) ; - if ( pGeoObj->GetType() != CRV_BEZIER && pGeoObj->GetType() != CRV_COMPO) + if ( pGeoObj == nullptr || ( pGeoObj->GetType() != CRV_BEZIER && pGeoObj->GetType() != CRV_COMPO)) return GDB_ID_NULL ; // recupero il riferimento della curva Frame3d frCrv ;