From 93f9af85e7a9b3d7bf2ec9ddf9565635ae634854 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 10 May 2024 09:20:11 +0200 Subject: [PATCH] in SawPlusChain: - modifiche per contemplare funzione EgtSurfTmGetFacetOutlineInfo - migliorie alle funzioni di calcolo parametri lavorazione - ciclo step orizzontali lama spostato in funzione apposita ApplyAllSteps --- LuaLibs/BeamLib.lua | 4 +- LuaLibs/ProcessLapJoint.lua | 244 ++++++++++++++++++++++-------------- 2 files changed, 155 insertions(+), 93 deletions(-) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 20e1b23..3015832 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1217,9 +1217,9 @@ function BeamLib.GetMachiningSteps( dMachiningDepth, dStep) local MachiningSteps = {} MachiningSteps.StepLength = 0 - MachiningSteps.Count = ceil( ( dStep - 10 * GEO.EPS_SMALL) / dMachiningDepth) + MachiningSteps.Count = ceil( ( dMachiningDepth - 10 * GEO.EPS_SMALL) / dStep) if MachiningSteps.Count > 1 then - MachiningSteps.StepLength = ( dStep - dMachiningDepth) / ( MachiningSteps.Count - 1) + MachiningSteps.StepLength = ( dMachiningDepth - dStep) / ( MachiningSteps.Count - 1) end return MachiningSteps diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 5f6aca6..d62c3ba 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -4678,21 +4678,23 @@ function SawPlusChain.GetLongFace( Proc) table.sort( FacesAdjacentToBottom, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end) -- si sceglie la faccia adiacente sul lato più lungo - local FaceToMachine = {} - FaceToMachine.Id = FacesAdjacentToBottom[1].Id + local LongFace = {} + LongFace.Id = FacesAdjacentToBottom[1].Id for i = 1, Proc.Fct do - if FaceToMachine.Id == Proc.Face[i].Id then - FaceToMachine.Width = Proc.Face[i].Width - FaceToMachine.Height = Proc.Face[i].Height - FaceToMachine.Elevation = Proc.Face[i].Elevation - FaceToMachine.VtN = Proc.Face[i].VtN - if FaceToMachine.Height > FaceToMachine.Width then - FaceToMachine.Height, FaceToMachine.Width = FaceToMachine.Width, FaceToMachine.Height + if LongFace.Id == Proc.Face[i].Id then + LongFace.Width = Proc.Face[i].Width + LongFace.Height = Proc.Face[i].Height + LongFace.Elevation = Proc.Face[i].Elevation + LongFace.VtN = Proc.Face[i].VtN + if LongFace.Height > LongFace.Width then + LongFace.Height, LongFace.Width = LongFace.Width, LongFace.Height end end end - return FaceToMachine + LongFace.Edges = SawPlusChain.GetLongFaceEdges( Proc, LongFace) + + return LongFace end @@ -4732,26 +4734,47 @@ function SawPlusChain.GetSideFaces( Proc) end -function SawPlusChain.GetEdgeToMachine( sEdge, Proc, FaceToMachine) - -- TODO da modificare quando arriverà la funzione Egt che fornisce informazioni sui lati - local EdgeToMachine = {} +function SawPlusChain.GetLongFaceEdges( Proc, Face) + local Edges = {} + Edges.SideEdges = {} + Edges.OppositeEdges = {} - if sEdge == 'Bottom' then - EdgeToMachine.ToolDirection = Proc.MainFaces.BottomFace.VtN - EdgeToMachine.Length = FaceToMachine.Width - EdgeToMachine.AdjacentFaceId = Proc.MainFaces.BottomFace.Id - EdgeToMachine.Elevation = Proc.MainFaces.BottomFace.Elevation - EdgeToMachine.IsStartOpen = false - EdgeToMachine.IsEndOpen = false - elseif sEdge == 'SideStart' then + local nFaceType, vEdges = EgtSurfTmGetFacetOutlineInfo( Proc.Id, Face.Id, GDB_ID.ROOT) + if nFaceType < 1 then + for j = 1, #vEdges do + local nPreviousEdgeIndex = j - 1 + if j == 1 then + nPreviousEdgeIndex = #vEdges + end + local nNextEdgeIndex = j + 1 + if j == #vEdges then + nNextEdgeIndex = 1 + end - elseif sEdge == 'SideEnd' then - - elseif sEdge == 'Opposite' then + local CurrentEdge = {} + CurrentEdge.AdjacentFaceId = vEdges[j].Adj + CurrentEdge.ToolDirection = Vector3d( vEdges[j].Norm) + CurrentEdge.Length = vEdges[j].Len + CurrentEdge.Elevation = vEdges[j].Elev + CurrentEdge.IsOpen = vEdges[j].Open + CurrentEdge.IsStartOpen = ( vEdges[nPreviousEdgeIndex].Open) + CurrentEdge.IsEndOpen = ( vEdges[nNextEdgeIndex].Open) + if CurrentEdge.AdjacentFaceId == Proc.MainFaces.BottomFace.Id then + Edges.BottomEdge = CurrentEdge + elseif vEdges[nNextEdgeIndex].Adj == Proc.MainFaces.BottomFace.Id then + Edges.SideEdges.StartEdge = CurrentEdge + elseif vEdges[nPreviousEdgeIndex].Adj == Proc.MainFaces.BottomFace.Id then + Edges.SideEdges.EndEdge = CurrentEdge + else + table.insert( Edges.OppositeEdges, CurrentEdge) + end + end + else + error( 'Face with closed hole') end - return EdgeToMachine + return Edges end @@ -4818,14 +4841,10 @@ function SawPlusChain.IsStartOrEndClosed( Proc, Machining) end -function SawPlusChain.CalculateLeadInOut( Proc, Machining, EdgeToMachine) +function SawPlusChain.CalculateLeadInOut( Machining, EdgeToMachine) -- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom) - -- si determina se l'inizio o la fine della lavorazione sono chiusi e l'eventuale riduzione da applicare - -- TODO da rimuovere quando arriverà la funzione Egt che fornisce informazioni sui lati - -- TODO sarà da rimuovere anche l'argomento 'Proc' - local bIsStartClosed, bIsEndClosed = SawPlusChain.IsStartOrEndClosed( Proc, Machining) - + -- si determina l'eventuale riduzione da applicare in caso di inizio o fine chiusi local bIsMortising = ( Machining.Type == MCH_OY.MORTISING) local dAddLengthToReduce = 0 if bIsMortising then @@ -4834,6 +4853,10 @@ function SawPlusChain.CalculateLeadInOut( Proc, Machining, EdgeToMachine) dAddLengthToReduce = sqrt( Machining.Depth * Machining.Tool.Diameter - Machining.Depth * Machining.Depth) end + if Machining.Invert then + Machining.IsStartClosed, Machining.IsEndClosed = Machining.IsEndClosed, Machining.IsStartClosed + end + local LeadIn = {} local LeadOut = {} LeadIn.StartAddLength = 0 @@ -4849,14 +4872,14 @@ function SawPlusChain.CalculateLeadInOut( Proc, Machining, EdgeToMachine) LeadOut.Elevation = 0 LeadIn.CompLength = 0 LeadOut.CompLength = 0 - if bIsStartClosed and bIsEndClosed then + if Machining.IsStartClosed and Machining.IsEndClosed then LeadIn.StartAddLength = -dAddLengthToReduce LeadOut.EndAddLength = -dAddLengthToReduce - elseif bIsStartClosed then + elseif Machining.IsStartClosed then LeadIn.StartAddLength = -dAddLengthToReduce -- eventuale correzione per accorciamento maggiore di larghezza tasca LeadOut.EndAddLength = max( -LeadIn.StartAddLength - EdgeToMachine.Length + 10 * BD.CUT_EXTRA, BD.CUT_EXTRA) - elseif bIsEndClosed then + elseif Machining.IsEndClosed then LeadOut.EndAddLength = -dAddLengthToReduce -- eventuale correzione per accorciamento maggiore di larghezza tasca LeadIn.StartAddLength = max( -LeadOut.EndAddLength - EdgeToMachine.Length + 10 * BD.CUT_EXTRA, BD.CUT_EXTRA) @@ -4865,12 +4888,12 @@ function SawPlusChain.CalculateLeadInOut( Proc, Machining, EdgeToMachine) LeadOut.EndAddLength = BD.CUT_EXTRA end else - if bIsStartClosed then + if Machining.IsStartClosed then LeadIn.StartAddLength = -dAddLengthToReduce else LeadIn.StartAddLength = BD.CUT_EXTRA end - if bIsEndClosed then + if Machining.IsEndClosed then LeadOut.EndAddLength = -dAddLengthToReduce else LeadOut.EndAddLength = BD.CUT_EXTRA @@ -4892,7 +4915,7 @@ function SawPlusChain.ApplyMachining( Machining, b3Raw) -- impostazione parametri lavorazione local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) - EgtSetMachiningGeometry( {{ Machining.ProcId, Machining.FaceToMachine.Id}}) + EgtSetMachiningGeometry( Machining.Geometry) EgtSetMachiningParam( MCH_MP.FACEUSE, Machining.Faceuse) EgtSetMachiningParam( MCH_MP.SCC, Machining.SCC) EgtSetMachiningParam( MCH_MP.INVERT, Machining.Invert) @@ -4922,9 +4945,9 @@ function SawPlusChain.ApplyMachining( Machining, b3Raw) EgtSetMachiningParam( MCH_MP.STEP, Machining.Steps.StepLength) end end - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetBlockedAxis( Machining.Name, Machining.BlockedAxis.Orientation, b3Raw, Machining.FaceToMachine.VtN, Machining.BlockedAxis.VtOut)) + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetBlockedAxis( Machining.Name, Machining.BlockedAxis.Orientation, b3Raw, Machining.BlockedAxis.VtN, Machining.BlockedAxis.VtOut)) if Machining.Type == MCH_OY.MORTISING then - EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( Machining.FaceToMachine.VtN, Machining.Direction, Machining.SuggestedAngles.Index)) + EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( Machining.SuggestedAngles.VtN, Machining.SuggestedAngles.VtOrtho, Machining.SuggestedAngles.Index)) end EgtSetMachiningParam( MCH_MP.OVERL, Machining.Overlap) EgtSetMachiningParam( MCH_MP.STARTPOS, max( Machining.StartSafetyLength, EgtGetMachiningParam( MCH_MP.STARTPOS))) @@ -4945,13 +4968,13 @@ function SawPlusChain.ApplyMachining( Machining, b3Raw) else Machining.BlockedAxis.Orientation = 'perpendicular' end - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetBlockedAxis( Machining.Name, Machining.BlockedAxis.Orientation, b3Raw, Machining.FaceToMachine.VtN, Machining.BlockedAxis.VtOut)) + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetBlockedAxis( Machining.Name, Machining.BlockedAxis.Orientation, b3Raw, Machining.BlockedAxis.VtN, Machining.BlockedAxis.VtOut)) if Machining.SuggestedAngles.Index == 1 then Machining.SuggestedAngles.Index = 2 else Machining.SuggestedAngles.Index = 1 end - EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( Machining.FaceToMachine.VtN, Machining.Direction, Machining.SuggestedAngles.Index)) + EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( Machining.SuggestedAngles.VtN, Machining.SuggestedAngles.VtOrtho, Machining.SuggestedAngles.Index)) sErr = '' bIsApplyOk = ML.ApplyMachining( true, false) end @@ -5003,8 +5026,6 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg end Cutting.Type = MCH_OY.MILLING Cutting.Tool = SawPlusChain.GetToolFromMachining( Cutting.Name) - -- TODO serve? - Cutting.FaceToMachine = FaceToMachine -- verifica dimensioni tasca compatibili -- se tasca meno spessa della lama la strategia non è applicabile @@ -5014,7 +5035,7 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg EgtOutLog( Cutting.Message) return Cutting end - if #Proc.MainFaces.SideFaces > 1 then + if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della lama la strategia non è applicabile if Cutting.Tool.Diameter > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not applicable - pocket too narrow for saw blade diameter' @@ -5025,8 +5046,9 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg end -- parametri della lavorazione - -- direzione utensile - Cutting.Direction = EdgeToMachine.ToolDirection + -- inizio e fine aperti o chiusi + Cutting.IsStartClosed = not EdgeToMachine.IsStartOpen + Cutting.IsEndClosed = not EdgeToMachine.IsEndOpen -- lato di lavoro e inversioni if Cutting.Tool.IsCCW then Cutting.Workside = MCH_MILL_WS.RIGHT @@ -5036,7 +5058,7 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg Cutting.Invert = false end -- TODO gestire lama da sotto e lama downUp - if Cutting.FaceToMachine.VtN:getZ() < - 10 * GEO.EPS_SMALL then + if FaceToMachine.VtN:getZ() < - 10 * GEO.EPS_SMALL then Cutting.ToolInvert = true Cutting.Invert = not Cutting.Invert else @@ -5060,7 +5082,7 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg Cutting.Steps.StepType = MCH_MILL_ST.ONEWAY Cutting.MaxElev = Cutting.Steps.StepLength * Cutting.Steps.Count - 10 * GEO.EPS_SMALL if Cutting.ToolInvert and Cutting.Steps.Count > 1 then - Cutting.LongitudinalOffset = - FaceToMachine.Elevation + Cutting.LongitudinalOffset = - Proc.MainFaces.BottomFace.Height else Cutting.LongitudinalOffset = 0 end @@ -5069,17 +5091,20 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg -- overlap Cutting.Overlap = 0 -- faceuse - Cutting.Faceuse = BL.GetNearestOrthoOpposite( Cutting.Direction) + if EdgeToMachine.Elevation > - 10 * GEO.EPS_SMALL then + Cutting.Faceuse = BL.GetNearestOrthoOpposite( EdgeToMachine.ToolDirection) + else + Cutting.Faceuse = BL.GetNearestOrthoOpposite( -EdgeToMachine.ToolDirection) + end -- SCC - Cutting.SCC = SawPlusChain.Saw.GetSCC( Cutting.Direction) - -- angoli suggeriti - Cutting.SuggestedAngles = '' + Cutting.SCC = SawPlusChain.Saw.GetSCC( EdgeToMachine.ToolDirection) -- asse bloccato Cutting.BlockedAxis = {} Cutting.BlockedAxis.Orientation = 'perpendicular' - Cutting.BlockedAxis.VtOut = EgtIf( Cutting.FaceToMachine.VtN:getX() > 0, X_AX(), -X_AX()) + Cutting.BlockedAxis.VtN = FaceToMachine.VtN + Cutting.BlockedAxis.VtOut = EgtIf( FaceToMachine.VtN:getX() > 0, X_AX(), -X_AX()) -- approccio e retrazione - Cutting.LeadIn, Cutting.LeadOut = SawPlusChain.CalculateLeadInOut( Proc, Cutting) + Cutting.LeadIn, Cutting.LeadOut = SawPlusChain.CalculateLeadInOut( Cutting, EdgeToMachine) -- eventuale step orizzontale Cutting.HorizontalSteps = {} if Cutting.Tool.SideStep then @@ -5088,8 +5113,10 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg Cutting.HorizontalSteps.Count = 1 Cutting.HorizontalSteps.StepLength = 0 end + -- geometria + Cutting.Geometry = {{Proc.Id, FaceToMachine.Id}} -- nome operazione - Cutting.OperationName = 'Cut_' .. ( EgtGetName( Cutting.ProcId) or tostring( Cutting.ProcId)) .. '_' .. tostring( Cutting.FaceToMachine.Id + 1) + Cutting.OperationName = 'Cut_' .. ( EgtGetName( Cutting.ProcId) or tostring( Cutting.ProcId)) .. '_' .. tostring( FaceToMachine.Id + 1) -- eventuale avviso di danneggiamento pezzo successivo local dOffsideLength = max( Cutting.LeadIn.StartAddLength, Cutting.LeadOut.EndAddLength) + Cutting.Tool.Diameter / 2 + 10 * GEO.EPS_SMALL @@ -5107,6 +5134,30 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg end +function SawPlusChain.Saw.ApplyAllSteps( Cutting, b3Raw) + local bIsCuttingOk = false + local sCuttingApplyMessage = '' + + local dOriginalRadialOffset = Cutting.RadialOffset + local dOriginalLeadInPerpDistance = Cutting.LeadIn.PerpDistance + local dOriginalLeadOutPerpDistance = Cutting.LeadOut.PerpDistance + for i = Cutting.HorizontalSteps.Count, 1, -1 do + Cutting.RadialOffset = dOriginalRadialOffset + Cutting.HorizontalSteps.StepLength * ( i - 1) + -- update distanza perpendicolare attacco per contemplare l'offset applicato + Cutting.LeadIn.PerpDistance = dOriginalLeadInPerpDistance - Cutting.RadialOffset + Cutting.LeadOut.PerpDistance = dOriginalLeadOutPerpDistance - Cutting.RadialOffset + -- applicazione lavorazione + bIsCuttingOk, sCuttingApplyMessage = SawPlusChain.ApplyMachining( Cutting, b3Raw) + -- update messaggi + if sCuttingApplyMessage and #sCuttingApplyMessage > 0 then + sCuttingApplyMessage = sCuttingApplyMessage .. 'Apply : ' .. sCuttingApplyMessage .. '\n' + end + end + + return bIsCuttingOk, sCuttingApplyMessage +end + + function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) local Mortising = {} Mortising.CanApply = true @@ -5115,7 +5166,7 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine -- ricerca lavorazione -- TODO gestire elevazione negativa (determina come devo lavorare) - Mortising.Name = ML.FindSawing( 'Sawing', Proc.EdgeToMachine.Elevation) + Mortising.Name = ML.FindSawing( 'Sawing', EdgeToMachine.Elevation) if not Mortising.Name then Mortising.Name = ML.FindSawing( 'Sawing', nil, nil, 'Longest') end @@ -5127,8 +5178,6 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine end Mortising.Type = MCH_OY.MORTISING Mortising.Tool = SawPlusChain.GetToolFromMachining( Mortising.Name) - -- TODO serve?? - Mortising.FaceToMachine = FaceToMachine -- verifica dimensioni tasca compatibili -- se tasca meno spessa della sega a catena la strategia non è applicabile @@ -5149,8 +5198,9 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine end -- parametri della lavorazione - -- direzione utensile - Mortising.Direction = EdgeToMachine.VtN + -- inizio e fine aperti o chiusi + Mortising.IsStartClosed = not EdgeToMachine.IsStartOpen + Mortising.IsEndClosed = not EdgeToMachine.IsEndOpen -- lato di lavoro e inversioni if Mortising.Tool.IsCCW then Mortising.Workside = MCH_MILL_WS.RIGHT @@ -5177,20 +5227,25 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine -- overlap Mortising.Overlap = 0 -- faceuse - Mortising.Faceuse = BL.GetNearestParalOpposite( Mortising.Direction) + Mortising.Faceuse = BL.GetNearestParalOpposite( EdgeToMachine.ToolDirection) -- SCC Mortising.SCC = MCH_SCC.NONE -- asse bloccato e angoli suggeriti Mortising.BlockedAxis = {} Mortising.BlockedAxis.Orientation = 'perpendicular' + Mortising.BlockedAxis.VtN = FaceToMachine.VtN Mortising.SuggestedAngles = {} Mortising.SuggestedAngles.Index = 1 + Mortising.SuggestedAngles.VtN = FaceToMachine.VtN + Mortising.SuggestedAngles.VtOrthO = EdgeToMachine.ToolDirection -- approccio e retrazione - Mortising.LeadIn, Mortising.LeadOut = SawPlusChain.CalculateLeadInOut( Proc, Mortising) + Mortising.LeadIn, Mortising.LeadOut = SawPlusChain.CalculateLeadInOut( Mortising, EdgeToMachine) -- eventuale step verticale Mortising.VerticalSteps = BL.GetMachiningSteps( Proc.MainFaces.BottomFace.Height, Mortising.Tool.Thickness) + -- geometria + Mortising.Geometry = {{Proc.Id, FaceToMachine.Id}} -- nome operazione - Mortising.OperationName = 'Chainsaw_' .. ( EgtGetName( Mortising.ProcId) or tostring( Mortising.ProcId)) .. '_' .. tostring( Mortising.FaceToMachine.Id + 1) + Mortising.OperationName = 'Chainsaw_' .. ( EgtGetName( Mortising.ProcId) or tostring( Mortising.ProcId)) .. '_' .. tostring( FaceToMachine.Id + 1) -- eventuale avviso di danneggiamento pezzo successivo local dOffsideLength = max( Mortising.LeadIn.StartAddLength, Mortising.LeadOut.EndAddLength) + Mortising.Tool.Width / 2 + 10 * GEO.EPS_SMALL @@ -5209,7 +5264,6 @@ end function SawPlusChain.Make( bOnlySaw, Proc, nRawId) - SawPlusChain.ApplyOnlySawblade = bOnlySaw local b3Raw = EgtGetRawPartBBox( nRawId) -- TODO per implementare la strategia con lapjoint lunghe bisogna prima riconoscere le topologie che arrivano @@ -5239,43 +5293,51 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) Proc.MainFaces.LongFace = SawPlusChain.GetLongFace( Proc) Proc.MainFaces.SideFaces = SawPlusChain.GetSideFaces( Proc) - -- parametri lavorazione di lama - local FaceToMachine = Proc.MainFaces.LongFace - local EdgeToMachine = SawPlusChain.GetEdgeToMachine( 'Bottom', Proc, FaceToMachine) - local Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) - - -- applicazione lavorazione di lama con eventuali step XY + -- lavorazione di lama - fondo della tasca + local Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) local bIsCuttingOk = false - local sCuttingApplyMessage = '' if Cutting.CanApply then - local dOriginalRadialOffset = Cutting.RadialOffset - local dOriginalLeadInPerpDistance = Cutting.LeadIn.PerpDistance - local dOriginalLeadOutPerpDistance = Cutting.LeadOut.PerpDistance - for i = Cutting.HorizontalSteps.Count, 1, -1 do - Cutting.RadialOffset = dOriginalRadialOffset + Cutting.HorizontalSteps.StepLength * ( i - 1) - -- update distanza perpendicolare attacco per contemplare l'offset applicato - Cutting.LeadIn.PerpDistance = dOriginalLeadInPerpDistance - Cutting.RadialOffset - Cutting.LeadOut.PerpDistance = dOriginalLeadOutPerpDistance - Cutting.RadialOffset - -- applicazione lavorazione - bIsCuttingOk, sCuttingApplyMessage = SawPlusChain.ApplyMachining( Cutting, b3Raw) - -- update messaggi - if sCuttingApplyMessage and #sCuttingApplyMessage > 0 then - Cutting.Message = Cutting.Message .. 'Apply : ' .. sCuttingApplyMessage .. '\n' + bIsCuttingOk, Cutting.Message = SawPlusChain.Saw.ApplyAllSteps( Cutting, b3Raw) + end + if not bIsCuttingOk then + return bIsCuttingOk, Cutting.Message + end + + -- se la lama non è arrivata sul fondo e c'è almeno un lato aperto va lavorato + if Cutting.RadialOffset > 10 * GEO.EPS_SMALL then + -- eventuale lavorazione di lama - lato della tasca da cui inizia la lavorazione + if Proc.MainFaces.LongFace.Edges.BottomEdge.IsStartOpen then + Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.StartEdge) + bIsCuttingOk = false + if Cutting.CanApply then + bIsCuttingOk, Cutting.Message = SawPlusChain.Saw.ApplyAllSteps( Cutting, b3Raw) + end + if not bIsCuttingOk then + return bIsCuttingOk, Cutting.Message end end + -- eventuale lavorazione di lama - lato della tasca in cui finisce la lavorazione + if Proc.MainFaces.LongFace.Edges.BottomEdge.IsEndOpen then + Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.EndEdge) + bIsCuttingOk = false + if Cutting.CanApply then + bIsCuttingOk, Cutting.Message = SawPlusChain.Saw.ApplyAllSteps( Cutting, b3Raw) + end + if not bIsCuttingOk then + return bIsCuttingOk, Cutting.Message + end + end + -- la lama è arrivata sul fondo e tasca passante, non servono ulteriori lavorazioni + elseif #( Proc.MainFaces.SideFaces) == 0 then + SawPlusChain.ApplyOnlySawblade = true end - -- se tasca passante e la lama è arrivata sul fondo, non servono ulteriori lavorazioni - if #Proc.Pocket.SideFaces == 0 and Cutting.RadialOffset == 0 then - bOnlySaw = true - end - - if bOnlySaw or not bIsCuttingOk then + if SawPlusChain.ApplyOnlySawblade then return bIsCuttingOk, Cutting.Message end -- parametri lavorazione con sega a catena - local Mortising = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) + local Mortising = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) -- si lavora solo quanto non lavorato dalla lama Mortising.MaxElev = Cutting.RadialOffset + BD.CUT_EXTRA