From efb805cf987181c5d66e7a73950c08c4c34545db Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 8 May 2024 12:58:48 +0200 Subject: [PATCH] in SawPlusChain: - Chainsawing rinominata Mortising - GetVerticalSteps e GetHorizontalSteps sostituiti da funzione unica GetMachiningSteps in BeamLib - variabili specifiche della strategia ora fanno parte direttamente della tabella SawPlusChain - alcune correzioni --- LuaLibs/BeamLib.lua | 17 ++- LuaLibs/ProcessLapJoint.lua | 206 +++++++++++++++--------------------- 2 files changed, 100 insertions(+), 123 deletions(-) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index fc92583..20e1b23 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -792,10 +792,6 @@ end ------------------------------------------------------------------------------------------------------------- function BeamLib.IsSplittedPartPhase( nPhase) - if not nPhase then - nPhase = EgtGetCurrPhase() - end - local sVal = BeamLib.GetPhaseType( nPhase) return ( sVal == 'END' or sVal == 'MID2' or sVal == 'END2') end @@ -1216,5 +1212,18 @@ function BeamLib.GetFacetsInfo( Proc, b3Raw) return Face end +------------------------------------------------------------------------------------------------------------- +function BeamLib.GetMachiningSteps( dMachiningDepth, dStep) + + local MachiningSteps = {} + MachiningSteps.StepLength = 0 + MachiningSteps.Count = ceil( ( dStep - 10 * GEO.EPS_SMALL) / dMachiningDepth) + if MachiningSteps.Count > 1 then + MachiningSteps.StepLength = ( dStep - dMachiningDepth) / ( MachiningSteps.Count - 1) + end + + return MachiningSteps +end + ------------------------------------------------------------------------------------------------------------- return BeamLib \ No newline at end of file diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index b80a4b1..5f6aca6 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -4618,6 +4618,8 @@ end local SawPlusChain = {} SawPlusChain.Saw = {} SawPlusChain.Chainsaw = {} +SawPlusChain.Name = 'SawPlusChain' +SawPlusChain.ApplyOnlySawblade = false function SawPlusChain.IsTopologyOk( Proc) @@ -4737,7 +4739,7 @@ function SawPlusChain.GetEdgeToMachine( sEdge, Proc, FaceToMachine) if sEdge == 'Bottom' then EdgeToMachine.ToolDirection = Proc.MainFaces.BottomFace.VtN EdgeToMachine.Length = FaceToMachine.Width - EdgeToMachine.AdjacentFaceId = FaceToMachine.Id + EdgeToMachine.AdjacentFaceId = Proc.MainFaces.BottomFace.Id EdgeToMachine.Elevation = Proc.MainFaces.BottomFace.Elevation EdgeToMachine.IsStartOpen = false EdgeToMachine.IsEndOpen = false @@ -4785,38 +4787,6 @@ function SawPlusChain.GetToolFromMachining( sMachiningName) end -function SawPlusChain.GetVerticalSteps( Proc, Machining) - if not Proc.Pocket or not Proc.Pocket.Height then - error( 'Missing pocket depth') - elseif not Machining.Tool or not Machining.Tool.Thickness then - error( 'Missing tool thickness') - end - local VerticalSteps = {} - VerticalSteps.StepLength = 0 - VerticalSteps.Count = ceil( ( Proc.Pocket.Height - 10 * GEO.EPS_SMALL) / Machining.Tool.Thickness) - if VerticalSteps.Count > 1 then - VerticalSteps.StepLength = ( Proc.Pocket.Height - Machining.Tool.Thickness) / ( VerticalSteps.Count - 1) - end - - return VerticalSteps -end - - -function SawPlusChain.GetHorizontalSteps( Machining) - if not Machining.Depth then - error( 'Missing machining depth') - end - local HorizontalSteps = {} - HorizontalSteps.StepLength = 0 - HorizontalSteps.Count = ceil( ( Machining.Depth - 10 * GEO.EPS_SMALL) / Machining.Tool.SideStep) - if HorizontalSteps.Count > 1 then - HorizontalSteps.StepLength = ( Machining.Depth - Machining.Tool.SideStep) / ( HorizontalSteps.Count - 1) - end - - return HorizontalSteps -end - - function SawPlusChain.IsStartOrEndClosed( Proc, Machining) local bIsStartClosed = false local bIsEndClosed = false @@ -4885,11 +4855,11 @@ function SawPlusChain.CalculateLeadInOut( Proc, Machining, EdgeToMachine) elseif bIsStartClosed then LeadIn.StartAddLength = -dAddLengthToReduce -- eventuale correzione per accorciamento maggiore di larghezza tasca - LeadOut.EndAddLength = max( -LeadIn.StartAddLength - EdgeToMachine.Width + 10 * BD.CUT_EXTRA, BD.CUT_EXTRA) + LeadOut.EndAddLength = max( -LeadIn.StartAddLength - EdgeToMachine.Length + 10 * BD.CUT_EXTRA, BD.CUT_EXTRA) elseif bIsEndClosed then LeadOut.EndAddLength = -dAddLengthToReduce -- eventuale correzione per accorciamento maggiore di larghezza tasca - LeadIn.StartAddLength = max( -LeadOut.EndAddLength - EdgeToMachine.Width + 10 * BD.CUT_EXTRA, BD.CUT_EXTRA) + LeadIn.StartAddLength = max( -LeadOut.EndAddLength - EdgeToMachine.Length + 10 * BD.CUT_EXTRA, BD.CUT_EXTRA) else LeadIn.StartAddLength = BD.CUT_EXTRA LeadOut.EndAddLength = BD.CUT_EXTRA @@ -5026,7 +4996,7 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg -- ricerca lavorazione Cutting.Name = ML.FindCutting( 'HeadSide', true, false) if not Cutting.Name then - Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not applicable - saw blade not found' + Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not applicable - saw blade not found' Cutting.CanApply = false EgtOutLog( Cutting.Message) return Cutting @@ -5038,16 +5008,16 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg -- verifica dimensioni tasca compatibili -- se tasca meno spessa della lama la strategia non è applicabile - if Cutting.Tool.Thickness > FaceToMachine.Elevation + 10 * GEO.EPS_SMALL then - Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not applicable - pocket too narrow for saw blade thickness' + if Cutting.Tool.Thickness > Proc.MainFaces.BottomFace.Height + 10 * GEO.EPS_SMALL then + Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not applicable - pocket too narrow for saw blade thickness' Cutting.CanApply = false 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 ' .. Proc.Strategy.Name .. ' not applicable - pocket too narrow for saw blade diameter' + Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not applicable - pocket too narrow for saw blade diameter' Cutting.CanApply = false EgtOutLog( Cutting.Message) return Cutting @@ -5080,13 +5050,13 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg else Cutting.Depth = Cutting.Tool.MaxDepth Cutting.RadialOffset = abs( EdgeToMachine.Elevation) - Cutting.Depth - if Proc.Strategy.ApplyOnlySawblade then + if SawPlusChain.ApplyOnlySawblade then Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : sawblade elevation (' .. EgtNumToString( EdgeToMachine.Elevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Cutting.Depth, 1) .. ')' EgtOutLog( Cutting.Message) end end -- step verticale e offset longitudinale - Cutting.Steps = SawPlusChain.GetVerticalSteps( Proc, Cutting) + Cutting.Steps = BL.GetMachiningSteps( Proc.MainFaces.BottomFace.Height, Cutting.Tool.Thickness) 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 @@ -5113,7 +5083,7 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg -- eventuale step orizzontale Cutting.HorizontalSteps = {} if Cutting.Tool.SideStep then - Cutting.HorizontalSteps = SawPlusChain.GetHorizontalSteps( Cutting) + Cutting.HorizontalSteps = BL.GetMachiningSteps( Cutting.Depth, Cutting.Tool.SideStep) else Cutting.HorizontalSteps.Count = 1 Cutting.HorizontalSteps.StepLength = 0 @@ -5138,121 +5108,119 @@ end function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) - local Chainsawing = {} - Chainsawing.CanApply = true - Chainsawing.Message = '' - Chainsawing.ProcId = Proc.Id + local Mortising = {} + Mortising.CanApply = true + Mortising.Message = '' + Mortising.ProcId = Proc.Id -- ricerca lavorazione -- TODO gestire elevazione negativa (determina come devo lavorare) - Chainsawing.Name = ML.FindSawing( 'Sawing', Proc.EdgeToMachine.Elevation) - if not Chainsawing.Name then - Chainsawing.Name = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + Mortising.Name = ML.FindSawing( 'Sawing', Proc.EdgeToMachine.Elevation) + if not Mortising.Name then + Mortising.Name = ML.FindSawing( 'Sawing', nil, nil, 'Longest') end - if not Chainsawing.Name then - Chainsawing.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not applicable - chainsaw not found' - Chainsawing.CanApply = false - EgtOutLog( Chainsawing.Message) - return Chainsawing + if not Mortising.Name then + Mortising.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not applicable - chainsaw not found' + Mortising.CanApply = false + EgtOutLog( Mortising.Message) + return Mortising end - Chainsawing.Type = MCH_OY.MORTISING - Chainsawing.Tool = SawPlusChain.GetToolFromMachining( Chainsawing.Name) + Mortising.Type = MCH_OY.MORTISING + Mortising.Tool = SawPlusChain.GetToolFromMachining( Mortising.Name) -- TODO serve?? - Chainsawing.FaceToMachine = FaceToMachine + Mortising.FaceToMachine = FaceToMachine -- verifica dimensioni tasca compatibili -- se tasca meno spessa della sega a catena la strategia non è applicabile - if Chainsawing.Tool.Thickness > FaceToMachine.Elevation + 10 * GEO.EPS_SMALL then - Chainsawing.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not applicable - pocket too narrow for chainsaw thickness' - Chainsawing.CanApply = false - EgtOutLog( Chainsawing.Message) - return Chainsawing + if Mortising.Tool.Thickness > Proc.MainFaces.BottomFace.Height + 10 * GEO.EPS_SMALL then + Mortising.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not applicable - pocket too narrow for chainsaw thickness' + Mortising.CanApply = false + EgtOutLog( Mortising.Message) + return Mortising end if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della sega a catena la strategia non è applicabile - if Chainsawing.Tool.Width > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then - Chainsawing.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not applicable - pocket too narrow for chainsaw width' - Chainsawing.CanApply = false - EgtOutLog( Chainsawing.Message) - return Chainsawing + if Mortising.Tool.Width > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then + Mortising.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not applicable - pocket too narrow for chainsaw width' + Mortising.CanApply = false + EgtOutLog( Mortising.Message) + return Mortising end end -- parametri della lavorazione -- direzione utensile - Chainsawing.Direction = EdgeToMachine.VtN + Mortising.Direction = EdgeToMachine.VtN -- lato di lavoro e inversioni - if Chainsawing.Tool.IsCCW then - Chainsawing.Workside = MCH_MILL_WS.RIGHT - Chainsawing.Invert = false + if Mortising.Tool.IsCCW then + Mortising.Workside = MCH_MILL_WS.RIGHT + Mortising.Invert = false else - Chainsawing.Workside = MCH_MILL_WS.LEFT - Chainsawing.Invert = true + Mortising.Workside = MCH_MILL_WS.LEFT + Mortising.Invert = true end - Chainsawing.ToolInvert = false + Mortising.ToolInvert = false -- profondità e offset longitudinale - if Chainsawing.Tool.MaxMat > EdgeToMachine.Elevation - 10 * GEO.EPS_SMALL then - Chainsawing.Depth = EdgeToMachine.Elevation - Chainsawing.LongitudinalOffset = 0 + if Mortising.Tool.MaxMat > EdgeToMachine.Elevation - 10 * GEO.EPS_SMALL then + Mortising.Depth = EdgeToMachine.Elevation + Mortising.LongitudinalOffset = 0 else - Chainsawing.Depth = Chainsawing.Tool.MaxMat - Chainsawing.LongitudinalOffset = EdgeToMachine.Elevation - Chainsawing.Depth - Chainsawing.Message = 'Feature '.. Proc.FeatureId .. ' : chainsaw elevation (' .. EgtNumToString( EdgeToMachine.Elevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Chainsawing.Depth, 1) .. ')' - EgtOutLog( Chainsawing.Message) + Mortising.Depth = Mortising.Tool.MaxMat + Mortising.LongitudinalOffset = EdgeToMachine.Elevation - Mortising.Depth + Mortising.Message = 'Feature '.. Proc.FeatureId .. ' : chainsaw elevation (' .. EgtNumToString( EdgeToMachine.Elevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Mortising.Depth, 1) .. ')' + EgtOutLog( Mortising.Message) end -- offset radiale - Chainsawing.RadialOffset = 0 + Mortising.RadialOffset = 0 -- distanza di sicurezza - Chainsawing.StartSafetyLength = EdgeToMachine.Elevation + Mortising.StartSafetyLength = EdgeToMachine.Elevation -- overlap - Chainsawing.Overlap = 0 + Mortising.Overlap = 0 -- faceuse - Chainsawing.Faceuse = BL.GetNearestParalOpposite( Chainsawing.Direction) + Mortising.Faceuse = BL.GetNearestParalOpposite( Mortising.Direction) -- SCC - Chainsawing.SCC = MCH_SCC.NONE + Mortising.SCC = MCH_SCC.NONE -- asse bloccato e angoli suggeriti - Chainsawing.BlockedAxis = {} - Chainsawing.BlockedAxis.Orientation = 'perpendicular' - Chainsawing.SuggestedAngles = {} - Chainsawing.SuggestedAngles.Index = 1 + Mortising.BlockedAxis = {} + Mortising.BlockedAxis.Orientation = 'perpendicular' + Mortising.SuggestedAngles = {} + Mortising.SuggestedAngles.Index = 1 -- approccio e retrazione - Chainsawing.LeadIn, Chainsawing.LeadOut = SawPlusChain.CalculateLeadInOut( Proc, Chainsawing) + Mortising.LeadIn, Mortising.LeadOut = SawPlusChain.CalculateLeadInOut( Proc, Mortising) -- eventuale step verticale - Chainsawing.VerticalSteps = SawPlusChain.GetVerticalSteps( Proc, Chainsawing) + Mortising.VerticalSteps = BL.GetMachiningSteps( Proc.MainFaces.BottomFace.Height, Mortising.Tool.Thickness) -- nome operazione - Chainsawing.OperationName = 'Chainsaw_' .. ( EgtGetName( Chainsawing.ProcId) or tostring( Chainsawing.ProcId)) .. '_' .. tostring( Chainsawing.FaceToMachine.Id + 1) + Mortising.OperationName = 'Chainsaw_' .. ( EgtGetName( Mortising.ProcId) or tostring( Mortising.ProcId)) .. '_' .. tostring( Mortising.FaceToMachine.Id + 1) -- eventuale avviso di danneggiamento pezzo successivo - local dOffsideLength = max( Chainsawing.LeadIn.StartAddLength, Chainsawing.LeadOut.EndAddLength) + Chainsawing.Tool.Width / 2 + 10 * GEO.EPS_SMALL + local dOffsideLength = max( Mortising.LeadIn.StartAddLength, Mortising.LeadOut.EndAddLength) + Mortising.Tool.Width / 2 + 10 * GEO.EPS_SMALL if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.DistanceToNextPart < dOffsideLength) then local sDamageNextPieceMessage = 'Feature '.. Proc.FeatureId .. ' : chainsaw can damage next piece.' - if #Chainsawing.Message > 0 then - Chainsawing.Message = Chainsawing.Message .. '\n' .. sDamageNextPieceMessage + if #Mortising.Message > 0 then + Mortising.Message = Mortising.Message .. '\n' .. sDamageNextPieceMessage else - Chainsawing.Message = sDamageNextPieceMessage + Mortising.Message = sDamageNextPieceMessage end EgtOutLog( sDamageNextPieceMessage) end - return Chainsawing + return Mortising end function SawPlusChain.Make( bOnlySaw, Proc, nRawId) - Proc.Strategy = {} - Proc.Strategy.ApplyOnlySawblade = bOnlySaw - Proc.Strategy.Name = 'SawPlusChain' + SawPlusChain.ApplyOnlySawblade = bOnlySaw local b3Raw = EgtGetRawPartBBox( nRawId) -- TODO per implementare la strategia con lapjoint lunghe bisogna prima riconoscere le topologie che arrivano if Proc.IsSplittedLapJoint then - local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not implemented for long lapjoint' + local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not implemented for long lapjoint' EgtOutLog( sErr) return false, sErr end if not SawPlusChain.IsTopologyOk( Proc) then - local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not implemented' + local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not implemented' EgtOutLog( sErr) return false, sErr end @@ -5260,7 +5228,7 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) -- se tasca su faccia sotto la strategia non è applicabile (la sega a catena in generale non può lavorare da sotto) -- TODO se OnlySaw questo test è da rimuovere ma bisogna considerare anche la lama da sotto if Proc.AffectedFaces.Bottom and ( Proc.Fct > 3 or not Proc.AffectedFaces.Top) then - local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not applicable - pocket on bottom face' + local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not applicable - pocket on bottom face' EgtOutLog( sErr) return false, sErr end @@ -5307,32 +5275,32 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) end -- parametri lavorazione con sega a catena - local Chainsawing = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) + local Mortising = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) -- si lavora solo quanto non lavorato dalla lama - Chainsawing.MaxElev = Cutting.RadialOffset + BD.CUT_EXTRA + Mortising.MaxElev = Cutting.RadialOffset + BD.CUT_EXTRA -- applicazione lavorazione con sega a catena con eventuali step in Z - local bIsChainsawingOk = false - local sChainsawingApplyMessage = '' - if Chainsawing.CanApply then - local dOriginalRadialOffsetChainsawing = Chainsawing.RadialOffset - for i = Chainsawing.VerticalSteps.Count, 1, -1 do - Chainsawing.RadialOffset = dOriginalRadialOffsetChainsawing + Chainsawing.VerticalSteps.StepLength * ( i - 1) + local bIsMortisingOk = false + local sMortisingApplyMessage = '' + if Mortising.CanApply then + local dOriginalRadialOffsetMortising = Mortising.RadialOffset + for i = Mortising.VerticalSteps.Count, 1, -1 do + Mortising.RadialOffset = dOriginalRadialOffsetMortising + Mortising.VerticalSteps.StepLength * ( i - 1) -- applicazione lavorazione - bIsChainsawingOk, sChainsawingApplyMessage = SawPlusChain.ApplyMachining( Chainsawing, b3Raw) + bIsMortisingOk, sMortisingApplyMessage = SawPlusChain.ApplyMachining( Mortising, b3Raw) -- update messaggi - if sChainsawingApplyMessage and #sChainsawingApplyMessage > 0 then - Chainsawing.Message = Chainsawing.Message .. '\n' .. 'Apply : ' .. sChainsawingApplyMessage + if sMortisingApplyMessage and #sMortisingApplyMessage > 0 then + Mortising.Message = Mortising.Message .. '\n' .. 'Apply : ' .. sMortisingApplyMessage end end end local sFinalMessage = '' - if #Cutting.Message > 0 or #Chainsawing.Message > 0 then - sFinalMessage = Cutting.Message .. '\n' .. Chainsawing.Message + if #Cutting.Message > 0 or #Mortising.Message > 0 then + sFinalMessage = Cutting.Message .. '\n' .. Mortising.Message end - return bIsChainsawingOk, sFinalMessage + return bIsMortisingOk, sFinalMessage end --#endregion SawPlusChain