From 8f2a09e5c78255e3d0c4c6e6f58c59b9a2707ed6 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 11 Nov 2025 12:12:00 +0100 Subject: [PATCH] =?UTF-8?q?-=20in=20BLADEKEEPWASTE,=20se=20lavorazione=20f?= =?UTF-8?q?allisce=20da=20un=20lato,=20si=20fa=20codolo=20tutto=20da=20un?= =?UTF-8?q?=20lato=20alla=20massima=20profondit=C3=A0=20-=20in=20BLADETOWA?= =?UTF-8?q?STE.CutWholeWaste,=20se=20fallisce=20il=20taglio=20doppio,=20si?= =?UTF-8?q?=20verificano=20i=20lati=20a=20minor=20elevazione=20MachiningLi?= =?UTF-8?q?b.GetBladeEngagement=20si=20restituisce=20anche=20se=20la=20lav?= =?UTF-8?q?orazione=20richiede=20separazione,=20verificata=20in=20Check2DB?= =?UTF-8?q?ladeCollision=20-=20in=20FACEBYBLADE=20gestita=20forzatura=20do?= =?UTF-8?q?po=20split=20dall'esterno=20-=20in=20BatchProcessNew=20e=20Proc?= =?UTF-8?q?ess=20si=20restituisce=20sempre=20sMsg,=20anche=20se=20feature?= =?UTF-8?q?=20completa=20-=20in=20FaceData=20rimosso=20logging=20MainFaces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BatchProcessNew.lua | 2 +- LuaLibs/FaceData.lua | 4 -- LuaLibs/MachiningLib.lua | 61 +++++++++++++++++++++---- Process.lua | 2 +- Strategies/Standard/STR0005/STR0005.lua | 3 +- StrategyLibs/BLADEKEEPWASTE.lua | 48 +++++++++++++++---- StrategyLibs/BLADETOWASTE.lua | 43 +++++++++++++++-- StrategyLibs/FACEBYBLADE.lua | 14 ++++-- 8 files changed, 141 insertions(+), 36 deletions(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 04f5a8e..62f6506 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -673,7 +673,7 @@ if bToProcess then -- trovata almeno una strategia e feature lavorata completamente if RESULT[i].sType == 'Feature' and RESULT[i].ChosenStrategy.sStatus == 'Completed' then BEAM.ERR = 0 - BEAM.MSG = '---' + BEAM.MSG = sMsg or '' BEAM.ROT = -( RESULT[i].nRotation or 1) + 1 BEAM.CUTID = RESULT[i].idCut BEAM.TASKID = RESULT[i].idTask diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index aeae3be..3013d82 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -674,10 +674,6 @@ function FaceData.GetMainFaces( Proc, Part) MainFaces.LongFaces = GetLongFaces( Proc, MainFaces) MainFaces.SideFaces = GetSideFaces( Proc, MainFaces) - -- scrivo informazioni delle facce nel log - if EgtGetDebugLevel() >= 3 then - Logs.WriteMainFacesLog( Proc, MainFaces) - end else MainFaces = nil EgtOutLog( '---MainFaces NOT NEEDED---') diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 3ab9cfc..51c5c1e 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -271,11 +271,11 @@ end -- in base a tipo testa e angolo soglia, verifica se la faccia è troppo inclinata per la lavorazione scelta (per DownUp passare vtNFace opposta) local function IsFaceZOutOfRange ( vtNFace, Tool) - -- lama sotto: angolo negativo troppo basso + -- lama sopra: angolo negativo troppo basso if Tool.SetupInfo.HeadType.bTop and vtNFace:getZ() < Tool.SetupInfo.GetMinNz( vtNFace, Tool) - GEO.EPS_ZERO then return true end - -- lama sopra: angolo positivo troppo elevato + -- lama sotto: angolo positivo troppo elevato if Tool.SetupInfo.HeadType.bBottom and vtNFace:getZ() > Tool.SetupInfo.GetMaxNz( vtNFace, Tool) + GEO.EPS_ZERO then return true end @@ -312,6 +312,22 @@ local function Check2DBladeCollision( Edge, vtNFace, vtHead, Part, Tool, dDepthT -- creazione flat region dalla silhouette local idPartSurfFr = EgtSurfFlatRegion( idTempGroup, idFirstCurve) + -- costruzione flat region del grezzo restante nel piano perpendicolare al taglio + -- si costruisce il box in globale + local ptRestLengthMax = Point3d( Part.b3Part:getMin() + X_AX() * 500 * GEO.EPS_SMALL) + local ptRestLengthMin = Point3d( Part.b3Part:getMin():getX() - 2000, Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ()) + local b3RestLength = BBox3d( ptRestLengthMin, ptRestLengthMax) + -- si crea la trimesh dal box + local idRestLengthBoxTm = EgtSurfTmBBox( idTempGroup, b3RestLength , false, GDB_RT.GLOB) + -- si estrae la silhouette nel piano + idFirstCurve, nCurveCount = EgtGetSurfTmSilhouette( idRestLengthBoxTm, vtEdge, 10 * GEO.EPS_SMALL, idTempGroup, GDB_RT.GLOB) + -- se più curve c'è qualcosa che non va: errore + if nCurveCount > 1 then + error( 'Check2DBladeCollision : error in part box') + end + -- creazione flat region dalla silhouette + local idRestLengthSurfFr = EgtSurfFlatRegion( idTempGroup, idFirstCurve) + -- costruzione flat region approssimata del motore nel piano perpendicolare al taglio -- punto di congiunzione tra motore e lama local ptMaxElev = ptMachining + Edge.vtN * Tool.dMaxMaterial @@ -329,7 +345,7 @@ local function Check2DBladeCollision( Edge, vtNFace, vtHead, Part, Tool, dDepthT -- flat region dal rettangolo local idHeadSurfFr = EgtSurfFlatRegion( idTempGroup, idHeadRectangle) - -- intersezione (se fallisce si inverte la flat region del motore, probabile normale opposta) + -- intersezione tra pezzo e motore (se fallisce si inverte la flat region del motore, probabile normale opposta) local bIntersectSuccess = EgtSurfFrIntersect( idPartSurfFr, idHeadSurfFr) if not bIntersectSuccess then EgtInvertSurf( idHeadSurfFr) @@ -339,9 +355,24 @@ local function Check2DBladeCollision( Edge, vtNFace, vtHead, Part, Tool, dDepthT error( 'Check2DBladeCollision : intersect fail') end - local bCollisionFound = EgtExistsObj( idPartSurfFr) + local bCollisionFoundPiece = EgtExistsObj( idPartSurfFr) - return bCollisionFound + -- intersezione tra grezzo restante e motore, se con il pezzo non c'è collisione + local bCollisionFoundRestLength + if not bCollisionFoundPiece then + bIntersectSuccess = EgtSurfFrIntersect( idRestLengthSurfFr, idHeadSurfFr) + if not bIntersectSuccess then + EgtInvertSurf( idHeadSurfFr) + bIntersectSuccess = EgtSurfFrIntersect( idRestLengthSurfFr, idHeadSurfFr) + end + if not bIntersectSuccess then + error( 'Check2DBladeCollision : intersect fail') + end + + bCollisionFoundRestLength = EgtExistsObj( idRestLengthSurfFr) + end + + return bCollisionFoundPiece, bCollisionFoundRestLength end ------------------------------------------------------------------------------------------------------------- @@ -355,9 +386,10 @@ function MachiningLib.GetBladeEngagement( Face, Edge, Part, Tool, dDepthToMachin if not IsFaceZOutOfRange( Face.vtN, Tool) then -- TODO verifica collisione carro Z, collisione traversa PF, collisione 'C' Fast... La riduzione percorso cambia questo test? - if bCollisionCheckForDownUpOnly or not Check2DBladeCollision( Edge, Face.vtN, Face.vtN, Part, Tool, dDepthToMachine) then + local bCollisionFound, bMoveAfterSplit = Check2DBladeCollision( Edge, Face.vtN, Face.vtN, Part, Tool, dDepthToMachine) + if bCollisionCheckForDownUpOnly or not bCollisionFound then - return true, sBladeEngagement + return true, sBladeEngagement, bMoveAfterSplit end end @@ -380,11 +412,12 @@ function MachiningLib.GetBladeEngagement( Face, Edge, Part, Tool, dDepthToMachin end -- orientamento faccia / utensile compatibili con DownUp: lavorabile - if not Check2DBladeCollision( Edge, Face.vtN, -Face.vtN, Part, Tool, dDepthToMachine) then + local bCollisionFound, bMoveAfterSplit = Check2DBladeCollision( Edge, Face.vtN, -Face.vtN, Part, Tool, dDepthToMachine) + if not bCollisionFound then sBladeEngagement = 'DownUp' - return true, sBladeEngagement + return true, sBladeEngagement, bMoveAfterSplit end return false @@ -539,6 +572,8 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) local dBestToolResidualDepth = 0 local sCurrentBladeEngagement local sBestBladeEngagement + local bCurrentMoveAfterSplit + local bBestMoveAfterSplit for i = 1, #TOOLS do local bIsToolCompatible = false @@ -556,7 +591,7 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) if bIsToolCompatible then if FaceToMachine and EdgeToMachine and Part and dElevation then local bIsBladeOk = false - bIsBladeOk, sCurrentBladeEngagement = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachine, Part, TOOLS[i], dElevation, bCollisionCheckForDownUpOnly) + bIsBladeOk, sCurrentBladeEngagement, bCurrentMoveAfterSplit = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachine, Part, TOOLS[i], dElevation, bCollisionCheckForDownUpOnly) -- orientamento non raggiungibile if not bIsBladeOk then bIsToolCompatible = false @@ -582,12 +617,14 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) nBestToolIndex = i dBestToolResidualDepth = dCurrentResidualDepth sBestBladeEngagement = sCurrentBladeEngagement + bBestMoveAfterSplit = bCurrentMoveAfterSplit else -- prediligo utensile per tagli lungo vena, se richiesto if bForceLongcutBlade and not TOOLS[nBestToolIndex].bIsUsedForLongCut and TOOLS[i].bIsUsedForLongCut then nBestToolIndex = i dBestToolResidualDepth = dCurrentResidualDepth sBestBladeEngagement = sCurrentBladeEngagement + bBestMoveAfterSplit = bCurrentMoveAfterSplit else -- entrambi completi if dBestToolResidualDepth <= 10 * GEO.EPS_SMALL and dCurrentResidualDepth <= 10 * GEO.EPS_SMALL then @@ -599,12 +636,14 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) nBestToolIndex = i dBestToolResidualDepth = dCurrentResidualDepth sBestBladeEngagement = sCurrentBladeEngagement + bBestMoveAfterSplit = bCurrentMoveAfterSplit end -- si sceglie quello con le performance migliori elseif TOOLS[i].dPerformanceIndex > TOOLS[nBestToolIndex].dPerformanceIndex + 10 * GEO.EPS_SMALL then nBestToolIndex = i dBestToolResidualDepth = dCurrentResidualDepth sBestBladeEngagement = sCurrentBladeEngagement + bBestMoveAfterSplit = bCurrentMoveAfterSplit end -- entrambi incompleti elseif dBestToolResidualDepth > 10 * GEO.EPS_SMALL and dCurrentResidualDepth > 10 * GEO.EPS_SMALL then @@ -613,6 +652,7 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) nBestToolIndex = i dBestToolResidualDepth = dCurrentResidualDepth sBestBladeEngagement = sCurrentBladeEngagement + bBestMoveAfterSplit = bCurrentMoveAfterSplit end end end @@ -623,6 +663,7 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) ToolInfo.nToolIndex = nBestToolIndex ToolInfo.dResidualDepth = dBestToolResidualDepth ToolInfo.sBladeEngagement = sBestBladeEngagement + ToolInfo.bMoveAfterSplit = bBestMoveAfterSplit return ToolInfo end diff --git a/Process.lua b/Process.lua index b67d4d9..f89550b 100644 --- a/Process.lua +++ b/Process.lua @@ -320,7 +320,7 @@ local function MyProcessFeatures() sMsg = string.gsub( sMsg or '', '\r', ' ', 10) -- trovata almeno una strategia e feature lavorata completamente if RESULT[i].sType == 'Feature' and RESULT[i].ChosenStrategy.sStatus == 'Completed' then - -- nulla da segnalare + sOutput = sOutput .. string.format( '[%d,%d] %s\n', RESULT[i].idCut, RESULT[i].idTask, sMsg or '') -- trovata almeno una strategia ma nessuna applicabile oppure non trovata alcuna strategia elseif RESULT[i].sType == 'Feature' diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 405ffe6..9fe8b74 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -111,13 +111,14 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) or bKeepWasteAttached then local BladeKeepWasteResult - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dStripWidth = Strategy.Parameters.dStripWidth} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dStripWidth = Strategy.Parameters.dStripWidth, bForced = bKeepWasteAttached} AuxiliaryData.bIgnoreNotClampableLength = true Blade.Result, BladeKeepWasteResult = BladeKeepWaste.Make( Proc, Part, OptionalParameters) dTimeToMachine = BladeKeepWasteResult.dTimeToMachine dMRRBlade = BladeKeepWasteResult.dMRR dCompletionPercentage = BladeKeepWasteResult.dCompletionPercentage dQuality = BladeKeepWasteResult.dQuality + Strategy.Result.sInfo = BladeKeepWasteResult.sInfo or '' end -- lavorazione a cubetti / taglio singolo diff --git a/StrategyLibs/BLADEKEEPWASTE.lua b/StrategyLibs/BLADEKEEPWASTE.lua index 0c5409b..9ac4d8b 100644 --- a/StrategyLibs/BLADEKEEPWASTE.lua +++ b/StrategyLibs/BLADEKEEPWASTE.lua @@ -11,6 +11,7 @@ require( 'EgtBase') local FeatureLib = require( 'FeatureLib') local FaceData = require( 'FaceData') local MachiningLib = require( 'MachiningLib') +local BeamLib = require('BeamLib') -- strategie di base local FaceByBlade = require('FACEBYBLADE') local FaceByMill = require('FACEBYMILL') @@ -121,7 +122,6 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- TODO verificare funzionamento con lama da sotto -- TODO scelta utensile è corretto lasciarla a FaceByBlade? -- attenzione perchè se l'inclinazione della faccia la fa finire oltre lo spigolo questo riduce il massimo (come calcolare????) - -- il FindBlade dovrà restituire di utilizzare sempre la lama sopra se l'angolo lo permette, ma avendo un'altezza massima (da macchina) oltre cui il DownUp non sarà fattibile (evita collisioni tra asse e pezzo) local Result = {} local Machinings = {} @@ -172,6 +172,8 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) bFinishWithMill = OptionalParameters.bFinishWithMill end local dMillingOffsetFromSide = OptionalParameters.dMillingOffsetFromSide or 1 + local dStripWidth = OptionalParameters.dStripWidth or 5 + local bForced = OptionalParameters.bForced or false -- volume della feature local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part) @@ -218,19 +220,41 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) end -- taglio con codolo faccia di fondo - local dDepthToMachine = BottomEdgeToMachine.dElevation / 2 - OptionalParameters.dStripWidth / 2 - local OptionalParametersFaceByBlade = { dDepthToMachine = dDepthToMachine, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, nToolIndex = nToolIndex} + local dDepthToMachine = BottomEdgeToMachine.dElevation / 2 - dStripWidth / 2 + local OptionalParametersFaceByBlade1 = { dDepthToMachine = dDepthToMachine, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, nToolIndex = nToolIndex} -- primo lato - Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade) + Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade1) Cutting1.nInternalSortingPriority = 3 Cutting1.dResultWeight = 0.3 - table.insert( CalculatedMachinings, Cutting1) + -- secondo lato - OptionalParametersFaceByBlade.OppositeToolDirectionMode = 'Enabled' - Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade) + local OptionalParametersFaceByBlade2 = BeamLib.TableCopyDeep( OptionalParametersFaceByBlade1) + OptionalParametersFaceByBlade2.OppositeToolDirectionMode = 'Enabled' + Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade2) Cutting2.nInternalSortingPriority = 3 Cutting2.dResultWeight = 0.3 - table.insert( CalculatedMachinings, Cutting2) + + -- se uno dei due lati non è riuscito, si estende il più possibile il lato rimasto + if not Cutting1.bIsApplicable and Cutting2.bIsApplicable then + + dDepthToMachine = min( TOOLS[Cutting2.nToolIndex].dMaxMaterial, BottomEdgeToMachine.dElevation - dStripWidth) + OptionalParametersFaceByBlade2.dDepthToMachine = dDepthToMachine + + Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade2) + table.insert( CalculatedMachinings, Cutting2) + + elseif not Cutting2.bIsApplicable and Cutting1.bIsApplicable then + + dDepthToMachine = min( TOOLS[Cutting1.nToolIndex].dMaxMaterial, BottomEdgeToMachine.dElevation - dStripWidth) + OptionalParametersFaceByBlade1.dDepthToMachine = dDepthToMachine + + Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade1) + table.insert( CalculatedMachinings, Cutting1) + + else + table.insert( CalculatedMachinings, Cutting1) + table.insert( CalculatedMachinings, Cutting2) + end -- fresatura eventuali facce di chiusura if bFinishWithMill then @@ -254,8 +278,9 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) end end - -- calcolo completamento, serve la lista di lavorazioni che comprende le non applicabili - Result.dCompletionPercentage = GetStrategyCompletionPercentage( CalculatedMachinings) + -- calcolo completamento (non applicabili devono essere incluse) + -- se codolo non forzato si ritorna completa solo al 94% (completion index 4) + Result.dCompletionPercentage = bForced and GetStrategyCompletionPercentage( CalculatedMachinings) or 94 Result.dCompletionIndex = FeatureLib.GetFeatureCompletionIndex( Result.dCompletionPercentage) -- aggiunta eventuali lavorazioni splittate @@ -273,6 +298,9 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) Result.dMRR = ( dFeatureVolume / Result.dTimeToMachine) / pow( 10, 6) if Result.dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then Result.sStatus = 'Completed' + if bForced then + Result.sInfo = 'Waste attached. Remove manually.' + end else Result.sStatus = 'Not-Completed' end diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index b4b7e0f..b9f6128 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -390,7 +390,7 @@ local function GetSingleCutStrategy( Proc, Part, OptionalParameters) nToolIndex, sChosenBladeType = GetBestBlade( Proc, Part, FaceToMachine, OptionalParametersGetBestBlade) end - -- se ancora non è stato trovato un utensile e utensile e lati non arrivavano dall'esterno, se permesso, si prova a scegliere il lato "veloce" (bAllowFastCuts) + -- se ancora non è stato trovato un utensile e utensile e lati non arrivavano dall'esterno, se permesso, si prova a scegliere il primo lato a minor elevazione (bAllowFastCuts) if bAllowFastCuts and not nToolIndex and not OptionalParameters.nToolIndex and not OptionalParameters.EdgeToMachineList then EdgeToMachineList.Top = GetEdgeToMachine( FaceToMachine.Edges, 'Top', { bAllowFastCuts = true}) EdgeToMachineList.Bottom = GetEdgeToMachine( FaceToMachine.Edges, 'Bottom', { bAllowFastCuts = true}) @@ -400,6 +400,17 @@ local function GetSingleCutStrategy( Proc, Part, OptionalParameters) nToolIndex, sChosenBladeType = GetBestBlade( Proc, Part, FaceToMachine, OptionalParametersGetBestBlade) end + + -- se ancora non è stato trovato un utensile e utensile e lati non arrivavano dall'esterno, se permesso, si prova a scegliere il secondo lato a minor elevazione (bAllowFastCuts) + if bAllowFastCuts and not nToolIndex and not OptionalParameters.nToolIndex and not OptionalParameters.EdgeToMachineList then + EdgeToMachineList.Top = GetEdgeToMachine( FaceToMachine.Edges, 'Top', { bAllowFastCuts = true, nIndex = 2}) + EdgeToMachineList.Bottom = GetEdgeToMachine( FaceToMachine.Edges, 'Bottom', { bAllowFastCuts = true, nIndex = 2}) + OptionalParametersGetBestBlade.EdgeToMachineTop = EdgeToMachineList.Top + OptionalParametersGetBestBlade.EdgeToMachineBottom = EdgeToMachineList.Bottom + + nToolIndex, sChosenBladeType = GetBestBlade( Proc, Part, FaceToMachine, OptionalParametersGetBestBlade) + end + -- se possibile, upgrade del taglio tipo 'Top' a taglio a ghigliottina. Si tenta anche se il taglio singolo non è riuscito. if ( sChosenBladeType == 'Top' or not nToolIndex) and bReduceBladePath and FaceData.IsFaceRectangle( FaceToMachine) then local nToolIndexGuillotine @@ -645,6 +656,30 @@ local function CutWholeWaste( Proc, Part, OptionalParameters) end end + -- se nessun taglio è riuscito si riprova il taglio singolo permettendo i lati a minor elevazione, abbassando la qualità + if not ( Cutting and Cutting.bIsApplicable) or not ( CuttingDouble and CuttingDouble.bIsApplicable) then + + OptionalParameters.bAllowFastCuts = true + nToolIndex, EdgeToMachine, sChosenBladeType = GetSingleCutStrategy( Proc, Part, OptionalParameters) + + if nToolIndex then + local OptionalParametersFaceByBlade = { + dDepthToMachine = EdgeToMachine.dElevation + BeamData.CUT_EXTRA, + nToolIndex = nToolIndex, + dExtendAfterTail = dExtendAfterTail, + bReduceBladePath = bReduceBladePath + } + if sChosenBladeType == 'Top' or sChosenBladeType == 'Bottom' then + OptionalParametersFaceByBlade.OppositeToolDirectionMode = 'Optimized' + end + + Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParametersFaceByBlade) + end + + -- si abbassa la qualità per le possibili scheggiature + Result.dQuality = FeatureLib.GetStrategyQuality( 'STD') + end + if Cutting and Cutting.bIsApplicable then table.insert( Machinings, Cutting) dCompletionPercentage = Cutting.dCompletionPercentage or dCompletionPercentage @@ -665,7 +700,7 @@ local function CutWholeWaste( Proc, Part, OptionalParameters) end Result.dCompletionPercentage = dCompletionPercentage Result.dCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dCompletionPercentage) - Result.dQuality = FeatureLib.GetStrategyQuality( Machinings) + Result.dQuality = Result.dQuality or FeatureLib.GetStrategyQuality( Machinings) Result.dTimeToMachine = FeatureLib.GetStrategyTimeToMachine( Machinings) Result.dMRR = ( FeatureInfo.dFeatureVolume / Result.dTimeToMachine) / pow( 10, 6) else @@ -1050,10 +1085,10 @@ function BLADETOWASTE.Make( ProcOrId, Part, OptionalParameters) end -- feature concava >= 90deg: lavorata con cubetti, se attivi - elseif ( not bDisableDicing) and ( dAngleBetweenFaces >= -91) then + elseif not ( bDisableDicing or FeatureInfo.bIsFeatureSmall) and ( dAngleBetweenFaces >= -91) then Machinings, Result = CutWithDicing( Proc, Part, OptionalParameters) - -- qui arrivano feature concave < 90deg, oppure >= 90deg con cubetti disabilitati: lavorata come 2 facce singole con accorciamento + -- qui arrivano feature concave < 90deg, oppure >= 90deg con cubetti disabilitati: lavorata come 2 facce singole con eventuale accorciamento else -- per ogni faccia si calcola la lavorazione for i = 1, #Proc.Faces do diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index cd94b20..e87380c 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -273,7 +273,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if nToolIndex then Cutting.nToolIndex = nToolIndex - Cutting.bIsApplicable, Cutting.sBladeEngagement = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachine, Part, TOOLS[Cutting.nToolIndex], dDepthToMachine, bCollisionCheckForDownUpOnly) + Cutting.bIsApplicable, Cutting.sBladeEngagement, Cutting.bMoveAfterSplit = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachine, Part, TOOLS[Cutting.nToolIndex], dDepthToMachine, bCollisionCheckForDownUpOnly) -- utensile da cercare: si prende la lama migliore che può effettuare questo taglio, senza particolari analisi else @@ -289,6 +289,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) Cutting.nToolIndex = ToolInfo.nToolIndex Cutting.sBladeEngagement = ToolInfo.sBladeEngagement + Cutting.bMoveAfterSplit = ToolInfo.bMoveAfterSplit -- se non trovato utensile, la lavorazione non è applicabile if not Cutting.nToolIndex then @@ -353,7 +354,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if OppositeToolDirectionMode ~= 'Disabled' then -- lavorando dalla direzione opposta si verifica come se si lavorasse il lato opposto - local bIsApplicableOpposite, sBladeEngagementOpposite = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachineOpposite, Part, TOOLS[Cutting.nToolIndex], dDepthToMachine, bCollisionCheckForDownUpOnly) + local bIsApplicableOpposite, sBladeEngagementOpposite, bMoveAfterSplit = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachineOpposite, Part, TOOLS[Cutting.nToolIndex], dDepthToMachine, bCollisionCheckForDownUpOnly) -- taglio opposto non fattibile if not bIsApplicableOpposite then @@ -380,6 +381,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- la direzione di percorrenza del lato deve essere verso l'alto; bInvert va considerata perchè inverte la direzione di percorrenza -- il BladeEngagement non deve cambiare, altrimenti è inutile invertire la direzione if ( sBladeEngagementOpposite == Cutting.sBladeEngagement) + and ( bMoveAfterSplit == Cutting.MoveAfterSplit) and ( Cutting.bInvert and Cutting.vtEdgeDirection:getZ() > 100 * GEO.EPS_SMALL) or ( ( not Cutting.bInvert) and Cutting.vtEdgeDirection:getZ() < -100 * GEO.EPS_SMALL) then @@ -447,10 +449,10 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if OppositeToolDirectionMode == 'Enabled' then EdgeToMachineForEngagement = EdgeToMachineOpposite end - local bIsApplicable, sBladeEngagement = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachineForEngagement, Part, TOOLS[Cutting.nToolIndex], dDepthToMachine) + local bIsApplicable, sBladeEngagement, bMoveAfterSplit = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachineForEngagement, Part, TOOLS[Cutting.nToolIndex], dDepthToMachine) -- se non fattibile o cambiano le condizioni BladeEngagement, non si riduce - if not ( bIsApplicable and ( sBladeEngagement == Cutting.sBladeEngagement)) then + if not ( bIsApplicable and ( sBladeEngagement == Cutting.sBladeEngagement) and ( bMoveAfterSplit == Cutting.MoveAfterSplit)) then Cutting.sEdgeUsage = 'Standard' dDepthToMachine = Cutting.dDepthToMachine end @@ -545,7 +547,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- se lavorazione aperta sulla coda, eventuali aggiustamenti -- TODO valutare se fare funzione a parte local bIsTruncatingCutOnTail = Proc.Topology and ( Proc.Topology.sName == 'Cut-1-Through' or Proc.Topology.sName == 'TailCut') and Proc.AffectedFaces.bLeft - if bIsTruncatingCutOnTail then + if Cutting.bMoveAfterSplit or bIsTruncatingCutOnTail then Cutting.sStage = 'AfterTail' elseif Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( Cutting.vtToolDirection:getX() < 0.707)) then local dLengthOnX = Cutting.dLengthOnX @@ -562,12 +564,14 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtN, Y_AX()) then if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Cutting.sStage = 'AfterTail' + Cutting.bMoveAfterSplit = true else Cutting.bIsApplicable = false end elseif dAddLengthLeftSide + dAddLengthToReduce > dExtendAfterTail then if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Cutting.sStage = 'AfterTail' + Cutting.bMoveAfterSplit = true else if bStartLeft then Cutting.LeadIn.dStartAddLength = - dAddLengthToReduce + dExtendAfterTail