fc47bca0f1
- in BeamExec test BEAM.INFONGEPART per scrittura note pezzo in nge tramite Aedifica - in BeamLib aggiunta funzione RotateTableFromIndex per reindicizzare una tabella passata
96 lines
2.9 KiB
Lua
96 lines
2.9 KiB
Lua
-- BeamNestProcess.lua by Egalware s.r.l. 2026/05/11
|
|
-- Gestione nesting automatico travi anche oblique
|
|
|
|
-- Intestazioni
|
|
require( 'EgtBase')
|
|
_ENV = EgtProtectGlobal()
|
|
EgtEnableDebug( true)
|
|
|
|
-- Include
|
|
local BeamLib = require( 'BeamLib')
|
|
|
|
----------------------------------------------------------------------------------------------------------
|
|
-- stati che definiscono rotazione / inversione della parte
|
|
local STATE = {
|
|
STD = 1, -- Standard
|
|
ROT180 = 2, -- Rotazione 180deg attorno a X+
|
|
INV = 3, -- Inversione (rotazione 180deg attorno a Z+)
|
|
INV_ROT180 = 4 -- Inversione + rotazione
|
|
}
|
|
|
|
----------------------------------------------------------------------------------------------------------
|
|
-- inventario grezzi
|
|
local RawInventory = {
|
|
Stock = {},
|
|
ActiveBeams = {}
|
|
}
|
|
|
|
function RawInventory:BuildStock()
|
|
if #LEN ~= #QTY then
|
|
error( 'NestProcess: invalid stock data')
|
|
end
|
|
|
|
for i = 1, #LEN do
|
|
self.Stock[#self.Stock + 1] = {
|
|
Length = LEN[i],
|
|
Count = QTY[i]
|
|
}
|
|
end
|
|
|
|
return RawInventory
|
|
end
|
|
|
|
function RawInventory:AddActiveBeam()
|
|
-- TODO da fare
|
|
end
|
|
|
|
----------------------------------------------------------------------------------------------------------
|
|
-- PartTemplates (informazioni geometriche pezzi univoci) e JobPool (lista di tutti i singoli pezzi, multipli compresi, da nestare)
|
|
local PartTemplates = {}
|
|
local JobPool = {}
|
|
|
|
function PartTemplates:AddPart( id)
|
|
PartTemplates[id] = {}
|
|
PartTemplates[id].dLength = EgtGetInfo( id, 'L', 'd')
|
|
-- TODO qua gli stati abilitati dovranno arrivare dalle alternatives
|
|
local VerticesHead = EgtSplitString( EgtGetInfo( id, 'HEADOFFSETX', 'd'))
|
|
local vtNHead = Vector3d( EgtSplitString( EgtGetInfo( id, 'HEADVTN', 'd')))
|
|
local VerticesTail = EgtSplitString( EgtGetInfo( id, 'TAILOFFSETX', 'd'))
|
|
local vtNTail = Vector3d( EgtSplitString( EgtGetInfo( id, 'TAILVTN', 'd')))
|
|
PartTemplates[id].States = {
|
|
[STATE.STD] = {
|
|
Head = { Vertices = VerticesHead, vtN = vtNHead},
|
|
Tail = { Vertices = VerticesTail, vtN = vtNTail}
|
|
},
|
|
[STATE.ROT180] = {
|
|
Head = { Vertices = BeamLib.RotateTableFromIndex( VerticesHead, 3), vtN = vtNHead},
|
|
Tail = { Vertices = BeamLib.RotateTableFromIndex( VerticesTail, 3), vtN = vtNHead}
|
|
},
|
|
[STATE.INV] = {
|
|
Head = { Vertices = VerticesTail, vtN = vtNTail},
|
|
Tail = { Vertices = VerticesHead, vtN = vtNHead}
|
|
},
|
|
[STATE.INV_ROT180] = {
|
|
Head = { Vertices = BeamLib.RotateTableFromIndex( VerticesTail, 3), vtN = vtNHead},
|
|
Tail = { Vertices = BeamLib.RotateTableFromIndex( VerticesHead, 3), vtN = vtNHead}
|
|
}
|
|
}
|
|
end
|
|
|
|
-- creazione combinata (si cicla una sola volta) di entrambe le tabelle
|
|
local function BuildPartTemplatesAndJobPool()
|
|
for id, nCount in pairs( PART) do
|
|
PartTemplates:AddPart( id)
|
|
end
|
|
|
|
return PartTemplates, JobPool
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RawInventory:BuildStock()
|
|
BuildPartTemplatesAndJobPool() |