188 lines
8.7 KiB
Lua
188 lines
8.7 KiB
Lua
-- Strategia: STR0005
|
|
-- Descrizione
|
|
-- lama per taglio facce lasciando codolo o con cubetti
|
|
-- Feature: cut, longcut, ridgelap, ...
|
|
|
|
-- carico librerie
|
|
local BeamLib = require( 'BeamLib')
|
|
local BeamData = require( 'BeamData')
|
|
local MachiningLib = require( 'MachiningLib')
|
|
local FeatureLib = require( 'FeatureLib')
|
|
-- strategie di base
|
|
local BladeToWaste = require( 'BLADETOWASTE')
|
|
local BladeKeepWaste = require( 'BLADEKEEPWASTE')
|
|
|
|
-- Tabella per definizione modulo
|
|
local STR0005 = {}
|
|
local Strategy = {}
|
|
local Blade = {}
|
|
Blade.Result = {}
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function STR0005.Make( bAddMachining, Proc, Part, CustomParameters)
|
|
-- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti)
|
|
local StrategyLib = {}
|
|
StrategyLib.Config = require( 'STR0005\\STR0005Config')
|
|
Strategy.sName = StrategyLib.Config.sStrategyId
|
|
Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config)
|
|
Strategy.Result = {}
|
|
Strategy.Result.sInfo = ''
|
|
Blade.Result = {}
|
|
local dMRRBlade = 0
|
|
local dCompletionPercentage = 0
|
|
local dMRRBladeAddedFace = 0
|
|
local dCompletionPercentageAddedFace = 0
|
|
|
|
-- più di 3 facce non supportate
|
|
if Proc.nFct > 3 then
|
|
Strategy.Result.sStatus = 'Not-Applicable'
|
|
Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( 0)
|
|
Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Blade')
|
|
Strategy.Result.dMRR = dMRRBlade
|
|
Strategy.Result.sInfo = 'More than 3 faces not supported'
|
|
end
|
|
|
|
-- estensione oltre la coda
|
|
local dExtendAfterTail = Strategy.Parameters.dExtendAfterTail or max( Part.dDistanceToNextPiece - BeamData.CUT_EXTRA, 0)
|
|
if MachiningLib.CanExtendAfterTail( Strategy.Parameters.sCanDamageNextPiece, Part) then
|
|
dExtendAfterTail = 10000
|
|
end
|
|
|
|
-- disambiguazione caso 3 facce tipo RidgeLap
|
|
local idAddedTmFace
|
|
local nAddedFace
|
|
if Proc.nFct == 3 and not Proc.Topology.sName == 'Groove-3-Through' then
|
|
if Proc.AdjacencyMatrix[1][2] > 10 * GEO.EPS_ANG_SMALL and Proc.AdjacencyMatrix[2][3] < 10 * GEO.EPS_ANG_SMALL then
|
|
nAddedFace = 1 - 1
|
|
elseif Proc.AdjacencyMatrix[2][3] > 10 * GEO.EPS_ANG_SMALL and Proc.AdjacencyMatrix[3][1] < 10 * GEO.EPS_ANG_SMALL then
|
|
nAddedFace = 2 - 1
|
|
else
|
|
nAddedFace = 3 - 1
|
|
end
|
|
-- recupero gruppo per geometria addizionale
|
|
local nAddGrpId = BeamLib.GetAddGroup( Part.id)
|
|
-- faccia aggiuntiva da lavorare
|
|
idAddedTmFace = EgtCopySurfTmFacet( Proc.id, nAddedFace, nAddGrpId)
|
|
-- rimozione della terza faccia dalla Proc
|
|
local idNewProc = EgtCopyGlob( Proc.id, nAddGrpId)
|
|
EgtSurfTmRemoveFacet( idNewProc, nAddedFace)
|
|
Proc = FeatureLib.GetProcFromTrimesh( idNewProc, Part, Proc)
|
|
end
|
|
|
|
-- considerazioni necessarie a determinare se lavorare con codolo oppure no
|
|
local bKeepWasteAttached = ( Strategy.Parameters.sCuttingStrategy == 'KEEP_WASTE_ATTACHED')
|
|
local bDropWaste = ( Strategy.Parameters.sCuttingStrategy == 'DROP_WASTE')
|
|
local dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail = FeatureLib.GetFeatureMaxNotClampableLengths( Proc, Part)
|
|
local bFeatureHindersClamping = FeatureLib.IsMachiningLong( max( dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN})
|
|
local bIsFeatureLong = FeatureLib.IsMachiningLong( Proc.b3Box:getDimX(), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN})
|
|
|
|
-- lavorazione con codolo
|
|
if ( Proc.nFct > 2 and bIsFeatureLong)
|
|
or ( bFeatureHindersClamping and not bDropWaste)
|
|
or bKeepWasteAttached then
|
|
|
|
local BladeKeepWasteResult
|
|
local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dStripWidth = Strategy.Parameters.dStripWidth}
|
|
Blade.Result, BladeKeepWasteResult = BladeKeepWaste.Make( Proc, Part, OptionalParameters)
|
|
dMRRBlade = BladeKeepWasteResult.dMRR
|
|
dCompletionPercentage = BladeKeepWasteResult.dCompletionPercentage
|
|
end
|
|
|
|
-- lavorazione a cubetti / taglio singolo
|
|
if Proc.nFct < 3 and #Blade.Result == 0 and not bKeepWasteAttached then
|
|
local dMinZTopBlade
|
|
local dMaxNyTopBlade
|
|
local BladeToWasteResult
|
|
if Strategy.Parameters.dMinZAngleTopBlade then
|
|
dMinZTopBlade = sin( Strategy.Parameters.dMinZAngleTopBlade)
|
|
end
|
|
if Strategy.Parameters.dMaxYAngleTopBlade then
|
|
dMaxNyTopBlade = sin( Strategy.Parameters.dMaxYAngleTopBlade)
|
|
end
|
|
local OptionalParameters = { dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume,
|
|
dMaxWasteLength = Strategy.Parameters.dMaxWasteLength,
|
|
dMinNzTopBlade = dMinZTopBlade,
|
|
dMaxNyTopBlade = dMaxNyTopBlade,
|
|
bSaveAddedGeometries = bAddMachining,
|
|
dExtendAfterTail = dExtendAfterTail
|
|
}
|
|
Blade.Result, BladeToWasteResult = BladeToWaste.Make( Proc, Part, OptionalParameters)
|
|
dMRRBlade = BladeToWasteResult.dMRR
|
|
dCompletionPercentage = BladeToWasteResult.dCompletionPercentage
|
|
end
|
|
|
|
-- se arrivati qui non è stata ancora applicata alcuna lavorazione, si prova la lavorazione con codolo
|
|
if #Blade.Result == 0 and not bKeepWasteAttached then
|
|
local BladeKeepWasteResult
|
|
local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dStripWidth = Strategy.Parameters.dStripWidth}
|
|
Blade.Result, BladeKeepWasteResult = BladeKeepWaste.Make( Proc, Part, OptionalParameters)
|
|
dMRRBlade = BladeKeepWasteResult.dMRR
|
|
dCompletionPercentage = BladeKeepWasteResult.dCompletionPercentage
|
|
end
|
|
|
|
-- lavorazione eventuale terza faccia tipo RidgeLap
|
|
if idAddedTmFace then
|
|
local dMinZTopBlade
|
|
local dMaxNyTopBlade
|
|
local BladeToWasteResult
|
|
if Strategy.Parameters.dMinZAngleTopBlade then
|
|
dMinZTopBlade = sin( Strategy.Parameters.dMinZAngleTopBlade)
|
|
end
|
|
if Strategy.Parameters.dMaxYAngleTopBlade then
|
|
dMaxNyTopBlade = sin( Strategy.Parameters.dMaxYAngleTopBlade)
|
|
end
|
|
local OptionalParameters = { dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume,
|
|
dMaxWasteLength = Strategy.Parameters.dMaxWasteLength,
|
|
dMinNzTopBlade = dMinZTopBlade,
|
|
dMaxNyTopBlade = dMaxNyTopBlade,
|
|
bSaveAddedGeometries = bAddMachining,
|
|
dExtendAfterTail = dExtendAfterTail
|
|
}
|
|
Blade.Result, BladeToWasteResult = BladeToWaste.Make( idAddedTmFace, Part, OptionalParameters)
|
|
dMRRBladeAddedFace = BladeToWasteResult.dMRR
|
|
dCompletionPercentageAddedFace = BladeToWasteResult.dCompletionPercentage
|
|
|
|
-- la faccia aggiuntiva conta per 1/3
|
|
dMRRBlade = 2/3 * dMRRBlade + 1/3 * dMRRBladeAddedFace
|
|
dCompletionPercentage = 2/3 * dCompletionPercentage + 1/3 * dCompletionPercentageAddedFace
|
|
end
|
|
|
|
-- aggiunta lavorazioni
|
|
local nIsApplicableCount = 0
|
|
local dFinalCompletionPercentage = 100
|
|
local bAreAllMachiningsAdded = true
|
|
for i = 1, #Blade.Result do
|
|
if Blade.Result[i].bIsApplicable then
|
|
nIsApplicableCount = nIsApplicableCount + 1
|
|
if bAddMachining then
|
|
local bIsMachiningAdded = MachiningLib.AddMachinings( Proc, Blade.Result[i])
|
|
if not bIsMachiningAdded then
|
|
bAreAllMachiningsAdded = false
|
|
end
|
|
end
|
|
Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Blade.Result[i].sMessage
|
|
end
|
|
end
|
|
-- TODO migliorare calcolo area lavorata; se ho il codolo ha senso l'incompleta? se incompleta con codolo faccio i cubetti??
|
|
-- TODO settare che il codolo restituisce incompleta tranne quando è forzato
|
|
if nIsApplicableCount > 0 then
|
|
if dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then
|
|
Strategy.Result.sStatus = 'Completed'
|
|
else
|
|
Strategy.Result.sStatus = 'Not-Completed'
|
|
-- TODO al momento si assume che la percentuale di completamento dell'ultima lavorazione sia quella rilevante
|
|
dFinalCompletionPercentage = dCompletionPercentage
|
|
end
|
|
else
|
|
Strategy.Result.sStatus = 'Not-Applicable'
|
|
end
|
|
Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dFinalCompletionPercentage)
|
|
Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Blade')
|
|
Strategy.Result.dMRR = dMRRBlade
|
|
|
|
return bAreAllMachiningsAdded, Strategy.Result
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
|
|
return STR0005 |