- in MachiningLib.TestEngagement, PreSimulationLib e LeadInOutLib predisposte funzioni per calcolo extracorsa
This commit is contained in:
@@ -155,6 +155,10 @@ function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters)
|
||||
LeadOut.dPerpDistance = dLeadOutLength * vtLeadInOuttLoc:getY()
|
||||
LeadOut.dTangentDistance = dLeadOutLength * vtLeadInOuttLoc:getX()
|
||||
|
||||
-- punti dell'attacco
|
||||
LeadIn.ptPoint = Point3d( ptStartAtDepth + vtLeadInOut * dLeadInLength)
|
||||
LeadOut.ptPoint = Point3d( ptEndAtDepth + vtLeadInOut * dLeadOutLength)
|
||||
|
||||
elseif sLeadInOutType == 'Tangent' then
|
||||
|
||||
-- calcolo distanza per uscire dal box con questa lama nella direzione tangenziale
|
||||
@@ -166,8 +170,13 @@ function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters)
|
||||
LeadIn.dTangentDistance = dLeadInLength
|
||||
LeadOut.dPerpDistance = 0
|
||||
LeadOut.dTangentDistance = dLeadOutLength
|
||||
|
||||
-- punti dell'attacco
|
||||
LeadIn.ptPoint = Point3d( ptStartAtDepth) ; LeadIn.ptPoint = ptStartAtDepth - Edge.vtEdge * dLeadInLength
|
||||
LeadOut.ptPoint = Point3d( ptEndAtDepth) ; LeadOut.ptPoint = ptEndAtDepth + Edge.vtEdge * dLeadOutLength
|
||||
end
|
||||
|
||||
-- lunghezza totale attacco
|
||||
LeadIn.dTotalLength = sqrt( LeadIn.dPerpDistance ^ 2 + LeadIn.dTangentDistance ^ 2)
|
||||
LeadOut.dTotalLength = sqrt( LeadOut.dPerpDistance ^ 2 + LeadOut.dTangentDistance ^ 2)
|
||||
|
||||
|
||||
@@ -318,14 +318,25 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters)
|
||||
dDepthToMachine = dDepthToMachine
|
||||
}
|
||||
|
||||
local CheckCollisionOptionalParameters = BeamLib.TableCopyDeep( OptionalParameters or {})
|
||||
|
||||
local CheckOutOfStrokeParameters = {
|
||||
Edge = Edge,
|
||||
vtNFace = Face.vtN,
|
||||
vtHead = vtHead,
|
||||
Tool = Tool
|
||||
}
|
||||
|
||||
local CheckOutOfStrokeOptionalParameters = {}
|
||||
|
||||
-- check punti lavorazione
|
||||
-- lavorazione oltre le corse: non fattibile
|
||||
local bOutOfStroke = PreSimulationLib.CheckOutOfStroke()
|
||||
local bOutOfStroke = PreSimulationLib.CheckOutOfStroke( CheckOutOfStrokeParameters)
|
||||
if bOutOfStroke then
|
||||
return false
|
||||
end
|
||||
-- lavorazione in collisione con il pezzo: non fattibile
|
||||
local bCollisionFound, bMoveAfterSplit = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, OptionalParameters)
|
||||
local bCollisionFound, bMoveAfterSplit = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, CheckCollisionOptionalParameters)
|
||||
if bCollisionFound then
|
||||
return false
|
||||
end
|
||||
@@ -335,7 +346,9 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters)
|
||||
|
||||
-- attacco perpendicolare
|
||||
local PerpendicularLeadInOut = LeadInOutLib.CalculateLeadInOut( 'Perpendicular', Parameters)
|
||||
local bOutOfStrokePerpendicular = PreSimulationLib.CheckOutOfStroke() -- TODO passare punti custom attacco perpendicolare
|
||||
-- check finecorsa nei punti di attacco
|
||||
CheckOutOfStrokeOptionalParameters.PointsToCheck = { PerpendicularLeadInOut.LeadIn.ptPoint, PerpendicularLeadInOut.LeadOut.ptPoint}
|
||||
local bOutOfStrokePerpendicular = PreSimulationLib.CheckOutOfStroke( CheckOutOfStrokeParameters, CheckOutOfStrokeOptionalParameters)
|
||||
-- se non è in finecorsa si aggiunge come attacco possibile
|
||||
if not bOutOfStrokePerpendicular then
|
||||
LeadInOut.Perpendicular = PerpendicularLeadInOut
|
||||
@@ -353,10 +366,12 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters)
|
||||
|
||||
-- attacco tangenziale
|
||||
local TangentLeadInOut = LeadInOutLib.CalculateLeadInOut( 'Tangent', Parameters)
|
||||
local bOutOfStrokeTangent = PreSimulationLib.CheckOutOfStroke() -- TODO passare punti custom attacco tangenziale
|
||||
-- check finecorsa nei punti di attacco
|
||||
CheckOutOfStrokeOptionalParameters.PointsToCheck = { TangentLeadInOut.LeadIn.ptPoint, TangentLeadInOut.LeadOut.ptPoint}
|
||||
local bOutOfStrokeTangent = PreSimulationLib.CheckOutOfStroke( CheckOutOfStrokeParameters, CheckOutOfStrokeOptionalParameters)
|
||||
-- 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
|
||||
local bCollisionFoundTangent, bMoveAfterSplitTangent = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, CheckCollisionOptionalParameters) -- TODO passare punti custom attacco tangenziale
|
||||
-- attacco tangenziale possibile
|
||||
if not bCollisionFoundTangent then
|
||||
LeadInOut.Tangent = TangentLeadInOut
|
||||
|
||||
@@ -27,23 +27,32 @@ local function GetRestlengthSurfTm( Part)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- calcolo pivot in riferimento globale
|
||||
local function GetGlobalPivot( ptRef, vtC, vtHead, vtMovePivot)
|
||||
-- calcolo punto sull'uscita testa a partire dal punto di lavorazione o di attacco sul diametro utensile
|
||||
local function GetToolExitPoint( ptMachining, vtNEdge, vtHead, Tool, bIsDownUp)
|
||||
|
||||
local ptToolExitPoint = Point3d( ptMachining + vtNEdge * Tool.dDiameter / 2) + vtHead * EgtIf( bIsDownUp, ( Tool.dLength - Tool.dThickness), Tool.dLength)
|
||||
|
||||
return ptToolExitPoint
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- calcolo pivot in riferimento globale, datipunto sull'uscita utensile e direzioni
|
||||
local function GetGlobalPivot( ptToolExit, vtC, vtHead, vtMovePivot)
|
||||
|
||||
-- frame solidale all'utensile (lo stesso in cui vtMovePivot è definito)
|
||||
local frTool = Frame3d( ptRef, vtHead, vtC)
|
||||
local frTool = Frame3d( ptToolExit, vtHead, vtC)
|
||||
local vtMovePivotGlob = Vector3d( vtMovePivot)
|
||||
vtMovePivotGlob:toGlob( frTool)
|
||||
local ptPivot = ptRef + vtMovePivotGlob
|
||||
local ptPivot = ptToolExit + vtMovePivotGlob
|
||||
|
||||
return ptPivot
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- restituisce i punti notevoli della lavorazioni in cui fare il controllo
|
||||
local function GetMachiningPoints( Edge, dDepthToMachine)
|
||||
local function GetPointsToCheck( Edge, dDepthToMachine)
|
||||
|
||||
local MachiningPoints = {}
|
||||
local PointsToCheck = {}
|
||||
|
||||
-- punti notevoli
|
||||
local ptStart = Edge.ptStart + Edge.vtN * ( Edge.dElevation - dDepthToMachine)
|
||||
@@ -59,27 +68,67 @@ local function GetMachiningPoints( Edge, dDepthToMachine)
|
||||
-- aggiunta punti
|
||||
-- inizio e fine solo se lato obliquo
|
||||
if not bIsEdgeParallelToMainDirection then
|
||||
table.insert( MachiningPoints, ptStart)
|
||||
table.insert( PointsToCheck, ptStart)
|
||||
end
|
||||
table.insert( MachiningPoints, ptMid)
|
||||
table.insert( PointsToCheck, ptMid)
|
||||
if not bIsEdgeParallelToMainDirection then
|
||||
table.insert( MachiningPoints, ptEnd)
|
||||
table.insert( PointsToCheck, ptEnd)
|
||||
end
|
||||
|
||||
return MachiningPoints
|
||||
return PointsToCheck
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- TODO da fare
|
||||
function PreSimulationLib.CheckOutOfStroke()
|
||||
|
||||
local function CheckOutOfStrokePoint( ptToolExitToCheck, vtC, vtHead, PreCollisionData)
|
||||
|
||||
local bOutOfStroke = false
|
||||
local ptPivot = GetGlobalPivot( ptToolExitToCheck, vtC, vtHead, PreCollisionData.vtMovePivot)
|
||||
|
||||
|
||||
return bOutOfStroke
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- check finecorsa: se non vengono passati punti si controllano inizio e fine del lato
|
||||
function PreSimulationLib.CheckOutOfStroke( Parameters, OptionalParameters )
|
||||
|
||||
-- parametri obbligatori
|
||||
local Edge = Parameters.Edge
|
||||
local vtNFace = Parameters.vtNFace
|
||||
local vtHead = Parameters.vtHead
|
||||
local Tool = Parameters.Tool
|
||||
|
||||
-- parametri opzionali
|
||||
OptionalParameters = OptionalParameters or {}
|
||||
local PointsToCheck = OptionalParameters.PointsToCheck or { Edge.ptStart, Edge.ptEnd}
|
||||
|
||||
local bIsDownUp = AreOppositeVectorApprox( vtNFace, vtHead)
|
||||
|
||||
-- punti curva collisione e direzioni check da macchina
|
||||
-- TODO serve pivot???
|
||||
local vtMovePivot = nil
|
||||
|
||||
-- check collisione sui punti in centro lama su naso mandrino o aggregato. In base a direzione e punto
|
||||
for i = 1, #PointsToCheck do
|
||||
|
||||
local ToolExitPoint = GetToolExitPoint( PointsToCheck[i], Edge.vtN, vtHead, Tool, bIsDownUp)
|
||||
|
||||
--local bOutOfStroke = CheckOutOfStrokePoint( ptToolExitToCheck, vtC, vtHead, vtMovePivot)
|
||||
|
||||
-- se trovato finecorsa inutile procedere con gli altri punti
|
||||
if bOutOfStroke then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- arrivati qui nessun finecorsa
|
||||
return false
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function CheckCollisionPoint( ptPointToCheck, vtC, vtHead, PreCollisionData, Part, bCheckOnlyRestlength)
|
||||
local function CheckCollisionPoint( ptToolExitToCheck, vtC, vtHead, PreCollisionData, Part, bCheckOnlyRestlength)
|
||||
|
||||
local ptPivot = GetGlobalPivot( ptPointToCheck, vtC, vtHead, PreCollisionData.vtMovePivot)
|
||||
local ptPivot = GetGlobalPivot( ptToolExitToCheck, vtC, vtHead, PreCollisionData.vtMovePivot)
|
||||
|
||||
-- orientamento del riferimento locale
|
||||
local vtDirectionX = PreCollisionData.Directions.vtDirectionX
|
||||
@@ -169,13 +218,13 @@ local function CheckCollisionWithAxis( sAxis, MachiningParameters, OptionalParam
|
||||
-- end
|
||||
|
||||
-- punti notevoli della lavorazione in cui fare il check
|
||||
local MachiningPoints = OptionalParameters.MachiningPoints or GetMachiningPoints( Edge, dDepthToMachine)
|
||||
local PointsToCheck = OptionalParameters.PointsToCheck or GetPointsToCheck( Edge, dDepthToMachine)
|
||||
|
||||
-- punti in centro lama su naso mandrino o aggregato. In base a direzione e punto
|
||||
local bIsDownUp = AreOppositeVectorApprox( vtNFace, vtHead)
|
||||
local ToolExitPoints = {}
|
||||
for i = 1, #MachiningPoints do
|
||||
ToolExitPoints[i] = Point3d( MachiningPoints[i] + Edge.vtN * Tool.dDiameter / 2) + vtHead * EgtIf( bIsDownUp, ( Tool.dLength - Tool.dThickness), Tool.dLength)
|
||||
for i = 1, #PointsToCheck do
|
||||
ToolExitPoints[i] = GetToolExitPoint( PointsToCheck[i], Edge.vtN, vtHead, Tool, bIsDownUp)
|
||||
end
|
||||
|
||||
-- vtC punta sempre verso il corpo dell'asse C o verso l'aggregato
|
||||
@@ -227,7 +276,7 @@ function PreSimulationLib.CheckCollision( sBladeEngagement, Parameters, Optional
|
||||
|
||||
local OptionalParametersCheckCollisionWithAxis = {}
|
||||
OptionalParametersCheckCollisionWithAxis.bCheckOnlyRestlength = false
|
||||
OptionalParametersCheckCollisionWithAxis.MachiningPoints = OptionalParameters.MachiningPoints or nil
|
||||
OptionalParametersCheckCollisionWithAxis.PointsToCheck = OptionalParameters.PointsToCheck or nil
|
||||
|
||||
-- asse Z si controlla sempre
|
||||
bCollisionFound, bMoveAfterSplitZ = CheckCollisionWithAxis( 'Z', Parameters, OptionalParametersCheckCollisionWithAxis)
|
||||
|
||||
Reference in New Issue
Block a user