From 4c79eb18c2cadfbe04450d6779ae550053c87ded Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 16 Nov 2020 16:43:07 +0000 Subject: [PATCH] DataBeam : - modifiche Filippo. --- LuaLibs/BeamLib.lua | 41 ++++++++++++++++++++++++++- LuaLibs/FacesBySaw.lua | 18 ++++++++++-- LuaLibs/ProcessLapJoint.lua | 56 ++++++++++++++++++++++++++++++++----- 3 files changed, 104 insertions(+), 11 deletions(-) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index eecf5d3..79d2eda 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2020/11/03 +-- BeamLib.lua by Egaltech s.r.l. 2020/11/09 -- Libreria globale per Travi -- 2020/07/28 Corretto calcolo attacchi e uscite di lame per non uscire dalla faccia sotto. -- 2020/08/18 Aggiunto a GetNearestParalOpposite e GetNearestOrthoOpposite parametro opzionale vtNorm. @@ -513,8 +513,10 @@ function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId, bCompare3Fc, dCosSideAng) -- premio la faccia con minore elevazione local nFacOpt, nFacOpt2 local dMinElev, dMinElev2 = GEO.INFINITO, GEO.INFINITO + local dtElev = {} for i = 1, #nFacInd do local dElev = BeamLib.GetFaceElevation( nSurfId, nFacInd[i], nPartId) + table.insert( dtElev, dElev) if dElev < dMinElev then if dMinElev < dMinElev2 then nFacOpt2 = nFacOpt @@ -527,6 +529,43 @@ function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId, bCompare3Fc, dCosSideAng) dMinElev2 = dElev end end + -- faccio una ulteriore verifica + -- se le elevazioni di max 3 facce sono in un range minimo o al di sotto dell'elevazione ritenuta fattibile, + -- premio quella che non è sottosquadra e che ha la X minore + local bDiffSmall = true + for i = 1, #dtElev do + if dtElev[i] > dMinElev + 5 or dtElev[i] > 80 then + bDiffSmall = false + end + end + -- se tutte sono nel range minimo posso prendere la faccia che ha la componente Z magiore, e se sono uguali, prendo quella con componente X minore + local dMaxZ, dMaxZ2 = -1.1, -1.1 + if bDiffSmall and #nFacInd <= 3 then + for i = 1, #nFacInd do + if vvtN[nFacInd[i]+1]:getZ() > dMaxZ then + if dMaxZ > dMaxZ2 then + nFacOpt2 = nFacOpt + dMinElev2 = dMinElev + dMaxZ2 = dMaxZ + end + nFacOpt = nFacInd[i] + dMinElev = dtElev[i] + dMaxZ = vvtN[nFacInd[i]+1]:getZ() + elseif vvtN[nFacInd[i]+1]:getZ() > dMaxZ2 then + nFacOpt2 = nFacInd[i] + dMinElev2 = dtElev[i] + dMaxZ2 = vvtN[nFacInd[i]+1]:getZ() + end + end + -- se hanno uguale Z premio quella con la componente X minore + if abs( dMaxZ - dMaxZ2) < 10*GEO.EPS_SMALL then + if abs(vvtN[nFacOpt+1]:getX()) > abs(vvtN[nFacOpt2+1]:getX()) then + nFacOpt, nFacOpt2 = nFacOpt2, nFacOpt + dMinElev, dMinElev2 = dMinElev2, dMinElev + end + end + end + return nFacOpt, dMinElev, nFacOpt2, dMinElev2 end diff --git a/LuaLibs/FacesBySaw.lua b/LuaLibs/FacesBySaw.lua index 02571a8..1cab0c5 100644 --- a/LuaLibs/FacesBySaw.lua +++ b/LuaLibs/FacesBySaw.lua @@ -1,4 +1,4 @@ --- FacesBySaw.lua by Egaltech s.r.l. 2020/04/20 +-- FacesBySaw.lua by Egaltech s.r.l. 2020/11/13 -- Gestione taglio con lama di feature con una, due o tre facce -- Tabella per definizione modulo @@ -69,6 +69,12 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName) local nSmaInd = 3 - nBigInd local nUpInd = EgtIf( vtN[1]:getZ() >= vtN[2]:getZ(), 1, 2) local nOtInd = 3 - nUpInd + -- metto in relazione la scelta facce con il confronto del versore Z con la scelta in base alla grandezza faccia + -- se la faccia più grande è messa secondaria e il suo versore Z non è negativo + if nOtInd == nBigInd and vtN[nBigInd]:getZ() > -( 5 * GEO.EPS_SMALL) and vtN[nSmaInd]:getZ() < 0.866 then + nOtInd = nSmaInd + nUpInd = nBigInd + end -- recupero la lavorazione local sCutting = ML.FindCutting( sCutName) if not sCutting then @@ -123,11 +129,17 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName) end end else + nUpInd = EgtIf( vtN[1]:getZ() >= vtN[2]:getZ(), 1, 2) + nOtInd = 3 - nUpInd + -- se prima faccia lavorata è da sotto scambio le facce + if vtN[nOtInd]:getZ() < -0.5 then + nUpInd, nOtInd = nOtInd, nUpInd + end -- lavoro la prima faccia - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, vtRef[1], nil, dCutExtra, BD.CUT_SIC, 0, 0, nil, b3Raw) + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, nOtInd-1, sCutting, dSawDiam, vtRef[nOtInd], nil, dCutExtra, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end -- lavoro seconda faccia - bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 1, sCutting, dSawDiam, vtRef[2], nil, dCutExtra, BD.CUT_SIC, 0, 0, nil, b3Raw) + bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, nUpInd-1, sCutting, dSawDiam, vtRef[nUpInd], nil, dCutExtra, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 511b6c2..ef63746 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2020/11/08 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/11/13 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. @@ -559,7 +559,7 @@ function ProcessLapJoint.Classify( Proc, b3Raw) local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) -- se può essere fatto con utensile tipo lama local bUseBHSideMill, _, _, dMaxMat = VerifyIfByBHSideMill( Proc) - if bUseBHSideMill and ( dMaxMat <= dV) then + if bUseBHSideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then return true, false -- altrimenti controllo se deve essere ruotato con le altre lavorazioni else @@ -2740,6 +2740,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha local sWarn local sMchFind = 'Pocket' local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt + local bBadMach = false if sMchFindMaster and #sMchFindMaster > 0 then sMchFind = sMchFindMaster end @@ -2801,16 +2802,28 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha EgtOutLog( sWarn) -- altrimenti setto il flag per fare la svuotatura da due parti else + -- se l'altezza utensile riesce a lavorare completamente da due parti if dMaxMat > (dDepth / 2) then dMachDepth = 1 dElev = (dDepth / 2) + 1 + -- altrimenti non si riesce in due passate, limito la profondità e setto l'elevazione else dMachDepth = dMaxMat - (dDepth / 2) dElev = dMaxMat + -- se sono in questo caso verifico la direzione, se le componenti x,y e z deviano molto + -- allora considero la lavorazione no idonea perchè potrebbe avere anche delle collisioni + if abs(vtOrtho:getX()) > 0.5 or abs(vtOrtho:getY()) > 0.5 or abs(vtOrtho:getZ()) > 0.5 then + bBadMach = true + end end bDoubleSide = true end end + -- se lavorazione non idonea esco + if b3FacesUsed and bBadMach then + local sErr = 'Impossible apply perpendicular pocketing: ' .. sPocketing + return -2, sErr + end -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sPocketing) @@ -2948,6 +2961,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa local bClosedOrthoFaces local nFacInd, dFacElev, nFacInd2, dFacElev2 local nBottomFace + local sMchFindBackUp -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) if not nFacInd or nFacInd < 0 then @@ -3081,7 +3095,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2) -- se fattibile con fresa BH di fianco e spessore utensile inferiore alla larghezza faccia local bMakeBySideMill, bHead, sMilling, dMaxMat = VerifyIfByBHSideMill( Proc) - if bMakeBySideMill and ( dMaxMat <= dV) then + if bMakeBySideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then -- se smusso non è esclusivo if nChamfer < 2 then -- inserisco la lavorazione di fresatura @@ -3294,6 +3308,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa end -- settaggio voluto da Alessandro local sMchFind = EgtIf( bSinglePart, 'Pocket', 'OpenPocket') + sMchFindBackUp = sMchFind local nUseRoughTool = EgtIf( bSinglePart, 0, 1) -- fino a che nelle svuotature non si può decidere il punto di inizio faccio delle valutazioni -- se ho passi multipli controllo il numero delle facce @@ -3322,6 +3337,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa end -- verifico dalla forma se non posso prendere utensile grande if ( Proc.Fct == 3 and bIsU and bSinglePart) or ( Proc.Fct == 2 and bIsL) or Proc.Fct == 1 then + sMchFindBackUp = sMchFind --ottengo un diametro utensile opportuno dDiam, sMchFind, nUseRoughTool, dDiamMax = CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, ( dFacElev + dCollSic), nUseRoughTool) if not dDiam and nUseRoughTool == 0 then @@ -3389,7 +3405,18 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa if Proc.Fct == 3 and bIsU then -- lavoro con svuotature (singola o doppia contrapposta) nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFind, true, b3Solid) - if nOk < 0 then + -- se lavorazione non idonee ( asse della feature troppo inclinato e impossibile lavorare completamente da due parti) + if nOk == -2 then + if not sMchFind then + sMchFind = sMchFindBackUp + end + sPocketing = ML.FindPocketing( sMchFind, dDiam) + if not sPocketing then + local sErr = 'Error : '..sMchFind..' not found in library' + EgtOutLog( sErr) + return false, sErr + end + elseif nOk < 0 then return false, sErr elseif nOk == 0 then if sStat == 'MNF' then @@ -3435,7 +3462,19 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa if bTrySidePocketAtFirst and Proc.Fct == 3 and bIsU then -- lavoro con svuotature (singola o doppia contrapposta) nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFind, true, b3Solid) - if nOk < 0 then + if nOk == -2 then + if not sMchFind then + sMchFind = sMchFindBackUp + end + sPocketing = ML.FindPocketing( sMchFind, dDiam) + if not sPocketing then + local sErr2 = 'Error : '..sMchFind..' not found in library' + EgtOutLog( sErr2) + return false, sErr2 + end + bTryWithBlades = false + sWarn = sErr + elseif nOk < 0 then return false, sErr elseif nOk > 0 then bTryWithBlades = false @@ -3465,9 +3504,12 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa else return bOk, sWarn end - -- altrimenti ho già svuotato dal fianco, esco + -- altrimenti verifico se ho già svuotato dal fianco, se si esco else - return bOk, sWarn + -- se non ho annullato la/le svuotatura/e dal fianco + if nOk ~= -2 then + return bOk, sWarn + end end end end