diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 63d1bcc..cbd0f55 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2021/11/27 +-- BeamExec.lua by Egaltech s.r.l. 2021/12/15 -- Libreria esecuzione lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/09/04 Corretto controllo feature di testa e coda con sovramateriale di testa elevato. @@ -23,6 +23,7 @@ -- 2021/02/25 Aggiunta gestione eventuale ricalcolo per macchine tipo PF. -- 2021/07/13 Aggiunta gestione posizionamento pezzo TR/BR per macchine con carico a destra e scarico a sinistra. -- 2021/11/27 House mortise sempre prima di (dt)mortise, house tenon sempre dopo (dt)tenon. +-- 2021/12/15 Corretta CompareFeature (risultato deve essere simmetrico scambiando le feature). -- Tabella per definizione modulo local BeamExec = {} @@ -338,6 +339,24 @@ local function IsTailFeature( Proc, b3Raw, dCurrOvmH) return false end +------------------------------------------------------------------------------------------------------------- +local function PrintFeatures( vProc, b3Raw) + EgtOutLog( ' RawBox=' .. tostring( b3Raw)) + for i = 1, #vProc do + local Proc = vProc[i] + local sOut = string.format( ' Id=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Down=%s Side=%s Head=%s Tail=%s Fcse=%1d,%1d Diam=%.2f Fct=%2d Box=%s', + Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId, + Proc.Flg, EgtIf( Proc.Down, 'T', 'F'), EgtIf( Proc.Side, 'T', 'F'), EgtIf( Proc.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', 'F'), + Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, tostring( Proc.Box)) + -- info speciali per Block Haus Half Lap + if Proc.Prc == 37 then + local sSpec = string.format( ' N=%s Hd=%s', tostring( Proc.vtN or V_NULL()), EgtIf( Proc.HeadDir, 'T', 'F')) + sOut = sOut .. sSpec + end + EgtOutLog( sOut) + end +end + ------------------------------------------------------------------------------------------------------------- local function CollectFeatures( PartId, b3Raw, dCurrOvmH) -- recupero le feature @@ -434,12 +453,12 @@ local function OrderFeatures( vProc, b3Raw) -- funzione di confronto -- secondo centro box in X (taglio di intestazione prima di altri tagli di testa e taglio di separazione però prima di altri tagli di coda) local function CompareFeatures( B1, B2) - -- se primo disabilitato va sempre alla fine - if B1.Flg == 0 then + -- se primo disabilitato e secondo no va dopo + if B1.Flg == 0 and B2.Flg ~= 0 then return false end - -- se secondo disabilitato va sempre alla fine - if B2.Flg == 0 then + -- se secondo disabilitato e primo no va lasciato dopo + if B2.Flg == 0 and B1.Flg ~= 0 then return true end -- se primo è intestazione va sempre prima @@ -460,21 +479,23 @@ local function OrderFeatures( vProc, b3Raw) return ( ( B1.Prc == 50 or B1.Prc == 55) and B2.Prc == 52) end -- se primo house mortise, secondo mortise e si intersecano, metto prima house mortise - if Mortise.Identify( B1) and B1.Prc == 53 and ( Mortise.Identify( B2) or DtMortise.Identify( B2)) and + if Mortise.Identify( B1) and B1.Prc == 53 and ( Mortise.Identify( B2) or DtMortise.Identify( B2)) and B2.Prc ~= 53 and B1.Box:getMin():getX() < B2.Box:getMax():getX() + 100 * GEO.EPS_SMALL and B2.Box:getMin():getX() < B1.Box:getMax():getX() + 100 * GEO.EPS_SMALL then return true end -- se primo mortise, secondo house mortise e si intersecano, metto prima house mortise - if ( Mortise.Identify( B1) or DtMortise.Identify( B1)) and Mortise.Identify( B2) and B2.Prc == 53 and + if ( Mortise.Identify( B1) or DtMortise.Identify( B1)) and B1.Prc ~= 53 and Mortise.Identify( B2) and B2.Prc == 53 and B1.Box:getMin():getX() < B2.Box:getMax():getX() + 100 * GEO.EPS_SMALL and B2.Box:getMin():getX() < B1.Box:getMax():getX() + 100 * GEO.EPS_SMALL then return false end - -- se entrambi di testa e primo è scasso o mortasa va messo dopo - if B1.Head and B2.Head and ( LapJoint.Identify( B1) or Mortise.Identify( B1) or DtMortise.Identify( B1)) then + -- se entrambi di testa e primo è scasso o mortasa e secondo no va messo dopo + if B1.Head and B2.Head and ( LapJoint.Identify( B1) or Mortise.Identify( B1) or DtMortise.Identify( B1)) and + not ( LapJoint.Identify( B2) or Mortise.Identify( B2) or DtMortise.Identify( B2)) then return false end - -- se entrambi di testa e secondo è scasso o mortasa va messo dopo - if B1.Head and B2.Head and ( LapJoint.Identify( B2) or Mortise.Identify( B2) or DtMortise.Identify( B2)) then + -- se entrambi di testa e secondo è scasso o mortasa va lasciato dopo + if B1.Head and B2.Head and ( LapJoint.Identify( B2) or Mortise.Identify( B2) or DtMortise.Identify( B2)) and + not ( LapJoint.Identify( B1) or Mortise.Identify( B1) or DtMortise.Identify( B1)) then return true end -- se primo è feature di coda e l'altro è separazione o non è feature di coda @@ -508,19 +529,31 @@ local function OrderFeatures( vProc, b3Raw) end -- se primo è foro e l'altro no, lo penalizzo if B1.Prc == 40 and B2.Prc ~= 40 then - return B1.Box:getCenter():getX() - dDrillPenalty > B2.Box:getMax():getX() + return ( B1.Box:getCenter():getX() > B2.Box:getMax():getX() + dDrillPenalty) end -- se primo è altro e secondo è foro, lo premio if B1.Prc ~= 40 and B2.Prc == 40 then - return B1.Box:getMax():getX() + dDrillPenalty > B2.Box:getCenter():getX() + return ( B1.Box:getMax():getX() + dDrillPenalty > B2.Box:getCenter():getX()) end -- se entrambi fori con posizione praticamente uguale ordino secondo diametro e faccia di inizio (Fcs) if B1.Prc == 40 and B2.Prc == 40 and abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < dSmallDrillRange then if abs( B1.Diam - B2.Diam) < 1.0 then if B1.Fcs == B2.Fcs then - return B1.Box:getCenter():getX() > B2.Box:getCenter():getX() + if abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < 1.0 then + if abs( B1.Box:getCenter():getY() - B2.Box:getCenter():getY()) < 1.0 then + if abs( B1.Box:getCenter():getZ() - B2.Box:getCenter():getZ()) < 1.0 then + return ( B1.Id < B2.Id) + else + return ( B1.Box:getCenter():getZ() > B2.Box:getCenter():getZ()) + end + else + return ( B1.Box:getCenter():getY() > B2.Box:getCenter():getY()) + end + else + return ( B1.Box:getCenter():getX() > B2.Box:getCenter():getX()) + end else - return B1.Fcs > B2.Fcs + return ( B1.Fcs > B2.Fcs) end else return ( B1.Diam > B2.Diam) @@ -538,6 +571,25 @@ local function OrderFeatures( vProc, b3Raw) end end + -- test della funzione di ordinamento + if EgtGetDebugLevel() >= 3 then + EgtOutLog( ' CompareFeatures Test ') + local bCompTest = true + for i = 1, #vProc do + for j = i + 1, #vProc do + local bComp1 = CompareFeatures( vProc[i], vProc[j]) + local bComp2 = CompareFeatures( vProc[j], vProc[i]) + if bComp1 == bComp2 then + bCompTest = false + EgtOutLog( string.format( ' ProcId : %d vs %d --> ERROR', vProc[i].Id, vProc[j].Id)) + end + end + end + if bCompTest then + EgtOutLog( ' ALL OK') + end + end + -- eseguo ordinamento table.sort( vProc, CompareFeatures) @@ -812,24 +864,6 @@ local function ClassifyFeatures( vProc, b3Raw, Stats) return bAllOk, bSomeDown, bSomeSide, bSplitRot end -------------------------------------------------------------------------------------------------------------- -local function PrintFeatures( vProc, b3Raw) - EgtOutLog( ' RawBox=' .. tostring( b3Raw)) - for i = 1, #vProc do - local Proc = vProc[i] - local sOut = string.format( ' Id=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Down=%s Side=%s Head=%s Tail=%s Fcse=%1d,%1d Diam=%.2f Fct=%2d Box=%s', - Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId, - Proc.Flg, EgtIf( Proc.Down, 'T', 'F'), EgtIf( Proc.Side, 'T', 'F'), EgtIf( Proc.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', 'F'), - Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, tostring( Proc.Box)) - -- info speciali per Block Haus Half Lap - if Proc.Prc == 37 then - local sSpec = string.format( ' N=%s Hd=%s', tostring( Proc.vtN or V_NULL()), EgtIf( Proc.HeadDir, 'T', 'F')) - sOut = sOut .. sSpec - end - EgtOutLog( sOut) - end -end - ------------------------------------------------------------------------------------------------------------- local function AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, bNeedHCut, b3Raw) local bOk = true diff --git a/LuaLibs/DiceCut.lua b/LuaLibs/DiceCut.lua index 82bd6a9..1b4130f 100644 --- a/LuaLibs/DiceCut.lua +++ b/LuaLibs/DiceCut.lua @@ -626,7 +626,7 @@ local function DiceCutTest() CutTable = DiceCut.GetDice( nParent, BBoxRawPart, ptC1, vtN1, false, TabPlanesFeatures[2].ptC, TabPlanesFeatures[2].vtN) end - if EgtGetDebugLevel() > 1 then + if EgtGetDebugLevel() >= 3 then DiceCut.PrintOrderCut( CutTable) end