diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index d114730..085500b 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -146,11 +146,13 @@ function BeamExec.GetToolsFromDB() Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP', 'd') or ( Tool.dMaxMaterial / 3) -- se non settato nell'utensile, considero metà del tagliente Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP', 'd') or floor( Tool.dDiameter / 3) -- se non settato nell'utensile, considero metà del diametro Tool.bIsPen = abs( Tool.dSpeed) < 5 + Tool.dPerformanceIndex = ( Tool.dDiameter * Tool.dMaxMaterial) / Tool.dLength -- recupero parametri propri delle lame elseif sToolFamily == 'SAWBLADE' then Tool.bIsUsedForLongCut = EgtGetValInNotes( Tool.sUserNotes, 'LONGCUT') == 1 or false -- false come valore di default Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP', 'd') or Tool.dThickness -- se non settato nell'utensile, considero lo spessore lama Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP', 'd') or Tool.dMaxMaterial -- se non settato nell'utensile, considero un quarto del diametro + Tool.dPerformanceIndex = 1 / ( Tool.dDiameter * Tool.dLength) -- recupero parametri propri delle motoseghe elseif sToolFamily == 'MORTISE' then Tool.dDistance = EgtTdbGetCurrToolParam( MCH_TP.DIST) or 90 -- 90mm dimensione standard aggregato catena @@ -160,7 +162,11 @@ function BeamExec.GetToolsFromDB() Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP', 'd') or ( Tool.dThickness - 1) -- se non settato nell'utensile, considero spessore catena meno 1mm di sicurezza Tool.dCornerRadius = EgtTdbGetCurrToolParam( MCH_TP.CORNRAD) Tool.dWidth = Tool.dDiameter + Tool.dPerformanceIndex = 1 / Tool.dLength end + -- drillbit + else + Tool.dPerformanceIndex = Tool.dDiameter / Tool.dLength end -- se tutti i dati necessari sono disponibili, inserisco utensile nella lista globale degli utensili disponibili diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index bb15c35..0b713af 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -258,7 +258,7 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters) -- se hanno stesso montaggio elseif TOOLS[i].SetupInfo.bToolOnAggregate == TOOLS[nBestToolIndex].SetupInfo.bToolOnAggregate then -- scelgo utensile con indice di bontà utensile calcolato come: lunghezza / massimo materiale / diametro - if ( TOOLS[i].dLength / TOOLS[i].dMaxMaterial) / TOOLS[i].dDiameter < ( TOOLS[nBestToolIndex].dLength / TOOLS[nBestToolIndex].dMaxMaterial) / TOOLS[nBestToolIndex].dDiameter then + if TOOLS[i].dPerformanceIndex > TOOLS[nBestToolIndex].dPerformanceIndex then nBestToolIndex = i dBestToolResidualDepth = dCurrentResidualDepth end @@ -395,7 +395,7 @@ function MachiningLib.FindChainSaw( Proc, ToolSearchParameters) -- se entrambi completi if dBestToolResidualDepth <= 0 and dCurrentResidualDepth <= 0 then -- scelgo utensile con rapporto lunghezza / diametro minore - if ( TOOLS[i].dLength / pow( TOOLS[i].dDiameter, 1.5)) < ( TOOLS[nBestToolIndex].dLength / pow( TOOLS[nBestToolIndex].dDiameter, 1.5)) then + if TOOLS[i].dPerformanceIndex > TOOLS[nBestToolIndex].dPerformanceIndex then nBestToolIndex = i dBestToolResidualDepth = dCurrentResidualDepth end @@ -721,6 +721,9 @@ function MachiningLib.PrepareMachiningsForSorting( Part) for i = 1, #MACHININGS do local MachiningCurrent = MACHININGS[i].Machining local ProcCurrent = MACHININGS[i].Proc + if not MachiningCurrent.ptCenter then + MachiningCurrent.ptCenter = Point3d( ProcCurrent.b3Box:getCenter():getX(), 0, 0) + end -- conversione campo sStage in nStage, numerico e ordinabile if not MachiningCurrent.sStage or MachiningCurrent.sStage == '' then @@ -754,9 +757,6 @@ function MachiningLib.PrepareMachiningsForSorting( Part) -- se fase di lavoro standard, assegnazione dello spezzone if MachiningCurrent.nStage == 2 then - if not MachiningCurrent.ptCenter then - MachiningCurrent.ptCenter = Point3d( ProcCurrent.b3Box:getCenter():getX(), 0, 0) - end local nParts = #Part.SplittingPoints + 1 local dPartMinX = Part.b3Part:getMin():getX() local dPartMaxX = Part.b3Part:getMax():getX() @@ -823,6 +823,9 @@ local SortingComparisonRules = { end end, + -- testa + -- TODO da fare + -- famiglia utensile function ( MachiningA, MachiningB) -- TODO tirare fuori da qua?? @@ -832,14 +835,82 @@ local SortingComparisonRules = { MILL = 3, MORTISE = 4 } + local nToolFamilyOrderA = ToolFamilyOrder[ TOOLS[ MachiningA.Machining.nToolIndex].sFamily] + local nToolFamilyOrderB = ToolFamilyOrder[ TOOLS[ MachiningB.Machining.nToolIndex].sFamily] - if ToolFamilyOrder[ TOOLS[ MachiningA.Machining.nToolIndex].sFamily] < ToolFamilyOrder[ TOOLS[ MachiningB.Machining.nToolIndex].sFamily] then + if nToolFamilyOrderA < nToolFamilyOrderB then return 1 - elseif ToolFamilyOrder[ TOOLS[ MachiningA.Machining.nToolIndex].sFamily] > ToolFamilyOrder[ TOOLS[ MachiningB.Machining.nToolIndex].sFamily] then + elseif nToolFamilyOrderA > nToolFamilyOrderB then return -1 else return 0 end + end, + + -- performance utensile + function( MachiningA, MachiningB) + local dToolPerformanceIndexA = TOOLS[MachiningA.Machining.nToolIndex].dPerformanceIndex + local dToolPerformanceIndexB = TOOLS[MachiningB.Machining.nToolIndex].dPerformanceIndex + + if dToolPerformanceIndexA > dToolPerformanceIndexB then + return 1 + elseif dToolPerformanceIndexA < dToolPerformanceIndexB then + return -1 + else + return 0 + end + end, + + -- probabilmente arrivati qui significa che gli utensili A e B sono gli stessi + -- se così non fosse e tutte le caratteristiche sopra sono uguali, ordine alfabetico + function( MachiningA, MachiningB) + local sToolNameA = TOOLS[MachiningA.Machining.nToolIndex].sName + local sToolNameB = TOOLS[MachiningB.Machining.nToolIndex].sName + + if sToolNameA < sToolNameB then + return 1 + elseif sToolNameA > sToolNameB then + return -1 + else + return 0 + end + end, + + -- lato di lavoro + -- TODO questo, insieme all'ordinamento X, andranno sostituiti dallo shortest path pesato sulla quantità di rotazione della testa + function( MachiningA, MachiningB) + if MachiningA.Machining.vtToolDirection:getY() < 10 * GEO.EPS_SMALL and MachiningB.Machining.vtToolDirection:getY() >= 10 * GEO.EPS_SMALL then + return 1 + elseif MachiningA.Machining.vtToolDirection:getY() >= 10 * GEO.EPS_SMALL and MachiningB.Machining.vtToolDirection:getY() < 10 * GEO.EPS_SMALL then + return -1 + else + return 0 + end + end, + + -- ordinamento X + -- TODO questo andrà sostituito dallo shortest path pesato sulla quantità di rotazione della testa + function( MachiningA, MachiningB) + local bIsMachiningOnFront = MachiningA.Machining.vtToolDirection:getY() < 10 * GEO.EPS_SMALL + local nResult = 0 + + -- se lavorazione davanti ordine testa->coda + if bIsMachiningOnFront then + if MachiningA.Machining.ptCenter:getX() > MachiningB.Machining.ptCenter:getX() + 10 * GEO.EPS_SMALL then + nResult = 1 + elseif MachiningA.Machining.ptCenter:getX() < MachiningB.Machining.ptCenter:getX() - 10 * GEO.EPS_SMALL then + nResult = -1 + end + -- se lavorazione dietro ordine coda->testa + else + if MachiningA.Machining.ptCenter:getX() < MachiningB.Machining.ptCenter:getX() - 10 * GEO.EPS_SMALL then + nResult = 1 + elseif MachiningA.Machining.ptCenter:getX() > MachiningB.Machining.ptCenter:getX() + 10 * GEO.EPS_SMALL then + nResult = -1 + end + end + + return nResult end } diff --git a/Strategies/Core/FACEBYBLADE.lua b/Strategies/Core/FACEBYBLADE.lua index 424b70d..6a67764 100644 --- a/Strategies/Core/FACEBYBLADE.lua +++ b/Strategies/Core/FACEBYBLADE.lua @@ -77,6 +77,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.nToolIndex = OptionalParameters.nToolIndex Cutting.Geometry = {{ Proc.id, FaceToMachine}} Cutting.id = Proc.id + Cutting.vtToolDirection = vtMachiningDirection -- ===== calcolo LeadIn/out ===== diff --git a/Strategies/Core/SLOTBYBLADE.lua b/Strategies/Core/SLOTBYBLADE.lua index e0763b6..5bb1fbe 100644 --- a/Strategies/Core/SLOTBYBLADE.lua +++ b/Strategies/Core/SLOTBYBLADE.lua @@ -108,6 +108,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.dEdgeLength = EdgeToMachine.dLength Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtToolDirection, GDB_ID.ROOT) Cutting.vtEdgeDirection = EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN + Cutting.vtToolDirection = EdgeToMachine.vtToolDirection local dPocketHeight = 0 if Proc.Topology.sFamily == 'Tunnel' then diff --git a/Strategies/Core/SLOTBYCHAINSAW.lua b/Strategies/Core/SLOTBYCHAINSAW.lua index 692bc97..c6016fb 100644 --- a/Strategies/Core/SLOTBYCHAINSAW.lua +++ b/Strategies/Core/SLOTBYCHAINSAW.lua @@ -75,6 +75,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional Mortising.dEdgeLength = EdgeToMachine.dLength Mortising.ptEdge1, _, Mortising.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtToolDirection, GDB_ID.ROOT) Mortising.vtEdgeDirection = EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN + Mortising.vtToolDirection = EdgeToMachine.vtToolDirection -- altezza tasca, in base alla topologia local dPocketHeight = 0 @@ -185,7 +186,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional -- offset radiale Mortising.dRadialOffset = 0 -- distanza di sicurezza - Mortising.dStartSafetyLength = max( EdgeToMachine.dElevation, 10) + Mortising.dStartSafetyLength = max( EdgeToMachine.dElevation, ( TOOLS[Mortising.nToolIndex].SetupInfo.dZSafeDelta or 60) + EgtMdbGetGeneralParam( MCH_GP.SAFEZ)) -- overlap Mortising.dOverlap = 0 -- step diff --git a/Strategies/Standard/STR0002/STR0002.lua b/Strategies/Standard/STR0002/STR0002.lua index dda384a..2741a59 100644 --- a/Strategies/Standard/STR0002/STR0002.lua +++ b/Strategies/Standard/STR0002/STR0002.lua @@ -460,13 +460,15 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters) -- se ho una sola trimesh, sto lavorando la Proc direttamente e non ho spezzato. Applico direttamente alla geometria calcolata prima if #vAddId == 1 then Pocketing.Geometry = {{ Strategy.Machining[j].idProc, Strategy.Machining[j].idFaceToMachine}} + Pocketing.vtToolDirection = Proc.Faces[ Strategy.Machining[j].idFaceToMachine + 1].vtN bAreAllMachiningsAdded = MachiningLib.AddNewMachining( Proc, Pocketing) else -- TODO settare parametro per indicare qual è lo spezzone che deve essere fatto dopo il taglio di separazione for k = 1, Proc.nFct do local vtNSplitFace local nIdTm = EgtIf( Strategy.Machining[j].bMachAppliedToTunnelFace, vAddIdTunnel[i], vAddId[i]) - vtNSplitFace = EgtSurfTmFacetNormVersor( nIdTm, k - 1, GDB_ID.ROOT) + Pocketing.ptCenter, vtNSplitFace = EgtSurfTmFacetCenter( nIdTm, k - 1, GDB_ID.ROOT) + Pocketing.vtToolDirection = vtNSplitFace if vtNSplitFace and AreSameVectorApprox( vtNSplitFace * EgtIf( Pocketing.bToolInvert, -1, 1), Strategy.Machining[j].vtFaceNormal) then Pocketing.Geometry = {{ nIdTm, k - 1}} bAreAllMachiningsAdded = bAreAllMachiningsAdded and MachiningLib.AddNewMachining( Proc, Pocketing)