- in NestProcess agiunto sorting della JobPool
This commit is contained in:
@@ -147,6 +147,25 @@ function PartTemplates:AddPart( id)
|
||||
end
|
||||
end
|
||||
|
||||
-- ordinamento JobPool per lunghezza decrescente dei pezzi
|
||||
function JobPool:Sort()
|
||||
local function SortByLengthDescending( Part1, Part2)
|
||||
local dLength1 = PartTemplates[Part1.id].dLength
|
||||
local dLength2 = PartTemplates[Part2.id].dLength
|
||||
|
||||
if dLength1 > dLength2 + 10 * GEO.EPS_SMALL then
|
||||
return true
|
||||
elseif dLength2 > dLength1 + 10 * GEO.EPS_SMALL then
|
||||
return false
|
||||
end
|
||||
|
||||
-- tie breaker
|
||||
return Part1.id < Part2.id
|
||||
end
|
||||
|
||||
table.sort( self, SortByLengthDescending)
|
||||
end
|
||||
|
||||
-- creazione combinata (si cicla una sola volta) di entrambe le tabelle
|
||||
local function BuildPartTemplatesAndJobPool()
|
||||
for id, nCount in pairs( PART) do
|
||||
@@ -175,6 +194,9 @@ RawInventory:BuildStock()
|
||||
-- costruzione lista pezzi template con proprietà geometriche e lista pezzi fisici da nestare
|
||||
BuildPartTemplatesAndJobPool()
|
||||
|
||||
-- ordinamento pezzi per lunghezza decrescente
|
||||
JobPool:Sort()
|
||||
|
||||
-- loop principale: scorre le barre, sia già attive che a stock, e le riempie nel modo migliore possibile
|
||||
-- per ogni giro sceglie la soluzione con punteggio più alto
|
||||
while true do
|
||||
|
||||
Reference in New Issue
Block a user