From fc47bca0f1fee150632d366cd850776ca011d8cc Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 13 May 2026 11:47:25 +0200 Subject: [PATCH] - in NestProcess prime modifiche per nesting obliquo (da completare) - in BeamExec test BEAM.INFONGEPART per scrittura note pezzo in nge tramite Aedifica - in BeamLib aggiunta funzione RotateTableFromIndex per reindicizzare una tabella passata --- LuaLibs/BeamExec.lua | 12 ++++++ LuaLibs/BeamLib.lua | 12 ++++++ NestProcess.lua | 91 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 114 insertions(+), 1 deletion(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 72e6ac8..7f53c01 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -2446,6 +2446,18 @@ function BeamExec.ProcessAlternatives( PARTS) end + + + + -- TEST + BEAM.INFONGEPART = 'TEST=666,999,666,999' + -- TEST + + + + + + -- si cancella eventuale mach group creato per le alternative EgtRemoveMachGroup( nTempMachGroupName) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index b9f7033..d9fe22a 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -889,6 +889,18 @@ function BeamLib.CalculateStringBinaryFormat( dNumber, CharNumber) return NumberString end +------------------------------------------------------------------------------------------------------------- +-- reindicizza una tabella passata ripartendo dall'indice nStartIndex e mantenendo l'ordine +function BeamLib.RotateTableFromIndex( Table, nStartIndex) + local RotatedTable = {} + + for i = 1, #Table do + RotatedTable[#RotatedTable + 1] = Table[((RotatedTable + i - 2) % #Table) + 1] + end + + return RotatedTable +end + ------------------------------------------------------------------------------------------------------------- --- copia una tabella lua in modo ricorsivo, ossia mantiene indipendenti anche tutte le sottotabelle --- ATTENZIONE: in caso di modifiche vanno gestiti anche i tipi custom; sarebbe meglio metterla nel LuaLibs diff --git a/NestProcess.lua b/NestProcess.lua index 49a325f..1a8a075 100644 --- a/NestProcess.lua +++ b/NestProcess.lua @@ -4,4 +4,93 @@ -- Intestazioni require( 'EgtBase') _ENV = EgtProtectGlobal() -EgtEnableDebug( false) \ No newline at end of file +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() \ No newline at end of file