diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 08b9d21..8758272 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1394,6 +1394,7 @@ function BeamExec.ProcessMachinings( PARTS) local bIsCombinationMachinable = false local vProc, MatrixResult while not bIsCombinationMachinable do + bIsCombinationMachinable = true local bAllStrategiesApplied = false -- si calcola la combinazione di lavorazione migliore vProc, MatrixResult = GetBestResultFromCombinationsMatrix( PROCESSINGS[nPart], PARTS[nPart]) @@ -1411,17 +1412,16 @@ function BeamExec.ProcessMachinings( PARTS) MACHININGS.Info.nSplitCutRotation = 1 -- sltrimenti si fanno tutti i calcoli else - -- salvo sul PART la posizione di partenza che è stata scelta - PARTS[nPart].nInitialPosition = MatrixResult.nInitialPosition - -- ordinamento di base delle feature vProc = OrderFeatures( vProc) -- esegue le strategie migliori che ha precedentemente scelto e salva le lavorazioni nella lista globale bAllStrategiesApplied = false - MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProc, PARTS[nPart], PARTS[nPart].nInitialPosition) + MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProc, PARTS[nPart], MatrixResult.nInitialPosition) bIsCombinationMachinable = bAllStrategiesApplied end + -- salvo sul PART la posizione di partenza che è stata scelta + PARTS[nPart].nInitialPosition = MatrixResult.nInitialPosition -- aggiunge tagli testa e coda in fasi opportune local nRotHeadCut = MatrixResult.nInitialPosition + MACHININGS.Info.nHeadCutRotation - 1 @@ -1451,7 +1451,7 @@ function BeamExec.ProcessMachinings( PARTS) table.insert( vProcHeadTail, PROCESSINGS[nPart].Rotation[nRotSplitCut][MatrixResult.nIndexTailCutInVProc]) bAllStrategiesApplied = false - MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProcHeadTail, PARTS[nPart], PARTS[nPart].nInitialPosition) + MACHININGS, bAllStrategiesApplied = CalculateMachinings( vProcHeadTail, PARTS[nPart], MatrixResult.nInitialPosition) bIsCombinationMachinable = bIsCombinationMachinable and bAllStrategiesApplied end diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index efd97be..b7cdae5 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -564,6 +564,56 @@ function BeamLib.FindEdgeBestOrientedAsDirection( Edges, vtDirection) return BestEdge end +------------------------------------------------------------------------------------------------------------- +-- nNearSide : 3=Z+, -3=Z- +function BeamLib.PutStartNearestToEdge( nCrvId, b3Raw, dMaxDist, nNearSide) + -- verifico che la curva sia chiusa + if not EgtCurveIsClosed( nCrvId) then return false end + -- recupero il versore normale al piano di lavoro o estrusione + local vtN = EgtCurveExtrusion( nCrvId, GDB_ID.ROOT) + -- coefficienti per riportare la distanza nel piano di lavoro + local dCoeffY = 0 + if abs( vtN:getY()) < 0.999 then dCoeffY= 1 / ( sqrt( 1 - vtN:getY() * vtN:getY())) end + local dCoeffZ = 0 + if abs( vtN:getZ()) < 0.999 then dCoeffZ = 1 / ( sqrt( 1 - vtN:getZ() * vtN:getZ())) end + -- cerco l'estremo più vicino al box e lo imposto come inizio (se da sotto escludo Zmax e viceversa) + local dUopt = 0 + local dDopt = GEO.INFINITO + local dSopt = GEO.INFINITO + local dUi, dUf = EgtCurveDomain( nCrvId) + for dU = dUi, dUf, 0.5 do + local ptP = EgtUP( nCrvId, dU, GDB_ID.ROOT) + local vtDp = EgtUV( nCrvId, dU, -1, GDB_ID.ROOT) + local vtDs = EgtUV( nCrvId, dU, 1, GDB_ID.ROOT) + local bTg = ( vtDp and vtDs and vtDp * vtDs > 0.96) + if ptP and bTg then + local vtMin = ptP - b3Raw:getMin() + local vtMax = ptP - b3Raw:getMax() + local dD = abs( vtMin:getY()) * dCoeffY + dD = min( abs( vtMax:getY()) * dCoeffY, dD) + dD = min( abs( vtMin:getZ()) * dCoeffZ, dD) + dD = min( abs( vtMax:getZ()) * dCoeffZ, dD) + local dS + if nNearSide == -3 then + dS = abs( vtMin:getZ() * dCoeffZ) + else --nNearSide == 3 + dS = abs( vtMax:getZ() * dCoeffZ) + end + if dD < dMaxDist and dS < dSopt + GEO.EPS_SMALL then + dUopt = dU + dDopt = dD + dSopt = dS + end + end + end + if abs( dUopt - dUi) > GEO.EPS_ZERO and abs( dUopt - dUf) > GEO.EPS_ZERO then + -- TODO. Non utilizzare la funzione EgtChangeClosedCurveStart perchè cambia proprietà della geometria. + -- dopo aver trovato l'entità di partenza, calcolare l'offset da aggiungere alla lavorazione per poter cominciare da questa entità (senza modifica della geometria) + EgtChangeClosedCurveStart( nCrvId, dUopt) + end + return true +end + --------------------------------------------------------------------- -- Merge sorting - algoritmo di sorting stabile, ossia che mantiene l'ordine relativo se gli elementi sono equivalenti -- TODO vedere come riordinare (tutto in tabella MergeSort??) diff --git a/Strategies/Standard/STR0006/STR0006.lua b/Strategies/Standard/STR0006/STR0006.lua index 9898cb0..e92c6e8 100644 --- a/Strategies/Standard/STR0006/STR0006.lua +++ b/Strategies/Standard/STR0006/STR0006.lua @@ -10,7 +10,6 @@ local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base local BladeToWaste = require( 'BLADETOWASTE') -local FaceByBlade = require('FACEBYBLADE') -- Tabella per definizione modulo local STR0006 = {} @@ -70,10 +69,10 @@ function GetTenonStrategy( Proc, Part) Machining.Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) if Machining.Milling.ToolInfo.nToolIndex then local bMachIsOk = true - if ( Proc.FeatureInfo.vtTenonN[3] < 0 and TOOLS[Machining.Milling.ToolInfo.nToolIndex].SetupInfo.HeadType.bTop) or - ( Proc.FeatureInfo.vtTenonN[3] > 0 and TOOLS[Machining.Milling.ToolInfo.nToolIndex].SetupInfo.HeadType.bBottom) then + if ( Proc.FeatureInfo.vtTenonN:getZ() < 0 and TOOLS[Machining.Milling.ToolInfo.nToolIndex].SetupInfo.HeadType.bTop) or + ( Proc.FeatureInfo.vtTenonN:getZ() > 0 and TOOLS[Machining.Milling.ToolInfo.nToolIndex].SetupInfo.HeadType.bBottom) then local dTotalLen = TOOLS[Machining.Milling.ToolInfo.nToolIndex].dLength + TOOLS[Machining.Milling.ToolInfo.nToolIndex].SetupInfo.dPivot - local dHorizSpace = dTotalLen * sqrt( 1 - ( Proc.FeatureInfo.vtTenonN[3] * Proc.FeatureInfo.vtTenonN[3])) + local dHorizSpace = dTotalLen * sqrt( 1 - ( Proc.FeatureInfo.vtTenonN:getZ() * Proc.FeatureInfo.vtTenonN:getZ())) if dHorizSpace - ( TOOLS[Machining.Milling.ToolInfo.nToolIndex].SetupInfo.dCAxisSideEncumbrance / 2) < Proc.b3Box:getDimX() then bMachIsOk = false end @@ -219,7 +218,6 @@ function STR0006.Make( bAddMachining, Proc, Part, CustomParameters) -- taglio di lama else - for i = 1, #Strategy.Machining.Cutting do if Strategy.Machining.Cutting.bIsApplicable then if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then @@ -249,6 +247,23 @@ function STR0006.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Machining.Milling.vtToolDirection = Proc.vtTNormal Strategy.Machining.Milling.sDepth = min( -Strategy.Machining.Milling.ToolInfo.dResidualDepth, 0) + local nNearSide -- +3 = Z+, -3 = Z- + local bShortPart = ( Part.b3Part:getDimX() < BeamData.LEN_SHORT_PART) + if TOOLS[Strategy.Machining.Milling.nToolIndex].SetupInfo.HeadType.bTop then + if bShortPart and Proc.FeatureInfo.vtTenonN:getX() < 0 and Proc.FeatureInfo.vtTenonN:getZ() > 0 then + nNearSide = -3 + else + nNearSide = 3 + end + else + if bShortPart and Proc.FeatureInfo.vtTenonN:getX() < 0 and Proc.FeatureInfo.vtTenonN:getZ() < 0 then + nNearSide = 3 + else + nNearSide = -3 + end + end + + BeamLib.PutStartNearestToEdge( Proc.FeatureInfo.idAddAuxGeom, Part.b3Raw, Proc.FeatureInfo.dTenonMaxDist, nNearSide) -- LeadIn / LeadOut Strategy.Machining.Milling.LeadIn = {} Strategy.Machining.Milling.LeadOut = {}