149 lines
6.3 KiB
Lua
149 lines
6.3 KiB
Lua
-- Strategia: HEADCUT
|
|
-- Descrizione
|
|
-- HeadCut
|
|
-- Feature: HeadCut
|
|
|
|
-- 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 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 }
|
|
OptionalParameters.sRestLengthSideForPreSimulation = 'Head'
|
|
OptionalParameters.bCannotSplitRestLength = true
|
|
local bAreAllMachiningsAdded = true
|
|
|
|
-- si setta che è taglio di testa
|
|
Strategy.bIsHeadCut = true
|
|
-- quando si aggiunge la lavorazione, si cambia il nome della feature
|
|
if bAddMachining then
|
|
-- si forza il nome della feature
|
|
EgtSetName( Proc.id, 'StartCut')
|
|
end
|
|
|
|
-- 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
|
|
if Strategy.Result.sStatus ~= 'Completed' then
|
|
Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'Precut Head not possible')
|
|
return false, Strategy.Result
|
|
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 coincide con inizio grezzo, non va fatto
|
|
if abs( Proc.b3Box:getCenter():getX() - Part.b3Raw:getMax():getX()) < 10 * GEO.EPS_SMALL then
|
|
return true, Strategy.Result
|
|
end
|
|
|
|
-- se devo applicare le lavorazioni
|
|
if bAddMachining then
|
|
-- inserimento smussi su spigoli del taglio
|
|
if Strategy.Parameters.bMakeChamfer then
|
|
MakeChamfer()
|
|
end
|
|
|
|
local MachiningsToAdd = {}
|
|
local bExecutePrecutOnly = false
|
|
-- se abilitato, faccio tagli di PRECUT a zero (come SPLIT)
|
|
if Strategy.Parameters.bExecutePreCut then
|
|
bExecutePrecutOnly = Part.dHeadOverMaterial < 20
|
|
|
|
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
|
|
|
|
-- si recuperano gli estremi del box del materiale di testa da togliere
|
|
local b3PartWithHead = BeamLib.GetPartBoxWithHeadTail( Part, 'Head')
|
|
local ptStartRestLength = Point3d( Part.b3Part:getMax():getX() - 1, Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ())
|
|
local ptEndRestLength = Point3d( b3PartWithHead:getMax():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 = 'Head'
|
|
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 = Strategy.Machining[i]
|
|
table.insert( MachiningsToAdd, TempList)
|
|
end
|
|
else
|
|
Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'Head machining not possible')
|
|
return false, Strategy.Result
|
|
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 |