From 729143ce4517c34bd22d59b6ff0f48b39bf787c9 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 21 Aug 2025 16:47:07 +0200 Subject: [PATCH] - in BeamExec sia nelle dipendenze che dopo l'ordinamento si mettono i tagli di testa e coda troncanti sempre dopo taglio di testa e coda, rispettivamente; - in LapJoint se Front Slot sul retro e pezzo lungo si setta di coda --- LuaLibs/BeamExec.lua | 105 +++++++++++++++++++++++++++++++++--- LuaLibs/ProcessLapJoint.lua | 7 +-- 2 files changed, 103 insertions(+), 9 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 3af1aaa..bb9c72b 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -614,10 +614,10 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b local bEFinishingNeeded, nReplacedTailCutFeatureId, nTailCuttingFeatureId = AnalyzeTailFeatures( b3Solid, vProc, dRawW, dRawH) -- Scrivo gli di delle facce di taglio custom: serviranno dopo per calcolare l'elevazione rispetto a queste if nHeadCuttingFeatureId then - EgtSetInfo( vBeam[i].Id, 'HEADCUTID', nHeadCuttingFeatureId) + EgtSetInfo( vBeam[i].Id, 'HEADCUTFEATUREID', nHeadCuttingFeatureId) end if nTailCuttingFeatureId then - EgtSetInfo( vBeam[i].Id, 'TAILCUTID', nTailCuttingFeatureId) + EgtSetInfo( vBeam[i].Id, 'TAILCUTFEATUREID', nTailCuttingFeatureId) end if bBigSectionCut then -- lascio in coda solo il materiale necessario; il resto verrà tolto nell'head cut successivo @@ -795,7 +795,82 @@ local function PrintFeatures( vProc, b3Raw) end ------------------------------------------------------------------------------------------------------------- -local function OrderFeatures( vProc, b3Raw) +-- mi assicuro che i tagli di testa e coda troncanti (usati per ridurre i percorsi utensile in testa e coda) siano sempre fatti per primi +local function ReorderTruncatingCuts( vProc, nPartId) + if not nPartId or #vProc == 0 then return end + + local nHeadCuttingFeatureId = EgtGetInfo( nPartId, 'HEADCUTFEATUREID', 'i') + local nTailCuttingFeatureId = EgtGetInfo( nPartId, 'TAILCUTFEATUREID', 'i') + + -- tagli di testa + -- 1: si trovano gli indici del taglio di testa e del rispettivo taglio troncante + local nHeadCutIndex, nHeadCuttingFeatureIndex + for index, value in ipairs( vProc) do + if value.Prc == 340 then + nHeadCutIndex = index + end + if value.Id == nHeadCuttingFeatureId then + nHeadCuttingFeatureIndex = index + end + end + + -- 2: se non c'è il taglio di testa, il taglio troncante è il primo. Se c'è il taglio di testa, il taglio troncante lo deve seguire. + if not nHeadCutIndex and nHeadCuttingFeatureIndex then + local HeadCuttingFeature = vProc[ nHeadCuttingFeatureIndex] + table.remove( vProc, nHeadCuttingFeatureIndex) + table.insert( vProc, 1, HeadCuttingFeature) + elseif nHeadCutIndex and nHeadCuttingFeatureIndex then + if abs( nHeadCutIndex - nHeadCuttingFeatureIndex) ~= 1 then + local HeadCut = vProc[ nHeadCutIndex] + local HeadCuttingFeature = vProc[ nHeadCuttingFeatureIndex] + + table.remove( vProc, nHeadCutIndex) + -- rimuovere il primo potrebbe aver cambiato l'indice del secondo + if nHeadCutIndex < nHeadCuttingFeatureIndex then + nHeadCuttingFeatureIndex = nHeadCuttingFeatureIndex - 1 + end + table.remove( vProc, nHeadCuttingFeatureIndex) + + table.insert( vProc, nHeadCutIndex, HeadCut) + table.insert( vProc, nHeadCutIndex + 1, HeadCuttingFeature) + end + end + + -- tagli di coda + -- 1: si trovano gli indici del taglio di coda e del rispettivo taglio troncante + local nTailCutIndex, nTailCuttingFeatureIndex + for index, value in ipairs( vProc) do + if value.Prc == 350 then + nTailCutIndex = index + end + if value.Id == nTailCuttingFeatureId then + nTailCuttingFeatureIndex = index + end + end + + -- 2: il taglio di coda c'è sempre. Il taglio troncante lo deve seguire. + if nTailCutIndex and nTailCuttingFeatureIndex then + if abs( nTailCutIndex - nTailCuttingFeatureIndex) ~= 1 then + local TailCut = vProc[ nTailCutIndex] + local TailCuttingFeature = vProc[ nTailCuttingFeatureIndex] + + table.remove( vProc, nTailCutIndex) + -- rimuovere il primo potrebbe aver cambiato l'indice del secondo + if nTailCutIndex < nTailCuttingFeatureIndex then + nTailCuttingFeatureIndex = nTailCuttingFeatureIndex - 1 + end + table.remove( vProc, nTailCuttingFeatureIndex) + + table.insert( vProc, nTailCutIndex, TailCut) + table.insert( vProc, nTailCutIndex + 1, TailCuttingFeature) + end + end + + return true +end + +------------------------------------------------------------------------------------------------------------- +local function OrderFeatures( vProc, b3Raw, nPartId) local dDrillPenalty = EgtIf( BD.PRESS_ROLLER, 200, 100) local dSmallDrillRange = EgtIf( b3Raw:getDimX() < BD.LEN_SHORT_PART, BD.DRILL_RANGE_SP or 200, BD.DRILL_RANGE or 600) @@ -1114,6 +1189,8 @@ local function OrderFeatures( vProc, b3Raw) end end end + + ReorderTruncatingCuts( vProc, nPartId) end ------------------------------------------------------------------------------------------------------------- @@ -2036,7 +2113,7 @@ local function AreDrillingsMirrored( Proc, ProcMirror, b3Raw) end ------------------------------------------------------------------------------------------------------------- -function GetFeatureInfoAndDependency( vProc, b3Raw) +function GetFeatureInfoAndDependency( vProc, b3Raw, nPartId) -- ciclo tutte le feature for i = 1, #vProc do local Proc = vProc[i] @@ -2077,6 +2154,22 @@ function GetFeatureInfoAndDependency( vProc, b3Raw) end end end + -- verifiche per tagli troncanti testa e coda: devono sempre essere subito dopo il taglio di testa e il taglio di coda, rispettivamente + local nHeadCuttingFeatureId = EgtGetInfo( nPartId, 'HEADCUTFEATUREID', 'i') + local nTailCuttingFeatureId = EgtGetInfo( nPartId, 'TAILCUTFEATUREID', 'i') + if Proc.Prc == 340 and ProcB == nHeadCuttingFeatureId then + Proc.Dependency = {} + Proc.Dependency.ExecBefore = ProcB + elseif Proc == nHeadCuttingFeatureId and ProcB.Prc == 340 then + ProcB.Dependency = {} + ProcB.Dependency.ExecBefore = Proc + elseif Proc.Prc == 350 and ProcB == nTailCuttingFeatureId then + Proc.Dependency = {} + Proc.Dependency.ExecBefore = ProcB + elseif Proc == nTailCuttingFeatureId and ProcB.Prc == 350 then + ProcB.Dependency = {} + ProcB.Dependency.ExecBefore = Proc + end end end end @@ -2118,7 +2211,7 @@ function BeamExec.ProcessFeatures() -- recupero le feature di lavorazione della trave local vProc = CollectFeatures( nPartId, b3Raw, dCurrOvmH, dCurrOvmT) -- recupero informazioni ausiliarie feature e dipendenze tra feature stesse - GetFeatureInfoAndDependency( vProc, b3Raw) + GetFeatureInfoAndDependency( vProc, b3Raw, nPartId) -- verifica presenza forature influenzate da lavorazioni di testa o coda if BD.IMPROVE_HEAD_TAIL_DRILLINGS then @@ -2130,7 +2223,7 @@ function BeamExec.ProcessFeatures() SetMirroredFeatures( vProc, b3Raw) end -- le ordino lungo X - OrderFeatures( vProc, b3Raw) + OrderFeatures( vProc, b3Raw, nPartId) -- le classifico local bAllOk, bSomeDown, bSomeSide, bSplitRot = ClassifyFeatures( vProc, b3Raw, Stats) if not bAllOk then diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index a63154a..6b3b1ba 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -796,7 +796,8 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) if ( dEndDist > BD.MAX_DIST_HTFEA) or bUseBHSideMill then if not( BD.BH_MACHINE) and bUseBHSideMill and ( Proc.Box:getMax():getX() - b3Solid:getMin():getX()) < 400 and b3Solid:getDimX() > BD.LEN_VERY_SHORT_PART then return true - else + -- se Front Slot e pezzo abbastanza lungo si rimanda la decisione a più avanti + elseif not ( ( Proc.Prc == 17) and ( b3Solid:getDimX() > ( BD.LEN_VERY_SHORT_PART or BD.LEN_SHORT_PART))) then return false end end @@ -6476,8 +6477,8 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa local dCustomMaxElev -- se esistono tagli troncanti in testa o in coda, si calcola il MaxElev da applicare if not dUserMaxElev then - local nTailCutId = EgtGetInfo( nPartId, 'TAILCUTID', 'i') - local nHeadCutId = EgtGetInfo( nPartId, 'HEADCUTID', 'i') + local nTailCutId = EgtGetInfo( nPartId, 'TAILCUTFEATUREID', 'i') + local nHeadCutId = EgtGetInfo( nPartId, 'HEADCUTFEATUREID', 'i') if nHeadCutId or nTailCutId then local nSurfPartId = EgtCopyGlob( EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, 'Box'), nAddGrpId) if nHeadCutId then