diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 7f6a56f..1bb3a80 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachMgr.h b/MachMgr.h index 1bfd72e..9b117da 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -442,7 +442,7 @@ class MachMgr : public IMachMgr const ToolData* GetMachiningToolData( void) const ; // Simulation bool SimAddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) ; - bool SimExecCollisionCheck( int& nCdInd, int& nObjInd) ; + bool SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ; bool SimOnCollision( int nCdInd, int nObjInd, int& nErr) ; // Machine bool GetHeadAbove( const std::string& sHead) const ; diff --git a/MachMgrSimulation.cpp b/MachMgrSimulation.cpp index 6ab8ef6..00b0191 100644 --- a/MachMgrSimulation.cpp +++ b/MachMgrSimulation.cpp @@ -161,13 +161,13 @@ MachMgr::SimAddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, do //---------------------------------------------------------------------------- bool -MachMgr::SimExecCollisionCheck( int& nCdInd, int& nObjInd) +MachMgr::SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) { // verifico simulatore if ( m_pSimul == nullptr) return false ; // eseguo verifica di collisione (nessuna collisione -> true) - return m_pSimul->ExecCollisionCheck( nCdInd, nObjInd) ; + return m_pSimul->ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ; } //---------------------------------------------------------------------------- diff --git a/MachineLua.cpp b/MachineLua.cpp index fcbdf44..2b7ea55 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -1212,14 +1212,16 @@ Machine::LuaEmtAddCollisionObj( lua_State* L) int Machine::LuaEmtExecCollisionCheck( lua_State* L) { - // Nessun parametro + // 1 parametro opzionale + int nMoveType = 0 ; + LuaGetParam( L, 1, nMoveType) ; LuaClearStack( L) ; // verifico ci sia una macchina attiva if ( m_pMchLua == nullptr) return luaL_error( L, " Unknown Machine") ; // eseguo la verifica di collisione (nessuna collisione -> true) int nCdInd = -1, nObjInd = -1 ; - bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimExecCollisionCheck( nCdInd, nObjInd)) ; + bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimExecCollisionCheck( nCdInd, nObjInd, nMoveType)) ; // assegno risultato LuaSetParam( L, bOk) ; LuaSetParam( L, nCdInd) ; @@ -1231,7 +1233,7 @@ Machine::LuaEmtExecCollisionCheck( lua_State* L) int Machine::LuaEmtOnCollision( lua_State* L) { - // Due parametri : nCdInd, nObjInd + // 2 parametri : nCdInd, nObjInd int nCdInd ; LuaCheckParam( L, 1, nCdInd) int nObjInd ; diff --git a/Simulator.cpp b/Simulator.cpp index b761b60..ec2e69c 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -990,15 +990,17 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ; } // eseguo eventuale collision check - bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd) ; + bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ; } - // eseguo eventuale Vmill - Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ; - bool bOkF = GetHeadCurrPosDirAux( ptNoseF, vtDirF, vtAuxF) ; - for ( int j = 0 ; j < int( m_VmId.size()) ; ++ j) { - Frame3d frVzmF ; - bOkF = m_pGeomDB->GetGlobFrame( m_VmId[j], frVzmF) && bOkF ; - ExecLineVmill( m_VmId[j], ptNoseI, vtDirI, vtAuxI, vFrVzmI[j], ptNoseF, vtDirF, vtAuxF, frVzmF) ; + // se non è rapido o non c'è verifica collisioni, eseguo eventuale Vmill + if ( nMoveType != 0 || ! NeedCollisionCheck()) { + Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ; + bool bOkF = GetHeadCurrPosDirAux( ptNoseF, vtDirF, vtAuxF) ; + for ( int j = 0 ; j < int( m_VmId.size()) ; ++ j) { + Frame3d frVzmF ; + bOkF = m_pGeomDB->GetGlobFrame( m_VmId[j], frVzmF) && bOkF ; + ExecLineVmill( m_VmId[j], ptNoseI, vtDirI, vtAuxI, vFrVzmI[j], ptNoseF, vtDirF, vtAuxF, frVzmF) ; + } } } // Eseguo movimento su arco @@ -1051,7 +1053,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) vFrVzmI[k] = frVzmF ; } // eseguo eventuale collision check - bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd) ; + bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ; // aggiorno prossimo inizio ptNoseI = ptNoseF ; vtDirI = vtDirF ; @@ -1083,7 +1085,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) m_pMachine->SetAxisPos( m_AuxAxesName[i], dVal) ; } // eseguo eventuale collision check - bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd) ; + bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ; } // Se riscontrata collisione @@ -1188,7 +1190,7 @@ Simulator::ExecLineVmill( int nVmId, const Point3d& ptHi, const Vector3d& vtHi, //---------------------------------------------------------------------------- bool -Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd) +Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) { // se non ci sono oggetti da controllare o non ci sono grezzi o equivalenti, tutto bene if ( ! NeedCollisionCheck()) @@ -1219,8 +1221,8 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd) string sExit ; m_pGeomDB->GetName( m_CollObj[j].nFrameId, sExit) ; bool bIsTool = ( sHead == m_sHead && ( sExit == string( "_T") + ToString( m_nExit) || sExit == string( "_TT") + ToString( m_nExit))) ; - // se utensile attivo su grezzo in lavoro, salto - if ( bIsTool && bIsRaw) + // se utensile attivo su grezzo in lavoro e non è rapido, salto + if ( bIsTool && bIsRaw && nMoveType != 0) continue ; // se riferimento non trovato, si salta const IGeoFrame3d* pGeoFrame = GetGeoFrame3d( m_pGeomDB->GetGeoObj( m_CollObj[j].nFrameId)) ; diff --git a/Simulator.h b/Simulator.h index 9c7315d..4faee46 100644 --- a/Simulator.h +++ b/Simulator.h @@ -38,7 +38,7 @@ class Simulator bool GetOperationInfo( std::string& sName, int& nType) const ; bool GetMoveInfo( int& nGmove, double& dFeed) const ; bool AddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) ; - bool ExecCollisionCheck( int& nCdInd, int& nObjInd) ; + bool ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ; bool OnCollision( int nCdInd, int nObjInd, int& nErr) ; private :