From b5be93295587e73226078330566e711267698888 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 26 Aug 2024 15:17:31 +0200 Subject: [PATCH] =?UTF-8?q?-=20in=20FacesBySaw=20->=20MakeOne=20aggiunta?= =?UTF-8?q?=20la=20possibilit=C3=A0=20di=20passare=20una=20direzione=20di?= =?UTF-8?q?=20lavoro=20alternativa=20per=20poter=20rispettare=20contempora?= =?UTF-8?q?neamente=20la=20direzione=20di=20lavoro=20concorde=20e=20la=20d?= =?UTF-8?q?irezione=20di=20taglio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/FacesBySaw.lua | 34 +++++++++++++++++++++++++++++----- LuaLibs/ProcessCut.lua | 6 +++++- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/LuaLibs/FacesBySaw.lua b/LuaLibs/FacesBySaw.lua index 9bbb09d..83d6c26 100644 --- a/LuaLibs/FacesBySaw.lua +++ b/LuaLibs/FacesBySaw.lua @@ -192,7 +192,7 @@ local function GetNameSolidFaceIncludingLine( b3Solid, ptP1Comp, ptP2Comp) end --------------------------------------------------------------------- -function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert, bMaximizeVerticalDepth, bSpecialTangentLeadInOut, bForceTangentLeadInOut) +function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert, bMaximizeVerticalDepth, bSpecialTangentLeadInOut, bForceTangentLeadInOut, Par5Alternative) -- se lama con asse parallelo alla faccia, passo alla apposita funzione if ( Par5 == MCH_MILL_FU.PARAL_DOWN or Par5 == MCH_MILL_FU.PARAL_TOP or @@ -209,6 +209,8 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw -- risolvo parametro ambiguo local nOrthoOpposite local vtOrthO + local nOrthoOppositeAlternative + local vtOrthOAlternative if isVector3d( Par5) then nOrthoOpposite = BL.GetNearestOrthoOpposite( Par5, vtN) vtOrthO = Vector3d( Par5) @@ -216,6 +218,15 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw nOrthoOpposite = Par5 vtOrthO = BL.GetVersRef( Par5) end + if Par5Alternative then + if isVector3d( Par5Alternative) then + nOrthoOppositeAlternative = BL.GetNearestOrthoOpposite( Par5Alternative, vtN) + vtOrthOAlternative = Vector3d( Par5Alternative) + else + nOrthoOppositeAlternative = Par5Alternative + vtOrthOAlternative = BL.GetVersRef( Par5Alternative) + end + end EgtOutLog( 'VtOrthO='..tostring( vtOrthO)..' FaceUse='..tostring( nOrthoOpposite), 3) -- verifico se testa da sotto oppure se lavorazione sotto con testa da sopra if not dVzLimDwnUp then dVzLimDwnUp = BL.GetNzLimDownUp( b3Raw, vtN, vtOrthO) end @@ -235,13 +246,26 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw end local bIsSawCCW = ( EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) < 0) local bInvert = bForceInvert - -- se la lama ruota in senso antiorario inverto la direzione di lavorazione, per avere rotazione lama opposta a avanzamento + -- l'inversione può essere comandata da rotazione lama (direzione concorde, legata anche a DownUp) oppure da direzione Z del percorso (si preferisce lavorare dal basso verso l'alto per limitare le corse) + -- se c'è disaccordo tra rotazione e direzione si cambia il lato di lavoro, se possibile. Se ciò non è possbile comanda la direzione. if bInvert == nil then if not BD.TURN or abs( ptP2:getY() - ptP1:getY()) < 250 then - if bIsSawCCW ~= bDownUp then - bInvert = ( ptP2:getZ() < ptP1:getZ() + 100 * GEO.EPS_SMALL) + local bIsMachiningDownwards = ( ptP2:getZ() < ptP1:getZ() - 100 * GEO.EPS_SMALL) + local bIsMachiningUpwards = ( ptP2:getZ() > ptP1:getZ() + 100 * GEO.EPS_SMALL) + if ( bIsSawCCW ~= bDownUp) and bIsMachiningDownwards then + bInvert = true + elseif ( ( bIsSawCCW ~= bDownUp) ~= bIsMachiningDownwards) then + if Par5Alternative then + bInvert = true + nOrthoOpposite = nOrthoOppositeAlternative + vtOrthO = vtOrthOAlternative + elseif bIsMachiningDownwards or not bIsMachiningUpwards then + bInvert = true + else + bInvert = false + end else - bInvert = ( ptP2:getZ() < ptP1:getZ() - 100 * GEO.EPS_SMALL) + bInvert = false end else local vtTmp = ptP2 - ptP1 ; vtTmp:normalize() diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 9a9af10..0aab253 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -577,7 +577,11 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b dVzLimDwnUp = -0.708 end local bSpecialTangentLeadInOut = ( i % 2 == 0) and ( Proc.AffectedFaces.Left or Proc.AffectedFaces.Right) - local bOk, sErr = Fbs.MakeOne( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dVzLimDwnUp, dExtraCut, BD.CUT_SIC, 0, 0, 0, sNotes, b3Raw, nil, nil, bSpecialTangentLeadInOut) + local vtOrthoOAlternative + if ( i % 2 == 0) and ( Proc.Fct == 1) and bNoPerpCuts then + vtOrthoOAlternative = - vtOrthoO + end + local bOk, sErr = Fbs.MakeOne( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dVzLimDwnUp, dExtraCut, BD.CUT_SIC, 0, 0, 0, sNotes, b3Raw, nil, nil, bSpecialTangentLeadInOut, nil, vtOrthoOAlternative) if not bOk then return bOk, sErr end end end