From 0e6a15bf1f3c1fdfe2562520cc4a14b8577cdca2 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 20 Aug 2020 07:00:59 +0000 Subject: [PATCH] DataBeam : - correzioni a LapJoint per antischeggia con lama e verifica diametro utensile per svuotature con lati aperti. --- LuaLibs/ProcessLapJoint.lua | 95 ++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 43 deletions(-) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 588e5db..5c116ab 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2020/08/04 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/08/20 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. @@ -2464,7 +2464,7 @@ local function CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, dElev, n for i = 1, #vAdj do if vAdj[i] >= 0 then -- verifico l'angolo tra le facce ( esco se angolo compreso < 90) - local bAdj, pPt1, pPt2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) + local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) if bAdj and dAng < -90 - 20 * GEO.EPS_ANG_SMALL then return false end @@ -2475,7 +2475,7 @@ local function CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, dElev, n local b3Ref = EgtSurfTmGetFacetBBoxRef( Proc.Id, nFacInd, GDB_BB.STANDARD, frRef) if b3Ref then table.insert( tWidth, b3Ref:getDimY()) - table.insert( tExtremPt, { pPt1, pPt2}) + table.insert( tExtremPt, { ptP1, ptP2}) end end end @@ -2487,30 +2487,13 @@ local function CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, dElev, n for i = 1, #tWidth do dLargeVal = max( dLargeVal, tWidth[i]) end - -- se facce U verifico se le distanze tra i punti sono maggiori delle distanze tra le facce + -- se facce U verifico se le distanze tra i punti sono minori delle distanze tra le facce if bIsU then - local dLargeValU = 999999 - for i = 1, #tExtremPt do - local dLenPoint = dist( EgtIf( i == 1, tExtremPt[i][1], tExtremPt[1][2]), EgtIf( i == 1, tExtremPt[2][1], tExtremPt[i][2])) - -- prendo la distanza minore tra le maggiori ma solo se la distanza tra i punti non è minore della distanza tra le facce - if dLenPoint < dLargeVal then - dLargeValU = dLargeVal - break - else - dLargeValU = min( dLargeValU, dLenPoint) - end - -- inverto i punti e ricalcolo le distanze - dLenPoint = dist( EgtIf( i == 1, tExtremPt[i][1], tExtremPt[1][2]), EgtIf( i == 1, tExtremPt[2][2], tExtremPt[i][1])) - -- prendo la distanza minore tra le maggiori ma solo se la distanza tra i punti non è minore della distanza tra le facce - if dLenPoint < dLargeVal then - dLargeValU = dLargeVal - break - else - dLargeValU = min( dLargeValU, dLenPoint) - end - - end - dLargeVal = dLargeValU + local dLen11 = dist( tExtremPt[1][1], tExtremPt[2][1]) + local dLen12 = dist( tExtremPt[1][1], tExtremPt[2][2]) + local dLen21 = dist( tExtremPt[1][2], tExtremPt[2][1]) + local dLen22 = dist( tExtremPt[1][2], tExtremPt[2][2]) + dLargeVal = min( dLargeVal, dLen11, dLen12, dLen21, dLen22) end -- per essere accettabile, il diametro massimo deve essere minore della larghezza della faccia if dMaxDiam < dLargeVal + 20 * GEO.EPS_SMALL then @@ -3272,53 +3255,79 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSinglePart) local nPrefSide = 1 -- di preferenza il motore è meglio tenerlo sinistra -- se a U cerco di ottimizzare il lato di lavoro della lama if bIsU then - if abs(vtN:getZ()) > 0.7 or abs(vtN:getY()) > 0.7 then + if abs( vtN:getY()) > 0.996 then + nPrefSide = 0 + elseif abs( vtN:getZ()) > 0.7 or abs( vtN:getY()) > 0.7 then -- se X è negativa allora devo tenere il motore a destra if vtN:getX() < -(10 * GEO.EPS_SMALL) then nPrefSide = 2 end end end - -- va eseguito sulle facce diverse dalla principale for nFacet = 0, nNumFac do if nFacet ~= nFacInd then - local bInvertMach + local bInvertMach = false if bIsU then if abs(vtN:getZ()) > 0.7 or abs(vtN:getY()) > 0.7 then -- prendo il vettore normale alla faccia local _, vtNFc = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT) -- valuto l'angolo tra le due facce local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, nFacet, GDB_ID.ROOT) - -- se posizione ancora da definire perchè la superficie principale è parallela al piano XY o XZ + -- se superficie principale parallela al piano XZ + if nPrefSide == 0 then + -- se facce inclinate \\ allora mandrino a destra (per essere verso l'alto) + if vtNFc:getX() * vtNFc:getZ() > 0 then + nPrefSide = 2 + -- altrimenti facce inclinate // quindi mandrino a sinistra (per essere ancora verso l'alto) + else + nPrefSide = 1 + end + end + -- se faccia verso X+ e mandrino verso sinistra if vtNFc:getX() > 0 and nPrefSide == 1 then - -- se angolo interno e <= 90 - if dAng < -90 + 20 * GEO.EPS_ANG_SMALL then + -- se angolo interno e circa -90 + if abs( dAng + 90) < 5 then bInvertMach = true end + -- se faccia verso X- e mandrino verso destra elseif vtNFc:getX() < 0 and nPrefSide == 2 then - -- se angolo interno e <= 90 - if dAng < -90 + 20 * GEO.EPS_ANG_SMALL then + -- se angolo interno e circa -90 + if abs( dAng + 90) < 5 then bInvertMach = true end end end end --- debug --- bInvertMach = false local dSawThick = 0 bMadeASbyBld, sWarn, nIdMach, dSawThick = MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw) if not bMadeASbyBld then return false, sWarn end if bInvertMach then local bInvert = EgtGetMachiningParam( MCH_MP.INVERT) --- local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE) local bToolInvert = EgtGetMachiningParam( MCH_MP.TOOLINVERT) - -- inverto i parametri - EgtSetMachiningParam( MCH_MP.INVERT, not bInvert) --- EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( nWorkSide == MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) - EgtSetMachiningParam( MCH_MP.TOOLINVERT, not bToolInvert) - -- setto l'offset pari allo spessore lama - EgtSetMachiningParam( MCH_MP.OFFSL, -dSawThick) + local nSCC = EgtGetMachiningParam( MCH_MP.SCC) + local nInvSCC + if nSCC == MCH_SCC.ADIR_XP then + nInvSCC = MCH_SCC.ADIR_XM + elseif nSCC == MCH_SCC.ADIR_XM then + nInvSCC = MCH_SCC.ADIR_XP + elseif nSCC == MCH_SCC.ADIR_YP then + nInvSCC = MCH_SCC.ADIR_YM + elseif nSCC == MCH_SCC.ADIR_YM then + nInvSCC = MCH_SCC.ADIR_YP + else + nInvSCC = nSCC + end + local nFaceUse = EgtGetMachiningParam( MCH_MP.FACEUSE) + local bOrtUp = ( nFaceUse >= MCH_MILL_FU.ORTUP_DOWN and nFaceUse <= MCH_MILL_FU.ORTUP_RIGHT) + if not bOrtUp then + -- inverto i parametri + EgtSetMachiningParam( MCH_MP.INVERT, not bInvert) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, not bToolInvert) + EgtSetMachiningParam( MCH_MP.SCC, nInvSCC) + -- setto l'offset pari allo spessore lama + EgtSetMachiningParam( MCH_MP.OFFSL, -dSawThick) + end -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError()