aggiunta la gestione delle lavorazioni in coda, per decidere se spostare dopo separazione o accorciarle:
- in MachiningLib aggiunte funzioni StartsLeftSide e CanExtendAfterTail; modificata GetSplitMachinings - Machining.nPart rinominato nSegment - in SLOTBYCHAINSAW.Make aggiunta sezione per gestire lavorazioni di coda - STR0004 adeguata per passare alla strategia di base le informazioni sulle lavorazioni di coda
This commit is contained in:
+45
-12
@@ -60,14 +60,36 @@ local function GetToolEntryAngle( Proc, vtTool)
|
||||
Angle.dTan = dTanAngle
|
||||
|
||||
return Angle
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- TODO da completare
|
||||
function MachiningLib.CanMoveAfterSplitcut( Part)
|
||||
local bMoveAfterSplitcut = false
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function MachiningLib.StartsLeftSide( Machining)
|
||||
local bStartsLeftSide = ( Machining.vtEdgeDirection:getX() > 10 * GEO.EPS_SMALL and not Machining.bInvert)
|
||||
or ( not( Machining.vtEdgeDirection:getX() > 10 * GEO.EPS_SMALL) and Machining.bInvert)
|
||||
|
||||
return bMoveAfterSplitcut
|
||||
return bStartsLeftSide
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- TODO valutare se c'è un modo più preciso di prevedere i casi in cui le lavorazioni dopo separazione sono da saltare
|
||||
function MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part)
|
||||
local bCanMoveAfterSplitcut = ( dLengthOnX < BeamData.LEN_SHORT_PART - 10 * GEO.EPS_SMALL)
|
||||
or ( dLengthOnX > 0.7 * Part.dLength + 10 * GEO.EPS_SMALL)
|
||||
|
||||
return bCanMoveAfterSplitcut
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function MachiningLib.CanExtendAfterTail( sCanDamageNextPiece, Part)
|
||||
local bCanExtendAfterTail = false
|
||||
|
||||
if sCanDamageNextPiece == 'ALWAYS' then
|
||||
bCanExtendAfterTail = true
|
||||
elseif sCanDamageNextPiece == 'ONLY_IF_RAWPART' then
|
||||
bCanExtendAfterTail = Part.bIsLastPart
|
||||
end
|
||||
|
||||
return bCanExtendAfterTail
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -96,9 +118,15 @@ function MachiningLib.GetSplitMachinings( Machinings, vSplittingPoints, Part )
|
||||
local dOriginalStartAddLength = Machinings[i].LeadIn.dStartAddLength
|
||||
local dOriginalEndAddLength = Machinings[i].LeadOut.dEndAddLength
|
||||
local nCurrentMachiningIndex = i
|
||||
-- lo spezzone attivo è quello precedente al punto di spezzatura corrente
|
||||
for j = 1, nParts do
|
||||
-- il punto di spezzatura deve essere all'interno del lato che si sta lavorando
|
||||
if ( j == nParts) or ( vSplittingPoints[j]:getX() > dEdgeMinX + 10 * GEO.EPS_SMALL and vSplittingPoints[j]:getX() < dEdgeMaxX - 10 * GEO.EPS_SMALL) then
|
||||
-- check ultimo segmento della lavorazione (NON della feature)
|
||||
local bIsLastSegment = ( nParts == 1)
|
||||
or ( ( ( j ~= 1) and vSplittingPoints[j - 1]:getX() > dEdgeMinX + 10 * GEO.EPS_SMALL)
|
||||
and ( j == nParts or vSplittingPoints[j]:getX() < dEdgeMinX + 10 * GEO.EPS_SMALL))
|
||||
-- se non è l'ultimo segmento della lavorazione, il punto di spezzatura deve essere all'interno del lato che si sta lavorando
|
||||
if ( j ~= nParts and ( vSplittingPoints[j]:getX() > dEdgeMinX + 10 * GEO.EPS_SMALL and vSplittingPoints[j]:getX() < dEdgeMaxX - 10 * GEO.EPS_SMALL))
|
||||
or bIsLastSegment then
|
||||
if j > 1 then
|
||||
nCurrentMachiningIndex = nCurrentMachiningIndex + 1
|
||||
table.insert( Machinings, nCurrentMachiningIndex, BeamLib.TableCopyDeep( Machinings[i]))
|
||||
@@ -114,15 +142,17 @@ function MachiningLib.GetSplitMachinings( Machinings, vSplittingPoints, Part )
|
||||
dStartAddLength = - ( dEdgeMaxX - vSplittingPoints[j - 1]:getX()) + BeamData.MILL_OVERLAP
|
||||
dEndAddLength = - ( vSplittingPoints[j]:getX() - dEdgeMinX) + BeamData.MILL_OVERLAP
|
||||
end
|
||||
if ( Machinings[nCurrentMachiningIndex].vtEdgeDirection:getX() > 10 * GEO.EPS_SMALL and not Machinings[nCurrentMachiningIndex].bInvert)
|
||||
or ( not( Machinings[nCurrentMachiningIndex].vtEdgeDirection:getX() > 10 * GEO.EPS_SMALL) and Machinings[nCurrentMachiningIndex].bInvert) then
|
||||
if MachiningLib.StartsLeftSide( Machinings[nCurrentMachiningIndex]) then
|
||||
dStartAddLength, dEndAddLength = dEndAddLength, dStartAddLength
|
||||
end
|
||||
|
||||
Machinings[nCurrentMachiningIndex].LeadIn.dStartAddLength = dStartAddLength
|
||||
Machinings[nCurrentMachiningIndex].LeadOut.dEndAddLength = dEndAddLength
|
||||
end
|
||||
Machinings[nCurrentMachiningIndex].nPart = j
|
||||
if not bIsLastSegment then
|
||||
Machinings[nCurrentMachiningIndex].bMoveAfterSplitcut = false
|
||||
end
|
||||
Machinings[nCurrentMachiningIndex].nSegment = j
|
||||
end
|
||||
-- anche le lavorazioni non splittate necessitano del segmento assegnato
|
||||
else
|
||||
@@ -135,7 +165,7 @@ function MachiningLib.GetSplitMachinings( Machinings, vSplittingPoints, Part )
|
||||
dNextSplitX = vSplittingPoints[j]:getX()
|
||||
end
|
||||
if dEdgeMinX > dNextSplitX - 10 * GEO.EPS_SMALL and dEdgeMaxX < dPreviousSplitX + 10 * GEO.EPS_SMALL then
|
||||
Machinings[i].nPart = j
|
||||
Machinings[i].nSegment = j
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -414,6 +444,7 @@ function MachiningLib.AddNewMachining( ProcToAdd, MachiningToAdd, AuxiliaryDataT
|
||||
Machining.Machining = MachiningToAdd
|
||||
Machining.AuxiliaryData = AuxiliaryDataToAdd or {}
|
||||
table.insert( MACHININGS, Machining)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -638,12 +669,14 @@ function MachiningLib.AddOperations( vProc, Part, sRotation)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return bAreAllMachiningApplyOk, sErr, bSplitExecuted
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function MachiningLib.ApplyMachining( bRecalc, bApplyPost)
|
||||
local bResult = EgtApplyMachining( bRecalc, bApplyPost)
|
||||
|
||||
return bResult
|
||||
end
|
||||
|
||||
|
||||
@@ -66,6 +66,11 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional
|
||||
local dLengthToMachine = OptionalParameters.dLengthToMachine or EdgeToMachine.dLength
|
||||
local dCustomMaxElev = OptionalParameters.dMaxElev or abs( EdgeToMachine.dElevation)
|
||||
local bStopAtHalfElevation = OptionalParameters.bStopAtHalfElevation or false
|
||||
local dDistanceToNextPiece = OptionalParameters.dDistanceToNextPiece or Part.dDistanceToNextPiece
|
||||
local bCanExtendAfterTail = true
|
||||
if type( OptionalParameters.bCanExtendAfterTail) == "boolean" then
|
||||
bCanExtendAfterTail = OptionalParameters.bCanExtendAfterTail
|
||||
end
|
||||
|
||||
-- lunghezze e punti caratteristici della lavorazione e del lato lavorato
|
||||
Mortising.dLengthToMachine = dLengthToMachine
|
||||
@@ -220,21 +225,35 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional
|
||||
-- nome operazione
|
||||
Mortising.sOperationName = 'Chainsaw_' .. ( EgtGetName( Mortising.idProc) or tostring( Mortising.idProc)) .. '_' .. tostring( FaceToMachine.id + 1)
|
||||
|
||||
-- eventuale avviso di danneggiamento pezzo successivo
|
||||
-- TODO da sostituire con check se si riesce a separare e il grezzo dietro è lungo a sufficienza
|
||||
-- local dOffsideLength = max( Mortising.LeadIn.dStartAddLength, Mortising.LeadOut.dEndAddLength) + TOOLS[Mortising.nToolIndex].dWidth / 2 + 10 * GEO.EPS_SMALL
|
||||
-- if ( not Proc.bTail or Proc.bAdvTail) and Proc.AffectedFaces.bLeft and ( Proc.dDistanceToNextPart < dOffsideLength) then
|
||||
-- local sDamageNextPieceMessage = 'Feature '.. Proc.idFeature .. ' : chainsaw can damage next piece.'
|
||||
-- if #Mortising.sMessage > 0 then
|
||||
-- Mortising.sMessage = Mortising.sMessage .. '\n' .. sDamageNextPieceMessage
|
||||
-- else
|
||||
-- Mortising.sMessage = sDamageNextPieceMessage
|
||||
-- end
|
||||
-- EgtOutLog( sDamageNextPieceMessage)
|
||||
-- end
|
||||
-- se lavorazione aperta sulla coda, eventuali aggiustamenti
|
||||
-- TODO valutare se fare funzione a parte
|
||||
if Proc.AffectedFaces.bLeft then
|
||||
local bStartLeft = MachiningLib.StartsLeftSide( Mortising)
|
||||
local dAddLengthLeftSide = Mortising.LeadIn.dStartAddLength
|
||||
if bStartLeft then
|
||||
dAddLengthLeftSide = Mortising.LeadOut.dEndAddLength
|
||||
end
|
||||
if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtToolDirection, Y_AX()) then
|
||||
if MachiningLib.CanMoveAfterSplitcut( Mortising.dLengthOnX, Part) then
|
||||
Mortising.bMoveAfterSplitcut = true
|
||||
else
|
||||
Mortising.bIsApplicable = false
|
||||
end
|
||||
elseif dAddLengthLeftSide + TOOLS[Mortising.nToolIndex].dDiameter / 2 > dDistanceToNextPiece then
|
||||
if MachiningLib.CanMoveAfterSplitcut( Mortising.dLengthOnX, Part) then
|
||||
Mortising.bMoveAfterSplitcut = true
|
||||
elseif not bCanExtendAfterTail then
|
||||
Mortising.bShortenedOnLeftSide = true
|
||||
if bStartLeft then
|
||||
Mortising.LeadOut.dEndAddLength = - TOOLS[Mortising.nToolIndex].dDiameter / 2
|
||||
else
|
||||
Mortising.LeadIn.dStartAddLength = - TOOLS[Mortising.nToolIndex].dDiameter / 2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Mortising
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -58,9 +58,9 @@ end
|
||||
|
||||
|
||||
local function CompareMachinings( MachiningA, MachiningB)
|
||||
if MachiningA.nPart > MachiningB.nPart then
|
||||
if MachiningA.nSegment > MachiningB.nSegment then
|
||||
return false
|
||||
elseif MachiningB.nPart > MachiningA.nPart then
|
||||
elseif MachiningB.nSegment > MachiningA.nSegment then
|
||||
return true
|
||||
else
|
||||
if MachiningA.sEdgeType == 'Side' and MachiningB.sEdgeType ~= 'Side' then
|
||||
@@ -150,42 +150,43 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters)
|
||||
end
|
||||
|
||||
-- calcolo lavorazioni
|
||||
local bCanExtendAfterTail = MachiningLib.CanExtendAfterTail( CustomParameters.sCanDamageNextPiece, Part)
|
||||
local Mortising = {}
|
||||
OptionalParameters = {}
|
||||
OptionalParameters = { bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
if Proc.Topology.sName == 'Groove-4-Blind' or Proc.Topology.sName == 'Pocket-5-Blind' then
|
||||
-- si lavora tutto il fondo
|
||||
local OptionalParameters = {}
|
||||
local OptionalParameters = { bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters)
|
||||
Chainsaw.AddResult( Mortising)
|
||||
-- materiale residuo - se possibile si lavora dal lato
|
||||
if Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].dResidualDepth > 10 * GEO.EPS_SMALL and #Proc.MainFaces.SideFaces == 1 then
|
||||
if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then
|
||||
local OptionalParameters = {}
|
||||
local OptionalParameters = { bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters)
|
||||
elseif Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then
|
||||
local OptionalParameters = {}
|
||||
local OptionalParameters = { bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters)
|
||||
end
|
||||
Chainsaw.AddResult( Mortising)
|
||||
end
|
||||
elseif Proc.Topology.sName == 'Groove-3-Through' then
|
||||
-- si lavora tutto il fondo
|
||||
local OptionalParameters = {}
|
||||
local OptionalParameters = { bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters)
|
||||
Chainsaw.AddResult( Mortising)
|
||||
-- materiale residuo - si lavorano i lati
|
||||
if Chainsaw.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL then
|
||||
local OptionalParameters = {}
|
||||
local OptionalParameters = { bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters)
|
||||
Chainsaw.AddResult( Mortising)
|
||||
-- ancora materiale residuo - si lavora da entrambi i lati
|
||||
if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then
|
||||
Chainsaw.Result.Side[1].bIsApplicable = false
|
||||
local OptionalParameters = { bStopAtHalfElevation = true}
|
||||
local OptionalParameters = { bStopAtHalfElevation = true, bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters)
|
||||
Chainsaw.AddResult( Mortising)
|
||||
OptionalParameters = {}
|
||||
OptionalParameters = { bStopAtHalfElevation = true}
|
||||
OptionalParameters = { bStopAtHalfElevation = true, bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters)
|
||||
Chainsaw.AddResult( Mortising)
|
||||
-- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo
|
||||
@@ -195,16 +196,16 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters)
|
||||
end
|
||||
end
|
||||
elseif Proc.Topology.sName == 'Tunnel-4-Through' then
|
||||
local OptionalParameters = {}
|
||||
local OptionalParameters = { bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters)
|
||||
Chainsaw.AddResult( Mortising)
|
||||
if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL then
|
||||
Chainsaw.Result.Opposite[1].bIsApplicable = false
|
||||
local OptionalParameters = { bStopAtHalfElevation = true}
|
||||
local OptionalParameters = { bStopAtHalfElevation = true, bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters)
|
||||
Chainsaw.AddResult( Mortising)
|
||||
OptionalParameters = {}
|
||||
OptionalParameters = { bStopAtHalfElevation = true}
|
||||
OptionalParameters = { bStopAtHalfElevation = true, bCanExtendAfterTail = bCanExtendAfterTail}
|
||||
SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters)
|
||||
Chainsaw.AddResult( Mortising)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user