- in FaceData Elevation è sempre positiva nelle facce standard (non MainFaces)

- in MachiningLib in GetSplitMachinings correzioni alla definizione dello stage della lavorazione; correzione a FindBlade
- in SLOTBYBLADE e SLOTBYCHAINSAW correzioni per poter passare la profondità di lavoro
- in STR0005 primo implemento di lavorazione con codolo
This commit is contained in:
luca.mazzoleni
2025-01-21 15:27:33 +01:00
parent fc6b50b345
commit 40e76a23c9
6 changed files with 112 additions and 39 deletions
+14 -8
View File
@@ -116,11 +116,11 @@ local function GetEdgesInfo( Proc, idFace )
CurrentEdge.idAdjacentFace = EdgesEgt[i].Adj
CurrentEdge.vtToolDirection = Vector3d( EdgesEgt[i].Norm)
CurrentEdge.dLength = EdgesEgt[i].Len
CurrentEdge.dLengthOnX = abs( CurrentEdge.dLength * CurrentEdge.vtToolDirection:getY())
CurrentEdge.dElevation = EdgesEgt[i].Elev
CurrentEdge.dElevation = abs( EdgesEgt[i].Elev)
CurrentEdge.bIsOpen = EdgesEgt[i].Open
CurrentEdge.bIsStartOpen = EdgesEgt[nPreviousEdgeIndex].Open
CurrentEdge.bIsEndOpen = EdgesEgt[nNextEdgeIndex].Open
CurrentEdge.sType = 'Standard'
table.insert( Edges, CurrentEdge)
end
@@ -300,9 +300,11 @@ local function GetBottomFaces( Proc)
CurrentEdge.idAdjacentFace = BottomFaces[1].Edges[i].idAdjacentFace
CurrentEdge.vtToolDirection = BottomFaces[1].Edges[i].vtToolDirection
CurrentEdge.dLength = BottomFaces[1].Edges[i].dLength
CurrentEdge.dLengthOnX = BottomFaces[1].Edges[i].dLengthOnX
CurrentEdge.dElevation = BottomFaces[1].Edges[i].dElevation
CurrentEdge.bIsOpen = BottomFaces[1].Edges[i].bIsOpen
CurrentEdge.dElevation = BottomFaces[1].Edges[i].dElevation
if CurrentEdge.bIsOpen then
CurrentEdge.dElevation = -CurrentEdge.dElevation
end
CurrentEdge.bIsStartOpen = BottomFaces[1].Edges[i].bIsStartOpen
CurrentEdge.bIsEndOpen = BottomFaces[1].Edges[i].bIsEndOpen
@@ -386,9 +388,11 @@ local function GetLongFaces( Proc, MainFaces)
CurrentEdge.idAdjacentFace = LongFaces[i].Edges[j].idAdjacentFace
CurrentEdge.vtToolDirection = LongFaces[i].Edges[j].vtToolDirection
CurrentEdge.dLength = LongFaces[i].Edges[j].dLength
CurrentEdge.dLengthOnX = LongFaces[i].Edges[j].dLengthOnX
CurrentEdge.dElevation = LongFaces[i].Edges[j].dElevation
CurrentEdge.bIsOpen = LongFaces[i].Edges[j].bIsOpen
CurrentEdge.dElevation = LongFaces[i].Edges[j].dElevation
if CurrentEdge.bIsOpen then
CurrentEdge.dElevation = -CurrentEdge.dElevation
end
CurrentEdge.bIsStartOpen = LongFaces[i].Edges[j].bIsStartOpen
CurrentEdge.bIsEndOpen = LongFaces[i].Edges[j].bIsEndOpen
@@ -473,9 +477,11 @@ local function GetSideFaces( Proc, MainFaces)
CurrentEdge.idAdjacentFace = SideFaces[i].Edges[j].idAdjacentFace
CurrentEdge.vtToolDirection = SideFaces[i].Edges[j].vtToolDirection
CurrentEdge.dLength = SideFaces[i].Edges[j].dLength
CurrentEdge.dLengthOnX = SideFaces[i].Edges[j].dLengthOnX
CurrentEdge.dElevation = SideFaces[i].Edges[j].dElevation
CurrentEdge.bIsOpen = SideFaces[i].Edges[j].bIsOpen
CurrentEdge.dElevation = SideFaces[i].Edges[j].dElevation
if CurrentEdge.bIsOpen then
CurrentEdge.dElevation = -CurrentEdge.dElevation
end
CurrentEdge.bIsStartOpen = SideFaces[i].Edges[j].bIsStartOpen
CurrentEdge.bIsEndOpen = SideFaces[i].Edges[j].bIsEndOpen
+5
View File
@@ -118,6 +118,7 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part )
end
local dOriginalStartAddLength = Machinings[i].LeadIn.dStartAddLength
local dOriginalEndAddLength = Machinings[i].LeadOut.dEndAddLength
local sOriginalStage = Machinings[i].sStage
if FeatureLib.IsMachiningLong( Machinings[i].dLengthOnX, Part) then
local nCurrentMachiningIndex = i
-- lo spezzone attivo è quello precedente al punto di spezzatura corrente
@@ -158,6 +159,8 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part )
end
if not bIsLastSegment then
Machinings[nCurrentMachiningIndex].sStage = ''
else
Machinings[nCurrentMachiningIndex].sStage = sOriginalStage
end
Machinings[nCurrentMachiningIndex].nFeatureSegment = j
end
@@ -317,6 +320,8 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters)
bIsToolCompatible = TOOLS[i].SetupInfo.bIsTopHead
elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then
bIsToolCompatible = TOOLS[i].SetupInfo.bIsBottomHead
else
bIsToolCompatible = true
end
end
+58 -16
View File
@@ -10,7 +10,7 @@ local MachiningLib = require( 'MachiningLib')
local FeatureLib = require( 'FeatureLib')
-- strategie di base
local BladeToWaste = require( 'BLADETOWASTE')
local FaceByBlade = require( 'FACEBYBLADE')
local SlotByBlade = require( 'SLOTBYBLADE')
-- Tabella per definizione modulo
local STR0005 = {}
@@ -52,6 +52,31 @@ function Blade.AddResult( Cutting)
end
function Blade.AddMachiningAllSteps( Proc, Cutting, AuxiliaryData)
local bMachiningAdded = false
if not AuxiliaryData then
AuxiliaryData = {}
end
AuxiliaryData.Clones = {}
local dOriginalRadialOffset = Cutting.dRadialOffset
local dOriginalLeadInPerpDistance = Cutting.LeadIn.dPerpDistance
local dOriginalLeadOutPerpDistance = Cutting.LeadOut.dPerpDistance
for i = 1, Cutting.HorizontalSteps.nCount do
AuxiliaryData.Clones[i] = {}
AuxiliaryData.Clones[i].LeadIn = {}
AuxiliaryData.Clones[i].LeadOut = {}
AuxiliaryData.Clones[i].dRadialOffset = dOriginalRadialOffset + Cutting.HorizontalSteps.dStep * ( Cutting.HorizontalSteps.nCount - i)
-- update distanza perpendicolare attacco per contemplare l'offset applicato
AuxiliaryData.Clones[i].LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - Cutting.dRadialOffset
AuxiliaryData.Clones[i].LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - Cutting.dRadialOffset
end
bMachiningAdded = MachiningLib.AddNewMachining( Proc, Cutting, AuxiliaryData)
return bMachiningAdded
end
function STR0005.Make( bAddMachining, Proc, Part, CustomParameters)
-- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti)
local StrategyLib = {}
@@ -63,10 +88,17 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters)
Strategy.Result.sInfo = ''
Blade.Result = {}
local dExtendAfterTail = Strategy.Parameters.dExtendAfterTail or max( Part.dDistanceToNextPiece - BeamData.CUT_EXTRA, 0)
if MachiningLib.CanExtendAfterTail( Strategy.Parameters.sCanDamageNextPiece, Part) then
dExtendAfterTail = 10000
end
local dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail = FeatureLib.GetFeatureMaxNotClampableLengths( Proc, Part)
local bLeaveWasteAttached = Strategy.Parameters.sCuttingStrategy == 'LEAVE_WASTE_ATTACHED'
local bFeatureHindersClamping = FeatureLib.IsMachiningLong( max( dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN})
local Cutting = {}
local MRRParametersBlade = {}
if bFeatureHindersClamping or bLeaveWasteAttached then
-- TODO Lavorazione con codolo
-- La FaceByBlade (o altra??) dovrà accettare opzionalmente di fermarsi prima (basta l'Offset??) e accettare l'utensile forzato.
@@ -82,7 +114,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters)
end
table.sort( EdgesSorted, CompareEdges)
local dDepthToMachine = EdgesSorted[1].dElevation / 2 + BeamData.CUT_EXTRA
local dDepthToMachine = abs( EdgesSorted[1].dElevation) / 2 - Strategy.Parameters.dStripWidth / 2
-- ricerca utensile
local ToolSearchParameters = {}
@@ -98,15 +130,30 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters)
Cutting.sMessage = 'Blade not found'
Cutting.bIsApplicable = false
EgtOutLog( Cutting.sMessage)
return Cutting, EdgeToMachine.dElevation
return Cutting, abs( EdgesSorted[1].dElevation)
end
-- parametri per il calcolo della velocità di asportazione
MRRParametersBlade = {
dStep = min( TOOLS[Cutting.nToolIndex].dStep, abs( EdgesSorted[1].dElevation)),
dSideStep = TOOLS[Cutting.nToolIndex].dThickness,
dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed
}
-- eventuali punti di spezzatura
local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part)
local bIsSplitFeature = false
if #FeatureSplittingPoints then
bIsSplitFeature = true
end
-- si lavora il primo lato
local OptionalParameters = { dRadialOffset = 100}
Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[1], OptionalParameters)
-- primo lato
local OptionalParameters = { dDepthToMachine = dDepthToMachine, nToolIndex = Cutting.nToolIndex, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail}
Cutting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[1], OptionalParameters)
Blade.AddResult( Cutting)
-- secondo lato
Cutting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[2], OptionalParameters)
--Blade.AddResult( Cutting)
-- lavorazioni raggruppate in unica lista
Blade.Result.Sorted = {}
@@ -116,14 +163,13 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters)
end
end
-- TODO ordinamento lavorazioni (se necessario)
-- aggiunta eventuali lavorazioni splittate
local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part)
if #FeatureSplittingPoints > 0 then
Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result, FeatureSplittingPoints, Part)
if bIsSplitFeature then
Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result.Sorted, FeatureSplittingPoints, Part)
end
-- TODO ordinamento lavorazioni (se necessario)
-- se la lavorazione con codolo fallisce o non è possibile si proseguirà a quella con cubetti
end
@@ -160,10 +206,6 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters)
end
Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dFinalCompletionPercentage)
Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Blade')
local MRRParametersBlade = {
dStep = min( TOOLS[Cutting.nToolIndex].dStep, Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength),
dSideStep = TOOLS[Cutting.nToolIndex].dThickness,
dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed}
local dMRRBlade = MachiningLib.GetToolMRR( MRRParametersBlade)
Strategy.Result.dMRR = dMRRBlade
@@ -16,7 +16,8 @@ local STR0005Data = {
{ sValue = 'DROP_WHOLE_WASTE', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''},
{ sValue = 'LEAVE_WASTE_ATTACHED', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}},
{ sName = 'dMaxWasteLength', sNameNge = 'MAX_WASTE_LENGTH', sValue = '300', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'},
{ sName = 'dMaxWasteVolume', sNameNge = 'MAX_WASTE_VOLUME', sValue = '6000000', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}
{ sName = 'dMaxWasteVolume', sNameNge = 'MAX_WASTE_VOLUME', sValue = '6000000', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'},
{ sName = 'dStripWidth', sNameNge = 'STRIP_WIDTH', sValue = '5', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}
}
}
+19 -9
View File
@@ -102,12 +102,17 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar
local bForceLongcutBlade = OptionalParameters.bForceLongcutBlade or false
local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000
local dPocketHeight = OptionalParameters.dPocketHeight or 0
local dDepthToMachine = min( OptionalParameters.dDepthToMachine or abs( EdgeToMachine.dElevation), abs( EdgeToMachine.dElevation))
local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false
-- lunghezze e punti caratteristici della lavorazione e del lato lavorato
Cutting.dLengthToMachine = EdgeToMachine.dLength
Cutting.dLengthOnX = abs( EdgeToMachine.dLength * EdgeToMachine.vtToolDirection:getY())
Cutting.dEdgeLength = EdgeToMachine.dLength
-- TODO conviene spostare questi calcoli nel FaceData?
Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtToolDirection, GDB_ID.ROOT)
local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2)
Cutting.dLengthOnX = b3BoxEdge:getDimX()
--
Cutting.vtToolDirection = EdgeToMachine.vtToolDirection
if EdgeToMachine.bIsOpen then
Cutting.vtEdgeDirection = -EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN
@@ -140,7 +145,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar
EgtOutLog( Cutting.sMessage)
return Cutting, EdgeToMachine.dElevation
end
if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then
if #( Proc.MainFaces) > 0 and #( Proc.MainFaces.SideFaces) > 1 then
-- se tasca più stretta della lama la strategia non è applicabile
if TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then
Cutting.sMessage = 'Pocket too narrow for blade diameter'
@@ -175,14 +180,14 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar
Cutting.bToolInvert = false
end
-- profondità da lavorare e offset radiale
if TOOLS[Cutting.nToolIndex].dMaxDepth > abs( EdgeToMachine.dElevation) - 10 * GEO.EPS_SMALL then
if TOOLS[Cutting.nToolIndex].dMaxDepth > dDepthToMachine - 10 * GEO.EPS_SMALL then
-- TODO la depth dovrebbe essere quella del machining
Cutting.dDepthToMachine = abs( EdgeToMachine.dElevation)
Cutting.dDepthToMachine = dDepthToMachine
Cutting.dResidualDepth = 0
if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then
Cutting.dRadialOffset = 0
Cutting.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine
else
Cutting.dRadialOffset = EdgeToMachine.dElevation
Cutting.dRadialOffset = -dDepthToMachine
end
else
Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].dMaxDepth - 1
@@ -243,7 +248,12 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar
-- se lavorazione aperta sulla coda, eventuali aggiustamenti
-- TODO valutare se fare funzione a parte
if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 10 * GEO.EPS_SMALL)) then
if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 0.707)) then
local dLengthOnX = Cutting.dLengthOnX
-- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione
if bIsSplitFeature then
dLengthOnX = 0
end
local bStartLeft = MachiningLib.StartsLeftSide( Cutting)
local dAddLengthLeftSide = Cutting.LeadOut.dEndAddLength
local dAddLengthToReduce = sqrt( Cutting.dDepthToMachine * TOOLS[Cutting.nToolIndex].dDiameter - Cutting.dDepthToMachine * Cutting.dDepthToMachine)
@@ -251,13 +261,13 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar
dAddLengthLeftSide = Cutting.LeadIn.dStartAddLength
end
if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtToolDirection, Y_AX()) then
if MachiningLib.CanMoveAfterSplitcut( Cutting.dLengthOnX, Part) then
if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then
Cutting.sStage = 'AfterTail'
else
Cutting.bIsApplicable = false
end
elseif dAddLengthLeftSide + dAddLengthToReduce > dExtendAfterTail then
if MachiningLib.CanMoveAfterSplitcut( Cutting.dLengthOnX, Part) then
if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then
Cutting.sStage = 'AfterTail'
else
if bStartLeft then
+14 -5
View File
@@ -69,12 +69,16 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional
local bStopAtHalfElevation = OptionalParameters.bStopAtHalfElevation or false
local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000
local dPocketHeight = OptionalParameters.dPocketHeight or 0
local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false
-- lunghezze e punti caratteristici della lavorazione e del lato lavorato
Mortising.dLengthToMachine = dLengthToMachine
Mortising.dLengthOnX = abs( dLengthToMachine * EdgeToMachine.vtToolDirection:getY())
Mortising.dEdgeLength = EdgeToMachine.dLength
-- TODO conviene spostare questi calcoli nel FaceData?
Mortising.ptEdge1, _, Mortising.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtToolDirection, GDB_ID.ROOT)
local b3BoxEdge = BBox3d( Mortising.ptEdge1, Mortising.ptEdge2)
Mortising.dLengthOnX = b3BoxEdge:getDimX()
-- TODO conviene spostare questi calcoli nel FaceData?
Mortising.vtToolDirection = EdgeToMachine.vtToolDirection
if EdgeToMachine.bIsOpen then
Mortising.vtEdgeDirection = -EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN
@@ -122,7 +126,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional
EgtOutLog( Mortising.sMessage)
return Mortising
end
if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then
if #( Proc.MainFaces) > 0 and #( Proc.MainFaces.SideFaces) > 1 then
-- se tasca più stretta della sega a catena la strategia non è applicabile
if TOOLS[Mortising.nToolIndex].dWidth > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then
Mortising.sMessage = 'Pocket too narrow for chainsaw width'
@@ -218,20 +222,25 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional
-- se lavorazione aperta sulla coda, eventuali aggiustamenti
-- TODO valutare se fare funzione a parte
if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 10 * GEO.EPS_SMALL)) then
if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 0.707)) then
local dLengthOnX = Mortising.dLengthOnX
-- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione
if bIsSplitFeature then
dLengthOnX = 0
end
local bStartLeft = MachiningLib.StartsLeftSide( Mortising)
local dAddLengthLeftSide = Mortising.LeadOut.dEndAddLength
if bStartLeft then
dAddLengthLeftSide = Mortising.LeadIn.dStartAddLength
end
if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtToolDirection, Y_AX()) then
if MachiningLib.CanMoveAfterSplitcut( Mortising.dLengthOnX, Part) then
if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then
Mortising.sStage = 'AfterTail'
else
Mortising.bIsApplicable = false
end
elseif dAddLengthLeftSide + TOOLS[Mortising.nToolIndex].dDiameter / 2 > dExtendAfterTail then
if MachiningLib.CanMoveAfterSplitcut( Mortising.dLengthOnX, Part) then
if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then
Mortising.sStage = 'AfterTail'
else
if bStartLeft then