DataBeam :

- aggiunta gestione rotazioni di 90gradi (abilitata da BD.ROT90 e compatibilmente con sezione)
- migliorato ordinamento fori
- migliorata classificazione Contorni Liberi.
This commit is contained in:
Dario Sassi
2020-05-19 15:40:07 +00:00
parent c7411fe35d
commit 1c7db5d845
6 changed files with 188 additions and 64 deletions
+136 -35
View File
@@ -1,14 +1,16 @@
-- BeamExec.lua by Egaltech s.r.l. 2020/04/23
-- BeamExec.lua by Egaltech s.r.l. 2020/05/19
-- 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.
-- 2019/09/25 Aggiunta gestione StepJoint e StepJointNotch
-- 2020/01/21 Aggiunta gestione ScarfJoint
-- 2020/02/10 Aggiunta gestione FrenchRidgeLap
-- 2020/02/11 Aggiunta gestione BlockHausFront
-- 2019/09/25 Aggiunta gestione StepJoint e StepJointNotch.
-- 2020/01/21 Aggiunta gestione ScarfJoint.
-- 2020/02/10 Aggiunta gestione FrenchRidgeLap.
-- 2020/02/11 Aggiunta gestione BlockHausFront.
-- 2020/04/02 Fori di testa dal basso non danno errore e fanno ribaltare la trave.
-- 2020/04/07 Aggiunta gestione TyroleanDovetail
-- 2020/04/14 Aggiunta gestione Dovetail
-- 2020/04/07 Aggiunta gestione TyroleanDovetail.
-- 2020/04/14 Aggiunta gestione Dovetail.
-- 2020/05/16 Migliorie ordinamento fori.
-- 2020/05/16 Gestione rotazione di 90deg.
-- Tabella per definizione modulo
local BeamExec = {}
@@ -110,7 +112,7 @@ EgtMdbSave()
-------------------------------------------------------------------------------------------------------------
function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam)
-- Determinazione minimo grezzo scaricabile
-- Determinazione minimo grezzo scaricabile
BeamExec.CalcMinUnloadableRaw( dRawW, dRawH)
-- Creazione nuovo gruppo di lavoro
@@ -230,6 +232,17 @@ end
-------------------------------------------------------------------------------------------------------------
-- *** Inserimento delle lavorazioni nelle travi ***
-------------------------------------------------------------------------------------------------------------
local function Verify90DegRotation( nRawId)
if not nRawId then return false end
-- dimensioni sezione trave in posizione normale (rotazione 0°)
local dRawW = EgtGetRawPartBBox( nRawId):getDimY()
local dRawH = EgtGetRawPartBBox( nRawId):getDimZ()
-- verifica dell'altezza rispetto alla massima larghezza
return ( dRawH < BD.MAX_WIDTH + 10 * GEO.EPS_SMALL and dRawW < BD.MAX_HEIGHT + 10 * GEO.EPS_SMALL) or
( dRawH < BD.MAX_WIDTH2 + 10 * GEO.EPS_SMALL and dRawW < BD.MAX_HEIGHT2 + 10 * GEO.EPS_SMALL)
end
-------------------------------------------------------------------------------------------------------------
local function IsHeadFeature( Proc, b3Raw, dCurrOvmH)
-- feature sempre di testa o coda per il gruppo
@@ -373,6 +386,8 @@ end
-------------------------------------------------------------------------------------------------------------
local function OrderFeatures( vProc, b3Raw)
local dSmallDrillRange = EgtIf( b3Raw:getDimX() < BD.LEN_SHORT_PART, 150, 250)
-- 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)
@@ -384,6 +399,10 @@ local function OrderFeatures( vProc, b3Raw)
if Hcut.Identify( B2) then
return false
end
-- se uno di testa e non l'altro, privilegio quello di testa
if B1.Head ~= B2.Head then
return B1.Head
end
-- se primo è feature di coda e l'altro è separazione o non è feature di coda
if B1.Tail and ( Split.Identify( B2) or not B2.Tail) then
return false
@@ -415,14 +434,14 @@ 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() > B2.Box:getMax():getX() + 100
return B1.Box:getCenter():getX() - 100 > B2.Box:getMax():getX()
end
-- se secondo è foro e l'altro no, lo penalizzo
if B2.Prc == 40 and B1.Prc ~= 40 then
-- se primo è altro e secondo è foro, lo premio
if B1.Prc ~= 40 and B2.Prc == 40 then
return B1.Box:getMax():getX() + 100 > B2.Box:getCenter():getX()
end
-- se sono fori e hanno 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()) < 600 then
-- 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()
@@ -438,10 +457,6 @@ local function OrderFeatures( vProc, b3Raw)
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 ( B1.Prc == 50 and B2.Prc == 52)
end
-- se uno di testa e non l'altro, privilegio questo
if B1.Head ~= B2.Head then
return B1.Head
end
-- 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()
@@ -458,7 +473,7 @@ local function OrderFeatures( vProc, b3Raw)
table.sort( vProc, CompareFeatures)
-- riunisco fori con lo stesso diametro e non troppo lontani
local dDrillRange = EgtIf( BD.GO_FAST == 2, 6000, 600)
local dDrillRange = EgtIf( BD.GO_FAST == 2, 6000, EgtIf( b3Raw:getDimX() < BD.LEN_SHORT_PART, 200, 600))
for i = 1, #vProc do
local ProcI = vProc[i]
if ProcI.Prc == 40 then
@@ -468,11 +483,10 @@ local function OrderFeatures( vProc, b3Raw)
abs( ProcJ.Diam - ProcI.Diam) < 1.0 and abs( ProcJ.Box:getCenter():getX() - ProcI.Box:getCenter():getX()) < dDrillRange then
if j > i + 1 then
local ProcK = vProc[i+1]
if ProcK.Prc ~= 40 or abs( ProcK.Diam - ProcJ.Diam) > 1.0 or ProcJ.Box:getCenter():getX() < ProcK.Box:getCenter():getX() then
if ProcK.Prc ~= 40 or abs( ProcK.Diam - ProcJ.Diam) > 1.0 then
table.insert( vProc, i + 1, table.remove( vProc, j))
end
end
break
end
end
end
@@ -501,6 +515,7 @@ end
local function ClassifyFeatures( vProc, b3Raw, Stats)
local bAllOk = true
local bSomeDown = false
local bSomeSide = false
local bSplitRot = false
local nHeading
local nSplitting
@@ -508,7 +523,8 @@ local function ClassifyFeatures( vProc, b3Raw, Stats)
local Proc = vProc[i]
local bOk = true
local bDown = false
local bDownOnHeadOk = false
local bSide = false
local bDownSideOnHeadOk = false
-- se intestatura
if Hcut.Identify( Proc) then
nHeading = i
@@ -539,8 +555,8 @@ local function ClassifyFeatures( vProc, b3Raw, Stats)
bOk, bDown = LapJoint.Classify( Proc, b3Raw)
-- se foratura
elseif Drill.Identify( Proc) then
bOk, bDown = Drill.Classify( Proc, b3Raw)
bDownOnHeadOk = true
bOk, bDown, bSide = Drill.Classify( Proc, b3Raw)
bDownSideOnHeadOk = true
-- se tenone
elseif Tenon.Identify( Proc) then
bOk, bDown = Tenon.Classify( Proc, b3Raw)
@@ -588,15 +604,15 @@ local function ClassifyFeatures( vProc, b3Raw, Stats)
bOk, bDown = Dovetail.Classify( Proc, b3Raw)
-- se contorno libero
elseif FreeContour.Identify( Proc) then
bOk, bDown = FreeContour.Classify( Proc, b3Raw)
bOk, bDown, bSide = FreeContour.Classify( Proc, b3Raw)
-- se decorazione
elseif Decor.Identify( Proc) then
bOk, bDown = Decor.Classify( Proc)
end
-- assegno risultato
if bOk then
-- non ammessa feature di testa da lavorare ribaltata
if Proc.Head and bDown and not bDownOnHeadOk then
-- non ammessa feature di testa da lavorare ribaltata o ruotata
if Proc.Head and ( bDown or bSide) and not bDownSideOnHeadOk then
Proc.Flg = 0
Proc.Down = true
bAllOk = false
@@ -606,10 +622,17 @@ local function ClassifyFeatures( vProc, b3Raw, Stats)
Proc.Down = true
bSomeDown = true
bSplitRot = true
-- gestione feature di coda da lavorare ruotata
elseif Proc.Tail and bSide then
Proc.Side = true
bSomeSide = true
bSplitRot = true
-- caso normale
else
Proc.Down = bDown
Proc.Side = bSide
if bDown then bSomeDown = true end
if bSide then bSomeSide = true end
end
else
Proc.Flg = 0
@@ -620,12 +643,17 @@ local function ClassifyFeatures( vProc, b3Raw, Stats)
-- se necessario ribaltamento, assegno intestatura alla fase ribaltata
if bSomeDown and nHeading then
vProc[nHeading].Down = true
-- se altrimenti necessaria rotazione (senza ribaltamento), assegno intestatura alla fase ribaltata (creata ad hoc)
elseif bSomeSide and nHeading then
vProc[nHeading].Down = true
bSomeDown = true
end
-- se necessaria rotazione del ribaltato, assegno separazione alla fase ribaltata
if bSplitRot then
-- se necessaria separazione del ribaltato o ruotato, la assegno sempre alla fase ribaltata
if bSplitRot and nSplitting then
vProc[nSplitting].Down = true
bSomeDown = true
end
return bAllOk, bSomeDown, bSplitRot
return bAllOk, bSomeDown, bSomeSide, bSplitRot
end
-------------------------------------------------------------------------------------------------------------
@@ -633,9 +661,9 @@ local function PrintFeatures( vProc, b3Raw)
EgtOutLog( ' RawBox=' .. tostring( b3Raw))
for i = 1, #vProc do
local Proc = vProc[i]
local sOut = string.format( ' Proc=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Down=%s Head=%s Tail=%s Fcse=%1d,%1d Diam=%.2f Fct=%2d Box=%s',
local sOut = string.format( ' Proc=%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.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', 'F'),
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))
EgtOutLog( sOut)
end
@@ -801,6 +829,9 @@ end
-------------------------------------------------------------------------------------------------------------
function BeamExec.ProcessFeatures()
-- verifica se possibile rotazione di 90 gradi
BD.ROT90 = BD.ROT90 and Verify90DegRotation( EgtGetFirstRawPart())
-- ciclo sui pezzi
local nTotErr = 0
local Stats = {}
local nOrd = 1
@@ -828,7 +859,7 @@ function BeamExec.ProcessFeatures()
-- le ordino lungo X
OrderFeatures( vProc, b3Raw)
-- le classifico
local bAllOk, bSomeDown, bSplitRot = ClassifyFeatures( vProc, b3Raw, Stats)
local bAllOk, bSomeDown, bSomeSide, bSplitRot = ClassifyFeatures( vProc, b3Raw, Stats)
if not bAllOk then
nTotErr = nTotErr + 1
end
@@ -836,8 +867,8 @@ function BeamExec.ProcessFeatures()
if EgtGetDebugLevel() >= 1 then
PrintFeatures( vProc, b3Raw)
end
-- se richiesto ribaltamento
if bSomeDown then
-- se richiesto ribaltamento (oppure rotazione)
if bSomeDown or bSomeSide then
-- ribalto le travi della fase corrente
local nRId = nRawId
while nRId do
@@ -880,6 +911,76 @@ function BeamExec.ProcessFeatures()
if not bSplitRot then
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, 0)
-- altrimenti
else
---- se l'ultima fase è senza lavorazioni, la elimino
--local nLastOpeType = EgtGetOperationType( EgtGetLastOperation() or GDB_ID.NULL)
--if nLastOpeType == MCH_OY.DISP then
-- EgtRemoveLastPhase()
--end
-- aggiungo nuova fase con le travi in posizione standard
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, BD.RAW_OFFSET)
-- se grezzo successivo senza pezzi e finale, va tolto
local nNextRawId = EgtGetNextRawPart( nRawId)
if nNextRawId and EgtGetPartInRawPartCount( nNextRawId) == 0 and EgtGetRawPartBBox( nNextRawId):getDimX() < BD.MinRaw then
EgtRemoveRawPartFromCurrPhase( nNextRawId)
end
end
nPhase = EgtGetCurrPhase()
nDispId = EgtGetPhaseDisposition( nPhase)
local nType = 'MID'
if bSplitRot then nType = EgtIf( bSomeSide, 'MID2', 'END2') end
EgtSetInfo( nDispId, 'TYPE', nType)
EgtSetInfo( nDispId, 'ORD', nOrd)
end
-- se richiesta rotazione
if bSomeSide then
-- vettore movimento grezzi per rotazione di 90deg
local dDeltaYZ = EgtGetRawPartBBox( nRawId):getDimY() - EgtGetRawPartBBox( nRawId):getDimZ()
local vtMove = Vector3d( 0, dDeltaYZ / 2, dDeltaYZ / 2)
-- ruoto le travi della fase corrente
local nRId = nRawId
while nRId do
EgtMoveRawPart( nRId, vtMove)
EgtRotateRawPart( nRId, X_AX(), 90)
nRId = EgtGetNextRawPart( nRId)
end
EgtSetInfo( nDispId, 'ROT', -1)
-- inserisco le lavorazioni da lavorare ruotate
for i = 1, #vProc do
-- creo la lavorazione
local Proc = vProc[i]
if Proc.Flg ~= 0 and Proc.Side then
local bOk, sMsg, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
if not bOk then
nTotErr = nTotErr + 1
table.insert( Stats, {Err=1, Msg=sMsg, Rot=-2, CutId=Proc.CutId, TaskId=Proc.TaskId})
elseif sMsg and #sMsg > 0 then
table.insert( Stats, {Err=-1, Msg=sMsg, Rot=-2, CutId=Proc.CutId, TaskId=Proc.TaskId})
else
table.insert( Stats, {Err=0, Msg='', Rot=-2, CutId=Proc.CutId, TaskId=Proc.TaskId})
end
-- se era taglio di separazione, aggiungo nuova fase
if bNewPhase then
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, BD.RAW_OFFSET)
EgtMoveRawPart( nRawId, vtMove)
EgtRotateRawPart( nRawId, X_AX(), 90)
-- se grezzo successivo senza pezzi e finale, va tolto
local nNextRawId = EgtGetNextRawPart( nRawId)
if nNextRawId and EgtGetPartInRawPartCount( nNextRawId) == 0 and EgtGetRawPartBBox( nNextRawId):getDimX() < BD.MinRaw then
EgtRemoveRawPartFromCurrPhase( nNextRawId)
end
nPhase = EgtGetCurrPhase()
nDispId = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( nDispId, 'TYPE', 'MID2')
EgtSetInfo( nDispId, 'ORD', nOrd)
EgtSetInfo( nDispId, 'ROT', -1)
end
end
end
-- se separazione non ancora effettuata, aggiungo nuova fase con le travi in posizione standard
if not bSplitRot then
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, 0)
-- altrimenti
else
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, BD.RAW_OFFSET)
-- se grezzo successivo senza pezzi e finale, va tolto
@@ -897,7 +998,7 @@ function BeamExec.ProcessFeatures()
for i = 1, #vProc do
-- creo la lavorazione
local Proc = vProc[i]
if Proc.Flg ~= 0 and not Proc.Down then
if Proc.Flg ~= 0 and not ( Proc.Down or Proc.Side) then
local bOk, sMsg, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
if not bOk then
nTotErr = nTotErr + 1