diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 2ecc723..399a1c7 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2022/05/04 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2022/05/24 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. -- 2021/01/24 Con sega a catena ora sempre impostato asse A. @@ -41,6 +41,7 @@ -- 2022/03/29 Aggiunta gestione antischeggia con Q06 anche su 3/4-033-X. -- 2022/04/28 Lavorazione BH forzata sempre OneWay. -- 2022/05/04 Corretta classificazione due facce sotto. Modificati criteri assegnazione due facce alla coda. +-- 2022/05/24 Miglioramenti vari per BH, compreso controlli per lavorazione da sotto. -- Tabella per definizione modulo local ProcessLapJoint = {} @@ -698,11 +699,6 @@ end function ProcessLapJoint.Classify( Proc, b3Raw) -- se 1 faccia if Proc.Fct == 1 then - -- dati della faccia - --local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) - -- verifico se è lavorabile solo dal basso - --local bDown = ( vtN:getZ() < BD.NZ_MINA) - --return true, bDown return true, false -- se 2 facce elseif Proc.Fct == 2 then @@ -802,9 +798,14 @@ function ProcessLapJoint.Classify( Proc, b3Raw) rfFac:rotate( rfFac:getOrigin(), rfFac:getVersZ(), 90) end -- se può essere fatto con utensile tipo lama - local bUseBHSideMill = VerifyBHSideMill( Proc) + local bUseBHSideMill, _, _, _, _, dTDiam = VerifyBHSideMill( Proc) if bUseBHSideMill then - return true, false + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT) + if vtN:getZ() > -0.5 or b3Raw:getDimZ() - Proc.Box:getDimZ() < ( BD.MAX_DIST_BH_FROM_BOTTOM or 395) - dTDiam / 2 then + return true, false + else + return true, true + end -- altrimenti controllo se deve essere ruotato con le altre lavorazioni else -- dati della faccia @@ -4549,6 +4550,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd2, GDB_ID.ROOT) if vtN2 and abs( vtN2:getX()) < 0.866 then nFacInd, nFacInd2 = nFacInd2, nFacInd + dFacElev, dFacElev2 = dFacElev2, dFacElev vtN, vtN2 = vtN2, vtN end end diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index d2b425a..f380f79 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -254,7 +254,7 @@ local function CalcBladeUse( bUseBlade, bDown_Head, nSide, vtN1, vtN2, bConvex, end end else - if ( vtN1 and vtN1:getZ() >= EgtIf( dCustomAngle, dCustomAngle, -0.5)) or ( vtN2 and vtN2:getZ() >= -0.5) then + if ( vtN1 and vtN1:getZ() >= EgtIf( dCustomAngle, dCustomAngle, -0.5)) and ( not vtN2 or vtN2:getZ() >= -0.5) then bCanUseBlade = true end end @@ -305,39 +305,21 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster local bConvex local bOrtho local ptM + local ptRef = ( ptC[1] + ptC[2]) / 2 if bInt then bConvex = ( dAng >= 0) bOrtho = ( abs( dAng + 90) < 1) ptM = ( ptP1 + ptP2) / 2 else - bConvex = true + ptM = ptRef + local vtM1 = ptC[1] - ptM ; vtM1:normalize() + local vtM2 = ptC[2] - ptM ; vtM2:normalize() + bConvex = ( vtM1 * vtN[1] > 0 and vtM2 * vtN[2] > 0) bOrtho = false dAng = acos( vtN[1] * vtN[2]) - ptM = ( ptC[1] + ptC[2]) / 2 + -- se facce contrapposte e quindi concavo, angolo sempre negativo + if not bConvex and dAng > 0 then dAng = -dAng end end - local ptRef = ( ptC[1] + ptC[2]) / 2 - -- analisi del taglio - local vOrd = {} - local vFaceUse = {} - if nSide == 1 or ( nSide == -1 and ( BD.DOWN_HEAD or BD.TURN)) then - vOrd = EgtIf( ptC[1]:getY() < ptRef:getY(), { 1, 2}, { 2, 1}) - vFaceUse = { BL.GetNearestOrthoOpposite( ptC[1] - ptM), BL.GetNearestOrthoOpposite( ptC[2] - ptM)} - elseif nSide == -1 then - vOrd = EgtIf( ptC[1]:getY() < ptM:getY(), { 1, 2}, { 2, 1}) - vFaceUse = { BL.GetNearestParalOpposite( ptC[1] - ptM), BL.GetNearestParalOpposite( ptC[2] - ptM)} - else - local bFront = ( vtN[1]:getY() < 0) - if bFront then - vOrd = EgtIf( ptC[1]:getZ() < ptM:getZ(), { 1, 2}, { 2, 1}) - vFaceUse = { BL.GetNearestOrthoOpposite( ptC[1] - ptM), BL.GetNearestOrthoOpposite( ptC[2] - ptM)} - else - vOrd = EgtIf( ptC[1]:getZ() < ptM:getZ(), { 2, 1}, { 1, 2}) - vFaceUse = { BL.GetNearestOrthoOpposite( ptC[1] - ptM), BL.GetNearestOrthoOpposite( ptC[2] - ptM)} - end - end - local vWidth = {} - _, _, vWidth[1] = BL.GetFaceHvRefDim( Proc.Id, tFaceLong[1]) - _, _, vWidth[2] = BL.GetFaceHvRefDim( Proc.Id, tFaceLong[2]) -- ottengo la distanza tra la fine del pezzo e il pezzo successivo local dDistToNextPiece = EgtGetInfo( nRawId, 'BDST', 'd') or 5.4 @@ -380,6 +362,29 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster return false, sErr end + -- analisi del taglio + local vOrd = {} + local vFaceUse = {} + if nSide == 1 or ( nSide == -1 and ( BD.DOWN_HEAD or BD.TURN)) then + vOrd = EgtIf( ptC[1]:getY() < ptRef:getY(), { 1, 2}, { 2, 1}) + vFaceUse = { BL.GetNearestOrthoOpposite( ptC[1] - ptM), BL.GetNearestOrthoOpposite( ptC[2] - ptM)} + elseif nSide == -1 then + vOrd = EgtIf( ptC[1]:getY() < ptRef:getY(), { 1, 2}, { 2, 1}) + vFaceUse = { BL.GetNearestParalOpposite( ptC[1] - ptM), BL.GetNearestParalOpposite( ptC[2] - ptM)} + else + local bFront = ( vtN[1]:getY() < 0) + if bFront then + vOrd = EgtIf( ptC[1]:getZ() < ptRef:getZ(), { 1, 2}, { 2, 1}) + vFaceUse = { BL.GetNearestOrthoOpposite( ptC[1] - ptM), BL.GetNearestOrthoOpposite( ptC[2] - ptM)} + else + vOrd = EgtIf( ptC[1]:getZ() < ptRef:getZ(), { 2, 1}, { 1, 2}) + vFaceUse = { BL.GetNearestOrthoOpposite( ptC[1] - ptM), BL.GetNearestOrthoOpposite( ptC[2] - ptM)} + end + end + local vWidth = {} + _, _, vWidth[1] = BL.GetFaceHvRefDim( Proc.Id, tFaceLong[1]) + _, _, vWidth[2] = BL.GetFaceHvRefDim( Proc.Id, tFaceLong[2]) + -- Se senza facce limitanti, da sopra o ( da tutte i lati con testa da sotto) e taglio di lama e lunghezza facce maggiore del parametro lunghezza minima if nFaceLimit == 0 and ( bCanUseUnderBlade or bCanUseBlade) and bUseBlade and Proc.Box:getDimX() > dLimMinPiece - 1 then @@ -755,7 +760,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster -- se faccia da sotto e Z centro faccia è minore del centro altra faccia, segno il limite angolare da passare -- dovrebbe essere il limite angolare della testa 1 in sottosquadra if nSide == -1 and not BD.DOWN_HEAD then - if ptC[vOrd[j]]:getZ() < ptC[vOrd[OthFace]]:getZ() then + if ptC[vOrd[j]]:getZ() < ptC[vOrd[OthFace]]:getZ() - 1. then dSinLimit = -0.0157 else dSinLimit = -0.5