EgtMachKernel :
- in simulatore separata gestione VirtualMilling da gestione CollisionDetection.
This commit is contained in:
+14
-11
@@ -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 ;
|
||||
|
||||
Reference in New Issue
Block a user