195 lines
8.6 KiB
Lua
195 lines
8.6 KiB
Lua
-- Strategia: TAILCUT
|
|
-- Descrizione
|
|
-- Taglio di separazione
|
|
-- Feature: TailCut
|
|
|
|
-- carico librerie
|
|
local BeamLib = require( 'BeamLib')
|
|
local BeamData = require( 'BeamDataNew')
|
|
local FeatureLib = require( 'FeatureLib')
|
|
local MachiningLib = require( 'MachiningLib')
|
|
local SPLITCUT = require( 'SPLITCUT')
|
|
-- strategie di base
|
|
local BladeToWaste = require('BLADETOWASTE')
|
|
|
|
-- Tabella per definizione modulo
|
|
local TAILCUT = {}
|
|
local Strategy = {}
|
|
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
local function MakeChamfer()
|
|
-- TODO funzionalità da aggiungere
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function TAILCUT.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 }
|
|
OptionalParameters.sRestLengthSideForPreSimulation = 'Tail'
|
|
OptionalParameters.bCannotSplitRestLength = true
|
|
local bAreAllMachiningsAdded = true
|
|
local bExecutePrecutOnly = false
|
|
|
|
-- si setta che è taglio di coda
|
|
Strategy.bIsTailCut = true
|
|
-- quando si aggiunge la lavorazione, si cambia il nome della feature
|
|
if bAddMachining then
|
|
-- si forza il nome della feature
|
|
EgtSetName( Proc.id, 'EndCut')
|
|
end
|
|
|
|
-- separazione solo se esiste grezzo successivo con pezzi o scaricabile
|
|
Strategy.bSplit = not( Part.bIsLastPart) or Part.dRestLength >= BeamData.dMinRaw
|
|
|
|
-- se devo fare split perchè c'è un grezzo da scaricare o un altro pezzo
|
|
if Strategy.bSplit then
|
|
OptionalParameters.dOffset = 0
|
|
OptionalParameters.bDisableDicing = true
|
|
Strategy.SplitStrategy, Strategy.Result = SPLITCUT.GetMachining( Proc, Part, OptionalParameters)
|
|
|
|
if Strategy.Result.sStatus ~= 'Completed' then
|
|
Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'Split not possible')
|
|
return false, Strategy.Result
|
|
end
|
|
|
|
-- se devo rimuovere tutto il restante
|
|
else
|
|
-- se abilitato, faccio tagli di PRECUT a zero (come SPLIT)
|
|
if Strategy.Parameters.bExecutePreCut then
|
|
if Part.dRestLength < 20 then
|
|
bExecutePrecutOnly = true
|
|
OptionalParameters.dOffset = 0
|
|
else
|
|
Strategy.bIsPreCut = true
|
|
-- TODO questo dOffset è errato, va creata una nuova faccia oppure usare dLongitudinalOffset e farlo transitare per tutti, anche Engagement
|
|
-- TODO a dRestLength va anche aggiunto lo spessore lama se c'è a fine grezzo?
|
|
OptionalParameters.dOffset = Part.dRestLength
|
|
end
|
|
OptionalParameters.bDisableDicing = true
|
|
Strategy.SplitStrategy, Strategy.Result = SPLITCUT.GetMachining( Proc, Part, OptionalParameters)
|
|
|
|
if Strategy.Result.sStatus ~= 'Completed' then
|
|
Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'Precut Tail not possible')
|
|
return false, Strategy.Result
|
|
end
|
|
|
|
-- se non faccio tagli PRECUT, imposto tabella Result direttamente. Non serve verificare che riesca a rimuovere il materiale extra
|
|
else
|
|
Strategy.Result.sStatus = 'Completed'
|
|
Strategy.Result.dCompletionIndex = 5
|
|
Strategy.Result.dMRR = 1
|
|
-- si imposta qualità lama perchè verrà fatta BladeToWaste, probabilmente a cubetti
|
|
Strategy.Result.dQuality = FeatureLib.GetStrategyQuality( 'SAWBLADE')
|
|
end
|
|
end
|
|
|
|
-- se devo applicare le lavorazioni
|
|
if bAddMachining then
|
|
-- inserimento smussi su spigoli del taglio
|
|
if Strategy.Parameters.bMakeChamfer then
|
|
MakeChamfer()
|
|
end
|
|
|
|
local MachiningsToAdd = {}
|
|
-- se devo fare split perchè c'è un grezzo da scaricare o un altro pezzo
|
|
if Strategy.bSplit then
|
|
if Strategy.SplitStrategy and #Strategy.SplitStrategy > 0 then
|
|
for i = 1, #Strategy.SplitStrategy do
|
|
local TempList = {}
|
|
TempList.Splitting = Strategy.SplitStrategy[i]
|
|
if i == #Strategy.SplitStrategy then
|
|
TempList.Splitting.sUserNotes = 'Split;'
|
|
TempList.AuxiliaryData = { bIsSplitOrCut = true}
|
|
else
|
|
TempList.Splitting.sUserNotes = 'Presplit;'
|
|
end
|
|
table.insert( MachiningsToAdd, TempList)
|
|
end
|
|
end
|
|
|
|
-- se devo rimuovere tutto il restante
|
|
else
|
|
-- 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.Splitting = Strategy.SplitStrategy[i]
|
|
TempList.Splitting.dLongitudinalOffset = OptionalParameters.dOffset
|
|
if bExecutePrecutOnly then
|
|
if i == #Strategy.SplitStrategy then
|
|
TempList.Splitting.sUserNotes = 'Cut;'
|
|
TempList.AuxiliaryData = { bIsSplitOrCut = true}
|
|
else
|
|
TempList.Splitting.sUserNotes = 'Precut;'
|
|
end
|
|
end
|
|
table.insert( MachiningsToAdd, TempList)
|
|
end
|
|
end
|
|
end
|
|
|
|
if not bExecutePrecutOnly then
|
|
|
|
-- si recuperano gli estremi del box del materiale di coda da rimuovere
|
|
local b3PartWithTail = BeamLib.GetPartBoxWithHeadTail( Part, 'Tail')
|
|
local ptStartRestLength = Point3d( Part.b3Part:getMin():getX() + 1, Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ())
|
|
local ptEndRestLength = Point3d( b3PartWithTail:getMin():getX(), Part.b3Part:getMin():getY(), Part.b3Part:getMin():getZ())
|
|
|
|
local OptionalParametersBladeToWaste = {}
|
|
OptionalParametersBladeToWaste.b3BoxDicing = BBox3d( ptStartRestLength, ptEndRestLength)
|
|
OptionalParametersBladeToWaste.dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume
|
|
OptionalParametersBladeToWaste.dMaxWasteLength = Strategy.Parameters.dMaxWasteLength
|
|
OptionalParametersBladeToWaste.bReduceBladePath = Strategy.Parameters.bReduceBladePath
|
|
OptionalParametersBladeToWaste.sRestLengthSideForPreSimulation = 'Tail'
|
|
OptionalParametersBladeToWaste.bCannotSplitRestLength = true
|
|
|
|
Strategy.Machining, _ = BladeToWaste.Make( Proc, Part, OptionalParametersBladeToWaste)
|
|
-- se taglio non riuscito, si riprova con il riduci percorso forzato (collisione possibile in separazione pezzi alti)
|
|
if ( not Strategy.Machining) or ( #Strategy.Machining == 0) then
|
|
OptionalParametersBladeToWaste.bReduceBladePath = true
|
|
Strategy.Machining, _ = BladeToWaste.Make( Proc, Part, OptionalParametersBladeToWaste)
|
|
end
|
|
if Strategy.Machining and #Strategy.Machining > 0 then
|
|
for i = 1, #Strategy.Machining do
|
|
local TempList = {}
|
|
TempList.Splitting = Strategy.Machining[i]
|
|
if i == #Strategy.Machining then
|
|
TempList.Splitting.sUserNotes = 'Cut;'
|
|
TempList.AuxiliaryData = { bIsSplitOrCut = true}
|
|
else
|
|
TempList.Splitting.sUserNotes = 'Precut;'
|
|
end
|
|
table.insert( MachiningsToAdd, TempList)
|
|
end
|
|
else
|
|
Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'Tail machining not possible')
|
|
return false, Strategy.Result
|
|
end
|
|
end
|
|
end
|
|
|
|
-- aggiungo lavorazioni trovate alla lista generale
|
|
for i = 1, #MachiningsToAdd do
|
|
MachiningsToAdd[i].Splitting.sStage = 'Tail'
|
|
MachiningLib.AddMachinings( Proc, MachiningsToAdd[i].Splitting, MachiningsToAdd[i].AuxiliaryData)
|
|
end
|
|
|
|
return bAreAllMachiningsAdded, Strategy.Result
|
|
else
|
|
return nil, Strategy.Result
|
|
end
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
|
|
return TAILCUT |