diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 9114e59..951c832 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachMgr.h b/MachMgr.h index 9b117da..5776e73 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2015-2021 //---------------------------------------------------------------------------- -// File : MachMgr.h Data : 17.03.21 Versione : 2.3c1 +// File : MachMgr.h Data : 24.05.21 Versione : 2.3e3 // Contenuto : Dichiarazione della classe MachMgr. // // @@ -441,7 +441,7 @@ class MachMgr : public IMachMgr bool GetOperationNewName( std::string& sName) const ; const ToolData* GetMachiningToolData( void) const ; // Simulation - bool SimAddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) ; + bool SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; bool SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ; bool SimOnCollision( int nCdInd, int nObjInd, int& nErr) ; // Machine diff --git a/MachMgrSimulation.cpp b/MachMgrSimulation.cpp index 00b0191..7a5e6f0 100644 --- a/MachMgrSimulation.cpp +++ b/MachMgrSimulation.cpp @@ -150,13 +150,13 @@ MachMgr::SimExit( void) //---------------------------------------------------------------------------- bool -MachMgr::SimAddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) +MachMgr::SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) { // verifico simulatore if ( m_pSimul == nullptr) return false ; // aggiungo un oggetto da verificare per la collisione con il grezzo - return m_pSimul->AddCollisionObj( nInd, nFrameId, nType, dPar1, dPar2, dPar3) ; + return m_pSimul->AddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; } //---------------------------------------------------------------------------- diff --git a/Machine.h b/Machine.h index 0e7685c..ec80b37 100644 --- a/Machine.h +++ b/Machine.h @@ -332,6 +332,7 @@ class Machine static int LuaEmtSetLastError( lua_State* L) ; static int LuaEmtSetWarning( lua_State* L) ; static int LuaEmtAddCollisionObj( lua_State* L) ; + static int LuaEmtAddCollisionObjEx( lua_State* L) ; static int LuaEmtExecCollisionCheck( lua_State* L) ; static int LuaEmtOnCollision( lua_State* L) ; } ; diff --git a/MachineLua.cpp b/MachineLua.cpp index 2b7ea55..2c902ac 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -122,6 +122,8 @@ Machine::LuaInit( const string& sMachineName) m_LuaMgr.RegisterFunction( "EmtSetWarning", Machine::LuaEmtSetWarning) ; // registro la funzione per aggiungere un oggetto da verificare per la collisione in simulazione m_LuaMgr.RegisterFunction( "EmtAddCollisionObj", Machine::LuaEmtAddCollisionObj) ; + // registro la funzione estesa per aggiungere un oggetto da verificare per la collisione in simulazione + m_LuaMgr.RegisterFunction( "EmtAddCollisionObjEx", Machine::LuaEmtAddCollisionObjEx) ; // registro la funzione di esecuzione della verifica di collisione in simulazione m_LuaMgr.RegisterFunction( "EmtExecCollisionCheck", Machine::LuaEmtExecCollisionCheck) ; // registro la funzione di gestione della collisione in simulazione @@ -1202,7 +1204,37 @@ Machine::LuaEmtAddCollisionObj( lua_State* L) if ( m_pMchLua == nullptr) return luaL_error( L, " Unknown Machine") ; // assegno i dati - bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, dPar1, dPar2, dPar3)) ; + bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, Vector3d(), dPar1, dPar2, dPar3)) ; + // assegno risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +int +Machine::LuaEmtAddCollisionObjEx( lua_State* L) +{ + // 7 parametri : nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3 + int nInd ; + LuaCheckParam( L, 1, nInd) + int nFrameId ; + LuaCheckParam( L, 2, nFrameId) + int nType ; + LuaCheckParam( L, 3, nType) + Vector3d vtMove ; + LuaCheckParam( L, 4, vtMove) + double dPar1 ; + LuaCheckParam( L, 5, dPar1) + double dPar2 ; + LuaCheckParam( L, 6, dPar2) + double dPar3 ; + LuaCheckParam( L, 7, dPar3) + LuaClearStack( L) ; + // verifico ci sia una macchina attiva + if ( m_pMchLua == nullptr) + return luaL_error( L, " Unknown Machine") ; + // assegno i dati + bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3)) ; // assegno risultato LuaSetParam( L, bOk) ; return 1 ; diff --git a/Simulator.cpp b/Simulator.cpp index ec2e69c..58adec3 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -24,6 +24,7 @@ #include "/EgtDev/Include/EGkCDeBoxClosedSurfTm.h" #include "/EgtDev/Include/EGkCDeCylClosedSurfTm.h" #include "/EgtDev/Include/EGkCDeSpheClosedSurfTm.h" +#include "/EgtDev/Include/EGkCDeConeFrustumClosedSurfTm.h" #include "/EgtDev/Include/EGkVolZmap.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EXeConst.h" @@ -1231,6 +1232,10 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) // esecuzione controlli di collisione bool bOk = true ; Frame3d frObj = pGeoFrame->GetFrame() ; + if ( ! m_CollObj[j].vtMove.IsSmall()) + frObj.Translate( m_CollObj[j].vtMove.x * frObj.VersX() + + m_CollObj[j].vtMove.y * frObj.VersY() + + m_CollObj[j].vtMove.z * frObj.VersZ()) ; Frame3d frParent ; m_pGeomDB->GetGlobFrame( m_CollObj[j].nFrameId, frParent) ; frObj.LocToLoc( frParent, frCd) ; if ( m_CollObj[j].nType == MCH_SIM_COB_BOX) { @@ -1252,6 +1257,12 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) else bOk = ! CDeSpheClosedSurfTm( frObj.Orig(), m_CollObj[j].dPar1, m_dSafeDist, *pSTM) ; } + else if ( m_CollObj[j].nType == MCH_SIM_COB_CONE) { + if ( pVZM != nullptr) + bOk = pVZM->AvoidConeFrustum( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3, m_dSafeDist) ; + else + bOk = ! CDeConeFrustumClosedSurfTm( frObj, m_CollObj[j].dPar1, m_CollObj[j].dPar2, m_CollObj[j].dPar3, m_dSafeDist, *pSTM) ; + } if ( ! bOk) { nCdInd = i ; nObjInd = j ; @@ -1752,7 +1763,7 @@ Simulator::OnResetMachine( void) //---------------------------------------------------------------------------- bool -Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) +Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) { // verifiche sui parametri if ( nInd <= 0 || nFrameId <= GDB_ID_NULL) @@ -1763,17 +1774,21 @@ Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, dou return false ; break ; case MCH_SIM_COB_CYL : - if ( abs( dPar1) < EPS_SMALL || abs( dPar2) < EPS_SMALL) + if ( dPar1 < EPS_SMALL || abs( dPar2) < EPS_SMALL) return false ; break ; case MCH_SIM_COB_SPHE : - if ( abs( dPar1) < EPS_SMALL) + if ( dPar1 < EPS_SMALL) + return false ; + break ; + case MCH_SIM_COB_CONE : + if ( ( dPar1 < EPS_SMALL && dPar2 < EPS_SMALL) || dPar3 < EPS_SMALL) return false ; break ; default : return false ; } // aggiungo al vettore - m_CollObj.emplace_back( nInd, nFrameId, nType, dPar1, dPar2, dPar3) ; + m_CollObj.emplace_back( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; return true ; } diff --git a/Simulator.h b/Simulator.h index 4faee46..f5e746a 100644 --- a/Simulator.h +++ b/Simulator.h @@ -37,7 +37,7 @@ class Simulator bool GetToolInfo( std::string& sName, double& dSpeed) const ; 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 AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; bool ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ; bool OnCollision( int nCdInd, int nObjInd, int& nErr) ; @@ -94,12 +94,13 @@ class Simulator int nInd ; int nFrameId ; int nType ; + Vector3d vtMove ; double dPar1 ; double dPar2 ; double dPar3 ; - CollObj( void) : nInd( 0), nFrameId( -1), nType( 0), dPar1( 0), dPar2( 0), dPar3( 0) {} - CollObj( int nI, int nF, int nT, double dP1, double dP2, double dP3) - : nInd( nI), nFrameId( nF), nType( nT), dPar1( dP1), dPar2( dP2), dPar3( dP3) {} + CollObj( void) : nInd( 0), nFrameId( -1), nType( 0), vtMove(), dPar1( 0), dPar2( 0), dPar3( 0) {} + CollObj( int nI, int nF, int nT, const Vector3d& vtM, double dP1, double dP2, double dP3) + : nInd( nI), nFrameId( nF), nType( nT), vtMove( vtM), dPar1( dP1), dPar2( dP2), dPar3( dP3) {} } ; typedef std::vector< CollObj> COBVECTOR ;