Files
databeamnew/StrategyLibs/BLADETOWASTE.lua
T

87 lines
2.4 KiB
Lua

-- BLADETOWASTE.lua by Egalware s.r.l. 2025/01/08
-- Libreria di supporto a strategie con funzioni comune a strategie diverse.
-- Tabella per definizione modulo
local BLADETOWASTE = {}
-- Include
require( 'EgtBase')
-- Carico i dati globali
local BeamData = require( 'BeamData')
local FeatureLib = require( 'FeatureLib')
local MachiningLib = require( 'MachiningLib')
-- strategie di base
local FaceByBlade = require('FACEBYBLADE')
EgtOutLog( ' BLADETOWASTE started', 1)
-------------------------------------------------------------------------------------------------------------
function BLADETOWASTE.Make( Proc, Part, OptionalParameters)
local Result = {}
-- parametri opzionali e default
local nToolIndex = OptionalParameters.nToolIndex
local bDropWholeWaste = OptionalParameters.bDropWholeWaste or false
local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part)
local dFeatureMaxDimension = max( Proc.b3Box:getDimX(), Proc.b3Box:getDimY())
local bIsFeatureSmall = dFeatureVolume < StrategyParameters.dMaxWasteVolume + 10 * GEO.EPS_SMALL
and dFeatureMaxDimension < StrategyParameters.dMaxWasteLength + 10 * GEO.EPS_SMALL
if Proc.nFct == 1 and ( bIsFeatureSmall or bDropWholeWaste) then
local EdgeToMachine = {}
-- ricerca utensile
if not nToolIndex then
local ToolSearchParameters = {}
for i = 1, #Proc.Faces[1].Edges do
if Proc.Faces[1].Edges[i].dElevation < EdgeToMachine.dElevation - 10 * GEO.EPS_SMALL then
EdgeToMachine = Proc.Faces[1].Edges[i]
end
end
ToolSearchParameters.dElevation = EdgeToMachine.dElevation
ToolSearchParameters.vtToolDirection = EdgeToMachine.vtN
ToolSearchParameters.bAllowTopHead = true
-- TODO bisognerà implementare anche la lama da sotto
ToolSearchParameters.bAllowBottomHead = false
ToolSearchParameters.bForceLongcutBlade = false
local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters)
nToolIndex = ToolInfo.nToolIndex
end
local Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine)
table.insert( Result, Cutting)
-- restituire tabella contenente lavorazioni, già con cloni se necessari
end
return Result
end
-------------------------------------------------------------------------------------------------------------
return BLADETOWASTE