Prima versione funzionante scelta soluzioni che contempla le pre-rotazioni

This commit is contained in:
andrea.villa
2024-11-06 17:31:38 +01:00
parent 21dd75b4a6
commit 23bbd938fc
+52 -11
View File
@@ -926,10 +926,20 @@ end
-------------------------------------------------------------------------------------------------------------
-- funzione che controlla validità delle combinazioni proposte
local function IsCombinationAvailable( sCombination, nUnloadPos, bSquareSection)
-- se non utilizzo BEAMWALL, forzo comportamento BASIC
if not BEAM.BeamWall or not BEAM.Rotation then
BEAM.Rotation = {}
BEAM.Rotation.Basic = true
end
-- TODO scelta combinazione forzato DA RIMUOVERE!! Serve modifica al BEAM.
BEAM.BeamWall = true
BEAM.Rotation = {}
BEAM.Rotation.bBasic = true
BEAM.Rotation.bNoRotation = false
BEAM.Rotation.bAdvanced = false
-- BASIC : posizione di scarico come posizionamento iniziale
if not BEAM.BeamWall or BEAM.Rotation.bBasic then
@@ -975,13 +985,6 @@ local function IsCombinationAvailable( sCombination, nUnloadPos, bSquareSection)
end
end
end
else
-- forzo comportamento BASIC
if not BEAM.Rotation then
BEAM.Rotation = {}
end
BEAM.Rotation.Basic = true
return IsCombinationAvailable( sCombination, nUnloadPos)
end
end
@@ -1010,6 +1013,9 @@ local function GetBestCombination( ListToCompare)
-- scelgo soluzione con meno rotazioni
if ListToCompare[nIndexBestCombination].nRotations > ListToCompare[ListIndex].nRotations then
nIndexBestCombination = ListIndex
-- se anche le rotazioni sono le stesse, prendo la soluzione con più lavorazioni alla fine
elseif #ListToCompare[nIndexBestCombination].Rot0 < #ListToCompare[ListIndex].Rot0 then
nIndexBestCombination = ListIndex
end
-- se voto diverso
else
@@ -1174,7 +1180,7 @@ local function GetBestResultFromCombinationsMatrix( ProcessingsOnPart, PartInfo)
-- TODO funzione da sviluppare completamente
local BestCombination = {}
local CombinationsList = {}
local bSquareSection = ( PartInfo.dWidth - PartInfo.dHeight) < 100 * GEO.EPS_SMALL
local bSquareSection = abs( PartInfo.dWidth - PartInfo.dHeight) < 100 * GEO.EPS_SMALL
-- scrittura nel log della matrice delle rotazioni
if EgtGetDebugLevel() >= 3 then
@@ -1183,10 +1189,11 @@ local function GetBestResultFromCombinationsMatrix( ProcessingsOnPart, PartInfo)
-- per ogni posizione di scarico
for nUnloadPos = 1, 4 do
-- verifico tutte le combinazioni che ripettano lo scarico come desiderato
-- verifico tutte le combinazioni che possono essere considerate
for i = 1, BeamLib.BinaryToDecimal( 1111) do
local nBitIndexCombination = BeamLib.DecimalToBinary( i)
local sBitIndexCombination = BeamLib.CalculateStringBinaryFormat( nBitIndexCombination, 4)
-- TODO si potrebbero calcolare le combinazioni all'inizio, e ottimizzare facendo la collect solo nelle rotazioni che possono essere considerate
if IsCombinationAvailable( sBitIndexCombination, nUnloadPos, bSquareSection) then
local bRot90, bRot180
local SingleCombination = {}
@@ -1325,8 +1332,6 @@ function BeamExec.ProcessMachinings( PROCESSINGS, PARTS)
-- ordino le lavorazioni
-- MACHININGS = OrderMachining( MACHININGS, PARTS[nPart])
-- TODO se la posizione di partenza cambia, devo ruotare il pezzo!
-- aggiungo la fase, se non è la prima
if nOrd == 1 then
EgtSetCurrPhase( 1)
@@ -1403,6 +1408,42 @@ function BeamExec.ProcessMachinings( PROCESSINGS, PARTS)
end
end
-- ruoto il pezzo in caso la soluzione scelta sia con prerotazione
if nInitialPosition == 1 then
; -- il pezzo è già in posizione
elseif nInitialPosition == 2 then
local dDeltaYZ = EgtGetRawPartBBox( PARTS[nPart].idRaw):getDimY() - EgtGetRawPartBBox( PARTS[nPart].idRaw):getDimZ()
local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2)
local bPreMove = dDeltaYZ < 0
-- ruoto le travi della fase corrente
local nRId = PARTS[nPart].idRaw
while nRId do
if bPreMove then EgtMoveRawPart( nRId, vtMove) end
EgtRotateRawPart( nRId, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90))
if not bPreMove then EgtMoveRawPart( nRId, vtMove) end
nRId = EgtGetNextRawPart( nRId)
end
elseif nInitialPosition == 3 then
-- ribalto le travi della fase corrente
local nRId = PARTS[nPart].idRaw
while nRId do
EgtRotateRawPart( nRId, X_AX(), 180)
nRId = EgtGetNextRawPart( nRId)
end
elseif nInitialPosition == 4 then
local dDeltaYZ = EgtGetRawPartBBox( PARTS[nPart].idRaw):getDimY() - EgtGetRawPartBBox( PARTS[nPart].idRaw):getDimZ()
local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2)
local bPreMove = dDeltaYZ < 0
-- ruoto le travi della fase corrente
local nRId = PARTS[nPart].idRaw
while nRId do
if bPreMove then EgtMoveRawPart( nRId, vtMove) end
EgtRotateRawPart( nRId, X_AX(), EgtIf( BeamData.RIGHT_LOAD, 90, -90))
if not bPreMove then EgtMoveRawPart( nRId, vtMove) end
nRId = EgtGetNextRawPart( nRId)
end
end
-- aggiunta lavorazioni in ultima fase
MachiningLib.AddOperations( MACHININGS, PARTS[nPart], 'STD')