From 769c73765d43a4ad0ae8ad67049967fd295b2e95 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 3 May 2024 12:21:41 +0200 Subject: [PATCH 01/11] - in lapJoint -> SawPlusChain piccole modifiche - in mortise -> AddCleanCornersMachining resa locale variabile erroneamente dichiarata globale --- LuaLibs/ProcessLapJoint.lua | 43 +++++++++++++++++++++---------------- LuaLibs/ProcessMortise.lua | 2 +- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 63367ce..979b64a 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -4715,13 +4715,13 @@ function SawPlusChain.GetSideFaces( Proc) if ( not bIsFaceToMachineTheLargest and i < #FacesAdjacentToBottom) or ( bIsFaceToMachineTheLargest and i > 2) then table.insert( SideFaces, FacesAdjacentToBottom[i]) - SideFaces[ #SideFaces].Id = FacesAdjacentToBottom[i].Id - SideFaces[ #SideFaces].Width = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Width - SideFaces[ #SideFaces].Height = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Height - SideFaces[ #SideFaces].Elevation = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Elevation - SideFaces[ #SideFaces].VtN = Proc.Face[FacesAdjacentToBottom[i].Id + 1].VtN - if SideFaces[ #SideFaces].Height > SideFaces[ #SideFaces].Width then - SideFaces[ #SideFaces].Height, SideFaces[ #SideFaces].Width = SideFaces[ #SideFaces].Width, SideFaces[ #SideFaces].Height + SideFaces[#SideFaces].Id = FacesAdjacentToBottom[i].Id + SideFaces[#SideFaces].Width = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Width + SideFaces[#SideFaces].Height = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Height + SideFaces[#SideFaces].Elevation = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Elevation + SideFaces[#SideFaces].VtN = Proc.Face[FacesAdjacentToBottom[i].Id + 1].VtN + if SideFaces[#SideFaces].Height > SideFaces[#SideFaces].Width then + SideFaces[#SideFaces].Height, SideFaces[#SideFaces].Width = SideFaces[ #SideFaces].Width, SideFaces[ #SideFaces].Height end end end @@ -4793,20 +4793,10 @@ function SawPlusChain.GetHorizontalSteps( Machining) return HorizontalSteps end - -function SawPlusChain.CalculateLeadInOut( Proc, Machining) - -- 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 +function SawPlusChain.IsStartOrEndClosed( Proc, Machining) local bIsStartClosed = false local bIsEndClosed = false local bIsMortising = ( Machining.Type == MCH_OY.MORTISING) - local dAddLengthToReduce = 0 - if bIsMortising then - dAddLengthToReduce = Machining.Tool.Diameter / 2 - else - dAddLengthToReduce = sqrt( Machining.Depth * Machining.Tool.Diameter - Machining.Depth * Machining.Depth) - end if #( Proc.Pocket.SideFaces) == 2 then bIsStartClosed = true bIsEndClosed = true @@ -4830,6 +4820,23 @@ function SawPlusChain.CalculateLeadInOut( Proc, Machining) end end + return bIsStartClosed, bIsEndClosed +end + + +function SawPlusChain.CalculateLeadInOut( Proc, Machining) + -- 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 + local bIsStartClosed, bIsEndClosed = SawPlusChain.IsStartOrEndClosed( Proc, Machining) + local bIsMortising = ( Machining.Type == MCH_OY.MORTISING) + local dAddLengthToReduce = 0 + if bIsMortising then + dAddLengthToReduce = Machining.Tool.Diameter / 2 + else + dAddLengthToReduce = sqrt( Machining.Depth * Machining.Tool.Diameter - Machining.Depth * Machining.Depth) + end + local LeadIn = {} local LeadOut = {} LeadIn.StartAddLength = 0 diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index fecdfe7..db80299 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -128,7 +128,7 @@ end local nFaceUse = BL.GetNearestParalOpposite( vtN) EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- applico il parametro plunge, che setta la lavorazione per affondare solamente, senza lavorare tutto il contorno; 1: solo lato iniziale, 2: solo lato finale, 3: entrambi - sNotes = 'Plunge=3;' + local sNotes = 'Plunge=3;' EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) -- imposto angolo 3° asse rot local vtOrtho = BL.GetVersRef( nFaceUse) From 1572648a7e5f9dea441732c9aff9e54292683a5e Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 7 May 2024 18:59:30 +0200 Subject: [PATCH 02/11] - modifiche parziali a SawPlusChain per implemento funzione Egt che fornisce informazioni rigurado ai lati --- LuaLibs/BeamExec.lua | 3 + LuaLibs/BeamLib.lua | 11 ++- LuaLibs/ProcessLapJoint.lua | 177 +++++++++++++++++++++--------------- 3 files changed, 114 insertions(+), 77 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 0ab6135..af2d211 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -2104,6 +2104,7 @@ function BeamExec.ProcessFeatures() Proc.Box = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) Proc.Face = BL.GetFacetsInfo( Proc, b3Raw) Proc.AffectedFaces = BL.GetProcessAffectedFaces( Proc) + Proc.DistanceToNextPart = BL.GetDistanceToNextPart( nRawId, nPhase) Proc.PrevDouble = nPrevDouble nPrevDouble = Proc.Double local bOk, sMsg, nNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, bNeedHCut, b3Raw, nOrd, sDownOrSideOrStd, nil, nil, dCurrOvmT) @@ -2185,6 +2186,7 @@ function BeamExec.ProcessFeatures() Proc.Box = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) Proc.Face = BL.GetFacetsInfo( Proc, b3Raw) Proc.AffectedFaces = BL.GetProcessAffectedFaces( Proc) + Proc.DistanceToNextPart = BL.GetDistanceToNextPart( nRawId, nPhase) Proc.PrevDouble = nPrevDouble nPrevDouble = Proc.Double local bOk, sMsg, nNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, false, b3Raw, nOrd, sDownOrSideOrStd, bPreMove, vtMove, dCurrOvmT) @@ -2254,6 +2256,7 @@ function BeamExec.ProcessFeatures() Proc.Box = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) Proc.Face = BL.GetFacetsInfo( Proc, b3Raw) Proc.AffectedFaces = BL.GetProcessAffectedFaces( Proc) + Proc.DistanceToNextPart = BL.GetDistanceToNextPart( nRawId, nPhase) Proc.PrevDouble = nPrevDouble nPrevDouble = Proc.Double local bOk, sMsg, nNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, false, b3Raw, nOrd, sDownOrSideOrStd, nil, nil, dCurrOvmT) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 7373bd9..fc92583 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -792,6 +792,10 @@ 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 @@ -814,9 +818,10 @@ function BeamLib.GetDistanceToNextPart( nRawId, nPhase) -- se segue una parte rimanente riutilizzabile, modifico opportunamente questa distanza if not BeamLib.IsSplittedPartPhase( nPhase) then local nNextRawId = EgtGetNextRawPart( nRawId) - if nNextRawId and - EgtGetPartInRawPartCount( nNextRawId) <= 0 and - EgtGetRawPartBBox( nNextRawId):getDimX() >= BD.MinRaw then + if nNextRawId and + EgtGetPartInRawPartCount( nNextRawId) <= 0 and + EgtGetRawPartBBox( nNextRawId):getDimX() >= BD.MinRaw then + dDistToNextPiece = BD.OVM_MID end end diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 979b64a..b80a4b1 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -4666,13 +4666,13 @@ function SawPlusChain.GetBottomFace( Proc) end -function SawPlusChain.GetFaceToMachine( Proc) - if not Proc.Pocket.BottomFace or not Proc.Pocket.BottomFace.Id then - Proc.Pocket.BottomFace = SawPlusChain.GetBottomFace( Proc) +function SawPlusChain.GetLongFace( Proc) + if not Proc.MainFaces.BottomFace or not Proc.MainFaces.BottomFace.Id then + Proc.MainFaces.BottomFace = SawPlusChain.GetBottomFace( Proc) end -- facce adiacenti a quella di fondo, ordinate - local FacesAdjacentToBottom = BL.GetAdjacentFaces( Proc, Proc.Pocket.BottomFace.Id) + local FacesAdjacentToBottom = BL.GetAdjacentFaces( Proc, Proc.MainFaces.BottomFace.Id) table.sort( FacesAdjacentToBottom, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end) -- si sceglie la faccia adiacente sul lato più lungo @@ -4695,25 +4695,25 @@ end function SawPlusChain.GetSideFaces( Proc) - if not Proc.Pocket.BottomFace or not Proc.Pocket.BottomFace.Id then - Proc.Pocket.BottomFace = SawPlusChain.GetBottomFace( Proc) + if not Proc.MainFaces.BottomFace or not Proc.MainFaces.BottomFace.Id then + Proc.MainFaces.BottomFace = SawPlusChain.GetBottomFace( Proc) end - if not Proc.Pocket.FaceToMachine or not Proc.Pocket.FaceToMachine.Id then - Proc.Pocket.FaceToMachine = SawPlusChain.GetFaceToMachine( Proc) + if not Proc.MainFaces.LongFace or not Proc.MainFaces.LongFace.Id then + Proc.MainFaces.LongFace = SawPlusChain.GetLongFace( Proc) end -- facce adiacenti a quella di fondo, ordinate - local FacesAdjacentToBottom = BL.GetAdjacentFaces( Proc, Proc.Pocket.BottomFace.Id) + local FacesAdjacentToBottom = BL.GetAdjacentFaces( Proc, Proc.MainFaces.BottomFace.Id) table.sort( FacesAdjacentToBottom, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end) -- si determina il criterio di scelta delle facce laterali - local FacesAdjacentToFaceToMachine = BL.GetAdjacentFaces( Proc, Proc.Pocket.FaceToMachine.Id) - local bIsFaceToMachineTheLargest = not ( Proc.Fct == 4 and #FacesAdjacentToFaceToMachine == 3) + local FacesAdjacentToLongFace = BL.GetAdjacentFaces( Proc, Proc.MainFaces.LongFace.Id) + local bIsLongFaceTheLargest = not ( Proc.Fct == 4 and #FacesAdjacentToLongFace == 3) local SideFaces = {} for i = 1, #FacesAdjacentToBottom do - if ( not bIsFaceToMachineTheLargest and i < #FacesAdjacentToBottom) or - ( bIsFaceToMachineTheLargest and i > 2) then + if ( not bIsLongFaceTheLargest and i < #FacesAdjacentToBottom) or + ( bIsLongFaceTheLargest and i > 2) then table.insert( SideFaces, FacesAdjacentToBottom[i]) SideFaces[#SideFaces].Id = FacesAdjacentToBottom[i].Id SideFaces[#SideFaces].Width = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Width @@ -4730,6 +4730,29 @@ 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 = {} + + if sEdge == 'Bottom' then + EdgeToMachine.ToolDirection = Proc.MainFaces.BottomFace.VtN + EdgeToMachine.Length = FaceToMachine.Width + EdgeToMachine.AdjacentFaceId = FaceToMachine.Id + EdgeToMachine.Elevation = Proc.MainFaces.BottomFace.Elevation + EdgeToMachine.IsStartOpen = false + EdgeToMachine.IsEndOpen = false + elseif sEdge == 'SideStart' then + + elseif sEdge == 'SideEnd' then + + elseif sEdge == 'Opposite' then + + end + + return EdgeToMachine +end + + function SawPlusChain.GetToolFromMachining( sMachiningName) local Tool = {} if EgtMdbSetCurrMachining( sMachiningName) then @@ -4793,19 +4816,20 @@ function SawPlusChain.GetHorizontalSteps( Machining) return HorizontalSteps end + function SawPlusChain.IsStartOrEndClosed( Proc, Machining) local bIsStartClosed = false local bIsEndClosed = false local bIsMortising = ( Machining.Type == MCH_OY.MORTISING) - if #( Proc.Pocket.SideFaces) == 2 then + if #( Proc.MainFaces.SideFaces) == 2 then bIsStartClosed = true bIsEndClosed = true - elseif #( Proc.Pocket.SideFaces) == 1 then - local CCWDirection = ( Machining.FaceToMachine.VtN ^ Proc.Pocket.BottomFace.VtN) + elseif #( Proc.MainFaces.SideFaces) == 1 then + local CCWDirection = ( Machining.FaceToMachine.VtN ^ Proc.MainFaces.BottomFace.VtN) if Machining.ToolInvert or bIsMortising then CCWDirection = - CCWDirection end - if CCWDirection * Proc.Pocket.SideFaces[1].VtN > 10 * GEO.EPS_SMALL then + if CCWDirection * Proc.MainFaces.SideFaces[1].VtN > 10 * GEO.EPS_SMALL then if Machining.Tool.IsCCW then bIsStartClosed = true else @@ -4824,11 +4848,14 @@ function SawPlusChain.IsStartOrEndClosed( Proc, Machining) end -function SawPlusChain.CalculateLeadInOut( Proc, Machining) +function SawPlusChain.CalculateLeadInOut( Proc, 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) + local bIsMortising = ( Machining.Type == MCH_OY.MORTISING) local dAddLengthToReduce = 0 if bIsMortising then @@ -4846,8 +4873,8 @@ function SawPlusChain.CalculateLeadInOut( Proc, Machining) LeadOut.Type = MCH_MILL_LI.LINEAR LeadIn.TangentDistance = 0 LeadOut.TangentDistance = 0 - LeadIn.PerpDistance = Proc.Pocket.Depth + BD.CUT_SIC - LeadOut.PerpDistance = Proc.Pocket.Depth + BD.CUT_SIC + LeadIn.PerpDistance = EdgeToMachine.Elevation + BD.CUT_SIC + LeadOut.PerpDistance = EdgeToMachine.Elevation + BD.CUT_SIC LeadIn.Elevation = 0 LeadOut.Elevation = 0 LeadIn.CompLength = 0 @@ -4858,11 +4885,11 @@ function SawPlusChain.CalculateLeadInOut( Proc, Machining) elseif bIsStartClosed then LeadIn.StartAddLength = -dAddLengthToReduce -- eventuale correzione per accorciamento maggiore di larghezza tasca - LeadOut.EndAddLength = max( -LeadIn.StartAddLength - Proc.Pocket.Width + 10 * BD.CUT_EXTRA, BD.CUT_EXTRA) + LeadOut.EndAddLength = max( -LeadIn.StartAddLength - EdgeToMachine.Width + 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 - Proc.Pocket.Width + 10 * BD.CUT_EXTRA, BD.CUT_EXTRA) + LeadIn.StartAddLength = max( -LeadOut.EndAddLength - EdgeToMachine.Width + 10 * BD.CUT_EXTRA, BD.CUT_EXTRA) else LeadIn.StartAddLength = BD.CUT_EXTRA LeadOut.EndAddLength = BD.CUT_EXTRA @@ -4990,7 +5017,7 @@ function SawPlusChain.Saw.GetSCC( vtMachiningDirection) end -function SawPlusChain.Saw.CalculateMachiningParameters( Proc) +function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) local Cutting = {} Cutting.CanApply = true Cutting.Message = '' @@ -4999,27 +5026,28 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc) -- ricerca lavorazione Cutting.Name = ML.FindCutting( 'HeadSide', true, false) if not Cutting.Name then - Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - saw blade not found' + Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not applicable - saw blade not found' Cutting.CanApply = false EgtOutLog( Cutting.Message) return Cutting end Cutting.Type = MCH_OY.MILLING Cutting.Tool = SawPlusChain.GetToolFromMachining( Cutting.Name) - Cutting.FaceToMachine = Proc.Pocket.FaceToMachine + -- TODO serve? + Cutting.FaceToMachine = FaceToMachine -- verifica dimensioni tasca compatibili -- se tasca meno spessa della lama la strategia non è applicabile - if Cutting.Tool.Thickness > Proc.Pocket.Height + 10 * GEO.EPS_SMALL then - Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for saw blade thickness' + 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' Cutting.CanApply = false EgtOutLog( Cutting.Message) return Cutting end - if #( Proc.Pocket.SideFaces) > 1 then + if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della lama la strategia non è applicabile - if Cutting.Tool.Diameter > Proc.Pocket.Width + 10 * GEO.EPS_SMALL then - Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for saw blade diameter' + 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.CanApply = false EgtOutLog( Cutting.Message) return Cutting @@ -5028,7 +5056,7 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc) -- parametri della lavorazione -- direzione utensile - Cutting.Direction = Proc.Pocket.Direction + Cutting.Direction = EdgeToMachine.ToolDirection -- lato di lavoro e inversioni if Cutting.Tool.IsCCW then Cutting.Workside = MCH_MILL_WS.RIGHT @@ -5045,14 +5073,15 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc) Cutting.ToolInvert = false end -- profondità e offset radiale - if Cutting.Tool.MaxDepth > Proc.Pocket.Depth - 10 * GEO.EPS_SMALL then - Cutting.Depth = Proc.Pocket.Depth + -- TODO gestire elevazione negativa (determina come devo lavorare) + if Cutting.Tool.MaxDepth > abs( EdgeToMachine.Elevation) - 10 * GEO.EPS_SMALL then + Cutting.Depth = abs( EdgeToMachine.Elevation) Cutting.RadialOffset = 0 else Cutting.Depth = Cutting.Tool.MaxDepth - Cutting.RadialOffset = Proc.Pocket.Depth - Cutting.Depth - if Proc.Pocket.ApplyOnlySawblade then - Cutting.Message = 'Feature '.. Proc.FeatureId .. ' : sawblade elevation (' .. EgtNumToString( Proc.Pocket.Depth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Cutting.Depth, 1) .. ')' + Cutting.RadialOffset = abs( EdgeToMachine.Elevation) - Cutting.Depth + if Proc.Strategy.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 @@ -5061,7 +5090,7 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc) 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 = - Proc.Pocket.Height + Cutting.LongitudinalOffset = - FaceToMachine.Elevation else Cutting.LongitudinalOffset = 0 end @@ -5094,7 +5123,7 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc) -- eventuale avviso di danneggiamento pezzo successivo local dOffsideLength = max( Cutting.LeadIn.StartAddLength, Cutting.LeadOut.EndAddLength) + Cutting.Tool.Diameter / 2 + 10 * GEO.EPS_SMALL - if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.Pocket.DistanceToNextPart < dOffsideLength) then + if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.DistanceToNextPart < dOffsideLength) then local sDamageNextPieceMessage = 'Feature '.. Proc.FeatureId .. ' : sawblade can damage next piece.' if #Cutting.Message > 0 then Cutting.Message = Cutting.Message .. '\n' .. sDamageNextPieceMessage @@ -5108,39 +5137,41 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc) end -function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc) +function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) local Chainsawing = {} Chainsawing.CanApply = true Chainsawing.Message = '' Chainsawing.ProcId = Proc.Id -- ricerca lavorazione - Chainsawing.Name = ML.FindSawing( 'Sawing', Proc.Pocket.Depth) + -- 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') end if not Chainsawing.Name then - Chainsawing.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - chainsaw not found' + Chainsawing.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not applicable - chainsaw not found' Chainsawing.CanApply = false EgtOutLog( Chainsawing.Message) return Chainsawing end Chainsawing.Type = MCH_OY.MORTISING Chainsawing.Tool = SawPlusChain.GetToolFromMachining( Chainsawing.Name) - Chainsawing.FaceToMachine = Proc.Pocket.FaceToMachine + -- TODO serve?? + Chainsawing.FaceToMachine = FaceToMachine -- verifica dimensioni tasca compatibili -- se tasca meno spessa della sega a catena la strategia non è applicabile - if Chainsawing.Tool.Thickness > Proc.Pocket.Height + 10 * GEO.EPS_SMALL then - Chainsawing.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for chainsaw thickness' + 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 end - if #( Proc.Pocket.SideFaces) > 1 then + if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della sega a catena la strategia non è applicabile - if Chainsawing.Tool.Width > Proc.Pocket.Width + 10 * GEO.EPS_SMALL then - Chainsawing.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for chainsaw width' + 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 @@ -5149,7 +5180,7 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc) -- parametri della lavorazione -- direzione utensile - Chainsawing.Direction = Proc.Pocket.Direction + Chainsawing.Direction = EdgeToMachine.VtN -- lato di lavoro e inversioni if Chainsawing.Tool.IsCCW then Chainsawing.Workside = MCH_MILL_WS.RIGHT @@ -5160,19 +5191,19 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc) end Chainsawing.ToolInvert = false -- profondità e offset longitudinale - if Chainsawing.Tool.MaxMat > Proc.Pocket.Depth - 10 * GEO.EPS_SMALL then - Chainsawing.Depth = Proc.Pocket.Depth + if Chainsawing.Tool.MaxMat > EdgeToMachine.Elevation - 10 * GEO.EPS_SMALL then + Chainsawing.Depth = EdgeToMachine.Elevation Chainsawing.LongitudinalOffset = 0 else Chainsawing.Depth = Chainsawing.Tool.MaxMat - Chainsawing.LongitudinalOffset = Proc.Pocket.Depth - Chainsawing.Depth - Chainsawing.Message = 'Feature '.. Proc.FeatureId .. ' : chainsaw elevation (' .. EgtNumToString( Proc.Pocket.Depth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Chainsawing.Depth, 1) .. ')' + 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) end -- offset radiale Chainsawing.RadialOffset = 0 -- distanza di sicurezza - Chainsawing.StartSafetyLength = Proc.Pocket.Depth + Chainsawing.StartSafetyLength = EdgeToMachine.Elevation -- overlap Chainsawing.Overlap = 0 -- faceuse @@ -5193,7 +5224,7 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc) -- eventuale avviso di danneggiamento pezzo successivo local dOffsideLength = max( Chainsawing.LeadIn.StartAddLength, Chainsawing.LeadOut.EndAddLength) + Chainsawing.Tool.Width / 2 + 10 * GEO.EPS_SMALL - if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.Pocket.DistanceToNextPart < dOffsideLength) then + 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 @@ -5207,21 +5238,21 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc) end -function SawPlusChain.Make( Proc, nRawId, nPhase, bOnlySaw) - Proc.Pocket = {} - Proc.Pocket.ApplyOnlySawblade = bOnlySaw - Proc.Pocket.Strategy = 'SawPlusChain' +function SawPlusChain.Make( bOnlySaw, Proc, nRawId) + Proc.Strategy = {} + Proc.Strategy.ApplyOnlySawblade = bOnlySaw + Proc.Strategy.Name = 'SawPlusChain' 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.Pocket.Strategy .. ' not implemented for long lapjoint' + local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.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.Pocket.Strategy .. ' not implemented' + local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not implemented' EgtOutLog( sErr) return false, sErr end @@ -5229,23 +5260,21 @@ function SawPlusChain.Make( Proc, nRawId, nPhase, bOnlySaw) -- 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.Pocket.Strategy .. ' not applicable - pocket on bottom face' + local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Strategy.Name .. ' not applicable - pocket on bottom face' EgtOutLog( sErr) return false, sErr end - -- caratteristiche della tasca - Proc.Pocket.BottomFace = SawPlusChain.GetBottomFace( Proc) - Proc.Pocket.FaceToMachine = SawPlusChain.GetFaceToMachine( Proc) - Proc.Pocket.SideFaces = SawPlusChain.GetSideFaces( Proc) - Proc.Pocket.Width = Proc.Pocket.BottomFace.Width - Proc.Pocket.Height = Proc.Pocket.BottomFace.Height - Proc.Pocket.Depth = Proc.Pocket.BottomFace.Elevation - Proc.Pocket.Direction = Proc.Pocket.BottomFace.VtN - Proc.Pocket.DistanceToNextPart = BL.GetDistanceToNextPart( nRawId, nPhase) + -- facce principali + Proc.MainFaces = {} + Proc.MainFaces.BottomFace = SawPlusChain.GetBottomFace( Proc) + Proc.MainFaces.LongFace = SawPlusChain.GetLongFace( Proc) + Proc.MainFaces.SideFaces = SawPlusChain.GetSideFaces( Proc) -- parametri lavorazione di lama - local Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc) + 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 local bIsCuttingOk = false @@ -5278,7 +5307,7 @@ function SawPlusChain.Make( Proc, nRawId, nPhase, bOnlySaw) end -- parametri lavorazione con sega a catena - local Chainsawing = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc) + local Chainsawing = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) -- si lavora solo quanto non lavorato dalla lama Chainsawing.MaxElev = Cutting.RadialOffset + BD.CUT_EXTRA @@ -5332,11 +5361,11 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa end -- strategia lama + eventuale sega a catena - if ( EgtGetInfo( Proc.Id, Q_SAW_PLUS_CHAIN, 'i') or 0) > 0 then --TEST + if ( EgtGetInfo( Proc.Id, Q_SAW_PLUS_CHAIN, 'i') or 0) > 0 then local bOk local sErr local bOnlySaw = EgtGetInfo( Proc.Id, Q_SAW_PLUS_CHAIN, 'i') == 1 - bOk, sErr = SawPlusChain.Make ( Proc, nRawId, nPhase, bOnlySaw) + bOk, sErr = SawPlusChain.Make ( bOnlySaw, Proc, nRawId) return bOk, sErr end From efb805cf987181c5d66e7a73950c08c4c34545db Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 8 May 2024 12:58:48 +0200 Subject: [PATCH 03/11] 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 From 93f9af85e7a9b3d7bf2ec9ddf9565635ae634854 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 10 May 2024 09:20:11 +0200 Subject: [PATCH 04/11] 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 From e936f900868392e9a66f2f816dd8aaef9fb90e53 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 10 May 2024 14:22:28 +0200 Subject: [PATCH 05/11] Cut : in MakeFromTop ricalcolo direzione di lavorazione su facce a cubetti --- LuaLibs/ProcessCut.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 04883f4..d74d6b7 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -25,6 +25,7 @@ -- 2023/10/27 In MakeFromTop corretto massimo materiale in caso di lavorazione da sotto. -- 2023/12/07 Correzione in Classify in scelta ribaltamento trave quando si è in condizioni downUp. -- 2024/01/18 Gestita superficie limitante opzionale da passare a diceCut. +-- 2024/05/10 In MakeFromTop ricalcolo direzione di lavorazione su facce a cubetti -- Tabella per definizione modulo local ProcessCut = {} @@ -479,7 +480,15 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b if vtO then vtOrthoO = Vector3d( vtO) * EgtIf( bOrthInv, -1, 1) else - if bHorizCut then + -- ricalcolo tipo taglio perché "bHorizCut" è calcolato sulla feature, mentre il cubetto potrebbe essere lavorato in un altro modo + local _, dLen, dWidth = BL.GetFaceHvRefDim( vCuts[i][1], 0, b3Raw) + local bCutDirection = bHorizCut + -- se bisogna tagliare di fianco ma la lunghezza faccia è più del massimo materiale, forzo lavorazione da sopra + if not bHorizCut and dLen > dMaxDepth then + bCutDirection = true + end + + if bCutDirection then vtOrthoO = Z_AX() else if vtN:getZ() < dNzLimDwnUp then From ce68e2911213913f1c2cbb2628d2dd76aaa3fdff Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 10 May 2024 16:04:19 +0200 Subject: [PATCH 06/11] in SawPlusChain modifiche per contemplare lavorazioni con lama dei lati aperti --- LuaLibs/ProcessLapJoint.lua | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index d62c3ba..b4c35f7 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -775,6 +775,10 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) return false end end + -- se forzata lavorazione con lama e feature aperta sulla coda potrei lavorare anche dalla coda + if Proc.AffectedFaces.Left and ( EgtGetInfo( Proc.Id, Q_SAW_PLUS_CHAIN, 'i') or 0) > 0 then + return true + end -- deve avere la normale principale diretta verso la coda (oppure tunnel) Topology.Classify( Proc, b3Raw) local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc, nPartId) @@ -4866,8 +4870,13 @@ function SawPlusChain.CalculateLeadInOut( Machining, EdgeToMachine) LeadOut.Type = MCH_MILL_LI.LINEAR LeadIn.TangentDistance = 0 LeadOut.TangentDistance = 0 - LeadIn.PerpDistance = EdgeToMachine.Elevation + BD.CUT_SIC - LeadOut.PerpDistance = EdgeToMachine.Elevation + BD.CUT_SIC + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + LeadIn.PerpDistance = EdgeToMachine.Elevation + BD.CUT_SIC + LeadOut.PerpDistance = EdgeToMachine.Elevation + BD.CUT_SIC + else + LeadIn.PerpDistance = BD.CUT_SIC + LeadOut.PerpDistance = BD.CUT_SIC + end LeadIn.Elevation = 0 LeadOut.Elevation = 0 LeadIn.CompLength = 0 @@ -5057,6 +5066,9 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg Cutting.Workside = MCH_MILL_WS.LEFT Cutting.Invert = false end + if EdgeToMachine.Elevation < -10 * GEO.EPS_SMALL then + Cutting.Invert = not Cutting.Invert + end -- TODO gestire lama da sotto e lama downUp if FaceToMachine.VtN:getZ() < - 10 * GEO.EPS_SMALL then Cutting.ToolInvert = true @@ -5065,14 +5077,22 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg Cutting.ToolInvert = false end -- profondità e offset radiale - -- TODO gestire elevazione negativa (determina come devo lavorare) if Cutting.Tool.MaxDepth > abs( EdgeToMachine.Elevation) - 10 * GEO.EPS_SMALL then + -- TODO la depth dovrebbe essere quella del machining Cutting.Depth = abs( EdgeToMachine.Elevation) - Cutting.RadialOffset = 0 + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + Cutting.RadialOffset = 0 + else + Cutting.RadialOffset = EdgeToMachine.Elevation + end else Cutting.Depth = Cutting.Tool.MaxDepth - Cutting.RadialOffset = abs( EdgeToMachine.Elevation) - Cutting.Depth - if SawPlusChain.ApplyOnlySawblade then + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + Cutting.RadialOffset = EdgeToMachine.Elevation - Cutting.Depth + else + Cutting.RadialOffset = -Cutting.Depth + end + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL and 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 @@ -5264,6 +5284,7 @@ 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 From d6c08628fb3ec3b0e7a6f20a885027b9dd10ca5e Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 10 May 2024 18:25:46 +0200 Subject: [PATCH 07/11] - in SawPlusChain corretto MaxElev sega a catena --- LuaLibs/ProcessLapJoint.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index b4c35f7..c9b6c76 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -5323,6 +5323,7 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) if not bIsCuttingOk then return bIsCuttingOk, Cutting.Message end + local dBottomDepthToMachine = Cutting.RadialOffset -- se la lama non è arrivata sul fondo e c'è almeno un lato aperto va lavorato if Cutting.RadialOffset > 10 * GEO.EPS_SMALL then @@ -5360,7 +5361,7 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) -- parametri lavorazione con sega a catena 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 + Mortising.MaxElev = dBottomDepthToMachine + BD.CUT_EXTRA -- applicazione lavorazione con sega a catena con eventuali step in Z local bIsMortisingOk = false From 1b6c1721c51d151465246344d16f0c2b843a0295 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 13 May 2024 18:02:54 +0200 Subject: [PATCH 08/11] -in SawPlusChain implementato tunnel, per ora funzionante solo per lama --- LuaLibs/BeamLib.lua | 46 +++++- LuaLibs/FeatureTopology.lua | 26 +--- LuaLibs/ProcessLapJoint.lua | 288 ++++++++++++++++++++++++------------ 3 files changed, 240 insertions(+), 120 deletions(-) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 3015832..bb06fba 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1186,11 +1186,19 @@ end ------------------------------------------------------------------------------------------------------------- function BeamLib.GetFacetsInfo( Proc, b3Raw) - Face = {} + local Face = {} local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Proc.PartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + local vAdj + if Proc.AdjacencyMatrix then + vAdj = Proc.AdjacencyMatrix + else + vAdj = BeamLib.GetAdjacencyMatrix( Proc) + end for i = 1, Proc.Fct do - Face[i] = { Id = i - 1, VtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT )} + Face[i] = {} + Face[i].Id = i - 1 + Face[i].PtCenter, Face[i].VtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT) if Proc.Fct < 10 then local frHV, dFaceWidthTrimmed, dFaceHeightTrimmed = BeamLib.GetFaceHvRefDim( Proc.Id, i - 1, b3Raw) -- frame OCS faccia @@ -1206,12 +1214,46 @@ function BeamLib.GetFacetsInfo( Proc, b3Raw) Face[i].Height = dFaceHeight -- elevazione calcolata rispetto al box della parte Face[i].Elevation = EgtSurfTmFacetElevationInBBox( Proc.Id, i - 1, b3Solid, true, GDB_ID.ROOT) + -- area della faccia + -- TODO qui sarebbe meglio l'area vera e non quella del rettangolo minimo + local _, dLongEdgeDimension, dShortEdgeDimension = EgtSurfTmFacetMinAreaRectangle( Proc.Id, i - 1, GDB_ID.ROOT) + Face[i].Area = dShortEdgeDimension * dLongEdgeDimension + -- adiacenze della faccia + -- TODO chiamarle in modo che si capisca che sono solo gli id e non l'intero oggetto faccia + Face[i].Adjacencies = {} + for j = 1, Proc.Fct do + if vAdj[i][j] and vAdj[i][j] ~= 0 and ( i ~= j) then + table.insert( Face[i].Adjacencies, j - 1) + end + end end end return Face end +--------------------------------------------------------------------- +-- restituisce la matrice delle adiacenze di Proc dove i e j sono le facce e a(ij) è l'angolo tra di esse; 0 se nessuna adiacenza +function BeamLib.GetAdjacencyMatrix( Proc) + local vAdj = {} + -- essendo la matrice simmetrica a diagonale nulla, ne calcolo solo la metà superiore + for i = 1, Proc.Fct do + vAdj[i] = {} + for j = i + 1, Proc.Fct do + _, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i - 1, j - 1, GDB_ID.ROOT) + if not vAdj[i][j] then vAdj[i][j] = 0 end + end + end + -- riempio di conseguenza il resto della matrice + for i = 1, Proc.Fct do + vAdj[i][i] = 0 + for j = i + 1, Proc.Fct do + vAdj[j][i] = vAdj[i][j] + end + end + return vAdj +end + ------------------------------------------------------------------------------------------------------------- function BeamLib.GetMachiningSteps( dMachiningDepth, dStep) diff --git a/LuaLibs/FeatureTopology.lua b/LuaLibs/FeatureTopology.lua index df8d227..733f97c 100644 --- a/LuaLibs/FeatureTopology.lua +++ b/LuaLibs/FeatureTopology.lua @@ -19,32 +19,10 @@ local BL = require( 'BeamLib') EgtOutLog( ' FeatureTopology started', 1) ---------------------------------------------------------------------- --- restituisce la matrice delle adiacenze di Proc dove i e j sono le facce e a(ij) è l'angolo tra di esse; 0 se nessuna adiacenza -local function GetAdjacencyMatrix( Proc) - local vAdj = {} - -- essendo la matrice simmetrica a diagonale nulla, ne calcolo solo la metà superiore - for i = 1, Proc.Fct do - vAdj[i] = {} - for j = i + 1, Proc.Fct do - _, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i - 1, j - 1, GDB_ID.ROOT) - if not vAdj[i][j] then vAdj[i][j] = 0 end - end - end - -- riempio di conseguenza il resto della matrice - for i = 1, Proc.Fct do - vAdj[i][i] = 0 - for j = i + 1, Proc.Fct do - vAdj[j][i] = vAdj[i][j] - end - end - return vAdj -end - --------------------------------------------------------------------- -- restituisce gli id delle facce di Proc che hanno il numero di adiacenze nAdj function FeatureTopology.GetFacesWithGivenAdjacencyNumber( Proc, vAdj, nAdj) - if not vAdj then vAdj = GetAdjacencyMatrix( Proc) end + if not vAdj then vAdj = BL.GetAdjacencyMatrix( Proc) end local nFct = #( vAdj or {}) local vFacesWithGivenAdj = {} for i = 1, nFct do @@ -188,7 +166,7 @@ function FeatureTopology.Classify( Proc, b3Raw) Proc.Face = BL.GetFacetsInfo( Proc, b3Raw) end - local vAdj = GetAdjacencyMatrix( Proc) + local vAdj = Proc.AdjacencyMatrix or BL.GetAdjacencyMatrix( Proc) local bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( vAdj) local vTriangularFaces = GetTriangularFaces( Proc) local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index c9b6c76..0027678 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -4629,7 +4629,8 @@ SawPlusChain.ApplyOnlySawblade = false function SawPlusChain.IsTopologyOk( Proc) if Proc.TopologyLongName == 'Pocket-Blind-RightAngles-Parallel-5' or Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' or - Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' then + Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or + Proc.TopologyLongName == 'Tunnel-Through-RightAngles-Parallel-4' then return true else @@ -4638,7 +4639,59 @@ function SawPlusChain.IsTopologyOk( Proc) end +function SawPlusChain.GetTunnelFaces( Proc) + local TunnelAddedFaces = {} + + -- TODO scrivere il box della parte nella Proc o fare funzione per recuperarlo + local b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Proc.PartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + + if not ( Proc.IsThrough and Proc.AllRightAngles and Proc.Fct < 5) then + error( 'GetTunnelFaces : Topology not implemented') + end + + -- direzione del tunnel + local vtTunnelDirection = Proc.Face[1].VtN ^ Proc.Face[ Proc.Face[1].Adjacencies[1] + 1].VtN + + -- centro del tunnel + local frTunnel = Frame3d( Proc.Face[1].PtCenter, vtTunnelDirection) + local b3Tunnel = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frTunnel) + local ptTunnelCenter = b3Tunnel:getCenter() + ptTunnelCenter:toGlob( frTunnel) + + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( Proc.PartId) + if not nAddGrpId then + EgtOutLog( 'Error : missing AddGroup') + return TunnelAddedFaces + end + + -- faccia centrale, si crea larga come la parte e poi si trimma + TunnelAddedFaces.MiddleFaceTm = {} + TunnelAddedFaces.MiddleFaceTm.Id = EgtSurfTmPlaneInBBox( nAddGrpId, ptTunnelCenter, vtTunnelDirection, b3Part, GDB_ID.ROOT) + -- TODO se non si riesce a costruire la faccia bisogna dare errore o semplicemente non ritornarla?? + for i = 1, Proc.Fct do + EgtCutSurfTmPlane( TunnelAddedFaces.MiddleFaceTm.Id, Proc.Face[i].PtCenter, -Proc.Face[i].VtN, false, GDB_ID.ROOT) + end + + local _, dFaceWidth, dFaceHeight = BL.GetFaceHvRefDim( TunnelAddedFaces.MiddleFaceTm.Id, 0) + -- larghezza OCS faccia + TunnelAddedFaces.MiddleFaceTm.Width = dFaceWidth + -- altezza OCS faccia + TunnelAddedFaces.MiddleFaceTm.Height = dFaceHeight + if TunnelAddedFaces.MiddleFaceTm.Height > TunnelAddedFaces.MiddleFaceTm.Width then + TunnelAddedFaces.MiddleFaceTm.Height, TunnelAddedFaces.MiddleFaceTm.Width = TunnelAddedFaces.MiddleFaceTm.Width, TunnelAddedFaces.MiddleFaceTm.Height + end + + return TunnelAddedFaces +end + + function SawPlusChain.GetBottomFace( Proc) + local BottomFace = {} + if Proc.Topology == 'Tunnel' then + return nil + end + -- la faccia di fondo ha sempre Fct - 1 adiacenze. Se si trovano più facce di fondo si sceglie quella con minor elevazione local vBottomFace = Topology.GetFacesWithGivenAdjacencyNumber( Proc, Proc.vAdj, Proc.Fct - 1) local nBottomFace @@ -4658,7 +4711,6 @@ function SawPlusChain.GetBottomFace( Proc) nBottomFace = vBottomFace[1] end - local BottomFace = {} BottomFace.Id = nBottomFace BottomFace.Width = Proc.Face[nBottomFace + 1].Width BottomFace.Height = Proc.Face[nBottomFace + 1].Height @@ -4677,13 +4729,25 @@ function SawPlusChain.GetLongFace( Proc) Proc.MainFaces.BottomFace = SawPlusChain.GetBottomFace( Proc) end - -- facce adiacenti a quella di fondo, ordinate - local FacesAdjacentToBottom = BL.GetAdjacentFaces( Proc, Proc.MainFaces.BottomFace.Id) - table.sort( FacesAdjacentToBottom, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end) + local FacesToAnalyze = {} + -- tutte le facce, ordinate per dimensione + if Proc.Topology == 'Tunnel' then + for i = 1, Proc.Fct do + FacesToAnalyze[i] = {} + FacesToAnalyze[i].Id = Proc.Face[i].Id + FacesToAnalyze[i].Area = Proc.Face[i].Area + FacesToAnalyze[i].LengthOnMainFace = Proc.Face[i].LengthOnMainFace + end + table.sort( FacesToAnalyze, function( a, b) return a.Area > b.Area end) + -- facce adiacenti a quella di fondo, ordinate per lunghezza sul lato di fondo + else + FacesToAnalyze = BL.GetAdjacentFaces( Proc, Proc.MainFaces.BottomFace.Id) + table.sort( FacesToAnalyze, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end) + end - -- si sceglie la faccia adiacente sul lato più lungo + -- si sceglie la più grande (tunnel) o quella adiacente sul lato lungo local LongFace = {} - LongFace.Id = FacesAdjacentToBottom[1].Id + LongFace.Id = FacesToAnalyze[1].Id for i = 1, Proc.Fct do if LongFace.Id == Proc.Face[i].Id then LongFace.Width = Proc.Face[i].Width @@ -4710,24 +4774,35 @@ function SawPlusChain.GetSideFaces( Proc) Proc.MainFaces.LongFace = SawPlusChain.GetLongFace( Proc) end - -- facce adiacenti a quella di fondo, ordinate - local FacesAdjacentToBottom = BL.GetAdjacentFaces( Proc, Proc.MainFaces.BottomFace.Id) - table.sort( FacesAdjacentToBottom, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end) - + local FacesToAnalyze = {} + -- tutte le facce, ordinate per dimensione + if Proc.Topology == 'Tunnel' then + for i = 1, Proc.Fct do + FacesToAnalyze[i] = {} + FacesToAnalyze[i].Id = Proc.Face[i].Id + FacesToAnalyze[i].Area = Proc.Face[i].Area + FacesToAnalyze[i].LengthOnMainFace = Proc.Face[i].LengthOnMainFace + end + table.sort( FacesToAnalyze, function( a, b) return a.Area > b.Area end) + -- facce adiacenti a quella di fondo, ordinate per lunghezza sul lato di fondo + else + FacesToAnalyze = BL.GetAdjacentFaces( Proc, Proc.MainFaces.BottomFace.Id) + table.sort( FacesToAnalyze, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end) + end -- si determina il criterio di scelta delle facce laterali local FacesAdjacentToLongFace = BL.GetAdjacentFaces( Proc, Proc.MainFaces.LongFace.Id) local bIsLongFaceTheLargest = not ( Proc.Fct == 4 and #FacesAdjacentToLongFace == 3) local SideFaces = {} - for i = 1, #FacesAdjacentToBottom do - if ( not bIsLongFaceTheLargest and i < #FacesAdjacentToBottom) or + for i = 1, #FacesToAnalyze do + if ( not bIsLongFaceTheLargest and i < #FacesToAnalyze) or ( bIsLongFaceTheLargest and i > 2) then - table.insert( SideFaces, FacesAdjacentToBottom[i]) - SideFaces[#SideFaces].Id = FacesAdjacentToBottom[i].Id - SideFaces[#SideFaces].Width = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Width - SideFaces[#SideFaces].Height = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Height - SideFaces[#SideFaces].Elevation = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Elevation - SideFaces[#SideFaces].VtN = Proc.Face[FacesAdjacentToBottom[i].Id + 1].VtN + table.insert( SideFaces, FacesToAnalyze[i]) + SideFaces[#SideFaces].Id = FacesToAnalyze[i].Id + SideFaces[#SideFaces].Width = Proc.Face[FacesToAnalyze[i].Id + 1].Width + SideFaces[#SideFaces].Height = Proc.Face[FacesToAnalyze[i].Id + 1].Height + SideFaces[#SideFaces].Elevation = Proc.Face[FacesToAnalyze[i].Id + 1].Elevation + SideFaces[#SideFaces].VtN = Proc.Face[FacesToAnalyze[i].Id + 1].VtN if SideFaces[#SideFaces].Height > SideFaces[#SideFaces].Width then SideFaces[#SideFaces].Height, SideFaces[#SideFaces].Width = SideFaces[ #SideFaces].Width, SideFaces[ #SideFaces].Height end @@ -4764,14 +4839,22 @@ function SawPlusChain.GetLongFaceEdges( Proc, Face) 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 + if Proc.Topology == 'Tunnel' then + if CurrentEdge.AdjacentFaceId > -1 then + table.insert( Edges.SideEdges, CurrentEdge) + else + table.insert( Edges.OppositeEdges, CurrentEdge) + end else - table.insert( Edges.OppositeEdges, CurrentEdge) + 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 end else @@ -4814,37 +4897,6 @@ function SawPlusChain.GetToolFromMachining( sMachiningName) end -function SawPlusChain.IsStartOrEndClosed( Proc, Machining) - local bIsStartClosed = false - local bIsEndClosed = false - local bIsMortising = ( Machining.Type == MCH_OY.MORTISING) - if #( Proc.MainFaces.SideFaces) == 2 then - bIsStartClosed = true - bIsEndClosed = true - elseif #( Proc.MainFaces.SideFaces) == 1 then - local CCWDirection = ( Machining.FaceToMachine.VtN ^ Proc.MainFaces.BottomFace.VtN) - if Machining.ToolInvert or bIsMortising then - CCWDirection = - CCWDirection - end - if CCWDirection * Proc.MainFaces.SideFaces[1].VtN > 10 * GEO.EPS_SMALL then - if Machining.Tool.IsCCW then - bIsStartClosed = true - else - bIsEndClosed = true - end - else - if Machining.Tool.IsCCW then - bIsEndClosed = true - else - bIsStartClosed = true - end - end - end - - return bIsStartClosed, bIsEndClosed -end - - function SawPlusChain.CalculateLeadInOut( Machining, EdgeToMachine) -- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom) @@ -5025,6 +5077,13 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg Cutting.Message = '' Cutting.ProcId = Proc.Id + local dPocketHeight = 0 + if Proc.Topology == 'Tunnel' then + dPocketHeight = Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.Height + else + dPocketHeight = Proc.MainFaces.BottomFace.Height + end + -- ricerca lavorazione Cutting.Name = ML.FindCutting( 'HeadSide', true, false) if not Cutting.Name then @@ -5038,7 +5097,7 @@ 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 > Proc.MainFaces.BottomFace.Height + 10 * GEO.EPS_SMALL then + if Cutting.Tool.Thickness > dPocketHeight + 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) @@ -5098,11 +5157,11 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg end end -- step verticale e offset longitudinale - Cutting.Steps = BL.GetMachiningSteps( Proc.MainFaces.BottomFace.Height, Cutting.Tool.Thickness) + Cutting.Steps = BL.GetMachiningSteps( dPocketHeight, 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 - Cutting.LongitudinalOffset = - Proc.MainFaces.BottomFace.Height + Cutting.LongitudinalOffset = - dPocketHeight else Cutting.LongitudinalOffset = 0 end @@ -5183,10 +5242,16 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine Mortising.CanApply = true Mortising.Message = '' Mortising.ProcId = Proc.Id + + local dPocketHeight = 0 + if Proc.Topology == 'Tunnel' then + dPocketHeight = Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.Height + else + dPocketHeight = Proc.MainFaces.BottomFace.Height + end -- ricerca lavorazione - -- TODO gestire elevazione negativa (determina come devo lavorare) - Mortising.Name = ML.FindSawing( 'Sawing', EdgeToMachine.Elevation) + Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation)) if not Mortising.Name then Mortising.Name = ML.FindSawing( 'Sawing', nil, nil, 'Longest') end @@ -5201,7 +5266,7 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine -- verifica dimensioni tasca compatibili -- se tasca meno spessa della sega a catena la strategia non è applicabile - if Mortising.Tool.Thickness > Proc.MainFaces.BottomFace.Height + 10 * GEO.EPS_SMALL then + if Mortising.Tool.Thickness > dPocketHeight + 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) @@ -5229,14 +5294,25 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine Mortising.Workside = MCH_MILL_WS.LEFT Mortising.Invert = true end + if EdgeToMachine.Elevation < -10 * GEO.EPS_SMALL then + Mortising.Invert = not Mortising.Invert + end Mortising.ToolInvert = false -- profondità e offset longitudinale - if Mortising.Tool.MaxMat > EdgeToMachine.Elevation - 10 * GEO.EPS_SMALL then - Mortising.Depth = EdgeToMachine.Elevation - Mortising.LongitudinalOffset = 0 + if Mortising.Tool.MaxMat > abs( EdgeToMachine.Elevation) - 10 * GEO.EPS_SMALL then + Mortising.Depth = abs( EdgeToMachine.Elevation) + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + Mortising.LongitudinalOffset = 0 + else + Mortising.LongitudinalOffset = EdgeToMachine.Elevation + end else Mortising.Depth = Mortising.Tool.MaxMat - Mortising.LongitudinalOffset = EdgeToMachine.Elevation - Mortising.Depth + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + Mortising.LongitudinalOffset = EdgeToMachine.Elevation - Mortising.Depth + else + Mortising.LongitudinalOffset = -Mortising.Depth + end Mortising.Message = 'Feature '.. Proc.FeatureId .. ' : chainsaw elevation (' .. EgtNumToString( EdgeToMachine.Elevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Mortising.Depth, 1) .. ')' EgtOutLog( Mortising.Message) end @@ -5247,7 +5323,11 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine -- overlap Mortising.Overlap = 0 -- faceuse - Mortising.Faceuse = BL.GetNearestParalOpposite( EdgeToMachine.ToolDirection) + if EdgeToMachine.Elevation > - 10 * GEO.EPS_SMALL then + Mortising.Faceuse = BL.GetNearestParalOpposite( EdgeToMachine.ToolDirection) + else + Mortising.Faceuse = BL.GetNearestParalOpposite( -EdgeToMachine.ToolDirection) + end -- SCC Mortising.SCC = MCH_SCC.NONE -- asse bloccato e angoli suggeriti @@ -5261,7 +5341,7 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine -- approccio e retrazione Mortising.LeadIn, Mortising.LeadOut = SawPlusChain.CalculateLeadInOut( Mortising, EdgeToMachine) -- eventuale step verticale - Mortising.VerticalSteps = BL.GetMachiningSteps( Proc.MainFaces.BottomFace.Height, Mortising.Tool.Thickness) + Mortising.VerticalSteps = BL.GetMachiningSteps( dPocketHeight, Mortising.Tool.Thickness) -- geometria Mortising.Geometry = {{Proc.Id, FaceToMachine.Id}} -- nome operazione @@ -5313,9 +5393,17 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) Proc.MainFaces.BottomFace = SawPlusChain.GetBottomFace( Proc) Proc.MainFaces.LongFace = SawPlusChain.GetLongFace( Proc) Proc.MainFaces.SideFaces = SawPlusChain.GetSideFaces( Proc) + if Proc.Topology == 'Tunnel' then + Proc.MainFaces.TunnelAddedFaces = SawPlusChain.GetTunnelFaces( Proc) + end - -- lavorazione di lama - fondo della tasca - local Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) + -- lavorazione di lama - fondo della tasca o fino a massimo materiale se tunnel + local Cutting = {} + if Proc.Topology == 'Tunnel' then + Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[1]) + else + Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) + end local bIsCuttingOk = false if Cutting.CanApply then bIsCuttingOk, Cutting.Message = SawPlusChain.Saw.ApplyAllSteps( Cutting, b3Raw) @@ -5325,33 +5413,45 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) end local dBottomDepthToMachine = Cutting.RadialOffset - -- 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) + if not( Proc.Topology == 'Tunnel') then + -- 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 - if not bIsCuttingOk then - return bIsCuttingOk, Cutting.Message + -- 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 - -- 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 + -- lato opposto del tunnel + else + Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) + bIsCuttingOk = false + if Cutting.CanApply then + bIsCuttingOk, Cutting.Message = SawPlusChain.Saw.ApplyAllSteps( Cutting, b3Raw) + end + if not bIsCuttingOk then + return bIsCuttingOk, Cutting.Message end - -- la lama è arrivata sul fondo e tasca passante, non servono ulteriori lavorazioni - elseif #( Proc.MainFaces.SideFaces) == 0 then - SawPlusChain.ApplyOnlySawblade = true end if SawPlusChain.ApplyOnlySawblade then From 33be9ccaf01c107075363dff871f14d96c2d3f8f Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 14 May 2024 12:43:29 +0200 Subject: [PATCH 09/11] in SawPlusChain: - implementato tunnel con lama e con sega a catena - modificata calcolo parametri mortising per gestire lati con elevazione negativa --- LuaLibs/ProcessLapJoint.lua | 146 +++++++++++++++++++++++++++--------- 1 file changed, 109 insertions(+), 37 deletions(-) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 0027678..aeedf0e 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -5242,6 +5242,8 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine Mortising.CanApply = true Mortising.Message = '' Mortising.ProcId = Proc.Id + local dTestCornerRadius = 43 + local sMortisingType local dPocketHeight = 0 if Proc.Topology == 'Tunnel' then @@ -5251,9 +5253,22 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine end -- ricerca lavorazione - Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation)) + if Proc.Topology == 'Tunnel' then + Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation) + dTestCornerRadius + BD.CUT_EXTRA_MIN) + sMortisingType = "OneSideAndExtend" + if not Mortising.Name then + Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation) / 2 + dTestCornerRadius + BD.CUT_EXTRA_MIN) + sMortisingType = "BothSidesAndExtend" + end + else + Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation)) + sMortisingType = "OneSide" + end if not Mortising.Name then Mortising.Name = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + if Proc.Topology == 'Tunnel' then + sMortisingType = "BothSides" + end end if not Mortising.Name then Mortising.Message = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. SawPlusChain.Name .. ' not applicable - chainsaw not found' @@ -5287,31 +5302,36 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine Mortising.IsStartClosed = not EdgeToMachine.IsStartOpen Mortising.IsEndClosed = not EdgeToMachine.IsEndOpen -- lato di lavoro e inversioni - if Mortising.Tool.IsCCW then + Mortising.Invert = false + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then Mortising.Workside = MCH_MILL_WS.RIGHT - Mortising.Invert = false + Mortising.ToolInvert = false else Mortising.Workside = MCH_MILL_WS.LEFT - Mortising.Invert = true + Mortising.ToolInvert = true end - if EdgeToMachine.Elevation < -10 * GEO.EPS_SMALL then - Mortising.Invert = not Mortising.Invert - end - Mortising.ToolInvert = false -- profondità e offset longitudinale - if Mortising.Tool.MaxMat > abs( EdgeToMachine.Elevation) - 10 * GEO.EPS_SMALL then + if sMortisingType == "OneSide" then Mortising.Depth = abs( EdgeToMachine.Elevation) + elseif sMortisingType == 'OneSideAndExtend' then + Mortising.Depth = abs( EdgeToMachine.Elevation) + Mortising.Tool.CornerRadius + BD.CUT_EXTRA_MIN + elseif sMortisingType == 'BothSides' then + Mortising.Depth = abs( EdgeToMachine.Elevation) / 2 + elseif sMortisingType == 'BothSidesAndExtend' then + Mortising.Depth = abs( EdgeToMachine.Elevation) / 2 + Mortising.Tool.CornerRadius + BD.CUT_EXTRA_MIN + end + if Mortising.Tool.MaxMat > Mortising.Depth - 10 * GEO.EPS_SMALL then if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then Mortising.LongitudinalOffset = 0 else - Mortising.LongitudinalOffset = EdgeToMachine.Elevation + Mortising.LongitudinalOffset = abs( EdgeToMachine.Elevation) - Mortising.Depth end else Mortising.Depth = Mortising.Tool.MaxMat if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then Mortising.LongitudinalOffset = EdgeToMachine.Elevation - Mortising.Depth else - Mortising.LongitudinalOffset = -Mortising.Depth + Mortising.LongitudinalOffset = 0 end Mortising.Message = 'Feature '.. Proc.FeatureId .. ' : chainsaw elevation (' .. EgtNumToString( EdgeToMachine.Elevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Mortising.Depth, 1) .. ')' EgtOutLog( Mortising.Message) @@ -5363,6 +5383,25 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine end +function SawPlusChain.Chainsaw.ApplyAllSteps( Mortising, b3Raw) + local bIsMortisingOk = false + local sMortisingApplyMessage = '' + + local dOriginalRadialOffsetMortising = Mortising.RadialOffset + for i = Mortising.VerticalSteps.Count, 1, -1 do + Mortising.RadialOffset = dOriginalRadialOffsetMortising + Mortising.VerticalSteps.StepLength * ( i - 1) + -- applicazione lavorazione + bIsMortisingOk, sMortisingApplyMessage = SawPlusChain.ApplyMachining( Mortising, b3Raw) + -- update messaggi + if sMortisingApplyMessage and #sMortisingApplyMessage > 0 then + Mortising.Message = Mortising.Message .. '\n' .. 'Apply : ' .. sMortisingApplyMessage + end + end + + return bIsMortisingOk, sMortisingApplyMessage +end + + function SawPlusChain.Make( bOnlySaw, Proc, nRawId) SawPlusChain.ApplyOnlySawblade = bOnlySaw local b3Raw = EgtGetRawPartBBox( nRawId) @@ -5397,6 +5436,7 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) Proc.MainFaces.TunnelAddedFaces = SawPlusChain.GetTunnelFaces( Proc) end + -- lama -- lavorazione di lama - fondo della tasca o fino a massimo materiale se tunnel local Cutting = {} if Proc.Topology == 'Tunnel' then @@ -5413,7 +5453,17 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) end local dBottomDepthToMachine = Cutting.RadialOffset - if not( Proc.Topology == 'Tunnel') then + -- lato opposto del tunnel + if Proc.Topology == 'Tunnel' then + Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) + bIsCuttingOk = false + if Cutting.CanApply then + bIsCuttingOk, Cutting.Message = SawPlusChain.Saw.ApplyAllSteps( Cutting, b3Raw) + end + if not bIsCuttingOk then + return bIsCuttingOk, Cutting.Message + end + else -- 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 @@ -5442,39 +5492,61 @@ function SawPlusChain.Make( bOnlySaw, Proc, nRawId) elseif #( Proc.MainFaces.SideFaces) == 0 then SawPlusChain.ApplyOnlySawblade = true end - -- lato opposto del tunnel - else - Cutting = SawPlusChain.Saw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) - 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 if SawPlusChain.ApplyOnlySawblade then return bIsCuttingOk, Cutting.Message end - -- parametri lavorazione con sega a catena - local Mortising = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) - -- si lavora solo quanto non lavorato dalla lama - Mortising.MaxElev = dBottomDepthToMachine + BD.CUT_EXTRA - - -- applicazione lavorazione con sega a catena con eventuali step in Z + -- sega a catena + -- parametri lavorazione con sega a catena - fondo della tasca o tunnel + local Mortising = {} + if Proc.Topology == 'Tunnel' then + Mortising = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[1]) + else + Mortising = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) + -- si lavora solo quanto non lavorato dalla lama + Mortising.MaxElev = dBottomDepthToMachine + BD.CUT_EXTRA + end 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 - bIsMortisingOk, sMortisingApplyMessage = SawPlusChain.ApplyMachining( Mortising, b3Raw) - -- update messaggi - if sMortisingApplyMessage and #sMortisingApplyMessage > 0 then - Mortising.Message = Mortising.Message .. '\n' .. 'Apply : ' .. sMortisingApplyMessage + bIsMortisingOk, Mortising.Message = SawPlusChain.Chainsaw.ApplyAllSteps( Mortising, b3Raw) + end + + -- lato opposto del tunnel + if Proc.Topology == 'Tunnel' then + Mortising = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) + bIsMortisingOk = false + if Mortising.CanApply then + bIsMortisingOk, Mortising.Message = SawPlusChain.Chainsaw.ApplyAllSteps( Mortising, b3Raw) + end + if not bIsMortisingOk then + return bIsMortisingOk, Mortising.Message + end + else + -- se la sega a catena non è arrivata sul fondo e c'è almeno un lato aperto va lavorato + if Mortising.LongitudinalOffset > 10 * GEO.EPS_SMALL then + -- eventuale lavorazione di sega a catena - lato della tasca da cui inizia la lavorazione + if Proc.MainFaces.LongFace.Edges.BottomEdge.IsStartOpen then + Mortising = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.StartEdge) + bIsMortisingOk = false + if Mortising.CanApply then + bIsMortisingOk, Mortising.Message = SawPlusChain.Chainsaw.ApplyAllSteps( Mortising, b3Raw) + end + if not bIsMortisingOk then + return bIsMortisingOk, Mortising.Message + end + end + -- eventuale lavorazione di sega a catena - lato della tasca in cui finisce la lavorazione + if Proc.MainFaces.LongFace.Edges.BottomEdge.IsEndOpen then + Mortising = SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.EndEdge) + bIsMortisingOk = false + if Mortising.CanApply then + bIsMortisingOk, Mortising.Message = SawPlusChain.Chainsaw.ApplyAllSteps( Mortising, b3Raw) + end + if not bIsMortisingOk then + return bIsMortisingOk, Mortising.Message + end end end end From 648fa1d9bfc935e52105711b45d0fdeec57144f9 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 14 May 2024 13:07:37 +0200 Subject: [PATCH 10/11] - in SawPlusChain si arriva al massimo materiale - 1 --- LuaLibs/ProcessLapJoint.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index aeedf0e..cb3faf8 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -5145,7 +5145,7 @@ function SawPlusChain.Saw.CalculateMachiningParameters( Proc, FaceToMachine, Edg Cutting.RadialOffset = EdgeToMachine.Elevation end else - Cutting.Depth = Cutting.Tool.MaxDepth + Cutting.Depth = Cutting.Tool.MaxDepth - 1 if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then Cutting.RadialOffset = EdgeToMachine.Elevation - Cutting.Depth else @@ -5327,7 +5327,7 @@ function SawPlusChain.Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine Mortising.LongitudinalOffset = abs( EdgeToMachine.Elevation) - Mortising.Depth end else - Mortising.Depth = Mortising.Tool.MaxMat + Mortising.Depth = Mortising.Tool.MaxMat - 1 if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then Mortising.LongitudinalOffset = EdgeToMachine.Elevation - Mortising.Depth else From a89ad10f0b9fecf99390f4740bf3063192543837 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 14 May 2024 13:14:23 +0200 Subject: [PATCH 11/11] update log versione --- UpdateLog.txt | 10 +++++++--- Version.lua | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/UpdateLog.txt b/UpdateLog.txt index 74354e2..b488a6d 100644 --- a/UpdateLog.txt +++ b/UpdateLog.txt @@ -1,9 +1,13 @@ ==== Beam Update Log ==== +Versione 2.6e3 (14/05/2024) +- Modif : in SawPlusChain aggiunta gestione lavorazioni aggiuntive lati aperti e tunnel +- Fixed : in Cut -> MakeFromTop ricalcolo direzione di lavorazione su facce a cubetti. + Versione 2.6e2 (10/05/2024) -- Fixed : correzioni a FeatureTopology -- Modif : in LongCut allungamento percorso ingresso per evitare collisioni durante approccio pezzo quando si setta OutRaw -- Modif : in LongCut se non trova fresa per pulizia dà messaggio di warning anziché di errore +- Modif : in FeatureTopology aggiunta proprietà IsTrough = true anche a Cut +- Modif : LongCut : se non trova fresa per pulizia, da messaggio di warning anziché di errore +- Fixed : LongCut : allungamento percorso ingresso per evitare collisioni durante approccio pezzo quando si setta OutRaw. Versione 2.6e1 (03/05/2024) - Modif : in LapJoint Groove verso il basso lavorata di preferenza dal lato diff --git a/Version.lua b/Version.lua index 60b085b..3dd5ccb 100644 --- a/Version.lua +++ b/Version.lua @@ -2,5 +2,5 @@ -- Gestione della versione di Beam NAME = 'Beam' -VERSION = '2.6e2' -MIN_EXE = '2.6a1' +VERSION = '2.6e3' +MIN_EXE = '2.6e2'