From fe9aaf043996d67a63de0118f3f2722ef6a096df Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 11 Mar 2025 13:33:33 +0100 Subject: [PATCH] - SetupInfo.dMinNz sostituito con funzione GetMinNz (anche GetMaxNz); tutti hanno default in BeamLib - in BLADETOWASTE refactoring --- LuaLibs/BeamExec.lua | 11 ++- LuaLibs/BeamLib.lua | 8 +- LuaLibs/MachiningLib.lua | 8 +- StrategyLibs/BLADETOWASTE.lua | 165 +++++++++++++++++++--------------- 4 files changed, 112 insertions(+), 80 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index aea7b9e..edca3b5 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -122,7 +122,16 @@ function BeamExec.GetToolsFromDB() Tool.SetupInfo = {} Tool.SetupInfo = BeamData.GetSetupInfo( Tool.sHead) if not Tool.SetupInfo.GetMinNzDownUp then - Tool.SetupInfo.GetMinNzDownUp = BeamLib.GetMinNzDownUpDefault + Tool.SetupInfo.GetMinNzDownUp = BeamLib.GetMinNzDefault + end + if not Tool.SetupInfo.GetMinNz then + Tool.SetupInfo.GetMinNz = BeamLib.GetMinNzDefault + end + if not Tool.SetupInfo.GetMaxNz then + Tool.SetupInfo.GetMaxNz = BeamLib.GetMaxNzDefault + end + if not Tool.SetupInfo.dMaxMatDecrease then + Tool.SetupInfo.dMaxMatDecrease = 0 end Tool.sUUID = EgtTdbGetCurrToolParam( MCH_TP.UUID) Tool.sUserNotes = EgtTdbGetCurrToolParam( MCH_TP.USERNOTES) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index a37449b..ed24487 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -363,10 +363,16 @@ end ------------------------------------------------------------------------------------------------------------- -- funzione con valore di default in caso la GetSetupInfo della testa della macchina non avesse la funzione definita -function BeamLib.GetMinNzDownUpDefault( b3Raw, vtNFace, vtToolDirection) +function BeamLib.GetMinNzDefault( b3Raw, vtNFace, vtToolDirection) return -2 end +------------------------------------------------------------------------------------------------------------- +-- funzione con valore di default in caso la GetSetupInfo della testa della macchina non avesse la funzione definita +function BeamLib.GetMaxNzDefault( b3Raw, vtNFace, vtToolDirection) + return 2 +end + ------------------------------------------------------------------------------------------------------------- -- sovrascrivo i parametri personalizzati salvati su Proc a quelli di default dalla strategia -- N.B. : I parametri personalizzati non più presenti tra i default della strategia, verranno ignorati. Quelli extra avranno valore di default diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 1dc08e9..e750b7f 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -216,9 +216,9 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters) -- controlli standard elseif ToolSearchParameters.dMaxToolDiameter and TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then bIsToolCompatible = false - elseif TOOLS[i].SetupInfo.dMinNz and ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.dMinNz - GEO.EPS_ZERO then + elseif ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.GetMinNz( ToolSearchParameters.vtToolDirection) - GEO.EPS_ZERO then bIsToolCompatible = false - elseif TOOLS[i].SetupInfo.dMaxNz and ToolSearchParameters.vtToolDirection:getZ() > TOOLS[i].SetupInfo.dMaxNz + GEO.EPS_ZERO then + elseif ToolSearchParameters.vtToolDirection:getZ() > TOOLS[i].SetupInfo.GetMaxNz( ToolSearchParameters.vtToolDirection) + GEO.EPS_ZERO then bIsToolCompatible = false elseif ToolSearchParameters.sMillShape == 'STANDARD' and ( TOOLS[i].dSideAngle ~= 0 or TOOLS[i].bIsPen) then bIsToolCompatible = false @@ -334,10 +334,10 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) end -- check angolo limite lama - if TOOLS[i].SetupInfo.dMinNz and ToolSearchParameters.vtN:getZ() < TOOLS[i].SetupInfo.dMinNz - GEO.EPS_ZERO then + if ToolSearchParameters.vtN:getZ() < TOOLS[i].SetupInfo.GetMinNz( ToolSearchParameters.vtN) - GEO.EPS_ZERO then bIsToolCompatible = false end - if TOOLS[i].SetupInfo.dMaxNz and ToolSearchParameters.vtN:getZ() > TOOLS[i].SetupInfo.dMaxNz + GEO.EPS_ZERO then + if ToolSearchParameters.vtN:getZ() > TOOLS[i].SetupInfo.GetMaxNz( ToolSearchParameters.vtN) + GEO.EPS_ZERO then bIsToolCompatible = false end diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index 4026639..df4bd3c 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -17,7 +17,9 @@ local DiceCut = require( 'DiceCut') -- strategie di base local FaceByBlade = require('FACEBYBLADE') -EgtOutLog( ' BLADETOWASTE started', 1) +-- tabella per definizione modulo +local Machinings = {} +local FeatureInfo = {} ------------------------------------------------------------------------------------------------------------- local function CompareEdgesTopHead( EdgeA, EdgeB) @@ -176,10 +178,10 @@ local function GetBestBlade( Proc, Part, Face, OptionalParameters) dMinNzTopBlade = dMinNzTopBladeIfEqual -- lama sopra con aggregato - preferenza testa sopra elseif not TOOLS[nToolIndexTop].SetupInfo.bIsCSymmetrical then - dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexTop].SetupInfo.dMinNz / 2 + dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexTop].SetupInfo.GetMinNz( Face.vtN) / 2 -- lama sotto con aggregato - preferenza testa sotto elseif not TOOLS[nToolIndexBottom].SetupInfo.bIsCSymmetrical then - dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexBottom].SetupInfo.dMaxNz / 2 + dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexBottom].SetupInfo.GetMaxNz( Face.vtN) / 2 else error( 'GetBestBlade : unknown blade type') end @@ -232,11 +234,86 @@ local function SetDiceFaceInfo( Proc, idDiceFace, bSaveAddedGeometries) end -function BLADETOWASTE.Make( ProcOrId, Part, OptionalParameters) - local Machinings = {} +local function CutWholeWaste( Proc, Part, OptionalParameters) + local Cutting = {} local Result = {} + local EdgeToMachine = {} + local nToolIndex + local sChosenBladeType = '' + local dDepthToMachine = 0 local dCompletionPercentage = 0 + -- lato da lavorare in base al tipo di lama + local EdgeToMachineTopBlade = GetEdgeToMachine( Proc.Faces[1].Edges, Proc.Faces[1].vtN, 'Top') + local EdgeToMachineBottomBlade = GetEdgeToMachine( Proc.Faces[1].Edges, Proc.Faces[1].vtN, 'Bottom') + local EdgeToMachineTopBladeDownUp = GetEdgeToMachine( Proc.Faces[1].Edges, Proc.Faces[1].vtN, 'TopDownUp') + + -- scelta lama da sopra o da sotto + if OptionalParameters.nToolIndex then + nToolIndex = OptionalParameters.nToolIndex + else + local OptionalParametersGetBestBlade = { dElevationTop = EdgeToMachineTopBlade.dElevation + BeamData.CUT_EXTRA, + dElevationBottom = EdgeToMachineBottomBlade.dElevation + BeamData.CUT_EXTRA, + dElevationTopDownUp = EdgeToMachineTopBladeDownUp.dElevation + BeamData.CUT_EXTRA + } + nToolIndex, sChosenBladeType = GetBestBlade( Proc, Part, Proc.Faces[1], OptionalParametersGetBestBlade) + end + + -- utensile non trovato + if not nToolIndex then + Result.sStatus = 'Not-Applicable' + Result.dCompletionPercentage = 0 + + return Machinings, Result + end + + -- lato da lavorare definitivo + if sChosenBladeType == 'Top' then + EdgeToMachine = EdgeToMachineTopBlade + elseif sChosenBladeType == 'Bottom' then + EdgeToMachine = EdgeToMachineBottomBlade + elseif sChosenBladeType == 'TopDownUp' then + EdgeToMachine = EdgeToMachineTopBladeDownUp + end + + dDepthToMachine = EdgeToMachine.dElevation + BeamData.CUT_EXTRA + local dResidualDepth = dDepthToMachine - TOOLS[nToolIndex].dMaxMaterial + + -- TODO qui gestire il caso in cui si può tagliare da due lati (inizialmente solo se vtN:Y è ~= 0?). Andranno ricercati gli utensili di nuovo con l'elevazione a metà?? + if dResidualDepth < 10 * GEO.EPS_SMALL then + local OptionalParametersFaceByBlade = { dDepthToMachine = dDepthToMachine, nToolIndex = nToolIndex} + Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParametersFaceByBlade) + end + if Cutting.bIsApplicable or OptionalParameters.bDropWholeWaste then + table.insert( Machinings, Cutting) + dCompletionPercentage = Cutting.dCompletionPercentage or dCompletionPercentage + end + + -- risultati del calcolo + -- TODO funzione? + if Cutting.bIsApplicable then + if dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then + Result.sStatus = 'Completed' + else + Result.sStatus = 'Not-Completed' + end + else + Result.sStatus = 'Not-Applicable' + end + Result.dCompletionPercentage = dCompletionPercentage + Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dCompletionPercentage) + Result.nQuality = FeatureLib.GetFeatureQuality( 'Blade') + local dMRR = FeatureInfo.dFeatureVolume / ( EdgeToMachine.dLength / TOOLS[nToolIndex].Feeds.dFeed) + Result.dMRR = dMRR / pow( 10, 6) + + return Machinings, Result +end + + +function BLADETOWASTE.Make( ProcOrId, Part, OptionalParameters) + Machinings = {} + local Result = {} + -- disambiguazione feature vs id trimesh local Proc = {} if type( ProcOrId) == "table" then @@ -270,74 +347,16 @@ function BLADETOWASTE.Make( ProcOrId, Part, OptionalParameters) end -- dimensioni feature - local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part) - local dFeatureMaxDimension = max( Proc.b3Box:getDimX(), Proc.b3Box:getDimY()) - local bIsFeatureSmall = dFeatureVolume < dMaxWasteVolume + 10 * GEO.EPS_SMALL - and dFeatureMaxDimension < dMaxWasteLength + 10 * GEO.EPS_SMALL + FeatureInfo.dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part) + FeatureInfo.dFeatureMaxDimension = max( Proc.b3Box:getDimX(), Proc.b3Box:getDimY()) + FeatureInfo.bIsFeatureSmall = FeatureInfo.dFeatureVolume < dMaxWasteVolume + 10 * GEO.EPS_SMALL + and FeatureInfo.dFeatureMaxDimension < dMaxWasteLength + 10 * GEO.EPS_SMALL -- si taglia tutto lo scarto in una sola lavorazione -- TODO qui si deve entrare anche se lo spessore lama è maggiore dell'elevazione delle faccia - if Proc.nFct == 1 and ( bIsFeatureSmall or bDropWholeWaste) then - local Cutting = {} - local EdgeToMachine = {} - local sChosenBladeType = '' - local dDepthToMachine = 0 - - -- lato da lavorare in base al tipo di lama - local EdgeToMachineTopBlade = GetEdgeToMachine( Proc.Faces[1].Edges, Proc.Faces[1].vtN, 'Top') - local EdgeToMachineBottomBlade = GetEdgeToMachine( Proc.Faces[1].Edges, Proc.Faces[1].vtN, 'Bottom') - local EdgeToMachineTopBladeDownUp = GetEdgeToMachine( Proc.Faces[1].Edges, Proc.Faces[1].vtN, 'TopDownUp') - - -- scelta lama da sopra o da sotto - if not nToolIndex then - local OptionalParametersGetBestBlade = { dElevationTop = EdgeToMachineTopBlade.dElevation + BeamData.CUT_EXTRA, - dElevationBottom = EdgeToMachineBottomBlade.dElevation + BeamData.CUT_EXTRA, - dElevationTopDownUp = EdgeToMachineTopBladeDownUp.dElevation + BeamData.CUT_EXTRA - } - nToolIndex, sChosenBladeType = GetBestBlade( Proc, Part, Proc.Faces[1], OptionalParametersGetBestBlade) - end - - -- lato da lavorare definitivo - if sChosenBladeType == 'Top' then - EdgeToMachine = EdgeToMachineTopBlade - elseif sChosenBladeType == 'Bottom' then - EdgeToMachine = EdgeToMachineBottomBlade - elseif sChosenBladeType == 'TopDownUp' then - EdgeToMachine = EdgeToMachineTopBladeDownUp - end - - dDepthToMachine = EdgeToMachine.dElevation + BeamData.CUT_EXTRA - local dResidualDepth = dDepthToMachine - TOOLS[nToolIndex].dMaxMaterial - - -- TODO qui gestire il caso in cui si può tagliare da due lati (inizialmente solo se vtN:Y è ~= 0?). Andranno ricercati gli utensili di nuovo con l'elevazione a metà?? - if dResidualDepth < 10 * GEO.EPS_SMALL then - local OptionalParametersFaceByBlade = { dDepthToMachine = dDepthToMachine, nToolIndex = nToolIndex} - Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParametersFaceByBlade) - end - if Cutting.bIsApplicable or bDropWholeWaste then - table.insert( Machinings, Cutting) - dCompletionPercentage = Cutting.dCompletionPercentage or dCompletionPercentage - end - - -- risultati del calcolo - -- TODO funzione? - if Cutting.bIsApplicable then - if dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then - Result.sStatus = 'Completed' - else - Result.sStatus = 'Not-Completed' - end - else - Result.sStatus = 'Not-Applicable' - end - Result.dCompletionPercentage = dCompletionPercentage - Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dCompletionPercentage) - Result.nQuality = FeatureLib.GetFeatureQuality( 'Blade') - local dMRR = dFeatureVolume / ( EdgeToMachine.dLength / TOOLS[nToolIndex].Feeds.dFeed) - Result.dMRR = dMRR / pow( 10, 6) - - -- TODO bisogna ritornare solo se ha successo - if Cutting.bIsApplicable or bDropWholeWaste then + if Proc.nFct == 1 and ( FeatureInfo.bIsFeatureSmall or bDropWholeWaste) then + Machinings, Result = CutWholeWaste( Proc, Part, OptionalParameters) + if Result.sStatus == 'Completed' or ( bDropWholeWaste and Result.sStatus == 'Not-Completed') then return Machinings, Result end end @@ -371,9 +390,7 @@ function BLADETOWASTE.Make( ProcOrId, Part, OptionalParameters) -- calcolo dimensione cubetto e eventuale cubetto ridotto (tagli orizzontali con affondamento verticale) local dDiceDimension = min( TOOLS[nToolIndex].dMaxMaterial, BeamData.MAX_DIM_DICE) local dDiceDimensionReduced = dDiceDimension - if TOOLS[nToolIndex].SetupInfo.dMaxMatDecrease then - dDiceDimensionReduced = min( dDiceDimension, dDiceDimension - TOOLS[nToolIndex].SetupInfo.dMaxMatDecrease) - end + dDiceDimensionReduced = min( dDiceDimension, dDiceDimension - TOOLS[nToolIndex].SetupInfo.dMaxMatDecrease) dDiceDimension = dDiceDimension - BeamData.CUT_EXTRA dDiceDimensionReduced = dDiceDimensionReduced - BeamData.CUT_EXTRA @@ -511,7 +528,7 @@ function BLADETOWASTE.Make( ProcOrId, Part, OptionalParameters) Result.dCompletionPercentage = 0 end Result.nQuality = FeatureLib.GetFeatureQuality( 'Blade') - local dMRR = dFeatureVolume / ( dDiceDimension / TOOLS[nToolIndex].Feeds.dFeed) + local dMRR = FeatureInfo.dFeatureVolume / ( dDiceDimension / TOOLS[nToolIndex].Feeds.dFeed) Result.dMRR = dMRR / pow( 10, 6) -- restituire tabella contenente lavorazioni, già con cloni se necessari