diff --git a/Milling.cpp b/Milling.cpp index f787a40..f572052 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -1,13 +1,14 @@ //---------------------------------------------------------------------------- -// EgalTech 2015-2016 +// EgalTech 2015-2020 //---------------------------------------------------------------------------- -// File : Milling.cpp Data : 11.08.16 Versione : 1.6t2 +// File : Milling.cpp Data : 02.06.20 Versione : 2.2f1 // Contenuto : Implementazione gestione fresature. // // // // Modifiche : 07.06.15 DS Creazione modulo. // 11.08.16 DS Miglioria gestione PV per più loop. +// 02.06.20 DS Aggiunta gestione Tabs. // //---------------------------------------------------------------------------- @@ -30,6 +31,7 @@ #include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGnStringKeyVal.h" +#include "/EgtDev/Include/EgtNumUtils.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; @@ -107,6 +109,7 @@ Milling::Clone( void) const pMill->m_bAboveHead = m_bAboveHead ; pMill->m_bAggrBottom = m_bAggrBottom ; pMill->m_dCurrOscillLen = m_dCurrOscillLen ; + pMill->m_dCurrTabsLen = m_dCurrTabsLen ; } catch( ...) { delete pMill ; @@ -229,6 +232,7 @@ Milling::Milling( void) m_bAboveHead = true ; m_bAggrBottom = false ; m_dCurrOscillLen = 0 ; + m_dCurrTabsLen = 0 ; } //---------------------------------------------------------------------------- @@ -1553,11 +1557,16 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false)) return false ; - // flag di oscillazione del percorso corrente - bool bPathOscEnable = m_Params.m_bOscEnable ; + // flags per tabs e oscillazione del percorso corrente (se entrambi, solo tabs) + bool bPathTabsEnable = m_Params.m_bLeaveTab ; + bool bPathOscEnable = ( ! bPathTabsEnable && m_Params.m_bOscEnable) ; - // se utensile lama, disabilito eventuale oscillazione + // se utensile lama, disabilito eventuali tbas o oscillazione if ( ( m_TParams.m_nType & TF_SAWBLADE) != 0) { + if ( bPathTabsEnable) { + bPathTabsEnable = false ; + m_pMchMgr->SetWarning( 2359, "Warning in Milling : tabs incompatible with saw blade") ; + } if ( bPathOscEnable) { bPathOscEnable = false ; m_pMchMgr->SetWarning( 2359, "Warning in Milling : oscillation incompatible with saw blade") ; @@ -1778,19 +1787,19 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) // se altrimenti una sola passata else if ( dOkStep < EPS_SMALL || dOkStep > dElev) { m_bStepOn = false ; - if ( ! AddStandardMilling( pCompo, vtTool, dDepth, dElev, bSplitArcs, bPathOscEnable)) + if ( ! AddStandardMilling( pCompo, vtTool, dDepth, dElev, bSplitArcs, bPathTabsEnable, bPathOscEnable)) return false ; } // se altrimenti passate a zig-zag else if ( m_Params.m_nStepType == MILL_ST_ZIGZAG) { m_bStepOn = true ; - if ( ! AddZigZagMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs, bPathOscEnable)) + if ( ! AddZigZagMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs, bPathTabsEnable, bPathOscEnable)) return false ; } // se altrimenti passate a one-way else if ( m_Params.m_nStepType == MILL_ST_ONEWAY) { m_bStepOn = true ; - if ( ! AddOneWayMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs, bPathOscEnable)) + if ( ! AddOneWayMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs, bPathTabsEnable, bPathOscEnable)) return false ; } // se altrimenti passate a spirale @@ -1803,7 +1812,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) pCompo->Invert() ; m_dAddedOverlap = 0 ; } - if ( ! AddSpiralMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs, bPathOscEnable)) + if ( ! AddSpiralMilling( pCompo, vtTool, dDepth, dElev, dOkStep, bSplitArcs, bPathTabsEnable, bPathOscEnable)) return false ; } @@ -2046,7 +2055,7 @@ Milling::GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) //---------------------------------------------------------------------------- bool Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, - double dDepth, double dElev, bool bSplitArcs, bool bPathOscEnable) + double dDepth, double dElev, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) { // recupero distanze di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -2054,12 +2063,17 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo // lunghezza di approccio/retrazione double dAppr = m_Params.m_dStartPos ; + // in caso di tabs ne aggiusto i parametri secondo il percorso + double dTabsRampLen, dTabsBottomLen, dTabsTopLen ; + AdjustTabsParams( pCompo, bPathTabsEnable, dTabsRampLen, dTabsBottomLen, dTabsTopLen) ; + // in caso di oscillazione ne aggiusto i parametri secondo il percorso double dOscRampLen, dOscFlatLen ; AdjustOscillParams( pCompo, bPathOscEnable, dOscRampLen, dOscFlatLen) ; // ciclo sulle curve elementari bool bClosed = pCompo->IsClosed() ; + m_dCurrTabsLen = dTabsRampLen + 0.5 * dTabsBottomLen ; m_dCurrOscillLen = 2 * dOscRampLen + 1.5 * dOscFlatLen ; int nMaxInd = pCompo->GetCurveCount() - 1 ; for ( int i = 0 ; i <= nMaxInd ; ++ i) { @@ -2137,7 +2151,11 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo if ( pCurve->GetType() == CRV_LINE) { ICurveLine* pLine = GetCurveLine( pCurve) ; SetFeed( GetFeed()) ; - if ( bPathOscEnable) { + if ( bPathTabsEnable) { + if ( ! AddTabsLine( pLine, vtTool, dTabsRampLen, dTabsBottomLen, dTabsTopLen)) + return false ; + } + else if ( bPathOscEnable) { if ( ! AddOscillLine( pLine, vtTool, dOscRampLen, dOscFlatLen)) return false ; } @@ -2150,7 +2168,11 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo else if ( pCurve->GetType() == CRV_ARC) { ICurveArc* pArc = GetCurveArc( pCurve) ; SetFeed( GetFeed()) ; - if ( bPathOscEnable) { + if ( bPathTabsEnable) { + if ( ! AddTabsArc( pArc, vtTool, dTabsRampLen, dTabsBottomLen, dTabsTopLen)) + return false ; + } + else if ( bPathOscEnable) { if ( ! AddOscillArc( pArc, vtTool, dOscRampLen, dOscFlatLen)) return false ; } @@ -2207,7 +2229,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo //---------------------------------------------------------------------------- bool Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, - double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable) + double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) { // recupero distanze di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -2411,7 +2433,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool //---------------------------------------------------------------------------- bool Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, - double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable) + double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) { // recupero distanze di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -2625,7 +2647,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool //---------------------------------------------------------------------------- bool Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, - double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable) + double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) { // recupero distanze di sicurezza double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ; @@ -4096,6 +4118,330 @@ Milling::AddOscillArc( const ICurveArc* pArc, const Vector3d& vtTool, double dRa return true ; } +//---------------------------------------------------------------------------- +bool +Milling::AdjustTabsParams( const ICurve* pCrv, bool& bPathTabsEnable, double& dTabsRampLen, double& dTabsBottomLen, double& dTabsTopLen) +{ + // se c'è oscillazione cerco di aggiustare le lunghezze dei Bottom per finire con la stessa quota di partenza + double dTabAngle = Clamp( abs( m_Params.m_dTabAngle), 15., 75.) ; + dTabsRampLen = min( abs( m_Params.m_dTabHeight) / tan( dTabAngle * DEGTORAD), abs( m_Params.m_dTabLen) / 2 - OSC_MIN_LEN) ; + dTabsTopLen = abs( m_Params.m_dTabLen) - 2 * dTabsRampLen ; + dTabsBottomLen = abs( m_Params.m_dTabDist) - abs( m_Params.m_dTabLen) ; + if ( bPathTabsEnable) { + // lunghezza del percorso + double dLen ; pCrv->GetLength( dLen) ; dLen -= m_dAddedOverlap ; + // se percorso più corto di due tabs, disabilito + if ( dLen < 2 * dTabsRampLen + 2 * dTabsTopLen) + bPathTabsEnable = false ; + else { + int nTabs = max( static_cast( dLen / ( 2 * dTabsRampLen + dTabsTopLen + dTabsBottomLen)), 1) ; + dTabsBottomLen = ( dLen - nTabs * ( 2 * dTabsRampLen + dTabsTopLen)) / nTabs ; + } + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Milling::AddTabsLine( const ICurveLine* pLine, const Vector3d& vtTool, double dTabsRampLen, double dTabsBottomLen, double dTabsTopLen) +{ + // lunghezze dei tratti di oscillazione + dTabsRampLen = max( dTabsRampLen, OSC_MIN_LEN) ; + dTabsBottomLen = max( dTabsBottomLen, OSC_MIN_LEN) ; + dTabsTopLen = max( dTabsTopLen, OSC_MIN_LEN) ; + double vLenRef[4] = { dTabsRampLen, + dTabsRampLen + dTabsBottomLen, + dTabsRampLen + dTabsBottomLen + dTabsRampLen, + dTabsRampLen + dTabsBottomLen + dTabsRampLen + dTabsTopLen} ; + // lunghezza della linea + double dLen ; pLine->GetLength( dLen) ; + // lunghezza corrente sulla linea + double dCurrLen = 0 ; + // emissione oscillazioni + while ( dCurrLen < dLen - EPS_ZERO) { + // lunghezza rimanente + double dNextLen = dLen - dCurrLen ; + // se inizio è sul primo tratto (rampa discendente) + if ( m_dCurrTabsLen < vLenRef[0] - 10 * EPS_SMALL) { + // se fine linea è entro il tratto + if ( m_dCurrTabsLen + dNextLen < vLenRef[0] - 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen += dNextLen ; + Point3d ptP3 = pLine->GetEnd() ; + ptP3 += vtTool * ( abs( m_Params.m_dTabHeight) * ( vLenRef[0] - m_dCurrTabsLen) / ( vLenRef[0] - 0)) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + // se fine linea è alla fine del tratto + else if ( m_dCurrTabsLen + dNextLen < vLenRef[0] + 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen = vLenRef[0] ; + Point3d ptP3 = pLine->GetEnd() ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + // altrimenti fine linea è oltre + else { + dCurrLen += vLenRef[0] - m_dCurrTabsLen ; + m_dCurrTabsLen = vLenRef[0] ; + double dU ; pLine->GetParamAtLength( dCurrLen, dU) ; + Point3d ptP3 ; pLine->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + } + // se inizio è sul secondo tratto (parte piatta in basso) + else if ( m_dCurrTabsLen < vLenRef[1] - 10 * EPS_SMALL) { + // se fine linea è entro il tratto + if ( m_dCurrTabsLen + dNextLen < vLenRef[1] - 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen += dNextLen ; + Point3d ptP3 = pLine->GetEnd() ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + // se fine linea è alla fine del tratto + else if ( m_dCurrTabsLen + dNextLen < vLenRef[1] + 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen = vLenRef[1] ; + Point3d ptP3 = pLine->GetEnd() ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + // altrimenti fine linea è oltre + else { + dCurrLen += vLenRef[1] - m_dCurrTabsLen ; + m_dCurrTabsLen = vLenRef[1] ; + double dU ; pLine->GetParamAtLength( dCurrLen, dU) ; + Point3d ptP3 ; pLine->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + } + // se inizio è sul terzo tratto (rampa ascendente) + else if ( m_dCurrTabsLen < vLenRef[2] - 10 * EPS_SMALL) { + // se fine linea è entro il tratto + if ( m_dCurrTabsLen + dNextLen < vLenRef[2] - 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen += dNextLen ; + Point3d ptP3 = pLine->GetEnd() ; + ptP3 += vtTool * ( abs( m_Params.m_dTabHeight) * ( m_dCurrTabsLen - vLenRef[1]) / ( vLenRef[2] - vLenRef[1])) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + // se fine linea è alla fine del tratto + else if ( m_dCurrTabsLen + dNextLen < vLenRef[2] + 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen = vLenRef[2] ; + Point3d ptP3 = pLine->GetEnd() ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + // altrimenti fine linea è oltre + else { + dCurrLen += vLenRef[2] - m_dCurrTabsLen ; + m_dCurrTabsLen = vLenRef[2] ; + double dU ; pLine->GetParamAtLength( dCurrLen, dU) ; + Point3d ptP3 ; pLine->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + } + // altrimenti è sul quarto tratto (parte piatta in alto) + else { + // se fine linea è entro il tratto + if ( m_dCurrTabsLen + dNextLen < vLenRef[3] - 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen += dNextLen ; + Point3d ptP3 = pLine->GetEnd() ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + // se fine linea è alla fine del tratto + else if ( m_dCurrTabsLen + dNextLen < vLenRef[3] + 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen = 0 ; + Point3d ptP3 = pLine->GetEnd() ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + // altrimenti fine linea è oltre + else { + dCurrLen += vLenRef[3] - m_dCurrTabsLen ; + m_dCurrTabsLen = 0 ; + double dU ; pLine->GetParamAtLength( dCurrLen, dU) ; + Point3d ptP3 ; pLine->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + } + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Milling::AddTabsArc( const ICurveArc* pArc, const Vector3d& vtTool, double dTabsRampLen, double dTabsBottomLen, double dTabsTopLen) +{ + // lunghezze dei tratti di oscillazione + dTabsRampLen = max( dTabsRampLen, OSC_MIN_LEN) ; + dTabsBottomLen = max( dTabsBottomLen, OSC_MIN_LEN) ; + dTabsTopLen = max( dTabsTopLen, OSC_MIN_LEN) ; + double vLenRef[4] = { dTabsRampLen, + dTabsRampLen + dTabsBottomLen, + dTabsRampLen + dTabsBottomLen + dTabsRampLen, + dTabsRampLen + dTabsBottomLen + dTabsRampLen + dTabsTopLen} ; + // parametria dell'arco + Point3d ptCen = pArc->GetCenter() ; + double dAngCen = pArc->GetAngCenter() ; + Vector3d vtN = pArc->GetNormVersor() ; + double dLen ; pArc->GetLength( dLen) ; + // lunghezza corrente sull'arco + double dCurrLen = 0 ; + // emissione oscillazioni + while ( dCurrLen < dLen - EPS_ZERO) { + // lunghezza rimanente + double dNextLen = dLen - dCurrLen ; + // se inizio è sul primo tratto (rampa discendente) + if ( m_dCurrTabsLen < vLenRef[0] - 10 * EPS_SMALL) { + // se fine linea è entro il tratto + if ( m_dCurrTabsLen + dNextLen < vLenRef[0] - 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen += dNextLen ; + Point3d ptP3 ; pArc->GetEndPoint( ptP3) ; + ptP3 += vtTool * ( abs( m_Params.m_dTabHeight) * ( vLenRef[0] - m_dCurrTabsLen) / ( vLenRef[0] - 0)) ; + double dCurrAngCen = dAngCen * dNextLen / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + // se fine linea è alla fine del tratto + else if ( m_dCurrTabsLen + dNextLen < vLenRef[0] + 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen = vLenRef[0] ; + Point3d ptP3 ; pArc->GetEndPoint( ptP3) ; + double dCurrAngCen = dAngCen * dNextLen / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + // altrimenti fine linea è oltre + else { + dCurrLen += vLenRef[0] - m_dCurrTabsLen ; + m_dCurrTabsLen = vLenRef[0] ; + double dU ; pArc->GetParamAtLength( dCurrLen, dU) ; + Point3d ptP3 ; pArc->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ; + double dCurrAngCen = dAngCen * ( dNextLen + dCurrLen - dLen) / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + } + // se inizio è sul secondo tratto (parte piatta in basso) + else if ( m_dCurrTabsLen < vLenRef[1] - 10 * EPS_SMALL) { + // se fine linea è entro il tratto + if ( m_dCurrTabsLen + dNextLen < vLenRef[1] - 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen += dNextLen ; + Point3d ptP3 ; pArc->GetEndPoint( ptP3) ; + double dCurrAngCen = dAngCen * dNextLen / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + // se fine linea è alla fine del tratto + else if ( m_dCurrTabsLen + dNextLen < vLenRef[1] + 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen = vLenRef[1] ; + Point3d ptP3 ; pArc->GetEndPoint( ptP3) ; + double dCurrAngCen = dAngCen * dNextLen / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + // altrimenti fine linea è oltre + else { + dCurrLen += vLenRef[1] - m_dCurrTabsLen ; + m_dCurrTabsLen = vLenRef[1] ; + double dU ; pArc->GetParamAtLength( dCurrLen, dU) ; + Point3d ptP3 ; pArc->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ; + double dCurrAngCen = dAngCen * ( dNextLen + dCurrLen - dLen) / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + } + // se inizio è sul terzo tratto (rampa ascendente) + else if ( m_dCurrTabsLen < vLenRef[2] - 10 * EPS_SMALL) { + // se fine linea è entro il tratto + if ( m_dCurrTabsLen + dNextLen < vLenRef[2] - 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen += dNextLen ; + Point3d ptP3 ; pArc->GetEndPoint( ptP3) ; + ptP3 += vtTool * ( abs( m_Params.m_dTabHeight) * ( m_dCurrTabsLen - vLenRef[1]) / ( vLenRef[2] - vLenRef[1])) ; + double dCurrAngCen = dAngCen * dNextLen / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + // se fine linea è alla fine del tratto + else if ( m_dCurrTabsLen + dNextLen < vLenRef[2] + 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen = vLenRef[2] ; + Point3d ptP3 ; pArc->GetEndPoint( ptP3) ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + double dCurrAngCen = dAngCen * dNextLen / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + // altrimenti fine linea è oltre + else { + dCurrLen += vLenRef[2] - m_dCurrTabsLen ; + m_dCurrTabsLen = vLenRef[2] ; + double dU ; pArc->GetParamAtLength( dCurrLen, dU) ; + Point3d ptP3 ; pArc->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + double dCurrAngCen = dAngCen * ( dNextLen + dCurrLen - dLen) / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + } + // altrimenti è sul quarto tratto (parte piatta in alto) + else { + // se fine linea è entro il tratto + if ( m_dCurrTabsLen + dNextLen < vLenRef[3] - 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen += dNextLen ; + Point3d ptP3 ; pArc->GetEndPoint( ptP3) ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + double dCurrAngCen = dAngCen * dNextLen / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + // se fine linea è alla fine del tratto + else if ( m_dCurrTabsLen + dNextLen < vLenRef[3] + 10 * EPS_SMALL) { + dCurrLen = dLen ; + m_dCurrTabsLen = 0 ; + Point3d ptP3 ; pArc->GetEndPoint( ptP3) ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + double dCurrAngCen = dAngCen * dNextLen / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + // altrimenti fine linea è oltre + else { + dCurrLen += vLenRef[3] - m_dCurrTabsLen ; + m_dCurrTabsLen = 0 ; + double dU ; pArc->GetParamAtLength( dCurrLen, dU) ; + Point3d ptP3 ; pArc->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP3) ; + ptP3 += vtTool * abs( m_Params.m_dTabHeight) ; + double dCurrAngCen = dAngCen * ( dNextLen + dCurrLen - dLen) / dLen ; + if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL) + return false ; + } + } + } + return true ; +} + //---------------------------------------------------------------------------- double Milling::GetRadiusForStartEndElevation( void) const diff --git a/Milling.h b/Milling.h index b599253..608c3cd 100644 --- a/Milling.h +++ b/Milling.h @@ -79,13 +79,13 @@ class Milling : public Machining bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ; bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) ; bool AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, - double dDepth, double dElev, bool bSplitArcs, bool bPathOscEnable) ; + double dDepth, double dElev, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ; bool AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, - double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable) ; + double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ; bool AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, - double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable) ; + double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ; bool AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, - double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathOscEnable) ; + double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bPathTabsEnable, bool bPathOscEnable) ; bool AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dElev, double dOkStep, bool bSplitArcs) ; bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ, @@ -102,6 +102,9 @@ class Milling : public Machining bool AdjustOscillParams( const ICurve* pCrv, bool& bPathOscEnable, double& dRampLen, double& dFlatLen) ; bool AddOscillLine( const ICurveLine* pLine, const Vector3d& vtTool, double dRampLen, double dFlatLen) ; bool AddOscillArc( const ICurveArc* pArc, const Vector3d& vtTool, double dRampLen, double dFlatLen) ; + bool AdjustTabsParams( const ICurve* pCrv, bool& bPathTabsEnable, double& dTabsRampLen, double& dTabsBottomLen, double& dTabsTopLen) ; + bool AddTabsLine( const ICurveLine* pLine, const Vector3d& vtTool, double dTabsRampLen, double dTabsBottomLen, double dTabsTopLen) ; + bool AddTabsArc( const ICurveArc* pArc, const Vector3d& vtTool, double dTabsRampLen, double dTabsBottomLen, double dTabsTopLen) ; double GetRadiusForStartEndElevation( void) const ; bool GetPointOutOfRaw( const Point3d& ptP, const Vector3d& vtTool, double dElev) const ; bool GetPointAboveRaw( const Point3d& ptP, const Vector3d& vtTool) const ; @@ -148,4 +151,5 @@ class Milling : public Machining Vector3d m_vtAggrBottom ; // vettore direzione ausiliaria aggregato da sotto AggrBottom m_AggrBottom ; // dati eventuale aggregato da sotto double m_dCurrOscillLen ; // lunghezza corrente lungo il percorso per l'oscillazione + double m_dCurrTabsLen ; // lunghezza corrente lungo il percorso per tabs } ; \ No newline at end of file