diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index 18bf947..11b4926 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -138,6 +138,8 @@ function FaceData.GetEdgesInfo( ProcOrId, idFace ) CurrentEdge.bIsEndOpen = EdgesEgt[nNextEdgeIndex].Open CurrentEdge.ptStart = Point3d( EdgesEgt[i].Start) CurrentEdge.ptEnd = Point3d( EdgesEgt[nNextEdgeIndex].Start) + CurrentEdge.vtEdge = CurrentEdge.ptEnd - CurrentEdge.ptStart + CurrentEdge.vtEdge:normalize() CurrentEdge.sType = 'Standard' CurrentEdge.id = i - 1 @@ -419,6 +421,7 @@ local function GetBottomFaces( Proc) CurrentEdge.bIsEndOpen = BottomFaces[1].Edges[i].bIsEndOpen CurrentEdge.ptStart = BottomFaces[1].Edges[i].ptStart CurrentEdge.ptEnd = BottomFaces[1].Edges[i].ptEnd + CurrentEdge.vtEdge = BottomFaces[1].Edges[i].vtEdge if nFirstLongEdgeIndex then if i == nFirstLongEdgeIndex then @@ -516,6 +519,7 @@ local function GetLongFaces( Proc, MainFaces) CurrentEdge.bIsEndOpen = LongFaces[i].Edges[j].bIsEndOpen CurrentEdge.ptStart = LongFaces[i].Edges[j].ptStart CurrentEdge.ptEnd = LongFaces[i].Edges[j].ptEnd + CurrentEdge.vtEdge = LongFaces[i].Edges[j].vtEdge if Proc.Topology.sFamily == 'Tunnel' then if CurrentEdge.idAdjacentFace > -1 then @@ -614,6 +618,7 @@ local function GetSideFaces( Proc, MainFaces) CurrentEdge.bIsEndOpen = SideFaces[i].Edges[j].bIsEndOpen CurrentEdge.ptStart = SideFaces[i].Edges[j].ptStart CurrentEdge.ptEnd = SideFaces[i].Edges[j].ptEnd + CurrentEdge.vtEdge = SideFaces[i].Edges[j].vtEdge if Proc.Topology.sFamily == 'Tunnel' then if CurrentEdge.idAdjacentFace > -1 then diff --git a/LuaLibs/LeadInOutLib.lua b/LuaLibs/LeadInOutLib.lua index 7e4c810..c421d63 100644 --- a/LuaLibs/LeadInOutLib.lua +++ b/LuaLibs/LeadInOutLib.lua @@ -45,10 +45,46 @@ function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters) LeadIn.dCompLength = 0 LeadOut.dCompLength = 0 - -- TODO qui calcolo con EgtLineBoxInters if sLeadInOutType == 'Perpendicular' then - LeadIn.dPerpDistance = dDepthToMachine + BeamData.CUT_SIC - LeadOut.dPerpDistance = dDepthToMachine + BeamData.CUT_SIC + -- informazioni lati adiacenti + local nCurrentEdgeIndex = Edge.id + 1 + local nPreviousEdgeIndex = ( nCurrentEdgeIndex == 1 and #Face.Edges) or nCurrentEdgeIndex - 1 + local nNextEdgeIndex = ( nCurrentEdgeIndex == #Face.Edges and 1) or nCurrentEdgeIndex + 1 + local EdgeNext = Face.Edges[nNextEdgeIndex] + local EdgePrevious = Face.Edges[nPreviousEdgeIndex] + + -- frame solidale al lato di lavoro (X lungo il lato, Y normale al lato) + local frEdge = Frame3d( Edge.ptStart, Face.vtN, Edge.vtEdge) + + -- direzione lati adiacenti nel frame solidale al lato di lavoro + local vtEdgeNextLoc = Vector3d( EdgeNext.vtEdge) + vtEdgeNextLoc:toLoc( frEdge) + local vtEdgePreviousInvLoc = Vector3d( -EdgePrevious.vtEdge) + vtEdgePreviousInvLoc:toLoc( frEdge) + + -- profondità di lavoro proiettata sui lati adiacenti + local dDepthToMachinePrevious = dDepthToMachine / abs( vtEdgePreviousInvLoc:getY()) + local dDepthToMachineNext = dDepthToMachine / abs( vtEdgeNextLoc:getY()) + + -- punti di inizio e fine lavorazione alla profondità di lavoro reale + local ptStartAtDepth = Edge.ptStart + ( -EdgePrevious.vtEdge) * ( EdgePrevious.dLength - dDepthToMachinePrevious) + local ptEndAtDepth = Edge.ptEnd + EdgeNext.vtEdge * ( EdgeNext.dLength - dDepthToMachineNext) + + -- distanza dai punti di inizio e fine lavorazione reali al pezzo, nelle direzioni dei lati adiacenti + -- TODO bisogna controllare bOk??? + local b3BoxPartExpanded = BBox3d( Part.b3Part) + b3BoxPartExpanded:expand( BeamData.CUT_SIC) + local bOkStart, IntersectionTypeStart, PartDistanceStart = EgtLineBoxInters( ptStartAtDepth, -EdgePrevious.vtEdge, b3BoxPartExpanded) + local bOkEnd, IntersectionTypeEnd, PartDistanceEnd = EgtLineBoxInters( ptEndAtDepth, EdgeNext.vtEdge, b3BoxPartExpanded) + local dDistanceToPartStart = #IntersectionTypeStart > 0 and PartDistanceStart[#PartDistanceStart] or ( dDepthToMachinePrevious + BeamData.COLL_SIC) + local dDistanceToPartEnd = #IntersectionTypeEnd > 0 and PartDistanceEnd[#PartDistanceEnd] or ( dDepthToMachineNext + BeamData.COLL_SIC) + + -- componenti dell'attacco con aggiunta la sicurezza + LeadIn.dPerpDistance = max( dDistanceToPartStart * vtEdgePreviousInvLoc:getY(), dDepthToMachine) + LeadIn.dTangentDistance = max( dDistanceToPartStart, dDepthToMachinePrevious) * -abs( vtEdgePreviousInvLoc:getX()) + LeadOut.dPerpDistance = max( dDistanceToPartEnd * vtEdgeNextLoc:getY(), dDepthToMachine) + LeadOut.dTangentDistance = max( dDistanceToPartEnd, dDepthToMachine) * vtEdgeNextLoc:getX() + elseif sLeadInOutType == 'Tangent' then LeadIn.dTangentDistance = Tool.dDiameter / 2 + BeamData.CUT_SIC LeadOut.dTangentDistance = Tool.dDiameter / 2 + BeamData.CUT_SIC diff --git a/LuaLibs/PreSimulationLib.lua b/LuaLibs/PreSimulationLib.lua index b6c5544..a830646 100644 --- a/LuaLibs/PreSimulationLib.lua +++ b/LuaLibs/PreSimulationLib.lua @@ -51,12 +51,10 @@ local function GetMachiningPoints( Edge, dDepthToMachine) local ptMid = Point3d( ( ptStart + ptEnd) / 2) -- caso ottimizzato: lato parallelo ad una direzione principale - local vtEdge = Edge.ptEnd - Edge.ptStart - vtEdge:normalize() local bIsEdgeParallelToMainDirection = - AreSameOrOppositeVectorApprox( vtEdge, X_AX()) - or AreSameOrOppositeVectorApprox( vtEdge, Y_AX()) - or AreSameOrOppositeVectorApprox( vtEdge, Z_AX()) + AreSameOrOppositeVectorApprox( Edge.vtEdge, X_AX()) + or AreSameOrOppositeVectorApprox( Edge.vtEdge, Y_AX()) + or AreSameOrOppositeVectorApprox( Edge.vtEdge, Z_AX()) -- aggiunta punti -- inizio e fine solo se lato obliquo @@ -181,9 +179,7 @@ local function CheckCollisionWithAxis( sAxis, MachiningParameters, OptionalParam end -- vtC punta sempre verso il corpo dell'asse C o verso l'aggregato - local vtEdge = Edge.ptEnd - Edge.ptStart - vtEdge:normalize() - local nSCC = Tool.SetupInfo.GetSCC( Edge.vtN, vtEdge, vtNFace) + local nSCC = Tool.SetupInfo.GetSCC( Edge.vtN, Edge.vtEdge, vtNFace) local vtSCC = BeamLib.GetDirectionFromSCC( nSCC) local vtC = vtHead ^ Tool.SetupInfo.vtRotationAxisC vtC:normalize() @@ -269,12 +265,10 @@ function PreSimulationLib.CheckCollisionAxisAB( Edge, vtNFace, vtHead, Part, Too -- riferimento perpendicolare al taglio, X nel verso della normale al lato e Y verso il motore local ptMachining = Point3d( ( Edge.ptStart + Edge.ptEnd) / 2) + Edge.vtN * ( Edge.dElevation - dDepthToMachine) - local vtEdge = Edge.ptEnd - Edge.ptStart - vtEdge:normalize() -- costruzione flat region del pezzo e del grezzo restante nel piano perpendicolare al taglio - local idPartSurfFr = GetPartSurfFrInPlane( Part, vtEdge) - local idRestlengthSurfFr = GetRestlengthSurfFrInPlane( Part, vtEdge) + local idPartSurfFr = GetPartSurfFrInPlane( Part, Edge.vtEdge) + local idRestlengthSurfFr = GetRestlengthSurfFrInPlane( Part, Edge.vtEdge) -- costruzione flat region approssimata del motore nel piano perpendicolare al taglio -- punto di congiunzione tra motore e lama diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index 99ae72d..9b8b78c 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -37,12 +37,24 @@ local function GetLeadInOut( Machining, EdgeToMachine, bIsSplitFeature) end else - Machining.sLeadInOutType = Machining.LeadInOut.sChosen + -- se disponibili sia attacco perpendicolare che parallelo, si sceglie il più corto + if Machining.LeadInOut.Perpendicular and Machining.LeadInOut.Tangent then + + if Machining.LeadInOut.Perpendicular.dTotalLength > Machining.LeadInOut.Tangent.dTotalLength + 10 then + Machining.sLeadInOutType = 'Tangent' + else + Machining.sLeadInOutType = 'Perpendicular' + end + + else + + Machining.sLeadInOutType = Machining.LeadInOut.sChosen + end end -- si prendono i valori che arrivano da LeadInOut (engagement) - LeadIn = BeamLib.TableCopyDeep( Machining.LeadInOut[Machining.LeadInOut.sChosen].LeadIn) - LeadOut = BeamLib.TableCopyDeep( Machining.LeadInOut[Machining.LeadInOut.sChosen].LeadOut) + LeadIn = BeamLib.TableCopyDeep( Machining.LeadInOut[Machining.sLeadInOutType].LeadIn) + LeadOut = BeamLib.TableCopyDeep( Machining.LeadInOut[Machining.sLeadInOutType].LeadOut) -- se senso di percorrenza invertito si invertono anche gli attacchi if Machining.bInvert then @@ -66,6 +78,7 @@ local function GetLeadInOut( Machining, EdgeToMachine, bIsSplitFeature) end -- stima lunghezza reale attacchi per calcolo lunghezza lavorata + -- TODO sistemare per nuovi attacchi local dEstimatedLeadInPerpDistance = 0 local dEstimatedLeadInTangentDistance = 0 local dEstimatedLeadOutPerpDistance = 0 @@ -191,7 +204,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- lunghezze, direzioni e punti caratteristici della lavorazione e del lato lavorato Cutting.dEdgeLength = EdgeToMachine.dLength -- TODO questa deve essere ptEnd - ptStart - Cutting.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN + Cutting.vtEdgeDirection = Vector3d( EdgeToMachine.vtEdge) Cutting.vtToolDirection = EdgeToMachine.vtN Cutting.ptEdge1, Cutting.ptEdge2 = EdgeToMachine.ptStart, EdgeToMachine.ptEnd local EdgeToMachineOpposite = BeamLib.FindEdgeBestOrientedAsDirection( FaceToMachine.Edges, -EdgeToMachine.vtN) @@ -236,7 +249,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if Cutting.nToolIndex then Cutting.sBladeEngagement = ToolInfo.Engagement.sBladeEngagement Cutting.bMoveAfterSplit = ToolInfo.Engagement.bMoveAfterSplit - Cutting.LeadInOut = Engagement.LeadInOut + Cutting.LeadInOut = ToolInfo.Engagement.LeadInOut end -- se non trovato utensile, la lavorazione non è applicabile diff --git a/StrategyLibs/FACEBYCHAINSAW.lua b/StrategyLibs/FACEBYCHAINSAW.lua index 8a3d8b2..821cbd8 100644 --- a/StrategyLibs/FACEBYCHAINSAW.lua +++ b/StrategyLibs/FACEBYCHAINSAW.lua @@ -82,7 +82,7 @@ function FACEBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional else Mortising.vtToolDirection = EdgeToMachine.vtN end - Mortising.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN + Mortising.vtEdgeDirection = Vector3d( EdgeToMachine.vtEdge) Mortising.ptEdge1, Mortising.ptEdge2 = EdgeToMachine.ptStart, EdgeToMachine.ptEnd -- ricerca utensile diff --git a/StrategyLibs/FACEBYMILL.lua b/StrategyLibs/FACEBYMILL.lua index a8678a5..1a37080 100644 --- a/StrategyLibs/FACEBYMILL.lua +++ b/StrategyLibs/FACEBYMILL.lua @@ -203,7 +203,7 @@ function FACEBYMILL.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPara else Milling.vtToolDirection = EdgeToMachine.vtN end - Milling.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN + Milling.vtEdgeDirection = Vector3d( EdgeToMachine.vtEdge) Milling.ptEdge1, Milling.ptEdge2 = EdgeToMachine.ptStart, EdgeToMachine.ptEnd -- se si conosce il limite downUp (utensile forzato o downUp forzato) si decide se invertire (ToolInvert)