From 9be8d4b1b721c79593f8ed654ca7426b71b3fdf2 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 8 Nov 2019 07:21:42 +0000 Subject: [PATCH] DataBeam : - migliorato ordinamento features - in LapJoint gestione ElleShape con 4 lati - in LongCut gestione taglio con lama. --- LuaLibs/BeamExec.lua | 6 +- LuaLibs/FacesBySaw.lua | 2 +- LuaLibs/ProcessLapJoint.lua | 61 +++++++++++++++----- LuaLibs/ProcessLongCut.lua | 109 ++++++++++++++++++++++++++++++++++-- 4 files changed, 155 insertions(+), 23 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index f77c736..e91303a 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -409,10 +409,12 @@ local function OrderFeatures( vProc, b3Raw) -- confronto standard if abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) > 0.4 * ( B1.Box:getDimX() + B2.Box:getDimX()) then return B1.Box:getCenter():getX() > B2.Box:getCenter():getX() - elseif abs( B1.Box:getCenter():getY() - B2.Box:getCenter():getY()) > 0.4 * ( B1.Box:getDimY() + B2.Box:getDimY()) then + elseif abs( B1.Box:getCenter():getY() - B2.Box:getCenter():getY()) > 0.2 * ( B1.Box:getDimY() + B2.Box:getDimY()) then return B1.Box:getCenter():getY() > B2.Box:getCenter():getY() - else + elseif abs( B1.Box:getCenter():getZ() - B2.Box:getCenter():getZ()) > 0.1 * ( B1.Box:getDimZ() + B2.Box:getDimZ()) then return B1.Box:getCenter():getZ() > B2.Box:getCenter():getZ() + else + return B1.Box:getCenter():getX() > B2.Box:getCenter():getX() end end diff --git a/LuaLibs/FacesBySaw.lua b/LuaLibs/FacesBySaw.lua index a2f5e42..1d48a97 100644 --- a/LuaLibs/FacesBySaw.lua +++ b/LuaLibs/FacesBySaw.lua @@ -86,7 +86,7 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName) end -- calcolo extra taglio local dCutExtra = 0 - if dAngT < -92 then + if dAngT < -92 and dAngT > -178 then dCutExtra = - dSawThick / tan( 180 + dAngT) end -- verifico se necessari tagli supplementari diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index f0764ff..f9121a8 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2019/10/08 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2019/11/07 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. @@ -55,7 +55,7 @@ function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH) ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) nFacInd, nFacInd2 = nFacInd2, nFacInd end - if vtN:getX() < 0.5 then + if vtN:getX() < 0.499 then return false elseif Proc.Fct >= 5 then return true @@ -91,7 +91,7 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) nFacInd, nFacInd2 = nFacInd2, nFacInd end - if vtN:getX() > -0.5 then + if vtN:getX() > -0.499 then return false else return true @@ -147,11 +147,9 @@ function ProcessLapJoint.Classify( Proc) end --------------------------------------------------------------------- -local function TestElleShape( Proc) +local function TestElleShape3( Proc) -- valida solo nel caso di tre facce - if Proc.Fct ~= 3 then - return false - end + if Proc.Fct ~= 3 then return false end -- determino se L con una faccia terminale o U con tre facce local bIsL = true for i = 1, 3 do @@ -171,6 +169,41 @@ local function TestElleShape( Proc) return bIsL end +--------------------------------------------------------------------- +local function TestElleShape4( Proc) + -- valida solo nel caso di quattro facce + if Proc.Fct ~= 4 then return false end + -- determino se L con due facce terminali o O + local bIsL = false + local dMinArea3 = GEO.INFINITO + local dMaxArea2 = 0 + for i = 1, 4 do + local vFacAdj = EgtSurfTmFacetAdjacencies( Proc.Id, i - 1)[1] + -- le conto + local nCount = 0 + for j = 1, #vFacAdj do + if vFacAdj[j] >= 0 then + nCount = nCount + 1 + end + end + local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, i - 1, GDB_ID.ROOT) + local dArea = dH * dV + if nCount == 2 then + dMaxArea2 = max( dMaxArea2, dArea) + elseif nCount == 3 then + dMinArea3 = min( dMinArea3, dArea) + bIsL = true + end + end + if not bIsL then return false end + -- verifico se L profona oppure lunga + if dMinArea3 < dMaxArea2 then + return 1 + else + return 2 + end +end + --------------------------------------------------------------------- -- Lavorazione con fresa --------------------------------------------------------------------- @@ -344,11 +377,9 @@ local function MakePreCuts( Proc, nPhase, nRawId, nPartId, b3Raw) local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg} local nCutFacet = EgtSurfTmFacetCount( AddId) if nCutFacet == 1 then - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) - if not bOk then return bOk, sErr end + return Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) elseif nCutFacet == 2 then - local bOk, sErr = DoubleCut.Make( CutProc, nPhase, nRawId, nPartId, 0) - if not bOk then return bOk, sErr end + return DoubleCut.Make( CutProc, nPhase, nRawId, nPartId, 0) end end end @@ -641,7 +672,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) end -- recupero la lavorazione local sMchFind = 'Pocket' - if Proc.Fct <= 3 and not TestElleShape( Proc) then sMchFind = 'OpenPocket' end + if Proc.Fct <= 3 and not TestElleShape3( Proc) then sMchFind = 'OpenPocket' end local dDiam = min( dH, dV) local dCollSic = 2 * BD.COLL_SIC if abs( vtN:getX()) > 0.996 or abs( vtN:getY()) > 0.996 or abs( vtN:getZ()) > 0.996 then dCollSic = BD.COLL_SIC end @@ -650,7 +681,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) -- se non trova una svuotatura adatta if not sPocketing then -- verifico se due o tre facce a L con una faccia di terminazione - local bIsL = ( Proc.Fct == 2 or TestElleShape( Proc)) + local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2) -- se due facce o tre a L provo con contornatura if bIsL then return MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev) @@ -814,9 +845,9 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- due facce elseif Proc.Fct == 2 then -- determino l'angolo tra le facce - local _, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) + local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) -- se ortogonali e piccole, con fresa - if abs( dAng + 90) < 1 and + if bAdj and abs( dAng + 90) < 1 and ( ( Proc.Box:getDimX() < MAX_MILL_LIN and ( Proc.Box:getDimZ() < MAX_MILL_LIN or Proc.Box:getDimY() < MAX_MILL_LIN)) or Proc.Box:getDimX() * Proc.Box:getDimY() * Proc.Box:getDimZ() < MAX_MILL_VOL) then return MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId) diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index f9111f0..7b85139 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -1,4 +1,4 @@ --- ProcessLongCut.lua by Egaltech s.r.l. 2019/10/06 +-- ProcessLongCut.lua by Egaltech s.r.l. 2019/11/07 -- Gestione calcolo taglio longitudinale per Travi -- Tabella per definizione modulo @@ -80,8 +80,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) local b3Raw = EgtGetRawPartBBox( nRawId) -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) - local dLen = Proc.Box:getDimX() - local dWidth = sqrt( Proc.Box:getDimY() * Proc.Box:getDimY() + Proc.Box:getDimZ() * Proc.Box:getDimZ()) + local _, dLen, dWidth = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0, GDB_ID.ROOT) -- limitazioni su inizio e fine derivanti da altre facce local bLimXmin = false local bLimXmax = false @@ -107,8 +106,108 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) end local sWarn - -- Se non è sotto : lavorazione Long2Cut - if nSide ~= - 1 then + -- Se non limitato e da sopra e richiesto con doppio taglio di lama + if not bLimXmin and not bLimXmax and nSide == 1 and EgtGetInfo( Proc.Id, 'Q05', 'i') == 2 then + -- recupero la lavorazione + local sCutting = ML.FindCutting( 'HeadSide') + if not sCutting then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' sawing not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dToolDiam = 0 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- determino se lavorazione da davanti o da dietro + local bFront = ( vtN:getY() < 0) + -- determino numero di parti + local dStartAccDist = BD.LONGCUT_ENDLEN + local dEndAccDist = BD.LONGCUT_ENDLEN + local nC = ceil( ( dLen - dStartAccDist - dEndAccDist) / BD.LONGCUT_MAXLEN) + local dC = 0 + if nC > 0 then + dC = dLen / ( nC + 2) + dStartAccDist = dC + dEndAccDist = dC + nC = nC + 2 + else + if dLen > min( dStartAccDist, dEndAccDist) then + nC = 2 + dStartAccDist = dLen/2 + dEndAccDist = dStartAccDist + else + nC = 1 + dStartAccDist = 0 + dEndAccDist = 0 + end + end + -- determino l'utilizzo della faccia + local nFaceUse = EgtIf( abs( vtN:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)) + local nFaceUse2 = EgtIf( abs( vtN:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK)) + -- si percorrono i lati alto e basso della faccia + local nM = 0 + for i = 1, nC do + -- Posizione braccio portatesta + local nSCC + --if bFront then + nSCC = EgtIf( ( i == 1 or i == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) + --else + -- nSCC = EgtIf( ( i == 1 or i == nC - 1), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + --end + -- ciclo sulle passate + local d + local dOffset = ( dWidth + BD.DIM_STRIP) / 2 ; + local dLioTang = 0 + local dLioPerp = ( dWidth - BD.DIM_STRIP) / 2 + BD.CUT_SIC ; + for k = 1, 2 do + -- inserisco le parti di lavorazione + nM = nM + 1 + local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) + local nMchFId = EgtAddMachining( sNameF, sCutting) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCutting + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, 0}}) + -- limito opportunamente la lavorazione + local dSal = EgtIf( i == nC, 0, - dEndAccDist - ( nC - i - 1) * dC) + local dEal = EgtIf( i == 1, 0, - dStartAccDist - ( i - 2) * dC) + if ( not bFront and k == 1) or ( bFront and k == 2) then + dSal, dEal = dEal, dSal + end + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) + -- imposto offset radiale + EgtSetMachiningParam( MCH_MP.OFFSR, dOffset) + -- imposto attacco/uscita + EgtSetMachiningParam( MCH_MP.LITANG, dLioTang) + EgtSetMachiningParam( MCH_MP.LIPERP, dLioPerp) + EgtSetMachiningParam( MCH_MP.LOTANG, dLioTang) + EgtSetMachiningParam( MCH_MP.LOPERP, dLioPerp) + -- imposto posizione braccio porta testa per non ingombrare agli estremi + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- imposto uso della faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( k == 1, nFaceUse, nFaceUse2)) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end + end + + -- se altrimenti non è sotto : lavorazione Long2Cut + elseif nSide ~= - 1 then -- recupero la lavorazione local sMilling = ML.FindMilling( 'Long2Cut') if not sMilling then