Files
databeamnew/StrategyLibs/BLADETOWASTE.lua
T
luca.mazzoleni 7eb83ccf79 - in MachiningLib migliorie a FindBlade
- migliorata BLADETOWASTE
- in FACEBYBLADE la residualDepth si esprime rispetto alla DephToMachine passata e non rispetto all'elevazione del lato
2025-01-31 17:23:11 +01:00

102 lines
3.2 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 = {}
local dCompletionPercentage = 0
-- parametri opzionali e default
local nToolIndex = OptionalParameters.nToolIndex
local bDropWholeWaste = OptionalParameters.bDropWholeWaste or false
local dMaxWasteVolume = OptionalParameters.dMaxWasteVolume or 0
local dMaxWasteLength = OptionalParameters.dMaxWasteLength or 0
-- dimensioni feature
local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part)
local dFeatureMaxDimension = max( Proc.b3Box:getDimX(), Proc.b3Box:getDimY())
local bIsFeatureSmall = dFeatureVolume < dMaxWasteVolume + 10 * GEO.EPS_SMALL
and dFeatureMaxDimension < dMaxWasteLength + 10 * GEO.EPS_SMALL
-- si taglia tutto lo scarto in una sola lavorazione
if Proc.nFct == 1 and ( bIsFeatureSmall or bDropWholeWaste) then
local Cutting = {}
local EdgeToMachine = {}
local dDepthToMachine = 0
local ToolInfo = {}
-- ricerca utensile
if not nToolIndex then
local ToolSearchParameters = {}
for i = 1, #Proc.Faces[1].Edges do
if ( i == 1) or Proc.Faces[1].Edges[i].dElevation < EdgeToMachine.dElevation - 10 * GEO.EPS_SMALL then
EdgeToMachine = Proc.Faces[1].Edges[i]
end
end
dDepthToMachine = EdgeToMachine.dElevation + BeamData.CUT_EXTRA
ToolSearchParameters.dElevation = dDepthToMachine
ToolSearchParameters.vtToolDirection = EdgeToMachine.vtN
ToolSearchParameters.bAllowTopHead = true
-- TODO bisognerà implementare anche la lama da sotto
ToolSearchParameters.bAllowBottomHead = false
ToolSearchParameters.bForceLongcutBlade = false
ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters)
nToolIndex = ToolInfo.nToolIndex
end
if ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then
local OptionalParametersFaceByBlade = { dDepthToMachine = dDepthToMachine, nToolIndex = nToolIndex}
Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParametersFaceByBlade)
end
if Cutting.bIsApplicable or bDropWholeWaste then
table.insert( Result, Cutting)
dCompletionPercentage = Cutting.dCompletionPercentage or dCompletionPercentage
end
return Result, dCompletionPercentage
end
-- restituire tabella contenente lavorazioni, già con cloni se necessari
return Result, dCompletionPercentage
end
-------------------------------------------------------------------------------------------------------------
return BLADETOWASTE