diff --git a/SawFinishing.cpp b/SawFinishing.cpp index c475616..d1fa84d 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -3455,6 +3455,7 @@ SawFinishing::CalcAlong5ACuts( const SECTIONVECTOR& vSections, const Frame3d& fr continue ; // scorro le SubSection ottenute + bool bLastToolInv = false ; for ( int nSubSect = 0 ; nSubSect < ssize( Section.vSubSections) ; ++ nSubSect) { // recupero la SubSection corrente, se non valida, passo alla successiva @@ -3480,6 +3481,7 @@ SawFinishing::CalcAlong5ACuts( const SECTIONVECTOR& vSections, const Frame3d& fr // Ciclo sulle passate double dLastElev ; Point3d ptStartPrev ; + Vector3d vtCorrPrev = V_NULL ; for ( int i = 0 ; i <= nStep ; ++ i) { // coordinate nel punto, del versore correzione e del versore utensile double dLcurr = i * dStep ; @@ -3490,11 +3492,31 @@ SawFinishing::CalcAlong5ACuts( const SECTIONVECTOR& vSections, const Frame3d& fr return false ; Vector3d vtCorr = GetToGlob( vtTan, frSect) ; vtCorr.Rotate( vtGdDir, m_Params.m_bInvert ? - ANG_RIGHT : ANG_RIGHT) ; + // se tangente circa verticale + if ( abs( vtTan.y) < 2. * EPS_SMALL) { + if ( ( SubSection.nHeadSide == SAWFIN_HS_LEFT && vtTan.y < 0.) || + ( SubSection.nHeadSide == SAWFIN_HS_RIGHT && vtTan.y > 0.)) + vtTan.y = - vtTan.y ; + } Vector3d vtTool = GetToGlob( vtTan, frSect) ; - // determino l'orientamento della testa - if ( vtTool.z < - EPS_ZERO) + // determino l'orientamento della testa + bool bCurrToolInv = false ; + if ( vtTool.z < - EPS_ZERO) { vtTool.Invert() ; // NB. vtTool deve sempre avere la componente Z come positiva + bCurrToolInv = true ; + } + + // verifico se inversione della testa + bool bFirst = ( i == 0) ; + bool bSpecialAppr = ( m_Params.m_nLeadLinkType != SAWFIN_LL_CENT && ! bFirst && ( bCurrToolInv != bLastToolInv)) ; + if ( bSpecialAppr) { + SetFeed( GetEndFeed()) ; + Point3d ptCurr ; GetCurrPos( ptCurr) ; + if ( ! AddRetract( ptCurr, vtCorrPrev, GetSafeZ(), dLastElev, m_Params.m_dStartPos)) + return false ; + } + bLastToolInv = bCurrToolInv ; // se direzione utensile maggiore dell'angolo limite, blocco la direzione all'angolo limite if ( vtCorr * Z_AX < dCosAngLimit) { @@ -3585,7 +3607,6 @@ SawFinishing::CalcAlong5ACuts( const SECTIONVECTOR& vSections, const Frame3d& fr SetToolDir( vtTool) ; SetCorrAuxDir( vtCorr) ; // se diverso da precedente, eseguo il taglio - bool bFirst = ( i == 0) ; dElev = dElev / max( EPS_SMALL, ( vtCorr * Z_AX)) ; // non serve fare il max, ma meglio prevenire... if ( bFirst || ! AreSamePointEpsilon( ptStart, ptStartPrev, 10. * EPS_SMALL)) { if ( m_Params.m_nStepType != SAWFIN_ST_ZIGZAG) { @@ -3593,13 +3614,14 @@ SawFinishing::CalcAlong5ACuts( const SECTIONVECTOR& vSections, const Frame3d& fr return false ; } else { - if ( ! CalcAlongZigZagCut( ptStart, ptEnd, vtGdDir, vtTool, vtCorr, dElev, bExtend, false, bFirst)) + if ( ! CalcAlongZigZagCut( ptStart, ptEnd, vtGdDir, vtTool, vtCorr, dElev, bExtend, false, bFirst, bSpecialAppr)) return false ; } // salvo dati correnti dLastElev = dElev ; ptStartPrev = ptStart ; } + vtCorrPrev = vtCorr ; } // se ZigZag e non centrato aggiungo risalita if ( m_Params.m_nStepType == SAWFIN_ST_ZIGZAG && m_Params.m_nLeadLinkType != SAWFIN_LL_CENT) { @@ -3670,8 +3692,8 @@ SawFinishing::CalcAlongOneWayCut( const Point3d& ptStart, const Point3d& ptEnd, //---------------------------------------------------------------------------- bool -SawFinishing::CalcAlongZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir, - const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, bool bExtend, bool bVert, bool bFirst) +SawFinishing::CalcAlongZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir, const Vector3d& vtTool, + const Vector3d& vtCorr, double dElev, bool bExtend, bool bVert, bool bFirst, bool bAppr) { // recupero distanza di sicurezza double dSafeZ = GetSafeZ() ; @@ -3712,14 +3734,14 @@ SawFinishing::CalcAlongZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, // Sempre una sola passata // 1 -> approccio - if ( bFirst || m_Params.m_nLeadLinkType == SAWFIN_LL_CENT) { + if ( bFirst || m_Params.m_nLeadLinkType == SAWFIN_LL_CENT || bAppr) { if ( ! AddApproach( ptNewStart, vtCorr, dSafeZ, dElev, dAppr)) return false ; } // 2 -> movimento in affondo al punto iniziale SetFlag( 0) ; // con attacco centrato sono sul materiale e devo usare feed di testa - if ( m_Params.m_nLeadLinkType == SAWFIN_LL_CENT) { + if ( m_Params.m_nLeadLinkType == SAWFIN_LL_CENT || bAppr) { SetFeed( GetTipFeed()) ; if ( AddLinearMove( ptNewStart) == GDB_ID_NULL) return false ; diff --git a/SawFinishing.h b/SawFinishing.h index b23ec98..1f26338 100644 --- a/SawFinishing.h +++ b/SawFinishing.h @@ -127,8 +127,8 @@ class SawFinishing : public Machining const BBox3d& b3Raw, const ISurfTriMesh* pStmRaw) ; bool CalcAlongOneWayCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir, const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, bool bExtend, bool bVert) ; - bool CalcAlongZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir, - const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, bool bExtend, bool bVert, bool bFirst) ; + bool CalcAlongZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir, const Vector3d& vtTool, + const Vector3d& vtCorr, double dElev, bool bExtend, bool bVert, bool bFirst, bool bAppr = false) ; bool CalcAcrossOneWayCut( const PolyLine& PL, const Vector3d& vtMove, const Vector3d& vtTool, const Vector3d& vtCorr, double dRawZ, double dDepth) ; bool CalcAcrossZigZagCut( const PolyLine& PL, const Vector3d& vtMove,