From 79b7d2337f7caf22ea85f9cdc9ec1f88f2c5867b Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 30 Sep 2019 06:50:03 +0000 Subject: [PATCH] DataBeam : - correzioni e migliorie varie. --- BatchProcess.lua | 2 +- LuaLibs/BeamExec.lua | 4 +- LuaLibs/BeamLib.lua | 2 +- LuaLibs/ProcessDtTenon.lua | 40 +++++++++++++--- LuaLibs/ProcessLapJoint.lua | 91 +++++++++++++++++++++++-------------- LuaLibs/ProcessTenon.lua | 40 +++++++++++++--- 6 files changed, 130 insertions(+), 49 deletions(-) diff --git a/BatchProcess.lua b/BatchProcess.lua index 81bd501..6a8d81a 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -13,7 +13,7 @@ EgtEnableDebug( false) -- Per test --BEAM = {} ---BEAM.FILE = 'c:\\EgtData\\Varie\\TestEssetreFast\\Xxx\\2-Banchina smussata.nge' +--BEAM.FILE = 'c:\\EgtData\\Varie\\TestEssetreFast\\TestFabio\\BTL_TS37\\Bar_25_2.btl' --BEAM.MACHINE = 'FAST' --BEAM.FLAG = 3 diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 0c6af3f..c3939b9 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -486,13 +486,13 @@ local function ClassifyFeatures( vProc, b3Raw, Stats) bOk, bDown = Drill.Classify( Proc, b3Raw) -- se tenone elseif Tenon.Identify( Proc) then - bOk, bDown = Tenon.Classify( Proc) + bOk, bDown = Tenon.Classify( Proc, b3Raw) -- se mortasa (anche frontale) elseif Mortise.Identify( Proc) then bOk, bDown = Mortise.Classify( Proc) -- se tenone a coda di rondine elseif DtTenon.Identify( Proc) then - bOk, bDown = DtTenon.Classify( Proc) + bOk, bDown = DtTenon.Classify( Proc, b3Raw) -- se mortasa a coda di rondine (anche frontale) elseif DtMortise.Identify( Proc) then bOk, bDown = DtMortise.Classify( Proc) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index f611fa2..1e9baf1 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -638,7 +638,7 @@ function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, Par5, dV local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacet, GDB_ID.ROOT) -- linea o bilinea di lavorazione (qui uso nOrthoOpposite per ripetere esattamente il calcolo del Mach) local ptP1, ptPm, ptP2, vtV1, vtV2, dLen, dWidth = EgtSurfTmFacetOppositeSide( nSurfId, nFacet, BeamLib.GetVersRef( nOrthoOpposite), GDB_ID.ROOT) - if dLen < 1.1 or dWidth < 1.1 then + if not dLen or dLen < 1.1 or not dWidth or dWidth < 1.1 then local sWarn = 'Face ' .. string.format( '%d,%d', nSurfId, nFacet) .. ' skipped : too small' EgtOutLog( sWarn, 1) return true, '' diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index 6debdac..b04a688 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2019/09/25 +-- ProcessTenon.lua by Egaltech s.r.l. 2019/09/27 -- Gestione calcolo tenone a coda di rondine per Travi -- Tabella per definizione modulo @@ -15,6 +15,34 @@ EgtOutLog( ' ProcessTenon started', 1) local BD = require( 'BeamData') local ML = require( 'MachiningLib') + +--------------------------------------------------------------------- +local function VerifyOrientation( Proc, vtN, b3Raw) + -- se trave bassa + if b3Raw:getDimZ() <= 200 then + -- se tenone praticamente in asse, accetto fino a -30 deg + if abs( vtN:getY()) < 0.04 then + return ( vtN:getZ() >= -0.5) + -- altrimenti accetto fino a -20deg + else + return ( vtN:getZ() >= -0.343) + end + -- se trave media + elseif b3Raw:getDimZ() <= 300 then + -- se tenone praticamente in asse, accetto fino a -20 deg + if abs( vtN:getY()) < 0.04 then + return ( vtN:getZ() >= -0.343) + -- altrimenti, accetto fino a -10 deg + else + return ( vtN:getZ() >= -0.174) + end + -- altrimenti + else + -- accetto fino a -5deg + return ( vtN:getZ() >= -0.088) + end +end + --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessDtTenon.Identify( Proc) @@ -23,14 +51,14 @@ end --------------------------------------------------------------------- -- Classificazione della feature -function ProcessDtTenon.Classify( Proc) +function ProcessDtTenon.Classify( Proc, b3Raw) -- recupero i dati della curva di contorno della faccia top local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if not AuxId then return false end AuxId = AuxId + Proc.Id local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - -- verifico se il tenone è lavorabile solo da sotto (-20 deg) - local bDown = ( vtExtr:getZ() < -0.35) + -- verifico se il tenone è lavorabile solo da sotto + local bDown = not VerifyOrientation( Proc, vtExtr, b3Raw) return true, bDown end @@ -59,8 +87,8 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local dDepth = abs( EgtCurveThickness( AuxId)) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local ptBC = EgtGP( AuxId, GDB_RT.GLOB) - -- verifico che il tenone non sia orientato verso il basso (-20 deg) - if vtExtr:getZ() < - 0.35 then + -- verifico che il tenone non sia orientato verso il basso + if not VerifyOrientation( Proc, vtExtr, b3Raw) then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' DtTenon from bottom impossible' EgtOutLog( sErr) return false, sErr diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 4a68d30..3377084 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2019/09/25 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2019/09/27 -- Gestione calcolo mezzo-legno per Travi -- Tabella per definizione modulo @@ -144,6 +144,31 @@ function ProcessLapJoint.Classify( Proc) end end +--------------------------------------------------------------------- +local function TestElleShape( Proc) + -- valida solo nel caso di tre facce + 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 + 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 + if nCount == 1 then + bIsL = false + break + end + end + return bIsL +end + --------------------------------------------------------------------- -- Lavorazione con fresa --------------------------------------------------------------------- @@ -227,14 +252,19 @@ local function MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId) local nFacInd -- se entrambe possibili if bFaceOk[1] and bFaceOk[2] then - -- se in testa o coda, scelgo quella con la normale più parallela all'asse trave - if Proc.Head or Proc.Tail then - if vtN[1]:getZ() < BD.NZ_MINA then - nFacInd = 1 - elseif vtN[2]:getZ() < BD.NZ_MINA then + -- se in testa, scelgo quella orientata verso la testa + if Proc.Head then + if vtN[1]:getX() > vtN[2]:getX() then nFacInd = 0 else - nFacInd = EgtIf( abs( vtN[1]:getX()) > abs( vtN[2]:getX()), 0, 1) + nFacInd = 1 + end + -- se altrimenti in coda, scelgo quella orientata verso la coda + elseif Proc.Tail then + if vtN[1]:getX() < vtN[2]:getX() then + nFacInd = 0 + else + nFacInd = 1 end -- altrimenti, scelgo quella con la normale più perpendicolare all'asse trave (se uguali, quella verso X+) else @@ -512,8 +542,10 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) return false, sErr end end - -- recupero la lavorazione - local dDiam = min( dH, dV) * EgtIf( Proc.Fct > 3, 1, 1.4) + -- verifico se tre facce a L con una faccia di terminazione + local bIsL = TestElleShape( Proc) + -- recupero la lavorazione ( se L posso accettare utensili un poco più grandi) + local dDiam = min( dH, dV) * EgtIf( bIsL, 1.4, 1) EgtOutLog( 'Mortise Find Diam =' .. EgtNumToString( dDiam)) local sPocketing = ML.FindPocketing( 'Mortise', dDiam) -- se non trova una svuotatura adatta, provo con la sega a catena o lama @@ -628,34 +660,27 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- due facce elseif Proc.Fct == 2 then -- determino se due facce lunghe oppure una lunga e l'altra terminale - - return Long2Cut.Make( Proc, nPhase, nRawId, nPartId) - -- tre facce - elseif Proc.Fct == 3 then - -- determino se L con una faccia terminale o U con tre facce - local bIsL = true - for i = 1, 3 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 - if nCount == 1 then - bIsL = false - break - end - end - -- se una faccia terminale e due lunghe - if bIsL then + local CopyId = EgtCopyGlob( Proc.Id, Proc.Id, GDB_IN.AFTER) + local NewId, nCount = EgtExplodeSurf( CopyId) + local b3Fac1 = EgtGetBBoxGlob( NewId, GDB_BB.STANDARD) + local b3Fac2 = EgtGetBBoxGlob( NewId + 1, GDB_BB.STANDARD) + if abs( b3Fac1:getDimX() - b3Fac2:getDimX()) < 10 then return Long2Cut.Make( Proc, nPhase, nRawId, nPartId) - -- altrimenti U lunga + elseif b3Fac1:getDimX() < 1 then + -- la faccia 0 deve essere quella lunga + local nNew2Id = EgtSurfTmBySewing( EgtGetParent( Proc.Id), { NewId+1, NewId}) + EgtCopyAttributes( Proc.Id, nNew2Id) + EgtErase( Proc.Id) + EgtChangeId( nNew2Id, Proc.Id) + return LongCut.Make( Proc, nPhase, nRawId, nPartId) + elseif b3Fac2:getDimX() < 1 then + EgtErase( {NewId, NewId+1}) + return LongCut.Make( Proc, nPhase, nRawId, nPartId) else + EgtErase( {NewId, NewId+1}) return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) end - -- più facce + -- tre o più facce else return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) end diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index 9a318d2..0179cb5 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2019/09/25 +-- ProcessTenon.lua by Egaltech s.r.l. 2019/09/27 -- Gestione calcolo tenone per Travi -- Tabella per definizione modulo @@ -15,6 +15,34 @@ EgtOutLog( ' ProcessTenon started', 1) local BD = require( 'BeamData') local ML = require( 'MachiningLib') + +--------------------------------------------------------------------- +local function VerifyOrientation( Proc, vtN, b3Raw) + -- se trave bassa + if b3Raw:getDimZ() <= 200 then + -- se tenone praticamente in asse, accetto fino a -30 deg + if abs( vtN:getY()) < 0.04 then + return ( vtN:getZ() >= -0.5) + -- altrimenti accetto fino a -20deg + else + return ( vtN:getZ() >= -0.343) + end + -- se trave media + elseif b3Raw:getDimZ() <= 300 then + -- se tenone praticamente in asse, accetto fino a -20 deg + if abs( vtN:getY()) < 0.04 then + return ( vtN:getZ() >= -0.343) + -- altrimenti, accetto fino a -10 deg + else + return ( vtN:getZ() >= -0.174) + end + -- altrimenti + else + -- accetto fino a -5deg + return ( vtN:getZ() >= -0.088) + end +end + --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessTenon.Identify( Proc) @@ -24,14 +52,14 @@ end --------------------------------------------------------------------- -- Classificazione della feature -function ProcessTenon.Classify( Proc) +function ProcessTenon.Classify( Proc, b3Raw) -- recupero i dati della curva di contorno della faccia top local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if not AuxId then return false end AuxId = AuxId + Proc.Id local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - -- verifico se il tenone è lavorabile solo da sotto (-20 deg) - local bDown = ( vtExtr:getZ() < - 0.35) + -- verifico se il tenone è lavorabile solo da sotto + local bDown = not VerifyOrientation( Proc, vtExtr, b3Raw) return true, bDown end @@ -60,8 +88,8 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local ptBC = EgtGP( AuxId, GDB_RT.GLOB) local bClosed = EgtCurveIsClosed( AuxId) - -- verifico che il tenone non sia orientato verso il basso (-20 deg) - if vtExtr:getZ() < - 0.35 then + -- verifico che il tenone non sia orientato troppo verso il basso + if not VerifyOrientation( Proc, vtExtr, b3Raw) then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Tenon from bottom impossible' EgtOutLog( sErr) return false, sErr