EgtMachKernel 2.4l4 :

- modifiche per virtual milling con più utensili in simulazione.
This commit is contained in:
DarioS
2022-12-28 19:40:24 +01:00
parent f0b00ea95e
commit e5a072c896
7 changed files with 247 additions and 71 deletions
BIN
View File
Binary file not shown.
+1
View File
@@ -455,6 +455,7 @@ class MachMgr : public IMachMgr
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) ;
bool SimSetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst) ;
// Machine
bool GetHeadAbove( const std::string& sHead) const ;
double GetDeltaSafeZ( const std::string& sHead) const ;
+11
View File
@@ -180,3 +180,14 @@ MachMgr::SimOnCollision( int nCdInd, int nObjInd, int& nErr)
// lancio funzione di gestione collisione
return m_pSimul->OnCollision( nCdInd, nObjInd, nErr) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimSetToolForVmill( const string& sTool, const string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// imposto utensile per Vmill
return m_pSimul->SetToolForVmill( sTool, sHead, nExit, vVmill, bFirst) ;
}
+6
View File
@@ -53,6 +53,10 @@ class Machine
int GetHeadId( const std::string& sHead) const
{ int nId = GetGroup( sHead) ;
return ( IsHeadGroup( nId) ? nId : GDB_ID_NULL) ; }
int GetExitId( const std::string& sHead, int nExit) const
{ int nHeadId = GetHeadId( sHead) ;
int nId = ( m_pGeomDB != nullptr ? m_pGeomDB->GetFirstNameInGroup( nHeadId, MCH_EXIT + ToString( nExit)) : GDB_ID_NULL) ;
return ( IsExitGroup( nId) ? nId : GDB_ID_NULL) ; }
int GetTcPosId( const std::string& sTcPos) const
{ int nId = GetGroup( sTcPos) ;
return ( IsTcPosGroup( nId) ? nId : GDB_ID_NULL) ; }
@@ -350,6 +354,8 @@ class Machine
static int LuaEmtAddCollisionObjEx( lua_State* L) ;
static int LuaEmtExecCollisionCheck( lua_State* L) ;
static int LuaEmtOnCollision( lua_State* L) ;
static int LuaEmtSetToolForVmill( lua_State* L) ;
static int LuaEmtAddToolForVmill( lua_State* L) ;
} ;
//----------------------------------------------------------------------------
+56 -4
View File
@@ -132,6 +132,10 @@ Machine::LuaInit( const string& sMachineName)
m_LuaMgr.RegisterFunction( "EmtExecCollisionCheck", Machine::LuaEmtExecCollisionCheck) ;
// registro la funzione di gestione della collisione in simulazione
m_LuaMgr.RegisterFunction( "EmtOnCollision", Machine::LuaEmtOnCollision) ;
// registro la funzione di impostazione del primo utensile per virtual milling in simulazione
m_LuaMgr.RegisterFunction( "EmtSetToolForVmill", Machine::LuaEmtSetToolForVmill) ;
// registro la funzione di impostazione di utensile aggiuntivo per virtual milling in simulazione
m_LuaMgr.RegisterFunction( "EmtAddToolForVmill", Machine::LuaEmtAddToolForVmill) ;
return true ;
}
@@ -1202,7 +1206,7 @@ Machine::LuaEmtSetLastError( lua_State* L)
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// assegno i dati
// imposto informazioni di errore
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SetLastError( nErrId, sErrDesc)) ;
string sOut = "(" + ToString( nErrId) + ") " + sErrDesc ;
// se uscita dolce
@@ -1227,7 +1231,7 @@ Machine::LuaEmtSetWarning( lua_State* L)
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// assegno i dati
// imposto informazioni di warning
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SetWarning( nWarnId, sWarnDesc)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
@@ -1296,7 +1300,7 @@ Machine::LuaEmtAddCollisionObjEx( lua_State* L)
int
Machine::LuaEmtExecCollisionCheck( lua_State* L)
{
// 1 parametro opzionale
// 1 parametro opzionale : [nMoveType = 0]
int nMoveType = 0 ;
LuaGetParam( L, 1, nMoveType) ;
LuaClearStack( L) ;
@@ -1326,7 +1330,7 @@ Machine::LuaEmtOnCollision( lua_State* 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)
// eseguo gestione della collisione in simulazione
int nErr = 0 ;
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimOnCollision( nCdInd, nObjInd, nErr)) ;
// assegno risultato
@@ -1334,3 +1338,51 @@ Machine::LuaEmtOnCollision( lua_State* L)
LuaSetParam( L, nErr) ;
return 2 ;
}
//----------------------------------------------------------------------------
int
Machine::LuaEmtSetToolForVmill( lua_State* L)
{
// 4 parametri : sTool, sHead, nExit, vVmill
string sTool ;
LuaGetParam( L, 1, sTool) ;
string sHead ;
LuaGetParam( L, 2, sHead) ;
int nExit = 0 ;
LuaGetParam( L, 3, nExit) ;
INTVECTOR vVmill ;
LuaGetParam( L, 4, vVmill) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// imposto dati primo utensile per virtual milling in simulazione
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimSetToolForVmill( sTool, sHead, nExit, vVmill, true)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
int
Machine::LuaEmtAddToolForVmill( lua_State* L)
{
// 4 parametri : sTool, sHead, nExit, vVmill
string sTool ;
LuaGetParam( L, 1, sTool) ;
string sHead ;
LuaGetParam( L, 2, sHead) ;
int nExit = 0 ;
LuaGetParam( L, 3, nExit) ;
INTVECTOR vVmill ;
LuaGetParam( L, 4, vVmill) ;
LuaClearStack( L) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// imposto dati utensile aggiuntivo per virtual milling in simulazione
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimSetToolForVmill( sTool, sHead, nExit, vVmill, false)) ;
// assegno risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
+152 -62
View File
@@ -26,7 +26,9 @@
#include "/EgtDev/Include/EGkCDeSpheClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeConeFrustumClosedSurfTm.h"
#include "/EgtDev/Include/EGkVolZmap.h"
#include "/EgtDev/Include/EGkGeoVector3d.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EXeCmdLogOff.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EMkToolConst.h"
#include "/EgtDev/Include/EMkOperationConst.h"
@@ -67,8 +69,6 @@ Simulator::Simulator( void)
m_nAuxEInd = 0 ;
m_nExit = 0 ;
m_dTDiam = 0 ;
m_dVmTdOffs = 0 ;
m_dVmAdOffs = 0 ;
m_dSafeDist = SAFEDIST_STD ;
m_nAxesMask = 0 ;
m_bEnabAxes = true ;
@@ -206,8 +206,8 @@ Simulator::ResetInterpolation( void)
m_nAuxEInd = 0 ;
m_VmId.clear() ;
m_CdId.clear() ;
m_dVmTdOffs = 0 ;
m_dVmAdOffs = 0 ;
m_VmTool.clear() ;
m_CollObj.clear() ;
m_dSafeDist = SAFEDIST_STD ;
m_nAxesMask = 0 ;
m_bEnabAxes = true ;
@@ -472,23 +472,6 @@ Simulator::UpdateTool( bool bFirst, int& nErr)
// aggiorno gli assi macchina
if ( ! UpdateAxes())
return false ;
// eventuali offset per Vmill (per adattare lo ZeroT macchina con quello di Zmap)
int nToolType ; m_pMchMgr->TdbGetCurrToolParam( TPA_TYPE, nToolType) ;
if ( nToolType == TT_MORTISE_STD) {
double dThick ; m_pMchMgr->TdbGetCurrToolParam( TPA_THICK, dThick) ;
m_dVmTdOffs = 0 ;
m_dVmAdOffs = 0.5 * dThick ;
}
else if ( nToolType == TT_SAW_STD || nToolType == TT_SAW_FLAT) {
double dLen ; m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, dLen) ;
double dThick ; m_pMchMgr->TdbGetCurrToolParam( TPA_THICK, dThick) ;
m_dVmTdOffs = ( ( dLen <= dThick) ? -dLen + dThick : 0) ;
m_dVmAdOffs = 0 ;
}
else {
m_dVmTdOffs = 0 ;
m_dVmAdOffs = 0 ;
}
// se cambiato oppure prima volta, lancio lo script di selezione
if ( bDiffTool || bFirst) {
int nCurrErr ;
@@ -1006,9 +989,13 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
m_dCoeff = 1 ;
dMove = ( m_dCoeff - dPrevCoeff) * dDist ;
// Posizione e direzione attuali dell'utensile e riferimento attuale del pezzo (per Vmill)
Point3d ptNoseI ; Vector3d vtDirI ; Vector3d vtAuxI ;
bool bOkI = GetHeadCurrPosDirAux( ptNoseI, vtDirI, vtAuxI) ;
// Posizione e direzione attuali degli utensili e riferimenti dei pezzi (per Vmill)
bool bOkI = true ;
PNTVECTOR vPtNoseI( m_VmTool.size()) ;
VCT3DVECTOR vVtDirI( m_VmTool.size()) ;
VCT3DVECTOR vVtAuxI( m_VmTool.size()) ;
for ( int i = 0 ; i < int( m_VmTool.size()) ; ++ i)
bOkI = GetHeadCurrPosDirAux( m_VmTool[i].sHead, m_VmTool[i].nExit, vPtNoseI[i], vVtDirI[i], vVtAuxI[i]) && bOkI ;
vector<Frame3d> vFrVzmI( m_VmId.size()) ;
for ( int i = 0 ; i < int( m_VmId.size()) ; ++ i)
bOkI = m_pGeomDB->GetGlobFrame( m_VmId[i], vFrVzmI[i]) && bOkI ;
@@ -1052,12 +1039,15 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
}
// 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) ;
for ( int i = 0 ; i < int( m_VmTool.size()) ; ++ i) {
Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ;
bool bOkF = GetHeadCurrPosDirAux( m_VmTool[i].sHead, m_VmTool[i].nExit, 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], i, m_VmTool[i].dTdOffs, m_VmTool[i].dAdOffs,
vPtNoseI[i], vVtDirI[i], vVtAuxI[i], vFrVzmI[j], ptNoseF, vtDirF, vtAuxF, frVzmF) ;
}
}
}
}
@@ -1124,20 +1114,25 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
}
// eseguo eventuale Vmill
Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ;
bool bOkF = GetHeadCurrPosDirAux( ptNoseF, vtDirF, vtAuxF) ;
for ( int k = 0 ; k < int( m_VmId.size()) ; ++ k) {
Frame3d frVzmF ;
bOkF = m_pGeomDB->GetGlobFrame( m_VmId[k], frVzmF) && bOkF ;
ExecLineVmill( m_VmId[k], ptNoseI, vtDirI, vtAuxI, vFrVzmI[k], ptNoseF, vtDirF, vtAuxF, frVzmF) ;
// salvo riferimento per prossimo inizio
vFrVzmI[k] = frVzmF ;
for ( int j = 0 ; j < int( m_VmTool.size()) ; ++ j) {
Point3d ptNoseF ; Vector3d vtDirF ; Vector3d vtAuxF ;
bool bOkF = GetHeadCurrPosDirAux( m_VmTool[j].sHead, m_VmTool[j].nExit, ptNoseF, vtDirF, vtAuxF) ;
for ( int k = 0 ; k < int( m_VmId.size()) ; ++ k) {
Frame3d frVzmF ;
bOkF = m_pGeomDB->GetGlobFrame( m_VmId[k], frVzmF) && bOkF ;
ExecLineVmill( m_VmId[k], j, m_VmTool[j].dTdOffs, m_VmTool[j].dAdOffs,
vPtNoseI[j], vVtDirI[j], vVtAuxI[j], vFrVzmI[k], ptNoseF, vtDirF, vtAuxF, frVzmF) ;
// se ultimo utensile, salvo riferimento per prossimo inizio
if ( j == int( m_VmTool.size()) - 1)
vFrVzmI[k] = frVzmF ;
}
// aggiorno prossimo inizio
vPtNoseI[j] = ptNoseF ;
vVtDirI[j] = vtDirF ;
vVtAuxI[j] = vtAuxF ;
}
// eseguo eventuale collision check
bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
// aggiorno prossimo inizio
ptNoseI = ptNoseF ;
vtDirI = vtDirF ;
}
}
}
@@ -1238,30 +1233,33 @@ Simulator::CalcStatusOnError( int nErr)
//----------------------------------------------------------------------------
bool
Simulator::GetHeadCurrPosDirAux( Point3d& ptH, Vector3d& vtH, Vector3d& vtA)
Simulator::GetHeadCurrPosDirAux( const std::string& sHead, int nExit, Point3d& ptH, Vector3d& vtH, Vector3d& vtA)
{
// ci devono essere almeno i tre assi lineari
if ( m_AxesName.size() < 3)
int nHeadId = m_pMachine->GetHeadId( sHead) ;
int nExitId = m_pMachine->GetExitId( sHead, nExit) ;
if ( nHeadId == GDB_ID_NULL || nExitId == GDB_ID_NULL)
return false ;
// recupero le posizioni degli assi lineari
DBLVECTOR vLinAx( 3) ;
for ( size_t i = 0 ; i < 3 ; ++ i)
m_pMachine->GetAxisPos( m_AxesName[i], vLinAx[i]) ;
// recupero le posizioni degli eventuali assi rotanti
DBLVECTOR vRotAx( m_AxesName.size() - 3) ;
for ( size_t i = 3 ; i < m_AxesName.size() ; ++ i)
m_pMachine->GetAxisPos( m_AxesName[i], vRotAx[i-3]) ;
// determino posizione e orientamento della testa
m_pMachine->GetNoseFromPositions( vLinAx[0], vLinAx[1], vLinAx[2], vRotAx, ptH) ;
m_pMachine->GetToolDirFromAngles( vRotAx, vtH) ;
m_pMachine->GetAuxDirFromAngles( vRotAx, vtA) ;
Frame3d frExit ; m_pGeomDB->GetGroupGlobFrame( nExitId, frExit) ;
ptH = frExit.Orig() ;
vtH = frExit.VersZ() ;
vtA = V_NULL ;
int nDirAuxId = m_pGeomDB->GetFirstNameInGroup( nHeadId, MCH_AUX_VECT) ;
if ( nDirAuxId != GDB_ID_NULL) {
const IGeoVector3d* pGV = GetGeoVector3d( m_pGeomDB->GetGeoObj( nDirAuxId)) ;
if ( pGV != nullptr) {
Frame3d frHead ; m_pGeomDB->GetGroupGlobFrame( nHeadId, frHead) ;
vtA = pGV->GetVector() ;
vtA.ToGlob( frHead) ;
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::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)
Simulator::ExecLineVmill( int nVmId, int nCurrTool, double dVmTdOffs, double dVmAdOffs,
const Point3d& ptHi, const Vector3d& vtHi, const Vector3d& vtAi, const Frame3d& frVzmI,
const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF)
{
// Recupero Zmap
IVolZmap* pVZM = GetVolZmap( m_pGeomDB->GetGeoObj( nVmId)) ;
@@ -1275,16 +1273,17 @@ Simulator::ExecLineVmill( int nVmId, const Point3d& ptHi, const Vector3d& vtHi,
Vector3d vtHfL = vtHf ; vtHfL.ToLoc( frVzmF) ;
Vector3d vtAfL = vtAf ; vtAfL.ToLoc( frVzmF) ;
// Eventuali offset
ptHiL += m_dVmTdOffs * vtHiL + m_dVmAdOffs * vtAiL ;
ptHfL += m_dVmTdOffs * vtHfL + m_dVmAdOffs * vtAfL ;
ptHiL += dVmTdOffs * vtHiL + dVmAdOffs * vtAiL ;
ptHfL += dVmTdOffs * vtHfL + dVmAdOffs * vtAfL ;
// Log per debug
if ( ExeGetDebugLevel() >= 10) {
string sOut = "Pi=(" + ToString( ptHiL) + ") Vi=(" + ToString( vtHiL) + ") Ai=(" + ToString( vtAiL) +
string sOut = "Zmap=" + ToString( nVmId) + " CurrTool=" + ToString( nCurrTool) +
"Pi=(" + ToString( ptHiL) + ") Vi=(" + ToString( vtHiL) + ") Ai=(" + ToString( vtAiL) +
") Pf=(" + ToString( ptHfL) + ") Vf=(" + ToString( vtHfL) + ") Af=(" + ToString( vtAfL) + ")" ;
LOG_DBG_INFO( GetEMkLogger(), sOut.c_str())
}
// Eseguo
return pVZM->MillingStep( ptHiL, vtHiL, vtAiL, ptHfL, vtHfL, vtAfL) ;
return pVZM->MillingStep( nCurrTool, ptHiL, vtHiL, vtAiL, ptHfL, vtHfL, vtAfL) ;
}
//----------------------------------------------------------------------------
@@ -1950,3 +1949,94 @@ Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& v
m_CollObj.emplace_back( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::SetToolForVmill( const string& sTool, const string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst)
{
// disabilito eventuale registrazione comandi EXE (riabilitazione automatica)
CmdLogOff cmdLogOff ;
// se vVmill vuoto, esco
if ( vVmill.empty())
return true ;
// se utensile, testa o uscita non definiti, reset ed esco
if ( IsEmptyOrSpaces( sTool) || IsEmptyOrSpaces( sHead) || nExit < 1) {
ExeVolZmapResetTools( vVmill) ;
return false ;
}
// imposto utensile come corrente
string sOldTool ; m_pMchMgr->TdbGetCurrToolParam( TPA_NAME, sOldTool) ;
if ( sTool != sOldTool && ! m_pMchMgr->TdbSetCurrTool( sTool)) {
ExeVolZmapResetTools( vVmill) ;
return false ;
}
// recupero dati utensile
int nFlag = 1 ;
int nType ; m_pMchMgr->TdbGetCurrToolParam( TPA_TYPE, nType) ;
double dLen ; m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, dLen) ;
double dDiam ; m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, dDiam) ;
double dThick ; m_pMchMgr->TdbGetCurrToolParam( TPA_THICK, dThick) ;
double dCornR ; m_pMchMgr->TdbGetCurrToolParam( TPA_CORNRAD, dCornR) ;
double dSideAng ; m_pMchMgr->TdbGetCurrToolParam( TPA_SIDEANG, dSideAng) ;
double dMaxMat ; m_pMchMgr->TdbGetCurrToolParam( TPA_MAXMAT, dMaxMat) ;
// ricerca dell'outline e del diametro gambo
int nExitId = m_pMachine->GetExitId( sHead, nExit) ;
int nToolId = m_pGeomDB->GetFirstNameInGroup( nExitId, sTool) ;
int nOutlineId = m_pGeomDB->GetFirstNameInGroup( nToolId, "Outline") ;
double dMaxStemDiam = dDiam ; m_pGeomDB->GetInfo( nToolId, "D_STEM", dMaxStemDiam) ;
// imposto profilo utensile per Vmill
if ( nOutlineId != GDB_ID_NULL)
ExeVolZmapSetGenTool( vVmill, sTool, nOutlineId, nFlag, bFirst) ;
else if ( nType == TT_MORTISE_STD)
ExeVolZmapSetMortiserTool( vVmill, sTool, dLen, dDiam, dThick, dCornR, nFlag, bFirst) ;
else if ( nType == TT_SAW_STD || nType == TT_SAW_FLAT)
ExeVolZmapSetSawTool( vVmill, sTool, dLen, dDiam, dThick, 0, dCornR, nFlag, bFirst) ;
else if ( nType == TT_WATERJET)
ExeVolZmapSetStdTool( vVmill, sTool, dLen + 50, dDiam, dCornR, dMaxMat, nFlag, bFirst) ;
else if ( abs( dSideAng) < EPS_ANG_SMALL || abs( dThick) < EPS_SMALL) {
if ( dDiam <= dMaxStemDiam)
ExeVolZmapSetStdTool( vVmill, sTool, dLen, dDiam, dCornR, dMaxMat, nFlag, bFirst) ;
else
ExeVolZmapSetSawTool( vVmill, sTool, dLen, dDiam, dMaxMat, 0, dCornR, nFlag, bFirst) ;
}
else {
bool bExtra = ( dThick > 0) ;
double dTipLen = abs( dThick) ;
double dTotLen = ( bExtra ? dLen + dTipLen : dLen) ;
double dDelta ;
if ( dSideAng > 0) {
if ( dCornR < EPS_SMALL)
dDelta = 2 * dTipLen * tan( dSideAng * DEGTORAD) ;
else
dDelta = 2 * ( dCornR * cos( dSideAng * DEGTORAD) + ( dTipLen - dCornR + dCornR * sin( dSideAng * DEGTORAD)) * tan( dSideAng * DEGTORAD)) ;
}
else
dDelta = 2 * tan( dSideAng * DEGTORAD) * dTipLen ;
double dStemDiam = ( bExtra ? dDiam : dDiam + dDelta) ;
double dTipDiam = ( bExtra ? dDiam - dDelta : dDiam) ;
ExeVolZmapSetAdvTool( vVmill, sTool, dTotLen, dStemDiam, dTipLen, dTipDiam, dCornR, dMaxMat, nFlag, bFirst) ;
}
// eventuali offset per Vmill (per adattare lo ZeroT macchina con quello di Zmap)
double dVmTdOffs = 0 ;
double dVmAdOffs = 0 ;
if ( nType == TT_MORTISE_STD) {
dVmTdOffs = 0 ;
dVmAdOffs = 0.5 * dThick ;
}
else if ( nType == TT_SAW_STD || nType == TT_SAW_FLAT) {
dVmTdOffs = ( ( dLen <= dThick) ? -dLen + dThick : 0) ;
dVmAdOffs = 0 ;
}
// inserisco in lista utensili per virtual milling
if ( bFirst) {
m_VmTool.resize( 1) ;
m_VmTool[0] = VmTool( sTool, sHead, nExit, dVmTdOffs, dVmAdOffs) ;
}
else
m_VmTool.emplace_back( sTool, sHead, nExit, dVmTdOffs, dVmAdOffs) ;
// ripristino eventuale diverso utensile corrente
if ( sTool != sOldTool)
m_pMchMgr->TdbSetCurrTool( sOldTool) ;
return true ;
}
+21 -5
View File
@@ -21,6 +21,7 @@ class IGeomDB ;
class Machine ;
class PerformanceCounter ;
//----------------------------------------------------------------------------
class Simulator
{
@@ -40,6 +41,7 @@ class Simulator
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) ;
bool SetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst) ;
private :
bool UpdateTool( bool bFirst, int& nErr) ;
@@ -60,9 +62,10 @@ class Simulator
bool ManageMove( int& nStatus) ;
bool ManageSingleMove( int& nStatus, double& dMove) ;
int CalcStatusOnError( int nErr) ;
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 GetHeadCurrPosDirAux( const std::string& sHead, int nExit, Point3d& ptH, Vector3d& vtH, Vector3d& vtA) ;
bool ExecLineVmill( int nVmId, int nCurrTool, double dVmTdOffs, double dVmAdOffs,
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 NeedCollisionCheck( void) const
{ return ( ! m_CollObj.empty() && ! m_CdId.empty()) ; }
bool Stopped( void)
@@ -103,6 +106,18 @@ class Simulator
: nInd( nI), nFrameId( nF), nType( nT), vtMove( vtM), dPar1( dP1), dPar2( dP2), dPar3( dP3) {}
} ;
typedef std::vector< CollObj> COBVECTOR ;
struct VmTool
{
std::string sName ;
std::string sHead ;
int nExit ;
double dTdOffs ;
double dAdOffs ;
VmTool( void) : nExit( 0), dTdOffs( 0), dAdOffs( 0) {}
VmTool( std::string sN, std::string sH, int nE, double dT, double dA)
: sName( sN), sHead( sH), nExit( nE), dTdOffs( dT), dAdOffs( dA) {}
} ;
typedef std::vector< VmTool> VMTVECTOR ;
private :
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
@@ -128,8 +143,9 @@ class Simulator
double m_dTDiam ; // diametro 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
//double m_dVmTdOffs ; // offset utensile in direzione principale per VM
//double m_dVmAdOffs ; // offset utensile in direzione ausiliaria per VM
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
int m_nAxesMask ; // maschera a bit di abilitazione movimento assi (solo se rapido)