diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index dec0f9a..f388f61 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -802,7 +802,7 @@ local function AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, bN -- se mortasa ( 3/4-050-X) anche frontale ( 3/4-051-X) elseif Mortise.Identify( Proc) then -- esecuzione mortasa - bOk, sErr = Mortise.Make( Proc, nPhase, nRawId, nPartId) + bOk, sErr = Mortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se tenone a coda di rondine ( 1/2-055-X) elseif DtTenon.Identify( Proc) then -- esecuzione tenone @@ -810,7 +810,7 @@ local function AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, bN -- se mortasa a coda di rondine ( 3/4-055-X) anche frontale ( 3/4-056-X) elseif DtMortise.Identify( Proc) then -- esecuzione mortasa - bOk, sErr = DtMortise.Make( Proc, nPhase, nRawId, nPartId) + bOk, sErr = DtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se marcatura ( 3/4-060-X) elseif Mark.Identify( Proc) then -- esecuzione marcatura @@ -905,6 +905,52 @@ local function VerifyNeedForHeadCut( vProc, bSomeDown, bSomeSide) return ( nDownCnt == 1) end +------------------------------------------------------------------------------------------------------------- +local function SetCutsOnFrontMortises( vProc) + -- ciclo sulle feature + for i = 1, #vProc do + if vProc[i].Fct > 0 and Cut.Identify( vProc[i]) then + for j = 1, #vProc do + if vProc[j].Fct > 0 and Mortise.FrontIdentify( vProc[j]) then + -- se esiste intersezione tra le due features + if vProc[i].Box:getMin():getX() < vProc[j].Box:getMax():getX() + 100 * GEO.EPS_SMALL and + vProc[j].Box:getMin():getX() < vProc[i].Box:getMax():getX() + 100 * GEO.EPS_SMALL then + -- recupero il piano del taglio + local ptC1, vtN1 = Cut.GetCutPlane( vProc[i]) + -- recupero il piano frontale della mortasa + local ptC2, vtN2 = Mortise.GetCutPlane( vProc[j]) + -- verifico se i piani coincidono + local bSamePlane = ( ptC1 and vtN1 and ptC2 and vtN2 and AreSameVectorApprox( vtN1, vtN2) and ( ptC2 - ptC1) * vtN1 < 1.0) + if bSamePlane then + vProc[i].CutFront = vProc[j].Id + end + -- log + local sMsg = string.format( 'Cut %d meet Mortise %d', vProc[i].Id, vProc[j].Id) .. EgtIf( bSamePlane, ' with same plane', '') + EgtOutLog( sMsg, 3) + end + elseif vProc[j].Fct > 0 and DtMortise.FrontIdentify( vProc[j]) then + -- se esiste intersezione tra le due features + if vProc[i].Box:getMin():getX() < vProc[j].Box:getMax():getX() + 100 * GEO.EPS_SMALL and + vProc[j].Box:getMin():getX() < vProc[i].Box:getMax():getX() + 100 * GEO.EPS_SMALL then + -- recupero il piano del taglio + local ptC1, vtN1 = Cut.GetCutPlane( vProc[i]) + -- recupero il piano frontale della mortasa + local ptC2, vtN2 = DtMortise.GetCutPlane( vProc[j]) + -- verifico se i piani coincidono + local bSamePlane = ( ptC1 and vtN1 and ptC2 and vtN2 and AreSameVectorApprox( vtN1, vtN2) and ( ptC2 - ptC1) * vtN1 < 1.0) + if bSamePlane then + vProc[i].CutFront = vProc[j].Id + end + -- log + local sMsg = string.format( 'Cut %d meet DtMortise %d', vProc[i].Id, vProc[j].Id) .. EgtIf( bSamePlane, ' with same plane', '') + EgtOutLog( sMsg, 3) + end + end + end + end + end +end + ------------------------------------------------------------------------------------------------------------- local function MoveDrillsOnTenon( vProc) -- se non richiesto spostamento fori su tenone, esco @@ -982,6 +1028,8 @@ function BeamExec.ProcessFeatures() end -- verifico se comunque necessario taglio di testa local bNeedHCut = VerifyNeedForHeadCut( vProc, bSomeDown, bSomeSide) + -- inserisco corrispondenze di tagli coincidenti con mortase normali o a coda di rondine di testa + SetCutsOnFrontMortises( vProc) -- eventuale spostamento fori sui tenoni MoveDrillsOnTenon( vProc) -- se richiesto ribaltamento (oppure rotazione) diff --git a/LuaLibs/ProcessBlockHausFront.lua b/LuaLibs/ProcessBlockHausFront.lua index f195399..7421e7a 100644 --- a/LuaLibs/ProcessBlockHausFront.lua +++ b/LuaLibs/ProcessBlockHausFront.lua @@ -147,7 +147,7 @@ function ProcessBlockHausFront.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if bCut then local CutProc = { Id = AuxId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) -- se taglio applicato setto la nota al gruppo Mach per non doverla lavorare una seconda volta if bOk then bAuxMachined = true @@ -239,7 +239,7 @@ function ProcessBlockHausFront.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if bCut then local CutProc = { Id = AuxId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) -- se taglio applicato setto la nota al gruppo Mach per non doverla lavorare una seconda volta if bOk then bAuxMachined = true diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 7edaede..5fe7c7b 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -1,4 +1,4 @@ --- ProcessCut.lua by Egaltech s.r.l. 2020/09/24 +-- ProcessCut.lua by Egaltech s.r.l. 2020/10/09 -- Gestione calcolo singoli tagli di lama per Travi -- Tabella per definizione modulo @@ -45,6 +45,16 @@ function ProcessCut.Classify( Proc, b3Raw) return true, false end +--------------------------------------------------------------------- +-- Piano di taglio della feature +function ProcessCut.GetCutPlane( Proc) + if ProcessCut.Identify( Proc) then + return EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + else + return nil, nil + end +end + --------------------------------------------------------------------- -- verifica curva per smusso (-1=errore curva, 0=estrusione non va bene, 1=ok) local function VerifyCurveForChamfer( AuxId) @@ -194,6 +204,10 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) return true end end + -- se coincide con un taglio frontale non va fatto + if Proc.CutFront then + return true + end -- se vero taglio, eventuale inserimento smussi if Proc.Prc == 10 then local bOkc, sErrC = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) diff --git a/LuaLibs/ProcessDoubleCut.lua b/LuaLibs/ProcessDoubleCut.lua index 5eccc47..44bca12 100644 --- a/LuaLibs/ProcessDoubleCut.lua +++ b/LuaLibs/ProcessDoubleCut.lua @@ -1,4 +1,4 @@ --- ProcessDoubleCut.lua by Egaltech s.r.l. 2020/09/24 +-- ProcessDoubleCut.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo doppi tagli di lama per Travi -- Tabella per definizione modulo @@ -142,7 +142,7 @@ end -- Applicazione della lavorazione function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- se singola faccia, passo a quella lavorazione - if Proc.Fct == 1 then return Cut.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end + if Proc.Fct == 1 then return Cut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) -- ingombro del pezzo @@ -220,7 +220,7 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- applico lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Add, Fct = 1, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) if not bOk then return bOk, sErr end end -- creo piano di taglio coincidente con la seconda faccia e lo lavoro @@ -232,7 +232,7 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- applico lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Add, Fct = 1, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) if not bOk then return bOk, sErr end end -- altrimenti diff --git a/LuaLibs/ProcessDovetail.lua b/LuaLibs/ProcessDovetail.lua index 52d8bc3..fa7af41 100644 --- a/LuaLibs/ProcessDovetail.lua +++ b/LuaLibs/ProcessDovetail.lua @@ -1,4 +1,4 @@ --- ProcessDovetail.lua by Egaltech s.r.l. 2020/08/04 +-- ProcessDovetail.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo giunzione coda di rondine -- Tabella per definizione modulo @@ -1430,7 +1430,7 @@ local function MakeAuxCut( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Sol end -- inserisco la lavorazione local CutProc = { Id = AuxId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) if not bOk then return bOk, sErr end -- imposto la nota nel gruppo aggiuntivo di lavorazione per evitare di tagliare una seconda volta EgtSetInfo( nAddGrpId, 'AuxId.'..tostring(AuxId or 0), true) diff --git a/LuaLibs/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index 9a28585..58e38cc 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -1,4 +1,4 @@ --- ProcessDtMortise.lua by Egaltech s.r.l. 2020/08/26 +-- ProcessDtMortise.lua by Egaltech s.r.l. 2020/10/09 -- Gestione calcolo mortase a coda di rondine per Travi -- Tabella per definizione modulo @@ -6,11 +6,12 @@ local ProcessDtMortise = {} -- Include require( 'EgtBase') +local BL = require( 'BeamLib') +local Cut = require( 'ProcessCut') EgtOutLog( ' ProcessDtMortise started', 1) -- Dati -local BL = require( 'BeamLib') local BD = require( 'BeamData') local ML = require( 'MachiningLib') @@ -25,6 +26,12 @@ function ProcessDtMortise.Identify( Proc) (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 56)) end +--------------------------------------------------------------------- +-- Riconoscimento della sola feature frontale +function ProcessDtMortise.FrontIdentify( Proc) + return (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 56) +end + --------------------------------------------------------------------- -- Verifica se feature di coda function ProcessDtMortise.IsTailFeature( Proc, b3Raw) @@ -56,6 +63,16 @@ function ProcessDtMortise.Classify( Proc) return true, bDown end +--------------------------------------------------------------------- +-- Piano di taglio della feature +function ProcessDtMortise.GetCutPlane( Proc) + if ProcessDtMortise.FrontIdentify( Proc) then + return EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) + else + return nil, nil + end +end + --------------------------------------------------------------------- local function CalcTopPath( nProcId, AuxId, nAddGrpId, dAltMort, dSideAng, b3Solid) -- copio la curva di base @@ -91,7 +108,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione -function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) +function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- ingombro del pezzo local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) if not b3Solid then @@ -116,6 +133,32 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) EgtOutLog( sErr) return false, sErr end + -- verifico se di tipo pocket + local bPocket = ( EgtGetInfo( Proc.Id, 'P05', 'i') == 1) + if bPocket then bMakeAntiSplitPath = false end + -- verifico se frontale + local bFront = ( Proc.Prc == 56) + -- se mortasa di fronte, eseguo il taglio della faccia + if bFront then + -- verifico esista la faccia di taglio + local ptCutC, vtCutN = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) + if ptCutC and vtCutN and AreSameVectorApprox( vtExtr, vtCutN) then + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + local AddId = EgtSurfTmPlaneInBBox( nAddGrpId, ptCutC, vtCutN, b3Solid, GDB_RT.GLOB) + local b3Cut = EgtGetBBoxGlob( AddId or GDB_ID.NULL, GDB_BB.STANDARD) + local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Cut, Fct = 1, Flg = Proc.Flg, + Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} + local bFromBottom = ( b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getZ() > 0.25) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dCurrOvmH, bFromBottom) + if not bOk then return bOk, sErr end + end + end -- recupero la lavorazione local sMilling = ML.FindMilling( 'DtMortise') if not sMilling then diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index 7877667..ddf5ac4 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2020/09/07 +-- ProcessTenon.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo tenone a coda di rondine per Travi -- Tabella per definizione modulo @@ -205,7 +205,7 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} local bFromBottom = ( b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getZ() > 0.25) - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0, bFromBottom) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) if not bOk then return bOk, sErr end end end diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 2fbde57..a0d8210 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2020/09/19 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. @@ -854,7 +854,7 @@ local function MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId) end --------------------------------------------------------------------- -local function MakePreCuts( Proc, nPhase, nRawId, nPartId, b3Raw, nChamfer) +local function MakePreCuts( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, nChamfer) -- se interessa l'intera sezione della trave, necessaria sgrossatura if nChamfer < 2 and Proc.Box:getDimY() > 0.9 * b3Raw:getDimY() and Proc.Box:getDimZ() > 0.9 * b3Raw:getDimZ() then -- recupero gruppo per geometria addizionale @@ -873,9 +873,9 @@ local function MakePreCuts( Proc, nPhase, nRawId, nPartId, b3Raw, nChamfer) Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} local nCutFacet = EgtSurfTmFacetCount( AddId) if nCutFacet == 1 then - return Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + return Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) elseif nCutFacet == 2 then - return DoubleCut.Make( CutProc, nPhase, nRawId, nPartId, 0) + return DoubleCut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) end end end @@ -2879,7 +2879,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha end --------------------------------------------------------------------- -local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSinglePart) +local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePart) local sWarn -- recupero l'ingombro del grezzo di appartenenza local b3Raw = EgtGetRawPartBBox( nRawId) @@ -3091,7 +3091,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSinglePart) rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd2, GDB_ID.ROOT) -- eventuali tagli preliminari do - local bOk, sErr = MakePreCuts( Proc, nPhase, nRawId, nPartId, b3Raw, nChamfer) + local bOk, sErr = MakePreCuts( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, nChamfer) if not bOk then return false, sErr end end -- Recupero la lavorazione di fresa @@ -3232,7 +3232,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSinglePart) end -- eventuali tagli preliminari do - local bOk, sErr = MakePreCuts( Proc, nPhase, nRawId, nPartId, b3Raw, nChamfer) + local bOk, sErr = MakePreCuts( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, nChamfer) if not bOk then return false, sErr end end -- imposto altezza aggiuntiva di elevazione @@ -3577,7 +3577,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSinglePart) end --------------------------------------------------------------------- -local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) +local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) -- recupero gruppo per geometria addizionale local nAddGrpId = BL.GetAddGroup( nPartId) if not nAddGrpId then @@ -3612,7 +3612,7 @@ local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) local b3Box = EgtGetBBoxGlob( vAddId[i], GDB_BB.STANDARD) local nFct = EgtSurfTmFacetCount( vAddId[i]) local AddProc = { Id = vAddId[i], Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Box, Fct = nFct, Flg = Proc.Flg} - local bOk, sMyWarn = MakeMoreFaces( AddProc, nPhase, nRawId, nPartId, false) + local bOk, sMyWarn = MakeMoreFaces( AddProc, nPhase, nRawId, nPartId, dOvmHead, false) if not sWarn then sWarn = sMyWarn end if not bOk then return bOk, sWarn end end @@ -3655,12 +3655,12 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if bForcedBlade then return Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, 'HeadSide') else - return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) + return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) end end -- tre o più facce else - return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) + return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- altrimenti lavorazione unica @@ -3672,7 +3672,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) return MakeOneFaceByMill( Proc, nPhase, nRawId, nPartId) -- altrimenti, con lama else - return Cut.Make( Proc, nPhase, nRawId, nPartId, 0) + return Cut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- due facce elseif Proc.Fct == 2 then @@ -3684,7 +3684,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if ( Proc.Box:getDimX() < MAX_MILL_LIN and ( Proc.Box:getDimZ() < MAX_MILL_LIN or Proc.Box:getDimY() < MAX_MILL_LIN)) then return MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId) else - return MakeMoreFaces( Proc, nPhase, nRawId, nPartId, true) + return MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, true) end -- altrimenti, con lama else @@ -3717,7 +3717,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- tre o più facce else - return MakeMoreFaces( Proc, nPhase, nRawId, nPartId, true) + return MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, true) end end end diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index 7bd06d1..6424b78 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -1,4 +1,4 @@ --- ProcessLongCut.lua by Egaltech s.r.l. 2020/10/08 +-- ProcessLongCut.lua by Egaltech s.r.l. 2020/10/09 -- Gestione calcolo taglio longitudinale per Travi -- Tabella per definizione modulo @@ -312,7 +312,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth end end - -- se la fine (a sinistra) non è limitata e ho un pezzo successivo più distante da metà raggio. setto la fine come limitata + -- se la fine (a sinistra) non è limitata e ho un pezzo successivo meno distante di metà raggio. setto la fine come limitata if dDistToNextPiece < dToolDiam/2 and not bLimXmin then bForcedLim = true bLimXmin = true @@ -342,9 +342,17 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) local nC = ceil( ( dLen - dStartAccDist - dEndAccDist) / BD.LONGCUT_MAXLEN) local dC = 0 if nC > 0 then + local nIncStep = 2 if bStartFixed and bEndFixed then dC = ( dLen - dStartAccDist - dEndAccDist) / nC - if dC < min( dStartAccDist, dEndAccDist) then + -- se distanza rimanente è < della metà del minimo della distanza estremi allora aggiungo un passo in più + local dMinDist = EgtIf( min( dStartAccDist, dEndAccDist) / 2 > 300 , 300, min( dStartAccDist, dEndAccDist) / 2) + if dC <= dMinDist then + dC = dLen / ( nC + 1) + dStartAccDist = dC + dEndAccDist = dC + nIncStep = 1 + elseif dC < min( dStartAccDist, dEndAccDist) then dC = dLen / ( nC + 2) dStartAccDist = dC dEndAccDist = dC @@ -370,7 +378,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) dStartAccDist = dC dEndAccDist = dC end - nC = nC + 2 + nC = nC + nIncStep else if dLen > min( dStartAccDist, dEndAccDist) then nC = 2 @@ -498,7 +506,6 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) nExtendMach = nUseMillOnSide if nUseMillOnSide == 2 then bRemoveToolRadius = true --- nExtendMach = 0 -- arretro la lavorazione del raggio utensile (se non ha facce limite) end -- lavorazione da sotto else diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index 3d4a1b5..d34bfcf 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -1,4 +1,4 @@ --- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2020/10/08 +-- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2020/10/09 -- Gestione calcolo doppio taglio longitudinale per Travi -- Tabella per definizione modulo @@ -500,9 +500,17 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) local nC = ceil( ( dLen - dStartAccDist - dEndAccDist) / BD.LONGCUT_MAXLEN) local dC = 0 if nC > 0 then + local nIncStep = 2 if bStartFixed and bEndFixed then dC = ( dLen - dStartAccDist - dEndAccDist) / nC - if dC < min( dStartAccDist, dEndAccDist) then + -- se distanza rimanente è < della metà del minimo della distanza estremi allora aggiungo un passo in più + local dMinDist = EgtIf( min( dStartAccDist, dEndAccDist) / 2 > 300 , 300, min( dStartAccDist, dEndAccDist) / 2) + if dC < dMinDist then + dC = dLen / ( nC + 2) + dStartAccDist = dC + dEndAccDist = dC + nIncStep = 1 + elseif dC < min( dStartAccDist, dEndAccDist) then dC = dLen / ( nC + 2) dStartAccDist = dC dEndAccDist = dC @@ -528,7 +536,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) dStartAccDist = dC dEndAccDist = dC end - nC = nC + 2 + nC = nC + nIncStep else if dLen > min( dStartAccDist, dEndAccDist) then nC = 2 diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index 3a95de6..a9d7265 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -1,4 +1,4 @@ --- ProcessMortise.lua by Egaltech s.r.l. 2020/05/27 +-- ProcessMortise.lua by Egaltech s.r.l. 2020/10/09 -- Gestione calcolo mortase per Travi -- Tabella per definizione modulo @@ -7,6 +7,7 @@ local ProcessMortise = {} -- Include require( 'EgtBase') local BL = require( 'BeamLib') +local Cut = require( 'ProcessCut') EgtOutLog( ' ProcessMortise started', 1) @@ -22,6 +23,12 @@ function ProcessMortise.Identify( Proc) (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 53)) end +--------------------------------------------------------------------- +-- Riconoscimento della sola feature frontale +function ProcessMortise.FrontIdentify( Proc) + return (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 51) +end + --------------------------------------------------------------------- -- Classificazione della feature: decide se la feature è in una posizione che per lavorala -- deve essere ribaltata o no @@ -53,9 +60,26 @@ function ProcessMortise.Classify( Proc) return true, bDown end +--------------------------------------------------------------------- +-- Piano di taglio della feature +function ProcessMortise.GetCutPlane( Proc) + if ProcessMortise.FrontIdentify( Proc) then + return EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) + else + return nil, nil + end +end + --------------------------------------------------------------------- -- Applicazione della lavorazione -function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId) +function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + -- ingombro del pezzo + local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + if not b3Solid then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found' + EgtOutLog( sErr) + return false, sErr + end -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') local bForceOneSide @@ -98,15 +122,21 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId) end end end + -- verifico se frontale + local bFront = ( Proc.Prc == 51) -- recupero i dati della faccia di fondo local frMor, dL, dW = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0, GDB_ID.ROOT) - local ptC = frMor:getOrigin() - local vtN = frMor:getVersZ() - -- Confronto le direzioni Z dei 2 versori : se diverse la faccia 0 non è il fondo => mortasa passante - local bOpenBtm = ( abs( vtExtr:getZ() - vtN:getZ()) > GEO.EPS_SMALL) + local ptC = ORIG() + local vtN = V_NULL() + if frMor then + ptC = frMor:getOrigin() + vtN = frMor:getVersZ() + end + -- Confronto le direzioni dei 2 versori : se diverse la faccia 0 non è il fondo => mortasa passante + local bOpenBtm = not AreSameVectorApprox( vtExtr, vtN) if bOpenBtm then -- creo superficie chiusa - local nFlat = EgtSurfTmByFlatContour( EgtGetParent( AuxId), AuxId, 0.02) + local nFlat = EgtSurfTmByFlatContour( EgtGetParent( AuxId), AuxId, 0.05) if nFlat then frMor, dL, dW = EgtSurfTmFacetMinAreaRectangle( nFlat, 0, GDB_ID.ROOT) ptC = frMor:getOrigin() @@ -132,6 +162,7 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId) end -- scrivo info nel log EgtOutLog( 'ptC=' .. tostring( ptC) ..' vtN=' .. tostring( vtN), 3) + -- Se mortasa chiusa if not bOpenBtm then -- verifico che la mortasa non sia orientata verso il basso (limite -5 deg) if vtN:getZ() < - 0.1 then @@ -139,7 +170,7 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId) EgtOutLog( sErr) return false, sErr end - -- se mortasa passante + -- altrimenti passante else -- determino se la mortasa da lavorare sul lato opposto sia di angolo inferiore a quello consentito if abs(vtN:getZ()) > 0.1 then @@ -151,12 +182,36 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId) end end + -- se mortasa di fronte, eseguo il taglio della faccia + if bFront then + -- verifico esista la faccia di taglio + local ptCutC, vtCutN = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) + if ptCutC and vtCutN and AreSameVectorApprox( vtExtr, vtCutN) then + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + local AddId = EgtSurfTmPlaneInBBox( nAddGrpId, ptCutC, vtCutN, b3Solid, GDB_RT.GLOB) + local b3Cut = EgtGetBBoxGlob( AddId or GDB_ID.NULL, GDB_BB.STANDARD) + local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Cut, Fct = 1, Flg = Proc.Flg, + Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} + local bFromBottom = ( b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getZ() > 0.25) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dCurrOvmH, bFromBottom) + if not bOk then return bOk, sErr end + end + end + -- determino altezza della mortasa local b3Mor = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frMor) local dMorH = b3Mor:getDimZ() -- elevazione del punto centro - local _, dCenElev = BL.GetPointDirDepth( nPartId, ptC, vtN) - dMorH = max( dMorH, dCenElev or 0) + if not bFront then + local _, dCenElev = BL.GetPointDirDepth( nPartId, ptC, vtN) + dMorH = max( dMorH, dCenElev or 0) + end -- determino larghezza della mortasa if dL < dW then dL, dW = dW, dL end -- recupero la lavorazione diff --git a/LuaLibs/ProcessProfCamb.lua b/LuaLibs/ProcessProfCamb.lua index d9e5f74..ec1bdcd 100644 --- a/LuaLibs/ProcessProfCamb.lua +++ b/LuaLibs/ProcessProfCamb.lua @@ -1,4 +1,4 @@ --- ProcessProfCamb.lua by Egaltech s.r.l. 2020/10/06 +-- ProcessProfCamb.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo profilo caudato per Travi -- Tabella per definizione modulo @@ -238,7 +238,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico la lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dCurrOvmH) if not bOk then return bOk, sErr end end -- leggo anticipatamente i parametri utensile fresa per dare un valore opportuno all'elevazione della lama diff --git a/LuaLibs/ProcessProfConcave.lua b/LuaLibs/ProcessProfConcave.lua index 355db4a..361fca0 100644 --- a/LuaLibs/ProcessProfConcave.lua +++ b/LuaLibs/ProcessProfConcave.lua @@ -1,4 +1,4 @@ --- ProcessProfConcave.lua by Egaltech s.r.l. 2020/10/06 +-- ProcessProfConcave.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo profilo concavo per Travi -- Tabella per definizione modulo @@ -237,7 +237,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico la lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dCurrOvmH) if not bOk then return bOk, sErr end end end diff --git a/LuaLibs/ProcessProfConvex.lua b/LuaLibs/ProcessProfConvex.lua index f7a5e26..293b662 100644 --- a/LuaLibs/ProcessProfConvex.lua +++ b/LuaLibs/ProcessProfConvex.lua @@ -1,4 +1,4 @@ --- ProcessProfConvex.lua by Egaltech s.r.l. 2020/10/06 +-- ProcessProfConvex.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo profilo convesso per Travi -- Tabella per definizione modulo @@ -237,7 +237,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico la lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dCurrOvmH) if not bOk then return bOk, sErr end end end diff --git a/LuaLibs/ProcessProfFront.lua b/LuaLibs/ProcessProfFront.lua index e060e98..2eac9ea 100644 --- a/LuaLibs/ProcessProfFront.lua +++ b/LuaLibs/ProcessProfFront.lua @@ -1,4 +1,4 @@ --- ProcessProfFront.lua by Egaltech s.r.l. 2020/10/06 +-- ProcessProfFront.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo profilo frontale per Travi -- Tabella per definizione modulo @@ -232,7 +232,7 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico la lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dCurrOvmH) if not bOk then return bOk, sErr end end end diff --git a/LuaLibs/ProcessProfHead.lua b/LuaLibs/ProcessProfHead.lua index f857dc4..bfe142d 100644 --- a/LuaLibs/ProcessProfHead.lua +++ b/LuaLibs/ProcessProfHead.lua @@ -1,4 +1,4 @@ --- ProcessProfHead.lua by Egaltech s.r.l. 2020/10/06 +-- ProcessProfHead.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo profilo di testa per Travi -- Tabella per definizione modulo @@ -234,7 +234,7 @@ function ProcessProfHead.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- applico la lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dCurrOvmH) if not bOk then return bOk, sErr end end end diff --git a/LuaLibs/ProcessStepJoint.lua b/LuaLibs/ProcessStepJoint.lua index 2e96b93..5c613ce 100644 --- a/LuaLibs/ProcessStepJoint.lua +++ b/LuaLibs/ProcessStepJoint.lua @@ -210,7 +210,7 @@ local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) -- applico lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) if not bOk then return bOk, sErr end end -- creo piano di taglio coincidente con la seconda faccia e lo lavoro @@ -221,7 +221,7 @@ local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) -- applico lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) if not bOk then return bOk, sErr end end -- altrimenti @@ -380,7 +380,7 @@ local function MakeThreeFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) -- applico lavorazione local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) if not bOk then return bOk, sErr end end -- Taglio le facce 0 e 1 concave diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index 3d3b593..e7e1b1d 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2020/10/06 +-- ProcessTenon.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo tenone per Travi -- Tabella per definizione modulo @@ -213,7 +213,7 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Cut, Fct = 1, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} local bFromBottom = ( b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getZ() > 0.25) - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0, bFromBottom) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) if not bOk then return bOk, sErr end end end diff --git a/LuaLibs/ProcessTyroleanDovetail.lua b/LuaLibs/ProcessTyroleanDovetail.lua index 22b2873..f1a413d 100644 --- a/LuaLibs/ProcessTyroleanDovetail.lua +++ b/LuaLibs/ProcessTyroleanDovetail.lua @@ -1,4 +1,4 @@ --- ProcessTyroleanDovetail.lua by Egaltech s.r.l. 2020/08/03 +-- ProcessTyroleanDovetail.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo giunzione tirolese -- Tabella per definizione modulo @@ -225,7 +225,7 @@ local function MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, if bCut then local CutProc = { Id = AuxId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) -- se taglio applicato setto la nota al gruppo Mach per non doverla lavorare una seconda volta if bOk then bAuxMachined = true @@ -324,7 +324,7 @@ local function MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, if bCut then local CutProc = { Id = AuxId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead) -- se taglio applicato setto la nota al gruppo Mach per non doverla lavorare una seconda volta if bOk then bAuxMachined = true