diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 42fba8e..035bf74 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -45,6 +45,8 @@ -- 2022/05/31 Rese globali le funzioni GetChainSawBlockedAxis e GetChainSawInitAngs per essere richiamate dalla ProcessSplit per taglio sega a catena in sezioni alte e larghe. -- 2022/06/13 Modifiche per feature lunga con due facce non equivalenti a taglio long. doppio o singolo con faccia terminale. -- 2022/06/15 Correzione calcolo normale alla faccia per sega catena di fianco. +-- 2022/06/16 Implemento lavorazioni con fresatura di lato per L30 (al momento solo passanti) se parametro Q03=2. Modificate funzioni Make, MakeMoreFaces, Classify. +-- 2022/06/21 Implemento di lavorazioni non passanti con fresatura di lato per L30 se parametro Q03=2. Modificate funzioni MakeMoreFaces, Classify. -- Tabella per definizione modulo local ProcessLapJoint = {} @@ -722,7 +724,9 @@ function ProcessLapJoint.Classify( Proc, b3Raw) local bDown = ( vtN[1]:getZ() < BD.NZ_MINB and vtN[2]:getZ() < BD.NZ_MINB) or ( vtN[1]:getZ() < BD.NZ_MINA and vtN[2]:getZ() < 0.5 and ( vtN[2]:getZ() < -0.1 or not bSmall)) or ( vtN[2]:getZ() < BD.NZ_MINA and vtN[1]:getZ() < 0.5 and ( vtN[1]:getZ() < -0.1 or not bSmall)) - bDown = ( bDown and not BD.DOWN_HEAD and not BD.TURN) + -- per L30, se forzata la lavorazione con fresa di lato da parametro Q03=2 non devo ruotare + local bForceSideMill = ( Proc.Prc == 30 and EgtGetInfo( Proc.Id, 'Q03', 'd') == 2) + bDown = ( bDown and not BD.DOWN_HEAD and not BD.TURN and not bForceSideMill) return true, bDown -- se più di 2 facce else @@ -820,7 +824,12 @@ function ProcessLapJoint.Classify( Proc, b3Raw) local bDown = ( vtN:getZ() < BD.NZ_MINA and not BD.DOWN_HEAD and not BD.TURN) -- se verso il basso, verifico se utilizzabile seconda faccia if bDown then - if nFacInd2 and dElev2 < 2 * dElev then + local bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc)) + -- per lapjoint proc 30, se forzata la lavorazione con fresa di lato da parametro Q03=2 non devo ruotare + local bForceSideMill = ( Proc.Prc == 30 and EgtGetInfo( Proc.Id, 'Q03', 'd') == 2 and ( Proc.Fct == 3 or Proc.Fct == 4)) + if bForceSideMill then + bDown = false + elseif nFacInd2 and dElev2 < 2 * dElev then local ptC2, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) bDown = ( vtN2:getZ() < BD.NZ_MINB) elseif not nFacInd2 and bIsL and nFaceAdj >= 0 then @@ -3554,7 +3563,7 @@ local function GetUShapeWidth( Proc, nFacInd) end --------------------------------------------------------------------- -local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, bIs3Faces, b3Solid, bOrthoFacesMaster, bMillDown) +local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, bIs3Faces, b3Solid, bOrthoFacesMaster, bMillDown, bSetOpenBorders) local nFirstMachId local bOrthoFaces @@ -3612,8 +3621,8 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha -- e assegno l'estrusione nPathInt = EgtExtractSurfTmLoops( nSurfInt, nAddGrpId) EgtModifyCurveExtrusion( nPathInt, vtOrtho, GDB_RT.GLOB) - -- se ho 3 facce, ciclo sulle entià del percorso per segnare quelle che sono aperte - if bIs3Faces then + -- se ho 3 facce oppure se forzato, ciclo sulle entià del percorso per segnare quelle che sono aperte. + if bIs3Faces or bSetOpenBorders then SetOpenSide( nPathInt, vtOrtho, b3Solid, nAddGrpId) end -- variabili per parametri lavorazione @@ -4348,6 +4357,40 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, return true, sMyWarn end +--------------------------------------------------------------------- +-- Trova il numero (0 based) della faccia meglio orientata come l'asse 'sAxis'. Restituisce anche vtN e ptC della faccia stessa. +-- sAxis: 'X' o 'Y' o 'Z' +local function FindFaceBestOrientedAsAxis( Proc, sAxis) + local ptC = {} + local vtN = {} + local nFaceMaximumNormalComponentOnAxis = 0 + local dFaceMaximumNormalComponentOnAxisValue = 0 + for i = 1, Proc.Fct do + ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT) + if sAxis == 'X' then + if abs(vtN[i]:getX()) > dFaceMaximumNormalComponentOnAxisValue then + nFaceMaximumNormalComponentOnAxis = i - 1 + dFaceMaximumNormalComponentOnAxisValue = abs(vtN[i]:getX()) + end + elseif sAxis == 'Y' then + if abs(vtN[i]:getY()) > dFaceMaximumNormalComponentOnAxisValue then + nFaceMaximumNormalComponentOnAxis = i - 1 + dFaceMaximumNormalComponentOnAxisValue = abs(vtN[i]:getY()) + end + elseif sAxis == 'Z' then + if abs(vtN[i]:getZ()) > dFaceMaximumNormalComponentOnAxisValue then + nFaceMaximumNormalComponentOnAxis = i - 1 + dFaceMaximumNormalComponentOnAxisValue = abs(vtN[i]:getZ()) + end + else + local sErr = 'Error : FindFaceBestOrientedAsAxis - unknown axis name' + EgtOutLog( sErr) + return false, sErr + end + end + return nFaceMaximumNormalComponentOnAxis, vtN[ nFaceMaximumNormalComponentOnAxis + 1], ptC[ nFaceMaximumNormalComponentOnAxis + 1] +end + --------------------------------------------------------------------- local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePart, bPrevBhSideMill, bAllWithEndCap) local sWarn @@ -4545,6 +4588,8 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa local bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc)) -- verifico se due facce o L con una o due facce di terminazione local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2) + -- se L30 e paramtetro Q03=2 forzo la fresatura di lato + local bForceSideMill = Proc.Prc == 30 and EgtGetInfo( Proc.Id, Q_SIDE_ROUGH_TOOL, 'i') == 2 and ( Proc.Fct == 4 or Proc.Fct == 3 or Proc.Fct == 2) -- se fattibile con fresa BH di fianco e spessore utensile inferiore alla larghezza faccia local bMakeBySideMill, bHead, bHeadDir, sMilling, dMaxMat, dToolDiam = VerifyBHSideMill( Proc, bIsU, bIsL, bSinglePart, bPrevBhSideMill) if bPrevBhSideMill == nil then @@ -4778,9 +4823,9 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa dFacElev, dFacElev2 = dFacElev2, dFacElev bUseOtherFace = true end - -- verifico non sia orientata verso il basso o ci sia una testa dal basso + -- verifico non sia orientata verso il basso o ci sia una testa dal basso o la lavorazione sia dal lato. local bFaceDown = ( vtN:getZ() < BD.NZ_MINA) - if bFaceDown and not BD.DOWN_HEAD and not BD.TURN then + if bFaceDown and not BD.DOWN_HEAD and not BD.TURN and not bForceSideMill then local sErr = 'Error : LapJoint from bottom impossible' EgtOutLog( sErr) return false, sErr @@ -4990,14 +5035,18 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa if Proc.Prc == 16 and bForceUseBlade and Proc.Fct == 3 and bIsU then sPocketing = nil end + -- se richiesta fresatura di lato + if bForceSideMill then + sPocketing = nil + end -- leggo parametro Q local nQAntisplintResult = EgtGetInfo( Proc.Id, Q_ANTISPLINT_TYPE, 'i') or 0 - -- se lavorazione fresa come lama disabilito eveentuale antischegggia + -- se lavorazione fresa come lama disabilito eventuale antischeggia if bSpecialMillOnSide then nQAntisplintResult = 0 end -- se non trova una svuotatura adatta if not sPocketing then -- se forma a L provo con contornatura - if bIsL and not bSpecialMillOnSide then + if bIsL and not bSpecialMillOnSide and not bForceSideMill then -- se smusso non è esclusivo if nChamfer < 2 then return MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev, dCollSic) @@ -5109,60 +5158,98 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa bMadeASbyBld, bOk, sWarn = ManageAntiSplintBySaw( Proc, b3Raw, bIsU, vtN, nFacInd, sWarn, bSawDown, true) if not bOk then return false, sWarn end end - -- in base al flag interno e al numero di facce e se ha forma ad U: provo prima la svuotatura sul fianco e + -- in base al flag interno e al numero di facce e se ha forma ad U + -- oppure se richiesta lavorazione di lato: + -- provo prima la svuotatura sul fianco e -- se non è possibile allora provo in seguito con lama o segacatena -- o passare subito dalla lavorazione con lama/sega catena - if bTrySidePocketAtFirst and Proc.Fct == 3 and bIsU then + if ( bTrySidePocketAtFirst and Proc.Fct == 3 and bIsU) or bForceSideMill then -- lavoro con svuotature (singola o doppia contrapposta) local sMyMchFind = 'Pocket' local dDiamTool = 100 local nPathInt, nSurfInt, bOneShot, nFirstMachId - nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, dDiamTool, bDoubleSide, nPathInt, nSurfInt, bOneShot, bMillDown, nFirstMachId, - bOrthoFaces = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMyMchFind, true, b3Solid, nil, bMillDown) - if nOk == -2 then - if not sMchFind then - sMchFind = sMchFindBackUp - end - sPocketing = ML.FindPocketing( sMchFind, dDiam, nil, nil, not bMillDown, bMillDown) - if not sPocketing then - local sErr2 = 'Error : '..sMchFind..' not found in library' - EgtOutLog( sErr2) - return false, sErr2 + local bIs3Faces = true + local bOrthoFacesMaster = nil + local bSetOpenBorders = nil + -- trovo la faccia con normale più inclinata verso Y + local nFacApproxY, vtNFacApproxY, ptCFacApproxY = FindFaceBestOrientedAsAxis( Proc, 'Y') + -- se Q03 = 2 e + -- 3 facce a L, oppure + -- 3 facce non a L ma con una faccia favorevole a Y, oppure + -- 4 facce + -- lancio la MakePocket ( lavorazione solo da un lato, fondo della tasca la faccia più favorevole a Y) + if bForceSideMill and (( Proc.Fct == 3 and bIsL) or ( Proc.Fct == 3 and abs( vtNFacApproxY:getY()) >= 0.707 ) or Proc.Fct == 4) then + nFacInd, vtN, ptC = nFacApproxY, vtNFacApproxY, ptCFacApproxY + local tvtNx = {} + tvtNx[2] = vtN + local ptPs = ptC + dFacElev = BL.GetFaceElevation( Proc.Id, nFacInd) + dCollSic = CalcCollisionSafety( tvtNx[2]) + local dMachDepth = dFacElev + dCollSic + local _, _, dDimMin = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) + local _, sPocketing = VerifyPocket( Proc, dDimMin, dFacElev, nil, sMyMchFind) + bOk, sWarn2, sTuuidPk, dDiamTool = MakePocket( Proc, nPartId, ptPs, tvtNx, nFacInd, sMyMchFind, nUseRoughTool, sPocketing, dMachDepth, nil, nil, bAllWithEndCap) + if not bOk then return false, sWarn2 end + if sWarn2 then + if not sWarn then sWarn = '' end + sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) end bTryWithBlades = false - sWarn = sErr - elseif nOk < 0 then - return false, sErr - elseif nOk > 0 then - bTryWithBlades = false - sWarn = sErr - -- se ho antischeggia con fresa le inserisco --- if nChamfer < 2 and nQAntisplintResult == 2 and ( bIsU or bIsL) then - if nChamfer < 2 and nQAntisplintResult == 2 then - local bOk, sWarn2 = ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, bMillDown, dDiamTool, bDoubleSide, - vtOrtho, nPathInt, nSurfInt, b3Solid, dDepth, - bOneShot, nFirstMachId) - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) - end - end - -- se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola - local nContourSmallTool = EgtGetInfo( Proc.Id, Q_CONTOUR_SMALL_TOOL, 'i') or 0 - if nContourSmallTool > 0 then - local bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nPhase, nRawId, nPartId, b3Raw, - nFacInd, nAddGrpId, dDiamTool, nContourSmallTool, bMillDown, - bDoubleSide, vtOrtho, nPathInt, nSurfInt, b3Solid, - dDepth, bOneShotm) - if not bOk then return false, sWarn2 end - if sWarn2 then - if not sWarn then sWarn = '' end - sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) + -- in tutti gli altri casi lancio la MakeByPockets (lavorazione singola o doppia contrapposta, fondo della tasca una faccia fittizia perpendicolare al lato lungo) + else + -- se 2 facce setto i parametri corretti per la MakeByPockets + if bForceSideMill and Proc.Fct == 2 then + bIs3Faces = false + bOrthoFacesMaster = true + bSetOpenBorders = true + end + nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, dDiamTool, bDoubleSide, nPathInt, nSurfInt, bOneShot, bMillDown, nFirstMachId, + bOrthoFaces = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMyMchFind, bIs3Faces, b3Solid, bOrthoFacesMaster, bMillDown, bSetOpenBorders) + if nOk == -2 then + if not sMchFind then + sMchFind = sMchFindBackUp + end + sPocketing = ML.FindPocketing( sMchFind, dDiam, nil, nil, not bMillDown, bMillDown) + if not sPocketing then + local sErr2 = 'Error : '..sMchFind..' not found in library' + EgtOutLog( sErr2) + return false, sErr2 + end + bTryWithBlades = false + sWarn = sErr + elseif nOk < 0 then + return false, sErr + elseif nOk > 0 then + bTryWithBlades = false + sWarn = sErr + -- se ho antischeggia con fresa le inserisco + -- if nChamfer < 2 and nQAntisplintResult == 2 and ( bIsU or bIsL) then + if nChamfer < 2 and nQAntisplintResult == 2 then + local bOk, sWarn2 = ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, + nFacInd, nAddGrpId, bMillDown, dDiamTool, bDoubleSide, + vtOrtho, nPathInt, nSurfInt, b3Solid, dDepth, + bOneShot, nFirstMachId) + if sWarn2 then + if not sWarn then sWarn = '' end + sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) + end + end + -- se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola + local nContourSmallTool = EgtGetInfo( Proc.Id, Q_CONTOUR_SMALL_TOOL, 'i') or 0 + if nContourSmallTool > 0 then + local bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nPhase, nRawId, nPartId, b3Raw, + nFacInd, nAddGrpId, dDiamTool, nContourSmallTool, bMillDown, + bDoubleSide, vtOrtho, nPathInt, nSurfInt, b3Solid, + dDepth, bOneShotm) + if not bOk then return false, sWarn2 end + if sWarn2 then + if not sWarn then sWarn = '' end + sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) + end end end + bOk = true end - bOk = true end -- 03/09/2020 da conferma di Fabio Squaratti: Per ora solo sulla feature 016: -- se ha fallito la fresatura (qua sopra) allora di defalut ( anche se il flag Q della lama è disattivato) prima provo la lama @@ -5487,7 +5574,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local nUseRoughToolOnSide = EgtGetInfo( Proc.Id, Q_SIDE_ROUGH_TOOL, 'i') or 0 nForceUseBladeOnNotContinueFace = EgtGetInfo( Proc.Id, Q_BLADE_ON_ALONG_FACE, 'i') or 0 -- se antischeggia di fresa o abilitato sgrossatore di fianco - if nBladeAntisplint == 2 or nUseRoughToolOnSide == 1 then + if nBladeAntisplint == 2 or nUseRoughToolOnSide > 0 then bUseBlade = false end -- se ho attivo la lama e ho la feature 32, verifico i parametri Q propri della feature