- in LeadInOutLib calcolo attacco tangenziale con funzioni Tool Collision Avoidance e refactoring
- in FACEBYBLADE GetLeadInOut si aggiorna se necessario la TotalLength
This commit is contained in:
+78
-58
@@ -11,7 +11,41 @@ local BeamData = require( 'BeamDataNew')
|
||||
EgtOutLog( ' LeadInOutLib started', 1)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function CalculateLeadInOutLength( ptToolCenter, vtNFace, b3Box, vtLeadInOut, Tool)
|
||||
local function GetPerpendicularLeadInOutDirection( Face, Edge)
|
||||
|
||||
-- informazioni lati adiacenti
|
||||
local nCurrentEdgeIndex = Edge.id + 1
|
||||
local nPreviousEdgeIndex = ( nCurrentEdgeIndex == 1 and #Face.Edges) or nCurrentEdgeIndex - 1
|
||||
local nNextEdgeIndex = ( nCurrentEdgeIndex == #Face.Edges and 1) or nCurrentEdgeIndex + 1
|
||||
local EdgeNext = Face.Edges[nNextEdgeIndex]
|
||||
local EdgePrevious = Face.Edges[nPreviousEdgeIndex]
|
||||
|
||||
-- tra le direzioni dei due lati adiacenti, si sceglie la migliore da cui attaccare, ossia quella più vicina alla perpendicolare al lato di lavoro
|
||||
local dCosAngleStart = -EdgePrevious.vtEdge * Edge.vtN
|
||||
local dCosAngleEnd = EdgeNext.vtEdge * Edge.vtN
|
||||
local vtLeadInOut
|
||||
-- se le due direzioni sono entro i 5° scelgo quella a Z assoluta minore, altrimenti quella più vicino alla perpendicolare
|
||||
-- massima differenza scalare per variazione di 5deg: cos(0) - cos(0 + 5) = 1 - cos(5)
|
||||
local dScalarTolerance = 1 - 0.996
|
||||
if abs( dCosAngleStart - dCosAngleEnd) < dScalarTolerance then
|
||||
if abs( EdgePrevious.vtEdge:getZ()) < abs( EdgeNext.vtEdge:getZ()) then
|
||||
vtLeadInOut = Vector3d( -EdgePrevious.vtEdge)
|
||||
else
|
||||
vtLeadInOut = Vector3d( EdgeNext.vtEdge)
|
||||
end
|
||||
else
|
||||
if dCosAngleStart > dCosAngleEnd then
|
||||
vtLeadInOut = Vector3d( -EdgePrevious.vtEdge)
|
||||
else
|
||||
vtLeadInOut = Vector3d( EdgeNext.vtEdge)
|
||||
end
|
||||
end
|
||||
|
||||
return vtLeadInOut
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function CalculateLeadInOutLength( ptToolCenter, vtNFace, b3Box, vtLeadInOut, Tool)
|
||||
|
||||
-- al momento gestita solo lama
|
||||
if not Tool.sFamily == 'SawBlade' then
|
||||
@@ -69,71 +103,49 @@ function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters)
|
||||
LeadIn.dCompLength = 0
|
||||
LeadOut.dCompLength = 0
|
||||
|
||||
-- calcolo allungamenti / accorciamenti
|
||||
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
|
||||
|
||||
-- calcolo punti notevoli della lavorazione
|
||||
-- punti di inizio e fine lavorazione alla profondità di lavoro reale, considerando allungamenti/accorciamenti
|
||||
local ptStartAtDepth = Edge.ptStart - Edge.vtEdge * LeadIn.dStartAddLength + Edge.vtN * ( Edge.dElevation - dDepthToMachine)
|
||||
local ptEndAtDepth = Edge.ptEnd + Edge.vtEdge * LeadOut.dEndAddLength + Edge.vtN * ( Edge.dElevation - dDepthToMachine)
|
||||
-- punti in centro lama
|
||||
local ptStartBladeCenter = ptStartAtDepth + Edge.vtN * Tool.dDiameter / 2
|
||||
local ptEndBladeCenter = ptEndAtDepth + Edge.vtN * Tool.dDiameter / 2
|
||||
|
||||
-- box per calcolo uscita lama
|
||||
-- il box si espande in tutte le direzioni per contemplare la sicurezza CUT_SIC
|
||||
local b3BoxPartExpanded = BBox3d( Part.b3Part) ; b3BoxPartExpanded:expand( BeamData.CUT_SIC)
|
||||
|
||||
-- calcolo attacco scelto
|
||||
if sLeadInOutType == 'Perpendicular' then
|
||||
|
||||
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
|
||||
|
||||
-- informazioni lati adiacenti
|
||||
local nCurrentEdgeIndex = Edge.id + 1
|
||||
local nPreviousEdgeIndex = ( nCurrentEdgeIndex == 1 and #Face.Edges) or nCurrentEdgeIndex - 1
|
||||
local nNextEdgeIndex = ( nCurrentEdgeIndex == #Face.Edges and 1) or nCurrentEdgeIndex + 1
|
||||
local EdgeNext = Face.Edges[nNextEdgeIndex]
|
||||
local EdgePrevious = Face.Edges[nPreviousEdgeIndex]
|
||||
-- scelta direzione migliore per l'attacco
|
||||
local vtLeadInOut = GetPerpendicularLeadInOutDirection( Face, Edge)
|
||||
|
||||
-- frame solidale al lato di lavoro (X lungo il lato, Y normale al lato)
|
||||
local frEdge = Frame3d( Edge.ptStart, Face.vtN, Edge.vtEdge)
|
||||
|
||||
-- tra le direzioni dei due lati adiacenti, si sceglie la migliore da cui attaccare, ossia quella più vicina alla perpendicolare al lato di lavoro
|
||||
local dCosAngleStart = -EdgePrevious.vtEdge * Edge.vtN
|
||||
local dCosAngleEnd = EdgeNext.vtEdge * Edge.vtN
|
||||
local vtLeadInOut
|
||||
-- se le due direzioni sono entro i 5° scelgo quella a Z assoluta minore, altrimenti quella più vicino alla perpendicolare
|
||||
-- massima differenza scalare per variazione di 5deg: cos(0) - cos(0 + 5) = 1 - cos(5)
|
||||
local dScalarTolerance = 1 - 0.996
|
||||
if abs( dCosAngleStart - dCosAngleEnd) < dScalarTolerance then
|
||||
if abs( EdgePrevious.vtEdge:getZ()) < abs( EdgeNext.vtEdge:getZ()) then
|
||||
vtLeadInOut = Vector3d( -EdgePrevious.vtEdge)
|
||||
else
|
||||
vtLeadInOut = Vector3d( EdgeNext.vtEdge)
|
||||
end
|
||||
else
|
||||
if dCosAngleStart > dCosAngleEnd then
|
||||
vtLeadInOut = Vector3d( -EdgePrevious.vtEdge)
|
||||
else
|
||||
vtLeadInOut = Vector3d( EdgeNext.vtEdge)
|
||||
end
|
||||
end
|
||||
|
||||
-- direzione nel frame solidale al lato di lavoro
|
||||
local vtLeadInOuttLoc = Vector3d( vtLeadInOut)
|
||||
vtLeadInOuttLoc:toLoc( frEdge)
|
||||
|
||||
-- punti di inizio e fine lavorazione alla profondità di lavoro reale, considerando allungamenti/accorciamenti
|
||||
local ptStartAtDepth = Edge.ptStart - Edge.vtEdge * LeadIn.dStartAddLength + Edge.vtN * ( Edge.dElevation - dDepthToMachine)
|
||||
local ptEndAtDepth = Edge.ptEnd + Edge.vtEdge * LeadOut.dEndAddLength + Edge.vtN * ( Edge.dElevation - dDepthToMachine)
|
||||
|
||||
-- punti in centro lama
|
||||
local ptStartBladeCenter = ptStartAtDepth + Edge.vtN * Tool.dDiameter / 2
|
||||
local ptEndBladeCenter = ptEndAtDepth + Edge.vtN * Tool.dDiameter / 2
|
||||
|
||||
-- il box si espande in tutte le direzioni per contemplare la sicurezza CUT_SIC
|
||||
local b3BoxPartExpanded = BBox3d( Part.b3Part) ; b3BoxPartExpanded:expand( BeamData.CUT_SIC)
|
||||
|
||||
-- calcolo distanza per uscire dal box con questa lama
|
||||
-- calcolo distanza per uscire dal box con questa lama nella direzione vtLeadInOut
|
||||
local dLeadInLength = CalculateLeadInOutLength( ptStartBladeCenter, Face.vtN, b3BoxPartExpanded, vtLeadInOut, Tool)
|
||||
local dLeadOutLength = CalculateLeadInOutLength( ptEndBladeCenter, Face.vtN, b3BoxPartExpanded, vtLeadInOut, Tool)
|
||||
|
||||
@@ -144,8 +156,16 @@ function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters)
|
||||
LeadOut.dTangentDistance = dLeadOutLength * vtLeadInOuttLoc:getX()
|
||||
|
||||
elseif sLeadInOutType == 'Tangent' then
|
||||
LeadIn.dTangentDistance = Tool.dDiameter / 2 + BeamData.CUT_SIC
|
||||
LeadOut.dTangentDistance = Tool.dDiameter / 2 + BeamData.CUT_SIC
|
||||
|
||||
-- calcolo distanza per uscire dal box con questa lama nella direzione tangenziale
|
||||
local dLeadInLength = CalculateLeadInOutLength( ptStartBladeCenter, Face.vtN, b3BoxPartExpanded, -Edge.vtEdge, Tool)
|
||||
local dLeadOutLength = CalculateLeadInOutLength( ptEndBladeCenter, Face.vtN, b3BoxPartExpanded, Edge.vtEdge, Tool)
|
||||
|
||||
-- componenti dell'attacco
|
||||
LeadIn.dPerpDistance = 0
|
||||
LeadIn.dTangentDistance = dLeadInLength
|
||||
LeadOut.dPerpDistance = 0
|
||||
LeadOut.dTangentDistance = dLeadOutLength
|
||||
end
|
||||
|
||||
LeadIn.dTotalLength = sqrt( LeadIn.dPerpDistance ^ 2 + LeadIn.dTangentDistance ^ 2)
|
||||
|
||||
@@ -70,6 +70,8 @@ local function GetLeadInOut( Machining, EdgeToMachine, bIsSplitFeature)
|
||||
LeadIn.dTangentDistance = 0
|
||||
LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset
|
||||
LeadOut.dTangentDistance = 0
|
||||
LeadIn.dTotalLength = sqrt( LeadIn.dPerpDistance ^ 2 + LeadIn.dTangentDistance ^ 2)
|
||||
LeadOut.dTotalLength = sqrt( LeadOut.dPerpDistance ^ 2 + LeadOut.dTangentDistance ^ 2)
|
||||
elseif Machining.sEdgeUsage == 'Reduced' then
|
||||
LeadIn.dStartAddLength = - FACEBYBLADE.GetPathReductionLength( Machining.nToolIndex, Machining.dMaxRadialOffset)
|
||||
LeadOut.dEndAddLength = - FACEBYBLADE.GetPathReductionLength( Machining.nToolIndex, Machining.dMaxRadialOffset)
|
||||
@@ -77,6 +79,8 @@ local function GetLeadInOut( Machining, EdgeToMachine, bIsSplitFeature)
|
||||
LeadIn.dTangentDistance = 0
|
||||
LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset
|
||||
LeadOut.dTangentDistance = 0
|
||||
LeadIn.dTotalLength = sqrt( LeadIn.dPerpDistance ^ 2 + LeadIn.dTangentDistance ^ 2)
|
||||
LeadOut.dTotalLength = sqrt( LeadOut.dPerpDistance ^ 2 + LeadOut.dTangentDistance ^ 2)
|
||||
end
|
||||
|
||||
-- se lavorazione con OppositeToolDirection o ridotta l'attacco va corretto
|
||||
|
||||
Reference in New Issue
Block a user