diff --git a/LuaLibs/ProcessHeadCut.lua b/LuaLibs/ProcessHeadCut.lua index dbfbafb..12ccc6d 100644 --- a/LuaLibs/ProcessHeadCut.lua +++ b/LuaLibs/ProcessHeadCut.lua @@ -281,7 +281,7 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut local dLastCutOffset = i * dOffsL local vtMoveLimitingSurf = Vector3d( dLastCutOffset - 10 * GEO.EPS_SMALL, 0, 0) EgtMove( nLimitingSurf, vtMoveLimitingSurf, GDB_RT.GLOB) - local vtNLimitingSurf = EgtSurfTmFacetNormVersor( nLimitingSurf, 0) + local vtNLimitingSurf = EgtSurfTmFacetNormVersor( nLimitingSurf, 0, GDB_ID.ROOT) if AreSameVectorApprox( X_AX(), vtNLimitingSurf) then EgtInvertSurf( nLimitingSurf) end end -- tagli verticali diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 10e5ac8..a30b2c6 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -89,6 +89,8 @@ -- 2023/12/06 In VerifySideMillAsSaw, se SIDEDEPTH non definita, viene calcolata. -- 2024/01/18 Implementata GetBlockedAxis che gestisce gli assi bloccati per tutti i tipi di utensile. -- 2024/01/22 Implementata gestione seghe a catena multiple. +-- 2024/01/31 In tagli con sega a catena ora si considera l'ingombro della testa per il calcolo della massima profondità. +-- Aggiunta funzione GetToolEntryAngle per determinare l'angolo di ingresso dell'utensile nella faccia. -- Tabella per definizione modulo local ProcessLapJoint = {} @@ -323,7 +325,8 @@ local function VerifyChainSaw( Proc, dMinDim, dMaxDim, dDepth) local dMaxMat = 0 local dSawCornerRad = 0 local dSawThick = 0 - local dMaxDepth = 200 + local dMaxDepth = 200 + local dSawWidth = 0 -- se non trova una lavorazione di sawing esco if not sSawing then return bUseChainSaw @@ -346,7 +349,7 @@ local function VerifyChainSaw( Proc, dMinDim, dMaxDim, dDepth) end end end - return bUseChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick, dMaxDepth + return bUseChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick, dMaxDepth, dSawWidth end --------------------------------------------------------------------- @@ -1347,6 +1350,54 @@ local function CheckToInvert( AuxId, bPositive) return false end +--------------------------------------------------------------------- +--- +---@param Proc table la feature +---@param vtTool Vector3d il vettore direzione utensile +---@return number dAngle angolo tra la faccia d'ingresso e la direzione utensile +---@return number dSinAngle seno dell'angolo +---@return number dCosAngle coseno dell'angolo +---@return number|nil dTanAngle tangente dell'angolo +local function GetToolEntryAngle( Proc, vtTool) + + local dSinAngle = -10 * GEO.EPS_SMALL + local vtNorm + if Proc.AffectedFaces.Top then + vtNorm = Z_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.Bottom then + vtNorm = -Z_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.Front then + vtNorm = -Y_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.Back then + vtNorm = Y_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.Left then + vtNorm = -X_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.Right then + vtNorm = X_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + + local dCosAngle = sqrt( 1 - sqr( dSinAngle)) + local dAngle = acos( dCosAngle) + local dTanAngle + if dAngle ~= 0 and dAngle ~= 90 then + dTanAngle = sqrt( 1 - dCosAngle * dCosAngle) / dCosAngle + end + + return dAngle, dSinAngle, dCosAngle, dTanAngle + +end + --------------------------------------------------------------------- local function MakeRoundCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiam, bMillDown, bDoubleSide) @@ -2670,6 +2721,8 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, local b3Raw = EgtGetRawPartBBox( nRawId) -- ottengo la distanza tra la fine del pezzo e il pezzo successivo local dDistToNextPiece = BL.GetDistanceToNextPart( nRawId, nPhase) + -- angolo d'ingresso dell'utensile + local dToolEntryAngle, _, _, dTanToolEntryAngle = GetToolEntryAngle( Proc, rfFac:getVersZ()) -- verifico se fessura con 3 facce o tunnel local bOrthoFaces local bIs3Faces = ( Proc.Fct == 3) @@ -2883,6 +2936,14 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, if nStep > 1 then dStep = ( dV - dSawThick) / ( nStep - 1) end + -- se necessario riduco la profondità di lavoro per considerare l'ingombro della testa + local dChainSawTHLength = EgtIf( EgtTdbGetCurrToolThLength() > 10 * GEO.EPS_SMALL, EgtTdbGetCurrToolThLength(), 88) + local dChainSawExtraLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) - dChainSawTHLength - dMaxDepth + local dMaxMatReduction = 0 + if dToolEntryAngle > 10 * GEO.EPS_ANG_SMALL and dToolEntryAngle < 90 - 10 * GEO.EPS_ANG_SMALL then + dMaxMatReduction = max( ( ( 2 * BD.C_SIMM_ENC - dSawWidth) / ( 2 * dTanToolEntryAngle) - dChainSawExtraLength) - 5, 0) + end + dMaxDepth = dMaxDepth - dMaxMatReduction for i = 1, nStep do -- Applico la lavorazione con sega a catena a questa faccia local sName = 'Csaw_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i) @@ -2925,8 +2986,9 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, -- imposto offset radiale local dOffs = ( i - 1) * dStep EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) - -- se necessario, avverto limitazioneo dell'affondamento - if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then + -- se necessario, avverto limitazione dell'affondamento + if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then + EgtSetMachiningParam( MCH_MP.DEPTH, dMaxDepth) sWarn = 'Warning in LapJoint : elevation (' .. EgtNumToString( dElev, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' EgtOutLog( sWarn) --local dDepth = dMaxDepth - dElev @@ -4553,7 +4615,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa -- Se la svuotatura precedente non è stata fatta e chamfer non è mutuamente esclusivo provo con la sega-catena if bTryWithBlades and nChamfer < 2 then -- verifico se posso farlo con la sega-catena - local bMakeChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick = VerifyChainSaw( Proc, dDimMin, dDimMax, dDepth) + local bMakeChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick, _, dSawWidth = VerifyChainSaw( Proc, dDimMin, dDimMax, dDepth) if bMakeChainSaw then -- Ricalcolo l'affondamento tenendo conto di eventuale inclinazione local dSlDepth @@ -4587,12 +4649,20 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa dDepth = dDepth / 2 + BD.CUT_EXTRA end end - local dWorkDepth = dMaxMat + -- se necessario riduco la profondità di lavoro per considerare l'ingombro della testa + local dChainSawTHLength = EgtIf( EgtTdbGetCurrToolThLength() > 10 * GEO.EPS_SMALL, EgtTdbGetCurrToolThLength(), 88) + local dChainSawExtraLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) - dChainSawTHLength - dMaxMat + local dMaxMatReduction = 0 + local dToolEntryAngle, _, _, dTanToolEntryAngle = GetToolEntryAngle( Proc, vtOrtho) + if dToolEntryAngle > 10 * GEO.EPS_ANG_SMALL then + dMaxMatReduction = max( ( ( 2 * BD.C_SIMM_ENC - dSawWidth) / ( 2 * dTanToolEntryAngle) - dChainSawExtraLength) - 5, 0) + end + local dWorkDepth = dMaxMat - dMaxMatReduction -- cerco di estendere il taglio considerando la parte arrotondata della lama - if dMaxMat > dDepth + dSawCornerRad + 1 then + if dMaxMat - dMaxMatReduction > dDepth + dSawCornerRad + 1 then dWorkDepth = dDepth + dSawCornerRad + 1 -- se massimo affondamento utensile inferiore alla profondità da lavorare, setto la profondità di lavoro e emetto warning - elseif dMaxMat < dDepth then + elseif dMaxMat - dMaxMatReduction < dDepth then sWarn = 'Warning : elevation bigger than max tool depth' EgtOutLog( sWarn) end @@ -5895,6 +5965,8 @@ end -- Applicazione della lavorazione --------------------------------------------------------------------- function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) + -- inizializzazione costanti + if not BD.C_SIMM_ENC then BD.C_SIMM_ENC = EgtIf( BD.C_SIMM, 180, 90) end -- setto a nil la variabile smussi bMadeChamfer = nil -- limiti di fresatura semplice