Merge branch 'FlipRot' into develop

This commit is contained in:
luca.mazzoleni
2026-04-01 11:41:42 +02:00
2 changed files with 40 additions and 16 deletions
+5
View File
@@ -146,6 +146,11 @@ local function MyProcessFeatures()
BeamExec.GetProcessings( PARTS, true)
BeamExec.GetCombinationMatrix( PARTS, true)
BeamExec.ProcessMachinings( PARTS)
-- scrittura variabili globali per interfaccia
BEAM.PREROTATE90 = PARTS[1].nInitialPosition - 1
BEAM.PREINVERT = EgtIf( PARTS[1].bPartInCombiIsInverted, 1, 0)
local nErrCnt = 0
local nWarnCnt = 0
local sOutput = ''
+35 -16
View File
@@ -1297,7 +1297,7 @@ local function GetBestCombination( ListToCompare, Part)
-- scelgo soluzione senza rotazioni
if ListToCompare[ListIndex].nRotations == 0 then
-- scelgo soluzione con voto più alto
if ListToCompare[nIndexBestCombination].dTotalRating < ListToCompare[ListIndex].dTotalRating then
if ListToCompare[nIndexBestCombination].dTotalRating + 10 * GEO.EPS_SMALL < ListToCompare[ListIndex].dTotalRating then
nIndexBestCombination = ListIndex
end
end
@@ -1328,7 +1328,7 @@ local function GetBestCombination( ListToCompare, Part)
nIndexBestCombination = ListIndex
elseif ListToCompare[ListIndex].nComplete == ListToCompare[nIndexBestCombination].nComplete then
-- scelgo soluzione con voto più alto
if ListToCompare[nIndexBestCombination].dTotalRating < ListToCompare[ListIndex].dTotalRating then
if ListToCompare[nIndexBestCombination].dTotalRating + 10 * GEO.EPS_SMALL < ListToCompare[ListIndex].dTotalRating then
nIndexBestCombination = ListIndex
end
end
@@ -1343,10 +1343,10 @@ local function GetBestCombination( ListToCompare, Part)
local dOtherTotalRating = ListToCompare[ListIndex].dTotalRating
-- scelgo soluzione con voto più alto
if dBestTotalRating < dOtherTotalRating then
if dBestTotalRating + 10 * GEO.EPS_SMALL < dOtherTotalRating then
nIndexBestCombination = ListIndex
-- se stesso voto
elseif dBestTotalRating == dOtherTotalRating then
elseif abs( dBestTotalRating - dOtherTotalRating) < 10 * GEO.EPS_SMALL then
-- scelgo soluzione con meno rotazioni
if ListToCompare[nIndexBestCombination].nRotations > ListToCompare[ListIndex].nRotations then
nIndexBestCombination = ListIndex
@@ -1927,6 +1927,11 @@ end
-------------------------------------------------------------------------------------------------------------
function BeamExec.ProcessAlternatives( PARTS)
-- inizializzazione variabili globali per interfaccia
BEAM.ALTERNATIVESNEST2D = ''
BEAM.ALTERNATIVES = ''
-- ciclo sui pezzi
local BestCombination = {}
local nPart = 1
@@ -1935,7 +1940,7 @@ function BeamExec.ProcessAlternatives( PARTS)
local bTryToReProcess = false
-- se non serve trovare altre soluzioni, si esce subito
if not ( PARTS[nPart].GeneralParameters.GEN_bTestAlternative and not PARTS[nPart].bSquareSection) or not PARTS[nPart].GeneralParameters.GEN_bGetAlternativesNesting2D then
if not ( PARTS[nPart].GeneralParameters.GEN_bTestAlternative and not PARTS[nPart].bSquareSection) and not PARTS[nPart].GeneralParameters.GEN_bGetAlternativesNesting2D then
return
end
@@ -1982,33 +1987,33 @@ function BeamExec.ProcessAlternatives( PARTS)
if PARTS[nPart].GeneralParameters.GEN_bGetAlternativesNesting2D then
-- POSIZIONE 0 (e invertito)
local sCombinationToCheck = BeamLib.StringReplaceChar( '0000', PARTS[nPart].nInitialPosition, "1")
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck}})
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck}, bIsNesting2D = true})
if PARTS[nPart].GeneralParameters.GEN_bAllowPieceInversion then
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck, bPartInCombiIsInverted = true}})
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck, bPartInCombiIsInverted = true}, bIsNesting2D = true})
end
-- POSIZIONE 180 (e invertito)
if PARTS[nPart].GeneralParameters.GEN_sPiecesLoadingPosition == 'STD_PRE_ROTATION' then
local nOtherPosition = EgtIf( PARTS[nPart].nInitialPosition + 2 > 4, PARTS[nPart].nInitialPosition + 2 - 4, PARTS[nPart].nInitialPosition + 2)
sCombinationToCheck = BeamLib.StringReplaceChar( '0000', nOtherPosition, "1")
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck}})
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck}, bIsNesting2D = true})
if PARTS[nPart].GeneralParameters.GEN_bAllowPieceInversion then
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck, bPartInCombiIsInverted = true}})
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck, bPartInCombiIsInverted = true}, bIsNesting2D = true})
end
end
-- POSIZIONE 90/270 (e invertito)
if PARTS[nPart].GeneralParameters.GEN_sPiecesLoadingPosition == 'FULL_PRE_ROTATION' then
local nOtherPosition = EgtIf( PARTS[nPart].nInitialPosition + 1 > 4, PARTS[nPart].nInitialPosition + 1 - 4, PARTS[nPart].nInitialPosition + 1)
sCombinationToCheck = BeamLib.StringReplaceChar( '0000', nOtherPosition, "1")
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck}})
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck}, bIsNesting2D = true})
if PARTS[nPart].GeneralParameters.GEN_bAllowPieceInversion then
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck, bPartInCombiIsInverted = true}})
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck, bPartInCombiIsInverted = true}, bIsNesting2D = true})
end
nOtherPosition = EgtIf( PARTS[nPart].nInitialPosition + 3 > 4, PARTS[nPart].nInitialPosition + 3 - 4, PARTS[nPart].nInitialPosition + 3)
sCombinationToCheck = BeamLib.StringReplaceChar( '0000', nOtherPosition, "1")
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck}})
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck}, bIsNesting2D = true})
if PARTS[nPart].GeneralParameters.GEN_bAllowPieceInversion then
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck, bPartInCombiIsInverted = true}})
table.insert( TotalCombiToTest, {{ sBitIndexCombination = sCombinationToCheck, bPartInCombiIsInverted = true}, bIsNesting2D = true})
end
end
end
@@ -2035,6 +2040,7 @@ function BeamExec.ProcessAlternatives( PARTS)
BestCombination = GetBestCombination( CombinationListFromMatrix, PARTS[nPart])
-- se la soluzione alternativa migliore è completa, allora la verifico, altrimenti si tiene la migliore in assoluto
if BestCombination.nNotComplete == 0 and BestCombination.nNotExecute == 0 then
PARTS[nPart].bPartInCombiIsInverted = BestCombination.bPartInCombiIsInverted
-- compilazione della vProc finale contenente le feature da lavorare nella giusta rotazione
local vProc, MatrixResult = GetProcessingListFromCombination( BestCombination)
@@ -2253,11 +2259,24 @@ function BeamExec.ProcessAlternatives( PARTS)
-- Aggiornamento finale di tutto
EgtSetCurrPhase( 1)
local bApplOk, _, _ = EgtApplyAllMachinings()
-- se non ci sono errori, soluzione alternativa valida
-- se non ci sono errori, soluzione alternativa valida: scrittura variabili globali per interfaccia
if bApplOk then
-- TODO scrivere info su pezzo!
local Alternatives = {}
local sBitIndexCombinationWithInvert = BestCombination.sBitIndexCombination .. EgtIf( BestCombination.bPartInCombiIsInverted, '_INV', '')
if TotalCombiToTest[z].bIsNesting2D then
if BEAM.ALTERNATIVESNEST2D and BEAM.ALTERNATIVESNEST2D ~= "" then
table.insert( Alternatives, BEAM.ALTERNATIVESNEST2D)
end
table.insert( Alternatives, sBitIndexCombinationWithInvert)
BEAM.ALTERNATIVESNEST2D = table.concat( Alternatives, ', ')
else
if BEAM.ALTERNATIVES and BEAM.ALTERNATIVES ~= "" then
table.insert( Alternatives, BEAM.ALTERNATIVES)
end
table.insert( Alternatives, sBitIndexCombinationWithInvert)
BEAM.ALTERNATIVES = table.concat( Alternatives, ', ')
end
end
-- se ultima combinazione, si esce e non si riporta in posizione inizale. Verrà infatti cancellata
if z == #TotalCombiToTest then break end