100 lines
3.6 KiB
Lua
100 lines
3.6 KiB
Lua
-- LeadInOutLib.lua by Egalware s.r.l. 2025/11/24
|
|
-- Libreria stima collisioni per travi
|
|
|
|
-- Tabella per definizione modulo
|
|
local LeadInOutLib = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
local BeamData = require( 'BeamDataNew')
|
|
|
|
EgtOutLog( ' LeadInOutLib started', 1)
|
|
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters)
|
|
|
|
-- parametri obbligatori
|
|
local Face = Parameters.Face
|
|
local Edge = Parameters.Edge
|
|
local Part = Parameters.Part
|
|
local Tool = Parameters.Tool
|
|
local dDepthToMachine = Parameters.dDepthToMachine
|
|
|
|
local LeadInOut = {}
|
|
local bIsStartClosed = not Edge.bIsStartOpen
|
|
local bIsEndClosed = not Edge.bIsEndOpen
|
|
|
|
-- accorciamento per lati chiusi (è sempre l'impronta utensile)
|
|
LeadInOut.dToolMarkLength = sqrt( dDepthToMachine * Tool.dDiameter - dDepthToMachine * dDepthToMachine)
|
|
-- allungamento per faccia singola (aperta in tutte le direzioni)
|
|
LeadInOut.dAddedLengthOpenFace = BeamData.CUT_EXTRA
|
|
|
|
local LeadIn = {}
|
|
local LeadOut = {}
|
|
LeadIn.dStartAddLength = 0
|
|
LeadOut.dEndAddLength = 0
|
|
LeadIn.nType = MCH_MILL_LI.LINEAR
|
|
LeadOut.nType = MCH_MILL_LI.LINEAR
|
|
LeadIn.dPerpDistance = 0
|
|
LeadOut.dPerpDistance = 0
|
|
LeadIn.dTangentDistance = 0
|
|
LeadOut.dTangentDistance = 0
|
|
LeadIn.dElevation = 0
|
|
LeadOut.dElevation = 0
|
|
LeadIn.dCompLength = 0
|
|
LeadOut.dCompLength = 0
|
|
|
|
-- TODO qui calcolo con EgtLineBoxInters
|
|
if sLeadInOutType == 'Perpendicular' then
|
|
LeadIn.dPerpDistance = dDepthToMachine + BeamData.CUT_SIC
|
|
LeadOut.dPerpDistance = dDepthToMachine + BeamData.CUT_SIC
|
|
elseif sLeadInOutType == 'Tangent' then
|
|
LeadIn.dTangentDistance = Tool.dDiameter / 2 + BeamData.CUT_SIC
|
|
LeadOut.dTangentDistance = Tool.dDiameter / 2 + BeamData.CUT_SIC
|
|
end
|
|
|
|
if bIsStartClosed and bIsEndClosed then
|
|
LeadIn.dStartAddLength = -LeadInOut.dToolMarkLength
|
|
LeadOut.dEndAddLength = -LeadInOut.dToolMarkLength
|
|
elseif bIsStartClosed then
|
|
LeadIn.dStartAddLength = -LeadInOut.dToolMarkLength
|
|
-- eventuale correzione per accorciamento maggiore di larghezza tasca
|
|
LeadOut.dEndAddLength = max( -LeadIn.dStartAddLength - Edge.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA)
|
|
elseif bIsEndClosed then
|
|
LeadOut.dEndAddLength = -LeadInOut.dToolMarkLength
|
|
-- eventuale correzione per accorciamento maggiore di larghezza tasca
|
|
LeadIn.dStartAddLength = max( -LeadOut.dEndAddLength - Edge.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA)
|
|
else
|
|
LeadIn.dStartAddLength = LeadInOut.dAddedLengthOpenFace
|
|
LeadOut.dEndAddLength = LeadInOut.dAddedLengthOpenFace
|
|
end
|
|
|
|
LeadIn.dTotalLength = sqrt( LeadIn.dPerpDistance ^ 2 + LeadIn.dTangentDistance ^ 2)
|
|
LeadOut.dTotalLength = sqrt( LeadOut.dPerpDistance ^ 2 + LeadOut.dTangentDistance ^ 2)
|
|
|
|
LeadInOut.dTotalLength = LeadIn.dTotalLength + LeadOut.dTotalLength
|
|
LeadInOut.LeadIn = LeadIn
|
|
LeadInOut.LeadOut = LeadOut
|
|
|
|
return LeadInOut
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function LeadInOutLib.InvertLeadInOut( LeadIn, LeadOut)
|
|
|
|
local dOriginalStartAddLength = LeadIn.dStartAddLength
|
|
local dOriginalEndAddLength = LeadOut.dEndAddLength
|
|
|
|
LeadIn, LeadOut = LeadOut, LeadIn
|
|
|
|
LeadIn.dStartAddLength = dOriginalEndAddLength
|
|
LeadOut.dEndAddLength = dOriginalStartAddLength
|
|
LeadIn.dEndAddLength = nil
|
|
LeadOut.dStartAddLength = nil
|
|
|
|
return LeadIn, LeadOut
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
return LeadInOutLib |