a3a29dc5bf
- Migliorata gestione tagli testa e coda - Log result scrivono indici dettagliati per voto feature - Piccole sistemazioni varie
126 lines
4.9 KiB
Lua
126 lines
4.9 KiB
Lua
-- Strategia: HEADCUT
|
|
-- Descrizione
|
|
-- HeadCut
|
|
-- Feature: HeadCut
|
|
|
|
-- carico librerie
|
|
local BeamLib = require( 'BeamLib')
|
|
local BeamData = require( 'BeamData')
|
|
local FeatureLib = require( 'FeatureLib')
|
|
local MachiningLib = require( 'MachiningLib')
|
|
local SPLITCUT = require( 'SPLITCUT')
|
|
-- strategie di base
|
|
local BladeToWaste = require('BLADETOWASTE')
|
|
|
|
-- Tabella per definizione modulo
|
|
local HEADCUT = {}
|
|
local Strategy = {}
|
|
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
local function MakeChamfer()
|
|
-- TODO funzionalità da aggiungere
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters)
|
|
local StrategyLib = {}
|
|
StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId]
|
|
Strategy.sName = StrategyLib.Config.sStrategyId
|
|
Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config)
|
|
Strategy.SplitStrategy = {}
|
|
Strategy.Result = {}
|
|
Strategy.Machining = {}
|
|
Strategy.Result.sInfo = ''
|
|
local OptionalParameters = { bForceChainSaw = Strategy.Parameters.bForceChainSaw, bReduceBladePath = Strategy.Parameters.bReduceBladePath,
|
|
dMaxWasteLength = Strategy.Parameters.dMaxWasteLength, dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume }
|
|
local bAreAllMachiningsAdded = true
|
|
|
|
-- si setta che è taglio di coda
|
|
Strategy.bIsHeadCut = true
|
|
|
|
-- se abilitato, faccio tagli di PRECUT a zero (come SPLIT)
|
|
if Strategy.Parameters.bExecutePreCut then
|
|
Strategy.SplitStrategy, Strategy.Result = SPLITCUT.GetMachining( Proc, Part, OptionalParameters)
|
|
-- se non faccio tagli PRECUT, imposto tabella Result direttamente. Non serve verificare che riesca a rimuovere il materiale extra
|
|
if not Strategy.SplitStrategy or #Strategy.SplitStrategy == 0 then
|
|
Strategy.Result.sInfo = 'PreCut on head not possible'
|
|
end
|
|
end
|
|
|
|
Strategy.Result.sStatus = 'Completed'
|
|
Strategy.Result.dCompletionIndex = 5
|
|
Strategy.Result.dMRR = 1
|
|
-- TODO di quale utensile si deve impostare la qualità qui?
|
|
Strategy.Result.dQuality = FeatureLib.GetStrategyQuality( 'SAWBLADE')
|
|
|
|
|
|
-- se devo applicare le lavorazioni
|
|
if bAddMachining then
|
|
-- si forza il nome della feature
|
|
EgtSetName( Proc.id, 'StartCut')
|
|
|
|
-- inserimento smussi su spigoli del taglio
|
|
if Strategy.Parameters.bMakeChamfer then
|
|
MakeChamfer()
|
|
end
|
|
|
|
local MachiningsToAdd = {}
|
|
local bExecutePrecutOnly = Part.dHeadOverMaterial < 20
|
|
-- se abilitato, faccio tagli di PRECUT a zero (come SPLIT)
|
|
if Strategy.Parameters.bExecutePreCut then
|
|
|
|
if Strategy.SplitStrategy and #Strategy.SplitStrategy > 0 then
|
|
for i = 1, #Strategy.SplitStrategy do
|
|
local TempList = {}
|
|
TempList = Strategy.SplitStrategy[i]
|
|
if bExecutePrecutOnly then
|
|
TempList.dLongitudinalOffset = 0
|
|
else
|
|
TempList.bIsPreCut = true
|
|
TempList.dLongitudinalOffset = Part.dHeadOverMaterial
|
|
end
|
|
|
|
table.insert( MachiningsToAdd, TempList)
|
|
end
|
|
end
|
|
end
|
|
|
|
if not bExecutePrecutOnly then
|
|
local OptionalParameters = {}
|
|
-- si parte dal box della feature e si aggiunge il punto estremo del grezzo
|
|
-- ATTENZIONE : Proc.b3Box viene modificata dato che il tipo Box è come se fosse una tabella, ma da qui passa solo 1 volta per pezzo quindi non dovrebbero esserci problemi
|
|
local b3BoxDicing = Proc.b3Box
|
|
b3BoxDicing:Add( Part.b3Raw:getMax())
|
|
b3BoxDicing:expand( 1000 * GEO.EPS_SMALL)
|
|
OptionalParameters.b3BoxDicing = b3BoxDicing
|
|
|
|
OptionalParameters.dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume
|
|
OptionalParameters.dMaxWasteLength = Strategy.Parameters.dMaxWasteLength
|
|
OptionalParameters.bReduceBladePath = Strategy.Parameters.bReduceBladePath
|
|
|
|
Strategy.Machining, _ = BladeToWaste.Make( Proc, Part, OptionalParameters)
|
|
if Strategy.Machining and #Strategy.Machining > 0 then
|
|
for i = 1, #Strategy.Machining do
|
|
local TempList = {}
|
|
TempList = Strategy.Machining[i]
|
|
table.insert( MachiningsToAdd, TempList)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- aggiungo lavorazioni trovate alla lista generale
|
|
for i = 1, #MachiningsToAdd do
|
|
MachiningsToAdd[i].sStage = 'Head'
|
|
MachiningLib.AddMachinings( Proc, MachiningsToAdd[i], MachiningsToAdd[i].AuxiliaryData)
|
|
end
|
|
|
|
return bAreAllMachiningsAdded, Strategy.Result
|
|
else
|
|
return nil, Strategy.Result
|
|
end
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
|
|
return HEADCUT |