From a48fa50c857547160fd8524c8659685afd1a087a Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 6 Jun 2025 16:06:49 +0200 Subject: [PATCH] EgtMachKernel : - in simulazione SP prime sviluppi per tooltip trace. --- SimulatorSP.cpp | 74 ++++++++++++++++++++++++++++++++++++------------- SimulatorSP.h | 1 + 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/SimulatorSP.cpp b/SimulatorSP.cpp index 022f8be..0b98288 100644 --- a/SimulatorSP.cpp +++ b/SimulatorSP.cpp @@ -29,9 +29,11 @@ #include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h" #include "/EgtDev/Include/EGkVolZmap.h" #include "/EgtDev/Include/EGkGeoVector3d.h" +#include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkSurfLocal.h" #include "/EgtDev/Include/EXeCmdLogOff.h" +#include "/EgtDev/Include/EXeSetModifiedOff.h" #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EMkToolConst.h" #include "/EgtDev/Include/EMkOperationConst.h" @@ -1108,6 +1110,10 @@ SimulatorSP::ManageSingleMove( int& nStatus, double& dMove) for ( int i = 0 ; i < int( m_VmId.size()) ; ++ i) bOkI = m_pGeomDB->GetGlobFrame( m_VmId[i], vFrVzmI[i]) && bOkI ; + // Eventuale primo tracciamento punto tip utensile + if ( m_nCurrTrace == GDB_ID_NULL) + TraceToolTipMove( nMoveType) ; + // Dati per eventuale verifica di collisione int nCdInd, nObjInd ; bool bCollCheck = true ; @@ -1204,26 +1210,8 @@ SimulatorSP::ManageSingleMove( int& nStatus, double& dMove) } // eseguo eventuale collision check bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ; - } - // eventuale salvataggio punto tip utensile - if ( nMoveType == 1) { - int nTipTraceId ; - if ( m_pMachine->LuaGetGlobVar( GLOB_VAR + ".TIPTRACE", nTipTraceId)) { - int nHeadId = m_pMachine->GetHeadId( m_sHead) ; - int nExitId = m_pMachine->GetExitId( m_sHead, m_nExit) ; - Frame3d frExit ; - if ( m_pGeomDB->GetGroupGlobFrame( nExitId, frExit)) { - Point3d ptTip = frExit.Orig() - m_dTLen * frExit.VersZ() ; - if ( m_nCurrTrace == GDB_ID_NULL) { - PolyLine PL ; - PL.AddUPoint( -1, ptTip + 10 * EPS_SMALL * frExit.VersZ()) ; - PL.AddUPoint( 0, ptTip) ; - m_nCurrTrace = ExeCreateCurveCompoFromPoints( nTipTraceId, PL, GDB_ID_ROOT) ; - } - else - ExeAddCurveCompoLine( m_nCurrTrace, ptTip, true, GDB_ID_ROOT) ; - } - } + // eventuale tracciamento punto tip utensile + TraceToolTipMove( nMoveType) ; } } // Eseguo movimento su arco @@ -1308,6 +1296,8 @@ SimulatorSP::ManageSingleMove( int& nStatus, double& dMove) } // eseguo eventuale collision check bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ; + // eventuale tracciamento punto tip utensile + TraceToolTipMove( nMoveType) ; } } } @@ -1368,6 +1358,8 @@ SimulatorSP::ManageSingleMove( int& nStatus, double& dMove) } // eseguo eventuale collision check bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ; + // eventuale tracciamento punto tip utensile + TraceToolTipMove( nMoveType) ; } } @@ -1656,6 +1648,45 @@ SimulatorSP::ResetCollisionMark( void) return true ; } +//---------------------------------------------------------------------------- +bool +SimulatorSP::TraceToolTipMove( int nMoveType) +{ + // per ora disabilito + return true ; + // tracciatura + int nTipTraceId ; + if ( m_pMachine->LuaGetGlobVar( GLOB_VAR + ".TIPTRACE", nTipTraceId)) { + int nExitId = m_pMachine->GetExitId( m_sHead, m_nExit) ; + Frame3d frExit ; + if ( m_pGeomDB->GetGroupGlobFrame( nExitId, frExit)) { + // disabilito gestione segnalazione modifiche progetto + SetModifiedOff modOff ; + Point3d ptTip = frExit.Orig() - m_dTLen * frExit.VersZ() ; + if ( m_nCurrTrace == GDB_ID_NULL) { + m_nCurrTrace = ExeCreateGeoPoint( nTipTraceId, ptTip, GDB_ID_ROOT) ; + m_pGeomDB->SetInfo( m_nCurrTrace, "Move", nMoveType) ; + m_pGeomDB->SetStipple( m_nCurrTrace, ( nMoveType == 0 ? 3 : 0), 0x8C8C) ; + } + else { + int nTraMove ; + m_pGeomDB->GetInfo( m_nCurrTrace, "Move", nTraMove) ; + if ( ( nMoveType == 0) == ( nTraMove == 0)) + ExeAddCurveCompoLine( m_nCurrTrace, ptTip, true, GDB_ID_ROOT) ; + else { + Point3d ptPrev ; ExeEndPoint( m_nCurrTrace, GDB_ID_ROOT, ptPrev) ; + m_nCurrTrace = ExeCreateGeoPoint( nTipTraceId, ptPrev, GDB_ID_ROOT) ; + ExeAddCurveCompoLine( m_nCurrTrace, ptTip, true, GDB_ID_ROOT) ; + m_pGeomDB->SetInfo( m_nCurrTrace, "Move", nMoveType) ; + m_pGeomDB->SetStipple( m_nCurrTrace, ( nMoveType == 0 ? 3 : 0), 0x8C8C) ; + } + } + } + } + + return true ; +} + //---------------------------------------------------------------------------- bool SimulatorSP::OnInit( void) @@ -2502,6 +2533,9 @@ SimulatorSP::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) // Verifico collisioni int nCdInd, nObjInd ; bool bCollCheck = ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ; + // eventuale tracciamento punto tip utensile + TraceToolTipMove( nMoveType) ; + // Se riscontrata collisione if ( ! bCollCheck) { // Richiamo funzione di convalida collisione int nPrevErr ; diff --git a/SimulatorSP.h b/SimulatorSP.h index cf44102..a42bd9a 100644 --- a/SimulatorSP.h +++ b/SimulatorSP.h @@ -81,6 +81,7 @@ class SimulatorSP : public ISimulator { return ( m_nUiStatus == MCH_UISIM_STOP) ; } bool SetCollisionMark( int nCdInd, int nObjInd) ; bool ResetCollisionMark( void) ; + bool TraceToolTipMove( int nMoveType) ; bool OnInit( void) ; bool OnExit( void) ; bool OnProgramStart( bool bFirst) ;