diff --git a/Milling.cpp b/Milling.cpp index 4ccca19..1ae4c05 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -3121,7 +3121,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool Vector3d vtDir1 ; double dCalcStElev = 0 ; // se speciale e step intermedio - if ( bSpecial && j > 1) { + if ( bSpecial && k > 1) { ptP1 = ptStart + dStep * vtTool ; } // altrimenti @@ -3143,7 +3143,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool bool bOutStart = GetPointOutOfRaw( ptP1, vtTool, vtAppr, dStElev, dSafeZ) ; // aggiungo approccio per frese normali e frese che non lavorano di testa con attacco opportuno oppure fuori if ( ( m_TParams.m_nType & TF_MILL) != 0 && - ( m_TParams.m_nType != TT_MILL_NOTIP || LeadInRawIsOk() || m_bStartOutRaw || ! bSafeDirLinkStartEnd)) { + ( m_TParams.m_nType != TT_MILL_NOTIP || LeadInRawIsOk() || m_bStartOutRaw)) { // correggo elevazione iniziale per punto inizio attacco (se testa da sopra senza aggregato approccio mai Z-) Vector3d vtEscape = vtTool ; if ( ( m_bAboveHead && ! m_bAggrBottom && ! m_bTiltingTab && vtTool.z < -EPS_SMALL) || @@ -3172,7 +3172,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool dStElev = ( j - 1) * dStep ; } // approccio standard al punto iniziale - if ( j == 1 || bMidRetract) { + if ( k == 1 || bMidRetract) { if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dExtrAppr, bOutStart, bAhAboveStartEnd || bUhBelowStartEnd)) { m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ; return false ; @@ -3188,6 +3188,8 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool } // altrimenti, approccio per lame e frese che non lavorano di testa else { + // flag necessità movimento preliminare di inserzione in direzione utensile + bool bAddInsert = ( k > 1 && ! bSafeDirLinkStartEnd) ; // verifico di entrare in aria if ( ! bOutStart) { // verifico se sono sopra @@ -3239,17 +3241,28 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool m_pMchMgr->SetLastError( 2314, "Error in Milling : LeadIn must be out of rawpart") ; bOk = false ; } + // aggiungo opportuno approccio - if ( ! AddSawBladeSideApproach( ptP1, vtAppr, vtTool, dSafeZ, dSawStartElev, dStElev, dAppr)) { + if ( ! AddSawBladeSideApproach( ptP1, vtAppr, vtTool, dSafeZ, dSawStartElev, dStElev, dAppr, bAddInsert)) { m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ; return false ; } } else { - // affondo al punto iniziale SetFlag( 0) ; - if ( AddRapidStart( ptP1) == GDB_ID_NULL) - return false ; + // se necessario inserimento + if ( bAddInsert) { + Point3d ptInsert = ptP1 + ( dStElev + dSafeZ) * vtTool ; + if ( AddRapidStart( ptInsert) == GDB_ID_NULL) + return false ; + if ( AddRapidMove( ptP1) == GDB_ID_NULL) + return false ; + } + // altrimenti direttamente al punto iniziale + else { + if ( AddRapidStart( ptP1) == GDB_ID_NULL) + return false ; + } } } } @@ -3333,7 +3346,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool bool bOutEnd = GetPointOutOfRaw( ptP1, vtTool, vtRetr, dEndElev, dSafeZ) ; // aggiungo retrazione per frese normali e frese che non lavorano di testa già fuori if ( ( m_TParams.m_nType & TF_MILL) != 0 && - ( m_TParams.m_nType != TT_MILL_NOTIP || m_bEndOutRaw || ! bSafeDirLinkStartEnd)) { + ( m_TParams.m_nType != TT_MILL_NOTIP || m_bEndOutRaw)) { // correggo elevazione finale per punto fine uscita (se testa da sopra senza aggregato approccio mai Z-) Vector3d vtEscape = vtTool ; if ( ( m_bAboveHead && ! m_bAggrBottom && ! m_bTiltingTab && vtTool.z < -EPS_SMALL) || @@ -3364,6 +3377,9 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool } // per lame e frese che non lavorano di testa quando è necessario else { + // flag necessità movimento successivo di estrazione in direzione utensile + bool bAddExtract = ( k < nStep && ! bSafeDirLinkStartEnd) ; + // se non è già fuori dal pezzo... if ( ! bOutEnd) { // verifico se sono sopra bool bGeomAboveEnd = GetPointAboveRaw( ptP1, vtTool) ; @@ -3414,11 +3430,17 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool bOk = false ; } // aggiungo opportuna retrazione - if ( ! AddSawBladeSideRetract( ptP1, vtRetr, vtTool, dSafeZ, dSawEndElev, dEndElev, dAppr)) { + if ( ! AddSawBladeSideRetract( ptP1, vtRetr, vtTool, dSafeZ, dSawEndElev, dEndElev, dAppr, bAddExtract)) { m_pMchMgr->SetLastError( 2312, "Error in Milling : Retract not computable") ; return false ; } } + // se richiesta estrazione in direzione utensile + else if ( bAddExtract) { + Point3d ptExtract = ptP1 + ( dEndElev + dSafeZ) * vtTool ; + if ( AddRapidMove( ptExtract) == GDB_ID_NULL) + return false ; + } } } } @@ -4342,7 +4364,7 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, //---------------------------------------------------------------------------- bool Milling::AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, const Vector3d& vtTool, - double dSafeZ, double dSawStElev, double dStElev, double dAppr) + double dSafeZ, double dSawStElev, double dStElev, double dAppr, bool bAddInsert) { // per approccio orizzontale vtAppr deve essere già stato sistemato dal chiamante SetFlag( 1) ; @@ -4354,24 +4376,46 @@ Milling::AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, co Vector3d vtMove = Vector3d( vtTool.x, vtTool.y, 0) ; if ( vtMove.Normalize()) { if ( m_bAboveHead && vtAppr.z < LIM_DOWN_APPRZ) { - double dSawStartElev ; + double dExtraElev ; if ( GetAhPointUnderRaw( ptP1a, vtTool, m_TParams.m_dTDiam / 2, GetRadiusForStartEndElevation( false), - m_TParams.m_dLen, true, dSafeZ, vtMove, dSawStartElev)) { - Point3d ptP1e = ptP1a + vtMove * ( dSawStartElev + dSafeZ) ; - if ( AddRapidStart( ptP1e) == GDB_ID_NULL) - return false ; + m_TParams.m_dLen, true, dSafeZ, vtMove, dExtraElev)) { + Point3d ptP1e = ptP1a + vtMove * ( dExtraElev + dSafeZ) ; + if ( bAddInsert) { + Point3d ptInsert = ptP1e + ( dStElev + dSafeZ) * vtTool ; + if ( AddRapidStart( ptInsert) == GDB_ID_NULL) + return false ; + SetFlag( 0) ; + if ( AddRapidMove( ptP1e) == GDB_ID_NULL) + return false ; + } + else { + if ( AddRapidStart( ptP1e) == GDB_ID_NULL) + return false ; + SetFlag( 0) ; + } bFirst = false ; } } else if ( ! m_bAboveHead && vtAppr.z > -LIM_DOWN_APPRZ) { - double dSawStartElev ; + double dExtraElev ; if ( GetUhPointAboveRaw( ptP1a, vtTool, m_TParams.m_dTDiam / 2, GetRadiusForStartEndElevation( false), - m_TParams.m_dLen, true, dSafeZ, vtMove, dSawStartElev)) { - Point3d ptP1e = ptP1a + vtMove * ( dSawStartElev + dSafeZ) ; - if ( AddRapidStart( ptP1e) == GDB_ID_NULL) - return false ; + m_TParams.m_dLen, true, dSafeZ, vtMove, dExtraElev)) { + Point3d ptP1e = ptP1a + vtMove * ( dExtraElev + dSafeZ) ; + if ( bAddInsert) { + Point3d ptInsert = ptP1e + ( dStElev + dSafeZ) * vtTool ; + if ( AddRapidStart( ptInsert) == GDB_ID_NULL) + return false ; + SetFlag( 0) ; + if ( AddRapidMove( ptP1e) == GDB_ID_NULL) + return false ; + } + else { + if ( AddRapidStart( ptP1e) == GDB_ID_NULL) + return false ; + SetFlag( 0) ; + } bFirst = false ; } } @@ -4379,12 +4423,21 @@ Milling::AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, co } // punto fuori inizio if ( bFirst) { - if ( AddRapidStart( ptP1a) == GDB_ID_NULL) - return false ; - SetFlag( 0) ; + if ( bAddInsert) { + Point3d ptInsert = ptP1a + ( dStElev + dSafeZ) * vtTool ; + if ( AddRapidStart( ptInsert) == GDB_ID_NULL) + return false ; + SetFlag( 0) ; + if ( AddRapidMove( ptP1a) == GDB_ID_NULL) + return false ; + } + else { + if ( AddRapidStart( ptP1a) == GDB_ID_NULL) + return false ; + SetFlag( 0) ; + } } else { - SetFlag( 0) ; if ( AddRapidMove( ptP1a) == GDB_ID_NULL) return false ; } @@ -4507,7 +4560,7 @@ Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, //---------------------------------------------------------------------------- bool Milling::AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, const Vector3d& vtTool, - double dSafeZ, double dSawEndElev, double dEndElev, double dAppr) + double dSafeZ, double dSawEndElev, double dEndElev, double dAppr, bool bAddExtract) { // per retrazione orizzontale vtAppr deve essere già stato sistemato dal chiamante Point3d ptP4 = ptP ; @@ -4530,21 +4583,21 @@ Milling::AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, con Vector3d vtMove = Vector3d( vtTool.x, vtTool.y, 0) ; if ( vtMove.Normalize()) { if ( m_bAboveHead && vtRetr.z < LIM_DOWN_APPRZ) { - double dSawEndElev ; + double dExtraElev ; if ( GetAhPointUnderRaw( ptP4, vtTool, m_TParams.m_dTDiam / 2, GetRadiusForStartEndElevation( false), - m_TParams.m_dLen, true, dSafeZ, vtMove, dSawEndElev)) { - Point3d ptP4b = ptP4 + vtMove * ( dSawEndElev + dSafeZ) ; + m_TParams.m_dLen, true, dSafeZ, vtMove, dExtraElev)) { + Point3d ptP4b = ptP4 + vtMove * ( dExtraElev + dSafeZ) ; if ( AddRapidMove( ptP4b) == GDB_ID_NULL) return false ; } } else if ( ! m_bAboveHead && vtRetr.z > -LIM_DOWN_APPRZ) { - double dSawEndElev ; + double dExtraElev ; if ( GetUhPointAboveRaw( ptP4, vtTool, m_TParams.m_dTDiam / 2, GetRadiusForStartEndElevation( false), - m_TParams.m_dLen, true, dSafeZ, vtMove, dSawEndElev)) { - Point3d ptP4b = ptP4 + vtMove * ( dSawEndElev + dSafeZ) ; + m_TParams.m_dLen, true, dSafeZ, vtMove, dExtraElev)) { + Point3d ptP4b = ptP4 + vtMove * ( dExtraElev + dSafeZ) ; if ( AddRapidMove( ptP4b) == GDB_ID_NULL) return false ; } @@ -4552,6 +4605,15 @@ Milling::AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, con } } + if ( bAddExtract) { + Point3d ptCurr ; + if ( ! GetCurrPos( ptCurr)) + return false ; + Point3d ptExtract = ptCurr + ( dEndElev + dSafeZ) * vtTool ; + if ( AddRapidMove( ptExtract) == GDB_ID_NULL) + return false ; + } + return true ; } diff --git a/Milling.h b/Milling.h index 11895a7..7a916df 100644 --- a/Milling.h +++ b/Milling.h @@ -101,12 +101,12 @@ class Milling : public Machining bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ, double dElev, double dAppr, bool bOutStart, bool bAboveStart) ; bool AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, const Vector3d& vtTool, - double dSafeZ, double dSawStElev, double dStElev, double dAppr) ; + double dSafeZ, double dSawStElev, double dStElev, double dAppr, bool bAddInsert = false) ; bool AddDirectApproach( const Point3d& ptP) ; bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ, double dElev, double dAppr, bool bAboveEnd) ; bool AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, const Vector3d& vtTool, - double dSafeZ, double dSawEndElev, double dEndElev, double dAppr) ; + double dSafeZ, double dSawEndElev, double dEndElev, double dAppr, bool bAddExtract = false) ; bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1, Vector3d& vtDir1) const ; bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart,