- in MachiningLib.TestEngagement si testa e restituisce il LeadInOut (funzioni da fare) per i casi perpendicular e tangent

This commit is contained in:
luca.mazzoleni
2025-12-10 19:09:06 +01:00
parent eb3cf0d7ff
commit 77d6d89e13
2 changed files with 52 additions and 42 deletions
+47 -33
View File
@@ -318,12 +318,12 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters)
dDepthToMachine = dDepthToMachine
}
-- check punti lavorazione
-- lavorazione oltre le corse: non fattibile
local bOutOfStroke = PreSimulationLib.CheckOutOfStroke()
if bOutOfStroke then
return false
end
-- lavorazione in collisione con il pezzo: non fattibile
local bCollisionFound, bMoveAfterSplit = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, OptionalParameters)
if bCollisionFound then
@@ -333,43 +333,59 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters)
-- calcolo e check attacchi
local LeadInOut = {}
local bNeedTangentLeadInOut = false
LeadInOut.Perpendicular = PreSimulationLib.CalculateLeadInOut
-- attacco perpendicolare
local PerpendicularLeadInOut = PreSimulationLib.CalculateLeadInOut()
local bOutOfStrokePerpendicular = PreSimulationLib.CheckOutOfStroke() -- TODO passare punti custom attacco perpendicolare
-- attacco perpendicolare oltre le corse: si prova attacco tangenziale
if bOutOfStrokePerpendicular then
local bOutOfStrokeTangent = PreSimulationLib.CheckOutOfStroke() -- TODO passare punti custom attacco tangenziale
-- entrambi gli attacchi oltre le corse: lavorazione non fattibile
if bOutOfStrokeTangent then
-- se non è in finecorsa si aggiunge come attacco possibile
if not bOutOfStrokePerpendicular then
LeadInOut.Perpendicular = PerpendicularLeadInOut
LeadInOut.Perpendicular.bMoveAfterSplit = bMoveAfterSplit
end
-- se c'è almeno un lato chiuso l'unico attacco possibile è il perpendicolare
if not ( Edge.bIsStartOpen and Edge.bIsEndOpen) then
if bOutOfStrokePerpendicular then
return false
-- check collisione attacco tangenziale
else
local bCollisionFoundTangent, bMoveAfterSplitTangent = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, OptionalParameters) -- TODO passare punti custom attacco tangenziale
-- attacco perpendicolare oltre le corse e attacco tangenziale in collisione: lavorazione non fattibile
if bCollisionFoundTangent then
return false
-- obbligatorio attacco tangenziale
else
bMoveAfterSplit = bMoveAfterSplit or bMoveAfterSplitTangent
bNeedTangentLeadInOut = true
end
LeadInOut.sChosen = 'Perpendicular'
return true, bMoveAfterSplit, LeadInOut
end
end
-- arrivati qui la lavorazione è fattibile: si restituisce se è necessario farla dopo separazione e se serve attacco tangenziale
return true, bMoveAfterSplit, bNeedTangentLeadInOut
-- attacco tangenziale
local TangentLeadInOut = PreSimulationLib.CalculateLeadInOut()
local bOutOfStrokeTangent = PreSimulationLib.CheckOutOfStroke() -- TODO passare punti custom attacco tangenziale
-- attacco tangenziale non in finecorsa: si verifica se è in collisione
if not bOutOfStrokeTangent then
local bCollisionFoundTangent, bMoveAfterSplitTangent = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, OptionalParameters) -- TODO passare punti custom attacco tangenziale
-- attacco tangenziale possibile
if not bCollisionFoundTangent then
LeadInOut.Tangent = TangentLeadInOut
LeadInOut.Tangent.bMoveAfterSplit = bMoveAfterSplitTangent
end
end
-- se disponibili più attacchi si sceglie il più corto, altrimenti quello possibile
if LeadInOut.Perpendicular and LeadInOut.Tangent then
if LeadInOut.Perpendicular.dTotalLength > LeadInOut.Tangent.dTotalLength + 10 then
LeadInOut.sChosen = 'Tangent'
else
LeadInOut.sChosen = 'Perpendicular'
end
elseif LeadInOut.Perpendicular and not LeadInOut.Tangent then
LeadInOut.sChosen = 'Perpendicular'
elseif LeadInOut.Tangent and not LeadInOut.Perpendicular then
LeadInOut.sChosen = 'Tangent'
-- nessun attacco possibile
-- TODO qui invece di uscire si dovranno provare i due attacchi SpecialTangent e SpecialTangentInverted
else
return false
end
return true, bMoveAfterSplit, LeadInOut
end
-------------------------------------------------------------------------------------------------------------
-- ritorna se la faccia e il lato sono lavorabili e, se sì, il modo di lavorare (standard/DownUp) e se è necessario un attacco tangenziale
-- ritorna se la faccia e il lato sono lavorabili e, se sì, il modo di lavorare (standard/DownUp) e i tipi di attacco disponibili
-- TODO si dovrà decidere come tagliare anche se pezzo corto (il motore non deve ingombrare con il pinzaggio)
-- TODO da gestire riduzione percorso
function MachiningLib.GetBladeEngagement( Parameters, OptionalParameters)
@@ -377,28 +393,26 @@ function MachiningLib.GetBladeEngagement( Parameters, OptionalParameters)
local Engagement
-- test lavorazione faccia in modo standard (no DownUp)
local bIsEngagementOk, bMoveAfterSplit, bNeedTangentLeadInOut = TestEngagement( 'Standard', Parameters, OptionalParameters)
local bIsEngagementOk, bMoveAfterSplit = TestEngagement( 'Standard', Parameters, OptionalParameters)
if bIsEngagementOk then
Engagement = {
sBladeEngagement = 'Standard',
bMoveAfterSplit = bMoveAfterSplit,
bNeedTangentLeadInOut = bNeedTangentLeadInOut,
LeadInOut = LeadInOut
}
return true, Engagement
end
-- faccia non lavorabile in modo standard: si verifica se il DownUp è fattibile
bIsEngagementOk, bMoveAfterSplit, bNeedTangentLeadInOut = TestEngagement( 'DownUp', Parameters, OptionalParameters)
bIsEngagementOk, bMoveAfterSplit = TestEngagement( 'DownUp', Parameters, OptionalParameters)
if bIsEngagementOk then
Engagement = {
sBladeEngagement = 'DownUp',
bMoveAfterSplit = bMoveAfterSplit,
bNeedTangentLeadInOut = bNeedTangentLeadInOut,
LeadInOut = LeadInOut
}
return true, Engagement