From bafb8f55eda0a25655c4d23c64fdd53143f663f9 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 22 Apr 2024 10:53:43 +0200 Subject: [PATCH] EgtMachKernel : - correzioni a collegamenti tra passate OneWay di Fresature con Utensili NoTip. --- Milling.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/Milling.cpp b/Milling.cpp index 2183ffd..3d32bd5 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -46,7 +46,8 @@ using namespace std ; const double OSC_MIN_LEN = 0.1 ; const double MIN_SAFEDIST = 5.0 ; const double LIM_DOWN_APPRZ = -0.5 ; -const double DELTA_ELEV_RAD = 4.0 ; +const double DELTA_ELEV_RAD = 4.0 ; +const double LIM_SIN_DIFF_DIR = 0.175 ; //------------------------------ Errors -------------------------------------- // 2301 = "Error in Milling : UpdateToolData failed" @@ -3050,7 +3051,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool bAhAboveStartEnd = GetPointAboveRaw( ptPs, vtTool) && GetPointAboveRaw( ptPe, vtTool) ; else bUhBelowStartEnd = GetPointBelowRaw( ptPs, vtTool) && GetPointBelowRaw( ptPe, vtTool) ; - // verifico se collegamento diretto tra inizio e uscita è fuori dal grezzo + // verifico se collegamento diretto tra ingresso e uscita è fuori dal grezzo bool bSafeDirLinkStartEnd = ( bAhAboveStartEnd || bUhBelowStartEnd) ; if ( ! bSafeDirLinkStartEnd) { // verifica dei punti intermedi @@ -3062,7 +3063,8 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool Vector3d vtCm = Media( vtCs, vtCe, dCoeff) ; if ( ! vtCm.Normalize()) vtCm = vtCs ; - if ( ! GetSimplePointOutOfRaw( ptPm, vtTool, vtCm)) { + if ( ! GetSimplePointOutOfRaw( ptPm, vtTool, vtCm) && + ( m_TParams.m_nType == TT_MILL_STD || ! GetSimplePointOutOfRaw( ptPm, vtTool, vtTool))) { bIsOut = false ; break ; } @@ -3312,7 +3314,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool // se ultima entità, uscita e retrazione if ( i == nMaxInd) { // se speciale e step intermedio salto uscita e retrazione - if ( bSpecial && j != nStep) + if ( bSpecial && k != nStep) continue ; // dati fine entità Point3d ptEnd ; @@ -3334,7 +3336,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool return false ; } // se step finale o intermedi con retrazione - if ( j == nStep || bMidRetract) { + if ( k == nStep || bMidRetract) { // determino se la fine dell'uscita è fuori dal grezzo Vector3d vtRetr( vtTool.x, vtTool.y, 0) ; if ( ! vtRetr.Normalize()) @@ -4372,7 +4374,7 @@ Milling::AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, co GetRadiusForStartEndElevation( false), m_TParams.m_dLen, true, dSafeZ, vtMove, dExtraElev)) { Point3d ptP1e = ptP1a + vtMove * ( dExtraElev + dSafeZ) ; - if ( bAddInsert) { + if ( bAddInsert && ! AreSameVectorEpsilon( vtMove, vtTool, LIM_SIN_DIFF_DIR)) { Point3d ptInsert = ptP1e + ( dStElev + dSafeZ) * vtTool ; if ( AddRapidStartOrMove( ptInsert, bFirst, bSplitArcs) == GDB_ID_NULL) return false ; @@ -4394,7 +4396,7 @@ Milling::AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, co GetRadiusForStartEndElevation( false), m_TParams.m_dLen, true, dSafeZ, vtMove, dExtraElev)) { Point3d ptP1e = ptP1a + vtMove * ( dExtraElev + dSafeZ) ; - if ( bAddInsert) { + if ( bAddInsert && ! AreSameVectorEpsilon( vtMove, vtTool, LIM_SIN_DIFF_DIR)) { Point3d ptInsert = ptP1e + ( dStElev + dSafeZ) * vtTool ; if ( AddRapidStartOrMove( ptInsert, bFirst, bSplitArcs) == GDB_ID_NULL) return false ; @@ -4414,7 +4416,7 @@ Milling::AddSawBladeSideApproach( const Point3d& ptP, const Vector3d& vtAppr, co } // punto fuori inizio if ( bOutStart) { - if ( bAddInsert) { + if ( bAddInsert && ! AreSameVectorEpsilon( vtAppr, vtTool, LIM_SIN_DIFF_DIR)) { Point3d ptInsert = ptP1a + ( dStElev + dSafeZ) * vtTool ; if ( AddRapidStartOrMove( ptInsert, bFirst, bSplitArcs) == GDB_ID_NULL) return false ; @@ -4570,15 +4572,18 @@ Milling::AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, con } // se necessaria ulteriore uscita + Vector3d vtMove ; + double dMove = 0 ; if ( ! m_bTiltingTab) { - Vector3d vtMove = Vector3d( vtTool.x, vtTool.y, 0) ; + vtMove = Vector3d( vtTool.x, vtTool.y, 0) ; if ( vtMove.Normalize()) { if ( m_bAboveHead && vtRetr.z < LIM_DOWN_APPRZ) { double dExtraElev ; if ( GetAhPointUnderRaw( ptP4, vtTool, m_TParams.m_dTDiam / 2, GetRadiusForStartEndElevation( false), m_TParams.m_dLen, true, dSafeZ, vtMove, dExtraElev)) { - Point3d ptP4b = ptP4 + vtMove * ( dExtraElev + dSafeZ) ; + dMove = dExtraElev + dSafeZ ; + Point3d ptP4b = ptP4 + vtMove * dMove ; if ( AddRapidMove( ptP4b) == GDB_ID_NULL) return false ; } @@ -4588,7 +4593,8 @@ Milling::AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, con if ( GetUhPointAboveRaw( ptP4, vtTool, m_TParams.m_dTDiam / 2, GetRadiusForStartEndElevation( false), m_TParams.m_dLen, true, dSafeZ, vtMove, dExtraElev)) { - Point3d ptP4b = ptP4 + vtMove * ( dExtraElev + dSafeZ) ; + dMove = dExtraElev + dSafeZ ; + Point3d ptP4b = ptP4 + vtMove * dMove ; if ( AddRapidMove( ptP4b) == GDB_ID_NULL) return false ; } @@ -4596,11 +4602,12 @@ Milling::AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, con } } - if ( bAddExtract) { + if ( bAddExtract && + ( ! AreSameVectorEpsilon( vtMove, vtTool, LIM_SIN_DIFF_DIR) || dEndElev + dSafeZ > dMove + 10 * EPS_SMALL)) { Point3d ptCurr ; if ( ! GetCurrPos( ptCurr)) return false ; - Point3d ptExtract = ptCurr + ( dEndElev + dSafeZ) * vtTool ; + Point3d ptExtract = ptCurr + ( dEndElev + dSafeZ - dMove) * vtTool ; if ( AddRapidMove( ptExtract) == GDB_ID_NULL) return false ; }