diff --git a/SimulatorSP.cpp b/SimulatorSP.cpp index 4b1b4e0..022f8be 100644 --- a/SimulatorSP.cpp +++ b/SimulatorSP.cpp @@ -88,7 +88,9 @@ SimulatorSP::SimulatorSP( void) m_nAuxEInd = 0 ; m_nExit = 0 ; m_dTDiam = 0 ; + m_dTLen = 0 ; m_bCutOnTip = false ; + m_nCurrTrace = GDB_ID_NULL ; m_bEnableVm = false ; m_dSafeDist = SAFEDIST_STD ; m_nAxesMask = 0 ; @@ -207,7 +209,9 @@ SimulatorSP::Start( bool bFirst) m_sHead.clear() ; m_nExit = 0 ; m_dTDiam = 0 ; + m_dTLen = 0 ; m_bCutOnTip = false ; + m_nCurrTrace = GDB_ID_NULL ; ResetInterpolation() ; ResetAxes() ; ResetAuxAxes() ; @@ -573,6 +577,7 @@ SimulatorSP::UpdateTool( bool bFirst, int& nErr) m_sHead = sHead ; m_nExit = nExit ; m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, m_dTDiam) ; + m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, m_dTLen) ; double dTipFeed = 0 ; m_pMchMgr->TdbGetCurrToolParam( TPA_TIPFEED, dTipFeed) ; m_bCutOnTip = ( dTipFeed > EPS_MACH_LEN_PAR) ; @@ -616,6 +621,7 @@ SimulatorSP::UpdateTool( bool bFirst, int& nErr) m_sHead = sHead ; m_nExit = nExit ; m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, m_dTDiam) ; + m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, m_dTLen) ; double dTipFeed = 0 ; m_pMchMgr->TdbGetCurrToolParam( TPA_TIPFEED, dTipFeed) ; m_bCutOnTip = ( dTipFeed > EPS_MACH_LEN_PAR) ; @@ -888,6 +894,8 @@ SimulatorSP::FindAndManagePathStart( int& nStatus) m_dCoeff = 0 ; } } + // reset eventuale curva di TipTrace + m_nCurrTrace = GDB_ID_NULL ; // se trovato nuovo CLpath con entità, gestisco inizio percorso di lavoro if ( m_nEntId != GDB_ID_NULL) { ++ m_nCLPathInd ; @@ -955,6 +963,8 @@ SimulatorSP::ManagePathEnd( int& nStatus) // gestione stato if ( ! bOk) nStatus = CalcStatusOnError( 0) ; + // reset eventuale curva di TipTrace + m_nCurrTrace = GDB_ID_NULL ; return bOk ; } @@ -1195,6 +1205,26 @@ SimulatorSP::ManageSingleMove( int& nStatus, double& dMove) // eseguo eventuale collision check bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ; } + // eventuale salvataggio punto tip utensile + if ( nMoveType == 1) { + int nTipTraceId ; + if ( m_pMachine->LuaGetGlobVar( GLOB_VAR + ".TIPTRACE", nTipTraceId)) { + int nHeadId = m_pMachine->GetHeadId( m_sHead) ; + int nExitId = m_pMachine->GetExitId( m_sHead, m_nExit) ; + Frame3d frExit ; + if ( m_pGeomDB->GetGroupGlobFrame( nExitId, frExit)) { + Point3d ptTip = frExit.Orig() - m_dTLen * frExit.VersZ() ; + if ( m_nCurrTrace == GDB_ID_NULL) { + PolyLine PL ; + PL.AddUPoint( -1, ptTip + 10 * EPS_SMALL * frExit.VersZ()) ; + PL.AddUPoint( 0, ptTip) ; + m_nCurrTrace = ExeCreateCurveCompoFromPoints( nTipTraceId, PL, GDB_ID_ROOT) ; + } + else + ExeAddCurveCompoLine( m_nCurrTrace, ptTip, true, GDB_ID_ROOT) ; + } + } + } } // Eseguo movimento su arco else { diff --git a/SimulatorSP.h b/SimulatorSP.h index ce7d858..cf44102 100644 --- a/SimulatorSP.h +++ b/SimulatorSP.h @@ -161,7 +161,9 @@ class SimulatorSP : public ISimulator std::string m_sHead ; // nome della testa corrente int m_nExit ; // indice dell'uscita corrente double m_dTDiam ; // diametro dell'utensile corrente + double m_dTLen ; // lunghezza dell'utensile corrente bool m_bCutOnTip ; // flag capacità di lavorare di testa dell'utensile corrente + int m_nCurrTrace ; // Id della curva composita corrente di trace bool m_bEnableVm ; // flag abilitazione Virtual Milling INTVECTOR m_VmId ; // vettore identificativi Zmap per Virtual Milling INTVECTOR m_CdId ; // vettore identificativi Zmap per Collision Detection