From 1664513c8fa4adfd57d4ef6c8578a07294047ca8 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 29 Nov 2023 16:07:18 +0100 Subject: [PATCH] =?UTF-8?q?Ottimizzate=20le=20chiamate=20al=20calcolo=20el?= =?UTF-8?q?evazione.=20Si=20evita=20di=20calcolarla=20pi=C3=B9=20volte=20i?= =?UTF-8?q?nutilmente=20perch=C3=A8=20calcolata=20inizialmente=20nel=20Col?= =?UTF-8?q?lectFeatures.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/BeamExec.lua | 12 +++++++----- LuaLibs/BeamLib.lua | 21 ++++++++++++++++++++- LuaLibs/FaceByPocket.lua | 2 +- LuaLibs/ProcessLapJoint.lua | 28 ++++++++++++++-------------- LuaLibs/ProcessLongCut.lua | 6 +++--- LuaLibs/ProcessLongDoubleCut.lua | 12 ++++++------ LuaLibs/ProcessProfCamb.lua | 2 +- LuaLibs/ProcessProfConcave.lua | 2 +- LuaLibs/ProcessProfConvex.lua | 2 +- LuaLibs/ProcessProfFront.lua | 2 +- LuaLibs/ProcessProfHead.lua | 2 +- LuaLibs/ProcessVariant.lua | 2 +- 12 files changed, 57 insertions(+), 36 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 1fa2b9e..1a6293a 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -305,11 +305,13 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH, dCurrOvmT) -- recupero l'elenco delle facce della parte interessate dalla feature Proc.AffectedFaces = BL.GetProcessAffectedFaces( Proc) -- recupero informazioni sulle facce della feature - Proc.Face = {} - for i = 1, Proc.Fct do - Proc.Face[i] = { Id = i - 1, VtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT )} - if Proc.Fct < 10 then - Proc.Face[i].Elevation = EgtSurfTmFacetElevationInBBox( Proc.Id, i - 1, b3Solid, GDB_ID.ROOT) + if not Proc.Face then + Proc.Face = {} + for i = 1, Proc.Fct do + Proc.Face[i] = { Id = i - 1, VtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT )} + if Proc.Fct < 10 then + Proc.Face[i].Elevation = EgtSurfTmFacetElevationInBBox( Proc.Id, i - 1, b3Solid, GDB_ID.ROOT) + end end end end diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index f641fe2..b129034 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -439,6 +439,25 @@ function BeamLib.GetBoxFaceNorm( b3Box, ptP, vtV) end end +--------------------------------------------------------------------- +function BeamLib.GetFaceElevation( procOrProcId, nFacet, b3Solid) + local Proc, nProcId + if type( procOrProcId) == "table" then + Proc = procOrProcId + nProcId = Proc.Id + else + nProcId = procOrProcId + end + local dElevation + if not Proc or not Proc.Face or not Proc.Face[nFacet + 1].Elevation then + dElevation = EgtSurfTmFacetElevationInBBox( nProcId, nFacet, b3Solid, GDB_ID.ROOT) + else + dElevation = Proc.Face[nFacet + 1].Elevation + end + + return dElevation +end + --------------------------------------------------------------------- function BeamLib.GetFaceElevationFromPointDir( nSurfId, nPartId, ptC, vtN, nIdGeomMaster) if not ptC or not vtN then return 0 end @@ -595,7 +614,7 @@ function BeamLib.GetFaceWithMostAdj( Proc, nPartId, bCompare3Fc, dCosSideAng) local dMinElev, dMinElev2 = GEO.INFINITO, GEO.INFINITO local dtElev = {} for i = 1, #nFacInd do - local dElev = EgtSurfTmFacetElevationInBBox( nSurfId, nFacInd[i], b3Solid, GDB_ID.ROOT) + local dElev = BeamLib.GetFaceElevation( Proc, nFacInd[i], b3Solid) table.insert( dtElev, dElev) if dElev < dMinElev then if dMinElev < dMinElev2 then diff --git a/LuaLibs/FaceByPocket.lua b/LuaLibs/FaceByPocket.lua index dd695d2..1503f72 100644 --- a/LuaLibs/FaceByPocket.lua +++ b/LuaLibs/FaceByPocket.lua @@ -78,7 +78,7 @@ function FaceByPocket.Make( Proc, nSurfId, nFacet, sPocketing, nPartId, b3Solid, end -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacet, GDB_ID.ROOT) - local dElev = EgtSurfTmFacetElevationInBBox( nSurfId, nFacet, b3Solid, GDB_ID.ROOT) + local dElev = BL.GetFaceElevation( nSurfId, nFacet, b3Solid) -- determino numero e valore degli step di lavorazione local nSurfStep = ceil( dElev / dMaxDepth) local dSurfStep = dElev / nSurfStep diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index d230e3c..a42c839 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1589,7 +1589,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, -- distanza di sicurezza per evitare collisioni dCollSic = BL.CalcCollisionSafety( vtN1) -- elevazione massima della faccia - dMaxElev = EgtSurfTmFacetElevationInBBox( Proc.Id, nFacInd, b3Solid, GDB_ID.ROOT) + dMaxElev = BL.GetFaceElevation( Proc, nFacInd, b3Solid) -- ciclo tutta la tabella local tPaths = {} local ptIniPath @@ -1634,7 +1634,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, -- distanza di sicurezza per evitare collisioni dCollSic = BL.CalcCollisionSafety( vtOrtho) -- calcolo elevazione dalla faccia trasversale aggiunta - local dSurfIntElev = EgtSurfTmFacetElevationInBBox( nSurfInt, 0, b3Solid, GDB_ID.ROOT) + local dSurfIntElev = BL.GetFaceElevation( nSurfInt, 0, b3Solid) if bDoubleSide then dMaxElev = dSurfIntElev else @@ -1645,13 +1645,13 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, -- se non è possibile svuotare completamente da una sola parte if dTMaxDepth <= ( dMaxElev + BD.CUT_EXTRA + dCollSic) then bDoubleSide = true - dMaxElev = EgtSurfTmFacetElevationInBBox( nSurfInt, 0, b3Solid, GDB_ID.ROOT) + dMaxElev = BL.GetFaceElevation( nSurfInt, 0, b3Solid) else - dExtraDepth = dMaxElev - EgtSurfTmFacetElevationInBBox( nSurfInt, 0, b3Solid, GDB_ID.ROOT) + dExtraDepth = dMaxElev - BL.GetFaceElevation( nSurfInt, 0, b3Solid) end -- altrimenti non è stata fatta completamente calcolo la distanza tra faccia aggiunta e profondità superficie else - dExtraDepth = dMaxElev - EgtSurfTmFacetElevationInBBox( nSurfInt, 0, b3Solid, GDB_ID.ROOT) + dExtraDepth = dMaxElev - BL.GetFaceElevation( nSurfInt, 0, b3Solid) end end -- normale alla faccia aggiunta @@ -4240,7 +4240,7 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, dCheckDepth = 0.5 * dDepth else if not nPathInt then - dCheckDepth = EgtSurfTmFacetElevationInBBox( Proc.Id, nFacInd, b3Solid, GDB_ID.ROOT) + dCheckDepth = BL.GetFaceElevation( Proc, nFacInd, b3Solid) else dCheckDepth = dDepth end @@ -4289,7 +4289,7 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, end local ptIniPath local nMaxLen = 0 - dMaxElevMaster = EgtSurfTmFacetElevationInBBox( Proc.Id, nFacInd, b3Solid, GDB_ID.ROOT) + dMaxElevMaster = BL.GetFaceElevation( Proc, nFacInd, b3Solid) -- ciclo tutta la tabella for i = 1, #tFacAdjMain do -- le 2 facce di contatto devono essere perpendicolari o non sottosquadra rispetto alla faccia di fondo @@ -4348,13 +4348,13 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, -- se non è possibile svuotare completamente da una sola parte if dMaxDepth <= ( dMaxElevMaster + BD.CUT_EXTRA + dCollSic) then bDoubleSide = true - dMaxElevMaster = EgtSurfTmFacetElevationInBBox( nSurfInt, 0, b3Solid, GDB_ID.ROOT) + dMaxElevMaster = BL.GetFaceElevation( nSurfInt, 0, b3Solid) else - dExtraDepth = dMaxElevMaster - EgtSurfTmFacetElevationInBBox( nSurfInt, 0, b3Solid, GDB_ID.ROOT) + dExtraDepth = dMaxElevMaster - BL.GetFaceElevation( nSurfInt, 0, b3Solid) end -- altrimenti non è stata fatta completamente calcolo la distanza tra faccia aggiunta e profondità superficie - else - dExtraDepth = dMaxElevMaster - EgtSurfTmFacetElevationInBBox( nSurfInt, 0, b3Solid, GDB_ID.ROOT) + else + dExtraDepth = dMaxElevMaster - BL.GetFaceElevation( nSurfInt, 0, b3Solid) end end vtN1 = Vector3d(vtOrtho) @@ -4897,7 +4897,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa return false, sErr end nFacInd = nFacAdj - dFacElev = EgtSurfTmFacetElevationInBBox( Proc.Id, nFacInd, b3Solid, GDB_ID.ROOT) + dFacElev = BL.GetFaceElevation( Proc, nFacInd, b3Solid) ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) end @@ -5159,7 +5159,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa local tvtNx = {} tvtNx[2] = vtN local ptPs = ptC - dFacElev = EgtSurfTmFacetElevationInBBox( Proc.Id, nFacInd, b3Solid, GDB_ID.ROOT) + dFacElev = BL.GetFaceElevation( Proc, nFacInd, b3Solid) dCollSic = BL.CalcCollisionSafety( tvtNx[2]) local dMachDepth = dFacElev + dCollSic local frFacRec, dFacDim1, dFacDim2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) @@ -5181,7 +5181,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa end vAdj[i] = nCount if vAdj[i] == Proc.Fct - 1 and i ~= nFacInd + 1 then - dV = EgtSurfTmFacetElevationInBBox( Proc.Id, i - 1, b3Solid, GDB_ID.ROOT) + dV = BL.GetFaceElevation( Proc, i - 1, b3Solid) vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT) end end diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index 4b66796..da98970 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -959,7 +959,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus if bForceUseBladeOnNotThruFace and ( bLimXmin or bLimXmax) then local nCountMilHead = 0 -- determino la massima elevazione - local dElev = EgtSurfTmFacetElevationInBBox( Proc.Id, 0, b3Solid, GDB_ID.ROOT) + local dElev = BL.GetFaceElevation( Proc, 0, b3Solid) -- recupero la lavorazione local sMilling = ML.FindMilling( 'Long2Cut_H2', dElev, nil, nil, nil, not bCanUseUnderBlade, bCanUseUnderBlade) if not sMilling then @@ -1209,7 +1209,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus -- se non è sotto e non uso fresa di fianco: lavorazione Long2Cut elseif ( nSide ~= - 1 or BD.DOWN_HEAD) and nUseMillOnSide == 0 then -- determino la massima elevazione - local dElev = EgtSurfTmFacetElevationInBBox( Proc.Id, 0, b3Solid, GDB_ID.ROOT) + local dElev = BL.GetFaceElevation( Proc, 0, b3Solid) -- recupero la lavorazione local bDownHead = ( nSide == - 1) sMchType = EgtIf( bDownHead, 'Long2Cut_H2', 'Long2Cut') @@ -1553,7 +1553,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus local dDistToEnd = dToolDiam / 2 local dDistToEndDn = dToolDiamDn / 2 -- calcolo l'elevazione della faccia principale - local dFacElev = EgtSurfTmFacetElevationInBBox( Proc.Id, 0, b3Solid, GDB_ID.ROOT) + local dFacElev = BL.GetFaceElevation( Proc, 0, b3Solid) -- se fresa di fianco o da sotto calcolo quanto l'utensile può andare vicino all'estremo con l'elevazione della faccia minore del raggio utensile if ( nUseMillOnSide <= 1 or nSide == -1) and dFacElev < dToolDiam / 2 then dDistToEnd = sqrt( dFacElev * ( dToolDiam - dFacElev)) diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index 68e66d3..f3dffd5 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -903,8 +903,8 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster if bForceUseBladeOnNotThruFace then -- determino la massima elevazione local dElev = 0 - local dFacElev1 = EgtSurfTmFacetElevationInBBox( Proc.Id, tFaceLong[1], b3Solid, GDB_ID.ROOT) - local dFacElev2 = EgtSurfTmFacetElevationInBBox( Proc.Id, tFaceLong[2], b3Solid, GDB_ID.ROOT) + local dFacElev1 = BL.GetFaceElevation( Proc, tFaceLong[1], b3Solid) + local dFacElev2 = BL.GetFaceElevation( Proc, tFaceLong[2], b3Solid) dElev = max( dFacElev1, dFacElev2) -- recupero la lavorazione local sMilling @@ -1079,8 +1079,8 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster elseif ( nSide ~= -1 or BD.DOWN_HEAD or BD.TURN) and nUseMillOnSide == 0 then -- determino la massima elevazione local dElev = 0 - local dFacElev1 = EgtSurfTmFacetElevationInBBox( Proc.Id, tFaceLong[1], b3Solid, GDB_ID.ROOT) - local dFacElev2 = EgtSurfTmFacetElevationInBBox( Proc.Id, tFaceLong[2], b3Solid, GDB_ID.ROOT) + local dFacElev1 = BL.GetFaceElevation( Proc, tFaceLong[1], b3Solid) + local dFacElev2 = BL.GetFaceElevation( Proc, tFaceLong[2], b3Solid) -- se facce concave e a 90 gradi, prendo l'elevazione minima if bOrtho then dElev = min( dFacElev1, dFacElev2) @@ -1450,8 +1450,8 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster local dDistToEnd = dToolDiam / 2 local dDistToEndDn = dToolDiamDn / 2 -- calcolo l'elevazione della faccia principale - local dFacElev1 = EgtSurfTmFacetElevationInBBox( Proc.Id, tFaceLong[vOrd[1]], b3Solid, GDB_ID.ROOT) - local dFacElev2 = EgtSurfTmFacetElevationInBBox( Proc.Id, tFaceLong[vOrd[2]], b3Solid, GDB_ID.ROOT) + local dFacElev1 = BL.GetFaceElevation( Proc, tFaceLong[vOrd[1]], b3Solid) + local dFacElev2 = BL.GetFaceElevation( Proc, tFaceLong[vOrd[2]], b3Solid) -- se fresa di fianco o da sotto calcolo quanto l'utensile può andare vicino al limite se l'elevazione della faccia è minore del raggio utensile if nUseMillOnSide <= 1 or nSide == -1 then local dFacElev = max( dFacElev1, dFacElev2) diff --git a/LuaLibs/ProcessProfCamb.lua b/LuaLibs/ProcessProfCamb.lua index 8df0a51..abd30f4 100644 --- a/LuaLibs/ProcessProfCamb.lua +++ b/LuaLibs/ProcessProfCamb.lua @@ -285,7 +285,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- aggiungo piano di sgrossatura e lo lavoro local ptStart, vtNP = GetSawCutData( AuxId, vtNF) local AddId = EgtSurfTmPlaneInBBox( nAddGrpId, ptStart, vtNP, b3Solid, GDB_RT.GLOB) - if AddId and EgtSurfTmFacetElevationInBBox( AddId, 0, b3Solid, GDB_ID.ROOT) > 20.0 then + if AddId and BL.GetFaceElevation( AddId, 0, b3Solid) > 20.0 then EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( AddId, 'TASKID', Proc.TaskId) -- se macchina PF o ONE e profilo sopra davanti e pezzo alto applico svuotatura diff --git a/LuaLibs/ProcessProfConcave.lua b/LuaLibs/ProcessProfConcave.lua index ba49c7c..23fc52e 100644 --- a/LuaLibs/ProcessProfConcave.lua +++ b/LuaLibs/ProcessProfConcave.lua @@ -289,7 +289,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- aggiungo piano di sgrossatura e lo lavoro local ptStart, vtNP = GetSawCutData( AuxId, vtN) local AddId = EgtSurfTmPlaneInBBox( nAddGrpId, ptStart, vtNP, b3Solid, GDB_RT.GLOB) - if AddId and EgtSurfTmFacetElevationInBBox( AddId, 0, b3Solid, GDB_ID.ROOT) > 20.0 then + if AddId and BL.GetFaceElevation( AddId, 0, b3Solid) > 20.0 then EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( AddId, 'TASKID', Proc.TaskId) -- se macchina PF o ONE e profilo sopra davanti e pezzo alto applico svuotatura diff --git a/LuaLibs/ProcessProfConvex.lua b/LuaLibs/ProcessProfConvex.lua index 6faad09..74b2054 100644 --- a/LuaLibs/ProcessProfConvex.lua +++ b/LuaLibs/ProcessProfConvex.lua @@ -289,7 +289,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- aggiungo piano di sgrossatura e lo lavoro local ptStart, vtNP = GetSawCutData( AuxId, vtN) local AddId = EgtSurfTmPlaneInBBox( nAddGrpId, ptStart, vtNP, b3Solid, GDB_RT.GLOB) - if AddId and EgtSurfTmFacetElevationInBBox( AddId, 0, b3Solid, GDB_ID.ROOT) > 20.0 then + if AddId and BL.GetFaceElevation( AddId, 0, b3Solid) > 20.0 then EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( AddId, 'TASKID', Proc.TaskId) -- se macchina PF o ONE e profilo sopra davanti e pezzo alto applico svuotatura diff --git a/LuaLibs/ProcessProfFront.lua b/LuaLibs/ProcessProfFront.lua index aacbc30..a07191d 100644 --- a/LuaLibs/ProcessProfFront.lua +++ b/LuaLibs/ProcessProfFront.lua @@ -236,7 +236,7 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- aggiungo piano di sgrossatura e lo lavoro local ptStart, vtNP = GetSawCutData( AuxId, vtN) local AddId = EgtSurfTmPlaneInBBox( nAddGrpId, ptStart, vtNP, b3Solid, GDB_RT.GLOB) - if AddId and EgtSurfTmFacetElevationInBBox( AddId, 0, b3Solid, GDB_ID.ROOT) > 20.0 then + if AddId and BL.GetFaceElevation( AddId, 0, b3Solid) > 20.0 then EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( AddId, 'TASKID', Proc.TaskId) -- se macchina PF o ONE e profilo sopra davanti e pezzo alto applico svuotatura diff --git a/LuaLibs/ProcessProfHead.lua b/LuaLibs/ProcessProfHead.lua index 2006c3c..acc2cab 100644 --- a/LuaLibs/ProcessProfHead.lua +++ b/LuaLibs/ProcessProfHead.lua @@ -271,7 +271,7 @@ function ProcessProfHead.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- aggiungo piano di sgrossatura e lo lavoro local ptStart, vtNP = GetSawCutData( AuxId, vtN) local AddId = EgtSurfTmPlaneInBBox( nAddGrpId, ptStart, vtNP, b3Solid, GDB_RT.GLOB) - if AddId and EgtSurfTmFacetElevationInBBox( AddId, 0, b3Solid, GDB_ID.ROOT) > 20.0 then + if AddId and BL.GetFaceElevation( AddId, 0, b3Solid) > 20.0 then EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( AddId, 'TASKID', Proc.TaskId) -- se macchina PF o ONE e profilo sopra davanti e pezzo alto applico svuotatura diff --git a/LuaLibs/ProcessVariant.lua b/LuaLibs/ProcessVariant.lua index f6e0d9c..0411982 100644 --- a/LuaLibs/ProcessVariant.lua +++ b/LuaLibs/ProcessVariant.lua @@ -84,7 +84,7 @@ local function MakePocket( Proc, nRawId, b3Raw, nPartId) local dTotDepth = 0 local vDepth = {} for i = 1, #vFace do - vDepth[i] = EgtSurfTmFacetElevationInBBox( Proc.Id, vFace[1], b3Solid, GDB_ID.ROOT) + vDepth[i] = BL.GetFaceElevation( Proc, vFace[1], b3Solid) dTotDepth = max( dTotDepth, vDepth[i]) end local vtN = EgtSurfTmFacetNormVersor( Proc.Id, vFace[1], GDB_ID.ROOT)