From d19dfc5f8f7bb802773c0df3a85732f3c990634f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 1 Nov 2023 19:21:28 +0100 Subject: [PATCH] EgtMachKernel 2.5j5 : - migliorato calcolo approcci di fresature e svuotature - in fresatura e svuotatura ora attacchi elica, zigzag e inseguimento partono 2mm sopra il materiale - in fresatura migliorato passaggio ad inseguimento tra uno step e il successivo. --- EgtMachKernel.rc | Bin 11782 -> 11782 bytes Milling.cpp | 37 +++++++++++++++++++++++++------------ Milling.h | 3 +++ Pocketing.cpp | 40 +++++++++++++++++++++------------------- 4 files changed, 49 insertions(+), 31 deletions(-) diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 82f3520b8ba01b935934a5533b33d255ffe3d08d..5e838f2309bec1bac76870454567323f2cc4f216 100644 GIT binary patch delta 97 zcmZpRX^YwLhmFy6^ItYwW=7M=j>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHQiUK= delta 97 zcmZpRX^YwLhmFx>^ItYwW=50Aj>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHQ1Kv2 diff --git a/Milling.cpp b/Milling.cpp index deccdf0..1c1c71f 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -2369,7 +2369,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo // se attacco a zigzag o a spirale, l'elevazione va nell'attacco if ( IsLeadInHelixOrZigzag()) { ptP1 += vtTool * ( dStElev + LIO_ELEV_TOL) ; - dStElev = - LIO_ELEV_TOL ; + dStElev = -LIO_ELEV_TOL ; } // approccio al punto iniziale if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart)) { @@ -2815,7 +2815,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool return false ; } // se attacco a zigzag o a spirale, non affondo - else if ( IsLeadInHelixOrZigzag()) { + else if ( IsLeadInHelixOrZigzagOrGlide()) { ptP1 += vtTool * ( dStElev + LIO_ELEV_TOL) ; dStElev = - LIO_ELEV_TOL ; } @@ -2888,6 +2888,8 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool // se non c'è attacco a zigzag o a spirale oppure ultimo step, aggiungo uscita Point3d ptP1 = ptEnd ; if ( ! IsLeadInHelixOrZigzag() || k == nStep) { + if ( k != nStep && GetLeadInType() == MILL_LI_GLIDE) + dEndElev = -LIO_ELEV_TOL ; SetFeed( GetEndFeed()) ; if ( ! AddLeadOut( ptEnd, vtEnd, vtTool, dEndElev, bInvert, pCompo, bSplitArcs, ptP1)) { m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ; @@ -3017,7 +3019,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool AdjustOscillParams( pCompo, bPathOscEnable, dOscRampLen, dOscFlatLen) ; // percorso speciale : chiuso e con attacco a spirale o zigzag - bool bSpecial = pCompo->IsClosed() && IsLeadInHelixOrZigzag() ; + bool bSpecial = ( pCompo->IsClosed() && IsLeadInHelixOrZigzagOrGlide()) ; // percorso senza retrazioni intermedie : chiuso e con attacco e uscita con punti esterni coincidenti bool bMidRetract = true ; @@ -3026,6 +3028,8 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool int nLoType = GetLeadOutType() ; if ( nLiType == MILL_LI_NONE && ( nLoType == MILL_LO_NONE || nLoType == MILL_LO_AS_LI)) bMidRetract = false ; + if ( nLiType == MILL_LI_GLIDE) + bMidRetract = false ; if ( ( nLiType == MILL_LI_TANGENT || nLiType == MILL_LI_LINEAR || nLiType == MILL_LI_TG_PERP) && nLoType == MILL_LO_AS_LI && abs( m_Params.m_dLiTang) < EPS_SMALL) @@ -3108,12 +3112,20 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool // ciclo sugli step bool bOk = true ; - int nMaxInd = pCompo->GetCurveCount() - 1 ; for ( int k = 1 ; k <= nStep ; ++ k) { int j = ( bStepUp ? nStep - k + 1 : k) ; m_dCurrTabsLen = 0 ; m_dCurrOscillLen = 2 * dOscRampLen + 1.5 * dOscFlatLen ; + // se percorso chiuso e attacco ad inseguimento sposto inizio + if ( k > 1 && pCompo->IsClosed() && GetLeadInType() == MILL_LI_GLIDE) { + double dU ; + if ( pCompo->GetParamAtLength( m_Params.m_dLiTang, dU)) { + const_cast( pCompo)->ChangeStartPoint( dU) ; + const_cast( pCompo)->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false) ; + } + } // ciclo sulle curve elementari + int nMaxInd = pCompo->GetCurveCount() - 1 ; for ( int i = 0 ; i <= nMaxInd ; ++ i) { // curva corrente const ICurve* pCrvC = pCompo->GetCurve( i) ; @@ -4059,33 +4071,34 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ; double dElevZ = vtAppr.z * dElev ; if ( ! bAboveStart && ! bBottomStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { + Point3d ptP1 = ptP + vtAppr * ( dElev + dAppr) ; // se distanza di sicurezza minore di distanza di inizio if ( dSafeDist < dAppr + 10 * EPS_SMALL) { // 1 -> punto sopra inizio - Point3d ptP1 = ptP + vtAppr * ( dElev + dAppr) ; if ( ( ! m_bAggrBottom && AddRapidStart( ptP1) == GDB_ID_NULL) || ( m_bAggrBottom && AddRapidMove( ptP1) == GDB_ID_NULL)) return false ; } else { - // 1a -> punto sopra inizio - Point3d ptP1b = ptP + vtAppr * ( dElev + dAppr) ; - Point3d ptP1a = ptP1b + vtAppr * ( dSafeDist - dAppr) ; + // 1a -> punto molto sopra inizio + Point3d ptP1a = ptP1 + vtAppr * ( dSafeDist - dAppr) ; if ( ( ! m_bAggrBottom && AddRapidStart( ptP1a) == GDB_ID_NULL) || ( m_bAggrBottom && AddRapidMove( ptP1a) == GDB_ID_NULL)) return false ; - // 1b -> punto appena sopra inizio - if ( ( dElev + dAppr) > EPS_SMALL) { + // 1 -> punto sopra inizio + if ( ( dElev + dAppr) > 10 * EPS_SMALL || (( dElev + dAppr) > -EPS_ZERO && dAppr > EPS_SMALL)) { SetFlag( 0) ; - if ( AddRapidMove( ptP1b) == GDB_ID_NULL) + if ( AddRapidMove( ptP1) == GDB_ID_NULL) return false ; } + else + ptP1 = ptP1a ; } // affondo al punto iniziale SetFlag( 0) ; bool bStartFeed = ( bOutStart || m_TParams.m_nType == TT_MILL_NOTIP || m_TParams.m_nType == TT_MILL_POLISHING) ; SetFeed( bStartFeed ? GetStartFeed() : GetTipFeed()) ; - if ( AddLinearMove( ptP) == GDB_ID_NULL) + if ( ! AreSamePointApprox( ptP1, ptP) && AddLinearMove( ptP) == GDB_ID_NULL) return false ; } // sono sopra il pezzo ma non abbastanza diff --git a/Milling.h b/Milling.h index 86b36a3..93b2273 100644 --- a/Milling.h +++ b/Milling.h @@ -147,6 +147,9 @@ class Milling : public Machining bool IsLeadInHelixOrZigzag() const { int nType = GetLeadInType() ; return ( nType == MILL_LI_ZIGZAG || nType == MILL_LI_HELIX) ; } + bool IsLeadInHelixOrZigzagOrGlide() const + { int nType = GetLeadInType() ; + return ( nType == MILL_LI_ZIGZAG || nType == MILL_LI_HELIX || nType == MILL_LI_GLIDE) ; } bool LeadInRawIsOk( void) const { if ( ( m_TParams.m_nType & TF_SAWBLADE) != 0) return false ; diff --git a/Pocketing.cpp b/Pocketing.cpp index d01a71b..9d5b211 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -2145,8 +2145,8 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con if ( bOptimizedZigZag && ! ( bOutRawLeadIn || m_bOpenOutRaw)) { // se richiesto attacco a zigzag o a spirale, l'elevazione va nell'attacco if ( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX) { - ptP1 += vtExtr * dStElev ; - dStElev = 0 ; + ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ; + dStElev = -LIO_ELEV_TOL ; } } // se inizio, approccio globale al punto iniziale @@ -2299,8 +2299,8 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con if ( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX || GetLeadInType() == POCKET_LI_GLIDE) { - ptP1 += vtExtr * dStElev ; - dStElev = 0 ; + ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ; + dStElev = -LIO_ELEV_TOL ; } // approccio al punto iniziale if ( ! AddLinkApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr)) { @@ -3137,8 +3137,8 @@ Pocketing::AddOneWay( const ICurveComposite* pCompo, const Vector3d& vtTool, con if ( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX || GetLeadInType() == POCKET_LI_GLIDE) { - ptP1 += vtExtr * dStElev ; - dStElev = 0 ; + ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ; + dStElev = -LIO_ELEV_TOL ; } // approccio al punto iniziale if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, false)) { @@ -3487,8 +3487,8 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c if ( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX || GetLeadInType() == POCKET_LI_GLIDE) { - ptP1 += vtExtr * dStElev ; - dStElev = 0 ; + ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ; + dStElev = -LIO_ELEV_TOL ; } // approccio al punto iniziale if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart || bForcedOutStart)) { @@ -3715,8 +3715,8 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool, if ( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX || GetLeadInType() == POCKET_LI_GLIDE) { - ptP1 += vtExtr * dStElev ; - dStElev = 0 ; + ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ; + dStElev = -LIO_ELEV_TOL ; } // approccio al punto iniziale if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, false)) { @@ -5072,32 +5072,34 @@ Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafe // se sopra attacco c'è spazio per sicurezza o approccio double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ; if ( ! bBottomOutStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { + Point3d ptP1 = ptP + vtTool * ( dElev + dAppr) ; // se distanza di sicurezza minore di distanza di inizio if ( dSafeDist < dAppr + 10 * EPS_SMALL) { // 1 -> punto sopra inizio - Point3d ptP1 = ptP + vtTool * ( dElev + dAppr) ; if ( ( ! m_bAggrBottom && AddRapidStart( ptP1) == GDB_ID_NULL) || ( m_bAggrBottom && AddRapidMove( ptP1) == GDB_ID_NULL)) return false ; } else { - // 1a -> punto sopra inizio - Point3d ptP1b = ptP + vtTool * ( dElev + dAppr) ; - Point3d ptP1a = ptP1b + vtTool * ( dSafeDist - dAppr) ; + // 1a -> punto molto sopra inizio + Point3d ptP1a = ptP1 + vtTool * ( dSafeDist - dAppr) ; if ( ( ! m_bAggrBottom && AddRapidStart( ptP1a) == GDB_ID_NULL) || ( m_bAggrBottom && AddRapidMove( ptP1a) == GDB_ID_NULL)) return false ; - // 1b -> punto appena sopra inizio - if ( ( dElev + dAppr) > EPS_SMALL) { + // 1 -> punto sopra inizio + if ( ( dElev + dAppr) > 10 * EPS_SMALL || (( dElev + dAppr) > -EPS_ZERO && dAppr > EPS_SMALL)) { SetFlag( 0) ; - if ( AddRapidMove( ptP1b) == GDB_ID_NULL) + if ( AddRapidMove( ptP1) == GDB_ID_NULL) return false ; } + else + ptP1 = ptP1a ; } // affondo al punto iniziale SetFlag( 0) ; - SetFeed( bOutStart ? GetStartFeed() : GetTipFeed()) ; - if ( AddLinearMove( ptP) == GDB_ID_NULL) + bool bStartFeed = ( bOutStart || m_TParams.m_nType == TT_MILL_NOTIP) ; + SetFeed( bStartFeed ? GetStartFeed() : GetTipFeed()) ; + if ( ! AreSamePointApprox( ptP1, ptP) && AddLinearMove( ptP) == GDB_ID_NULL) return false ; } else {