diff --git a/Simulator.cpp b/Simulator.cpp index f778f99..5c8684c 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -276,6 +276,9 @@ Simulator::Move( int& nStatus) m_pPerfCnt->Start() ; } + // reset visualizzazione collisioni + ResetCollisionMark() ; + // Se arrivato alla fine dell'interpolazione if ( m_dCoeff > COEFF_LIM) { // recupero una nuova entità @@ -453,6 +456,8 @@ Simulator::GoHome( void) // controllo validità stato if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr || m_pMachine == nullptr) return false ; + // reset visualizzazione collisioni + ResetCollisionMark() ; // reset stato macchina OnResetMachine() ; // porto la macchina in home @@ -1509,6 +1514,34 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) return true ; } +//---------------------------------------------------------------------------- +bool +Simulator::SetCollisionMark( int nCdInd, int nObjInd) +{ + if ( m_pGeomDB == nullptr) + return false ; + m_nCollMarkId.clear() ; + int nCdGeoId = m_pGeomDB->GetParentId( m_pGeomDB->GetParentId( m_CdId[nCdInd])) ; + int nCoGeoId = m_pGeomDB->GetParentId( m_pGeomDB->GetParentId( m_CollObj[nObjInd].nFrameId)) ; + m_nCollMarkId.push_back( nCdGeoId) ; + m_nCollMarkId.push_back( nCoGeoId) ; + for ( auto nId : m_nCollMarkId) + m_pGeomDB->SetMark( nId) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Simulator::ResetCollisionMark( void) +{ + if ( m_pGeomDB == nullptr) + return false ; + for ( auto nId : m_nCollMarkId) + m_pGeomDB->ResetMark( nId) ; + m_nCollMarkId.clear() ; + return true ; +} + //---------------------------------------------------------------------------- bool Simulator::OnInit( void) @@ -2069,6 +2102,10 @@ Simulator::OnCollision( int nCdInd, int nObjInd, int& nErr) nErr = ERR_COLLISION ; m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ; } + // evidenzio le geometrie in collisione + if ( nErr == ERR_COLLISION) + SetCollisionMark( nCdInd, nObjInd) ; + return ( nErr == 0) ; } @@ -2336,6 +2373,7 @@ Simulator::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) if ( ExeGetEnableUI()) { // Box di messaggio : Collisione! AVVERTIMENTO ExeMessageBox( ExeGetMsg( 5319), ExeGetMsg( 5315), MB_OK | MB_ICONWARNING) ; + ExeDraw() ; // Gestione Pausa m_nUiStatus = MCH_UISIM_PAUSE ; while ( m_nUiStatus == MCH_UISIM_PAUSE) { diff --git a/Simulator.h b/Simulator.h index afb8d56..7fabac9 100644 --- a/Simulator.h +++ b/Simulator.h @@ -88,6 +88,8 @@ class Simulator { return ( ! m_CollObj.empty() && ! m_CdId.empty()) ; } bool Stopped( void) { return ( m_nUiStatus == MCH_UISIM_STOP) ; } + bool SetCollisionMark( int nCdInd, int nObjInd) ; + bool ResetCollisionMark( void) ; bool OnInit( void) ; bool OnExit( void) ; bool OnProgramStart( bool bFirst) ; @@ -174,6 +176,7 @@ class Simulator VMTVECTOR m_VmTool ; // vettore utensili attivi per virtual milling COBVECTOR m_CollObj ; // vettore oggetti da testare per collisione con grezzo double m_dSafeDist ; // distanza di sicurezza per verifica collisioni + INTVECTOR m_nCollMarkId ; // elenco oggetti marcati per visualizzare meglio la collisione rilevata int m_nAxesMask ; // maschera a bit di abilitazione movimento assi (solo se rapido) bool m_bEnabAxes ; // flag abilitazione movimento assi attivi bool m_bShowAxes ; // flag visualizzazione assi attivi