diff --git a/OutputConst.h b/OutputConst.h index 5bc9123..7f82b83 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -140,7 +140,8 @@ static const std::string GVAR_ENABAXES = ".EnabAxes" ; // (bool) flag abili static const std::string GVAR_AUXAXES = ".AuxAxes" ; // (int) numero assi ausiliari per simulazione static const std::string GVAR_AN = ".AN" ; // (num) valore del N-esimo asse ausiliario per simulazione static const std::string GVAR_ANN = ".ANn" ; // (string) nome del N-esimo asse ausiliario per simulazione -static const std::string GVAR_VMILL = ".VMILL" ; // (int) identificativo Zmap attivo +static const std::string GVAR_VMILL = ".VMILL" ; // (int/s) identificativi Zmap attivi per Virtual Milling +static const std::string GVAR_CODET = ".CODET" ; // (int/s) identificativi Zmap attivi per Collision Detection static const std::string GVAR_SIM1ST = ".SIM1ST" ; // (bool) flag inizio simulazione static const std::string GVAR_SIMSTEP = ".SIMSTEP" ; // (num) step di movimento durante la simulazione static const std::string GVAR_SIMUISTAT = ".SIMUISTAT" ; // (num) stato simulazione imposto da utente diff --git a/Simulator.cpp b/Simulator.cpp index 02d26f5..46900a3 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -192,6 +192,7 @@ Simulator::ResetInterpolation( void) m_nAuxETot = 0 ; m_nAuxEInd = 0 ; m_VmId.clear() ; + m_CdId.clear() ; m_dVmTdOffs = 0 ; m_dVmAdOffs = 0 ; m_dSafeDist = SAFEDIST_STD ; @@ -1023,11 +1024,11 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) } // Eseguo eventuale verifica di collisione - int nVmInd, nObjInd ; - if ( ! ExecCollisionCheck( nVmInd, nObjInd)) { + int nCdInd, nObjInd ; + if ( ! ExecCollisionCheck( nCdInd, nObjInd)) { // Richiamo funzione di convalida collisione int nErr ; - if ( ! OnCollision( nVmInd, nObjInd, nErr)) { + if ( ! OnCollision( nCdInd, nObjInd, nErr)) { nStatus = ( Stopped() ? MCH_SIM_STOP : ( nErr == 1 ? MCH_SIM_COLLISION : MCH_SIM_ERR)) ; // Se arrivato a fine interpolazione movimento, salvo posizioni if ( m_dCoeff > COEFF_LIM && m_bEnabAxes) { @@ -1111,17 +1112,17 @@ Simulator::ExecLineVmill( int nVmId, const Point3d& ptHi, const Vector3d& vtHi, //---------------------------------------------------------------------------- bool -Simulator::ExecCollisionCheck( int& nVmInd, int& nObjInd) +Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd) { // se non ci sono oggetti da controllare o non c'è il grezzo lavorato, tutto bene - if ( m_CollObj.empty() || m_VmId.empty()) + if ( m_CollObj.empty() || m_CdId.empty()) return true ; // ciclo sui grezzi - for ( int i = 0 ; i < int( m_VmId.size()) ; ++ i) { - const IVolZmap* pVZM = GetVolZmap( m_pGeomDB->GetGeoObj( m_VmId[i])) ; + for ( int i = 0 ; i < int( m_CdId.size()) ; ++ i) { + const IVolZmap* pVZM = GetVolZmap( m_pGeomDB->GetGeoObj( m_CdId[i])) ; if ( pVZM == nullptr) continue ; - Frame3d frZM ; m_pGeomDB->GetGlobFrame( m_VmId[i], frZM) ; + Frame3d frZM ; m_pGeomDB->GetGlobFrame( m_CdId[i], frZM) ; // ciclo sugli oggetti da verificare for ( int j = 0 ; j < int( m_CollObj.size()) ; ++ j) { bool bOk = true ; @@ -1142,7 +1143,7 @@ Simulator::ExecCollisionCheck( int& nVmInd, int& nObjInd) bOk = pVZM->AvoidSphere( frObj.Orig(), m_CollObj[j].dPar1, m_dSafeDist) ; } if ( ! bOk) { - nVmInd = i ; + nCdInd = i ; nObjInd = j ; return false ; } @@ -1226,6 +1227,7 @@ Simulator::OnDispositionStart( int nOpId, int nOpInd, int nPhase, bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_START) ; // recupero i dati di ritorno m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_VMILL, m_VmId) ; + m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_CODET, m_CdId) ; // forzo aggiornamento posizione assi (possono essere stati mossi nello script) UpdateAxesPos() ; return bOk ; @@ -1242,6 +1244,7 @@ Simulator::OnDispositionEnd( void) bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_END) ; // recupero i dati di ritorno m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_VMILL, m_VmId) ; + m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_CODET, m_CdId) ; // forzo aggiornamento posizione assi (possono essere stati mossi nello script) UpdateAxesPos() ; return bOk ; @@ -1584,7 +1587,7 @@ Simulator::OnMoveEnd( void) //---------------------------------------------------------------------------- bool -Simulator::OnCollision( int nVmInd, int nObjInd, int& nErr) +Simulator::OnCollision( int nCdInd, int nObjInd, int& nErr) { // reset stato di errore da script nErr = 0 ; @@ -1595,7 +1598,7 @@ Simulator::OnCollision( int nVmInd, int nObjInd, int& nErr) if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr)) return false ; // assegno identificativi grezzo e oggetto in collisione - if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIMVMID, m_VmId[nVmInd])) + if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIMVMID, m_CdId[nCdInd])) return false ; if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIMCOBIND, m_CollObj[nObjInd].nInd)) return false ; diff --git a/Simulator.h b/Simulator.h index 9133f79..6fb157e 100644 --- a/Simulator.h +++ b/Simulator.h @@ -60,7 +60,7 @@ class Simulator bool GetHeadCurrPosDirAux( Point3d& ptH, Vector3d& vtH, Vector3d& vtA) ; bool ExecLineVmill( int nVmId, const Point3d& ptHi, const Vector3d& vtHi, const Vector3d& vtAi, const Frame3d& frVzmI, const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF) ; - bool ExecCollisionCheck( int& nVmInd, int& nObjInd) ; + bool ExecCollisionCheck( int& nCdInd, int& nObjInd) ; bool Stopped( void) { return ( m_nUiStatus == MCH_UISIM_STOP) ; } bool OnStart( bool bFirst) ; @@ -81,7 +81,7 @@ class Simulator bool OnPathEnd( int nAE) ; bool OnMoveStart( const CamData* pCamData, int& nErr) ; bool OnMoveEnd( void) ; - bool OnCollision( int nVmInd, int nObjInd, int& nErr) ; + bool OnCollision( int nCdInd, int nObjInd, int& nErr) ; bool OnResetMachine( void) ; private : @@ -118,6 +118,7 @@ class Simulator int m_nAuxEInd ; // indice del movimento ausiliario di fine percorso corrente std::string m_sTool ; // nome dell'utensile corrente INTVECTOR m_VmId ; // vettore identificativi Zmap per Virtual Milling + INTVECTOR m_CdId ; // vettore identificativi Zmap per Collision Detection double m_dVmTdOffs ; // offset utensile in direzione principale per VM double m_dVmAdOffs ; // offset utensile in direzione ausiliaria per VM COBVECTOR m_CollObj ; // vettore oggetti da testare per collisione con grezzo