From e9d71ab75e82e7534187c91834aa509f5dbda462 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Thu, 2 Jan 2025 16:41:36 +0100 Subject: [PATCH] - Aggiunta chiamata strategia in BasicCustomerStrategies - Calcolo parametri aggiuntivi - Prima bozza (non funzionante) della strategia --- LuaLibs/BasicCustomerStrategies.lua | 2 + LuaLibs/FeatureLib.lua | 76 ++++++++++++++++++++--- Strategies/Standard/STR0001/STR0001.lua | 82 +++++++++++++++++++++++-- 3 files changed, 144 insertions(+), 16 deletions(-) diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index f0a2a80..495546d 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -215,6 +215,7 @@ local function GetStrategies_Egalware( Proc) --------------------------------------------------------------------- -- Feature : Dovetail Tenon elseif ID.IsDovetailTenon( Proc) then + Strategies = { { sStrategyId = 'STR0001'}} --------------------------------------------------------------------- -- Feature : Dovetail Mortise elseif ID.IsDovetailMortise( Proc) then @@ -473,6 +474,7 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Dovetail Tenon elseif ID.IsDovetailTenon( Proc) then + Strategies = { { sStrategyId = 'STR0001'}} --------------------------------------------------------------------- -- Feature : Dovetail Mortise elseif ID.IsDovetailMortise( Proc) then diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index 0ae6034..18e7155 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -209,6 +209,19 @@ function FeatureLib.ClassifyTopology( Proc, Part) return FeatureTopology end +------------------------------------------------------------------------------------------------------------- +function FeatureLib.GetAdditionalInfo( Proc, Part) + -- se foro calcolo altri dati + if ID.IsDrilling( Proc) then + -- assegno diametro e facce di ingresso e uscita (dati tabelle sempre per riferimento) + Proc.dDiam, Proc.dLen, Proc.nFcs, Proc.nFce = FeatureLib.GetDrillingData( Proc) + elseif ID.IsDovetailTenon( Proc) then + Proc.dDTLength, Proc.dDTMaxDist, Proc.vtDTNormal, Proc.ptDTCenter = FeatureLib.GetDoveTailTenonData( Proc) + end + + return Proc +end + ------------------------------------------------------------------------------------------------------------- -- Recupero dati foro e adattamento se speciale function FeatureLib.GetDrillingData( Proc) @@ -230,6 +243,59 @@ function FeatureLib.GetDrillingData( Proc) return dDiam, dLen, nFcs, nFce end +------------------------------------------------------------------------------------------------------------- +-- Recupero dati tenone a coda di rondine +function FeatureLib.GetDoveTailTenonData( Proc) + -- recupero e verifico l'entità curva + local idAux = EgtGetInfo( Proc.id, 'AUXID', 'i') + if idAux then idAux = idAux + Proc.id end + -- recupero i dati della curva + local vtExtr = EgtCurveExtrusion( idAux, GDB_RT.GLOB) + local ptBC = EgtGP( idAux, GDB_RT.GLOB) + -- determino altezza del tenone + local frDtTen = Frame3d( ptBC, vtExtr) + local b3DtTen = EgtGetBBoxRef( Proc.id, GDB_BB.STANDARD, frDtTen) + local dDtTenH = b3DtTen:getDimZ() + -- assegno centro e normale della faccia top + local vtN = vtExtr + local ptC = ptBC + vtN * dDtTenH + -- calcolo distanza massima della curva dal punto più lontano della base tenone Dt (facet 0) + local dMaxDist + for i = 0, Proc.nFct - 1 do + local ptFC, vtFN = EgtSurfTmFacetCenter( Proc.id, i, GDB_ID.ROOT) + if not AreSameVectorApprox( vtFN, vtN) or abs( ( ptFC - ptBC) * vtN) > 100 * GEO.EPS_SMALL then + break + end + local nLoopId, nLoopCnt = EgtExtractSurfTmFacetLoops( Proc.id, i, EgtGetParent( Proc.id)) + if nLoopId then + local dUmin, dUmax = EgtCurveDomain( nLoopId) + for dU = dUmin, dUmax do + local ptP = EgtUP( nLoopId, dU, GDB_ID.ROOT) + local ptNear = EgtNP( idAux, ptP, GDB_ID.ROOT) + local dDist = dist( ptP, ptNear) + if not dMaxDist or dDist > dMaxDist then + dMaxDist = dDist + end + end + for j = 1, nLoopCnt do + EgtErase( nLoopId + j - 1) + end + end + end + if not dMaxDist then + local b3DtAux = EgtGetBBoxRef( idAux, GDB_BB.STANDARD, frDtTen) + dMaxDist = 2 * ( b3DtTen:getRadius() - b3DtAux:getRadius()) + end + + Proc.dDTLength = dDtTenH + Proc.dDTMaxDist = dMaxDist + Proc.vtDTNormal = vtExtr + Proc.ptDTCenter = ptC + + return Proc.dDTLength, Proc.dDTMaxDist, Proc.vtDTNormal, Proc.ptDTCenter + +end + ------------------------------------------------------------------------------------------------------------- -- funzione che restituisce indice di completamento in base alla percentuale di volume lavorato function FeatureLib.GetFeatureCompletionIndex( dCompletionPercentage) @@ -395,15 +461,5 @@ function FeatureLib.GetFeatureSplittingPoints( Proc, Part, OptionalParameters) return FeatureSplittingPoints end -------------------------------------------------------------------------------------------------------------- -function FeatureLib.GetAdditionalInfo( Proc, Part) - -- se foro calcolo altri dati - if ID.IsDrilling( Proc) then - -- assegno diametro e facce di ingresso e uscita (dati tabelle sempre per riferimento) - Proc.dDiam, Proc.dLen, Proc.nFcs, Proc.nFce = FeatureLib.GetDrillingData( Proc) - end - return Proc -end - ------------------------------------------------------------------------------------------------------------- return FeatureLib \ No newline at end of file diff --git a/Strategies/Standard/STR0001/STR0001.lua b/Strategies/Standard/STR0001/STR0001.lua index a0ee662..54c024f 100644 --- a/Strategies/Standard/STR0001/STR0001.lua +++ b/Strategies/Standard/STR0001/STR0001.lua @@ -5,18 +5,88 @@ -- carico librerie local BeamLib = require( 'BeamLib') +local BeamData = require( 'BeamData') +local MachiningLib = require( 'MachiningLib') +local FeatureLib = require( 'FeatureLib') -- Tabella per definizione modulo local STR0001 = {} +local Strategy = {} ------------------------------------------------------------------------------------------------------------- -function STR0001.Make( AddMachining, Proc, Part, CustomParameters) - -- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) - local StrategyLib = {} - StrategyLib.Config = require( 'STR0001\\STR0001Config') - CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) - StrategyParameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) +function STR0001.Make( bAddMachining, Proc, Part, CustomParameters) + -- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) + local StrategyLib = {} + StrategyLib.Config = require( 'STR0001\\STR0001Config') + Strategy.sName = StrategyLib.Config.sStrategyId + CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) + Strategy.Machining = {} + Strategy.Result = {} + + local bAreAllMachiningsAdded = true + local ToolSearchParameters = {} + local Milling = {} + local Cutting = {} + local Pocketing = {} + + -- ===== RICERCA UTENSILE ===== + -- ricerca utensile per lavorare tenone coda di rondine + -- ricerca utensile per taglio del tenone in lunghezza + -- ricerca utensile di svuotatura (se richiesto) + ToolSearchParameters.dElevation = Proc.MainFaces.BottomFaces[1].dElevation + ToolSearchParameters.vtToolDirection = Proc.MainFaces.BottomFaces[1].vtN + ToolSearchParameters.sMillShape = 'DOVETAIL' + Milling.idFaceToMachine = Proc.MainFaces.BottomFaces[1].id + Milling.idProc = Proc.id + Milling.vtFaceNormal = Proc.MainFaces.BottomFaces[1].vtN + Milling.dElevation = Proc.MainFaces.BottomFaces[1].dElevation + Milling.ToolInfo = {} + Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill') + if Milling.ToolInfo.nToolIndex then + -- se utensile scelto è su aggregato, ricalcolo la qualità + if TOOLS[Milling.ToolInfo.nToolIndex].SetupInfo.bToolOnAggregate then + Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'MillOnAggregate') + end + local ParametersMRR = {} + ParametersMRR.nToolIndex = Milling.ToolInfo.nToolIndex + Milling.dMRR = MachiningLib.GetToolMRR( ParametersMRR) + end + + -- setto il risultato in base agli utensili trovati + -- lavorazione completa + if Milling.bIsApplicable and Cutting.bIsApplicable and ( Pocketing.bIsApplicable or Pocketing.bNotNeeded) then + Strategy.Result.sStatus = 'Completed' + Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( 100) + Strategy.Result.dMRR = ( Milling.dMRR + Cutting.dMRR + Pocketing.dMRR) / 3 + Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill') + -- lavorazione incompleta + elseif Cutting.bIsApplicable then + Strategy.Result.sStatus = 'Not-Completed' + Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( 50) + Strategy.Result.dMRR = ( Milling.dMRR + Cutting.dMRR + Pocketing.dMRR) / 3 + Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill') + if not Milling.bIsApplicable then + Strategy.Result.sInfo = 'DoveTail-Mill not found' + else + Strategy.Result.sInfo = 'DoveTail tenon not completed' + end + -- strategia non applicabile, manca il taglio di lama sulla lunghezza del tenone + else + Strategy.Result.sStatus = 'Not-Applicable' + Strategy.Result.nCompletionIndex = 0 + Strategy.Result.dMRR = 0 + Strategy.Result.nQuality = 0 + Strategy.Result.sInfo = 'Mill not found' + end + + -- applicazione delle lavorazioni + if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then + end + + return bAreAllMachiningsAdded, Strategy.Result end -------------------------------------------------------------------------------------------------------------