diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 8efc44b..3af1aaa 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -442,7 +442,7 @@ local function CalcHeadTailMachBeforeIntersDrillings( vProc, b3Raw) local b3TailBox for i = 1, #vProc do local Proc = vProc[i] - if Proc.Box and not Proc.Box:isEmpty() then + if Proc.Box and not Proc.Box:isEmpty() then if Proc.Fct == 1 and BL.IsFeatureCuttingEntireSection( Proc.Box, b3Raw:getDimY(), b3Raw:getDimZ()) and ( Proc.Head or Proc.Tail) and Proc.Prc ~= 340 and Proc.Prc ~= 350 then if Proc.Head and Proc.Box:getCenter():getX() < dHeadX then dHeadX = Proc.Box:getCenter():getX() @@ -467,6 +467,7 @@ end local function AnalyzeHeadFeatures( b3Solid, vProc, dRawW, dRawH) local nReplacedFeatureId = nil local bHeadFinishingNeeded = true + local nCuttingFeatureId = nil for i = 1, #vProc do local Proc = vProc[i] -- controllo se esiste già una feature taglio di testa @@ -481,15 +482,19 @@ local function AnalyzeHeadFeatures( b3Solid, vProc, dRawW, dRawH) if Proc.Head and Proc.Id ~= nReplacedFeatureId and Proc.Prc ~= 340 then -- controllo se la feature taglia l'intera sezione; in caso positivo la finitura non è necessaria bHeadFinishingNeeded = not BL.IsFeatureCuttingEntireSection( Proc.Box, dRawW, dRawH) + if not bHeadFinishingNeeded and ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 10) and ( Proc.Flg > 0) then + nCuttingFeatureId = Proc.Id + end end end - return bHeadFinishingNeeded, nReplacedFeatureId + return bHeadFinishingNeeded, nReplacedFeatureId, nCuttingFeatureId end ------------------------------------------------------------------------------------------------------------- local function AnalyzeTailFeatures( b3Solid, vProc, dRawW, dRawH) local nReplacedFeatureId = nil local bTailFinishingNeeded = true + local nCuttingFeatureId = nil for i = 1, #vProc do local Proc = vProc[i] -- controllo se esistè già una feature taglio di coda @@ -504,9 +509,12 @@ local function AnalyzeTailFeatures( b3Solid, vProc, dRawW, dRawH) if Proc.Tail and Proc.Id ~= nReplacedFeatureId and Proc.Prc ~= 350 then -- controllo se la feature taglia l'intera sezione; in caso positivo la finitura non è necessaria bTailFinishingNeeded = not BL.IsFeatureCuttingEntireSection( Proc.Box, dRawW, dRawH) + if not bTailFinishingNeeded and ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 10) and ( Proc.Flg > 0) then + nCuttingFeatureId = Proc.Id + end end end - return bTailFinishingNeeded, nReplacedFeatureId + return bTailFinishingNeeded, nReplacedFeatureId, nCuttingFeatureId end ------------------------------------------------------------------------------------------------------------- @@ -600,6 +608,17 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b local b3Part = EgtGetBBoxGlob( Pz or GDB_ID.NULL, GDB_BB.EXACT) local b3Solid = vBeam[i].Box if b3Part:isEmpty() or b3Solid:isEmpty() then break end + -- analizzo le features per valutare l'esistenza di feature head/tail che renderebbero inutili le rispettive finiture o di tagli di testa/coda sostituiti da cui leggere il parametro Q05 + local vProc = CollectFeatures( Pz, b3Solid, 0) + local bSFinishingNeeded, nReplacedHeadCutFeatureId, nHeadCuttingFeatureId = AnalyzeHeadFeatures( b3Solid, vProc, dRawW, dRawH) + local bEFinishingNeeded, nReplacedTailCutFeatureId, nTailCuttingFeatureId = AnalyzeTailFeatures( b3Solid, vProc, dRawW, dRawH) + -- Scrivo gli di delle facce di taglio custom: serviranno dopo per calcolare l'elevazione rispetto a queste + if nHeadCuttingFeatureId then + EgtSetInfo( vBeam[i].Id, 'HEADCUTID', nHeadCuttingFeatureId) + end + if nTailCuttingFeatureId then + EgtSetInfo( vBeam[i].Id, 'TAILCUTID', nTailCuttingFeatureId) + end if bBigSectionCut then -- lascio in coda solo il materiale necessario; il resto verrà tolto nell'head cut successivo local lastB3Solid = nil @@ -612,9 +631,6 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b dOffset = dOvmMid end end - -- analizzo le features per valutare l'esistenza di feature head/tail che renderebbero inutili le rispettive finiture o di tagli di testa/coda sostituiti da cui leggere il parametro Q05 - local vProc = CollectFeatures( Pz, b3Solid, 0) - local bSFinishingNeeded, nReplacedHeadCutFeatureId = AnalyzeHeadFeatures( b3Solid, vProc, dRawW, dRawH) local iSQ05Value = nil if nReplacedHeadCutFeatureId then iSQ05Value = EgtGetInfo( nReplacedHeadCutFeatureId, 'Q05', 'i') @@ -624,7 +640,6 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b else DeltaSMin = BD.OVM_BLADE_HBEAM end - local bEFinishingNeeded, nReplacedTailCutFeatureId = AnalyzeTailFeatures( b3Solid, vProc, dRawW, dRawH) local iEQ05Value = nil if nReplacedTailCutFeatureId then iEQ05Value = EgtGetInfo( nReplacedTailCutFeatureId, 'Q05', 'i') diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 72188fb..1ebde0f 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1189,7 +1189,7 @@ end ------------------------------------------------------------------------------------------------------------- -- restituisce vero se la feature con box b3Proc taglia l'intera sezione della barra, rappresentata dalle sue dimensioni W e H function BeamLib.IsFeatureCuttingEntireSection( b3Proc, dRawW, dRawH) - return ((abs(b3Proc:getDimY() - dRawW) < 10 * GEO.EPS_SMALL or b3Proc:getDimY() > dRawW) and (abs(b3Proc:getDimZ() - dRawH) < 10 * GEO.EPS_SMALL or b3Proc:getDimZ() > dRawH)) + return ( b3Proc:getDimY() > ( dRawW - 500 * GEO.EPS_SMALL) and b3Proc:getDimZ() > ( dRawH - 500 * GEO.EPS_SMALL)) end ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index bfcf4e4..a63154a 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -3437,7 +3437,7 @@ local function MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw, nFacInd, bReduceDe end --------------------------------------------------------------------- -local function MakePocket( Proc, nPartId, b3Solid, ptPs, tvtN, nFaceRef, sMchFind, nUseRoughTool, sMasterPocket, dPrevFaceElev, tDimAndRef, dAng, bOpenOutRaw, bLapJointAngTrasm, nPhase, nRawId) +local function MakePocket( Proc, nPartId, b3Solid, ptPs, tvtN, nFaceRef, sMchFind, nUseRoughTool, sMasterPocket, dPrevFaceElev, tDimAndRef, dAng, bOpenOutRaw, bLapJointAngTrasm, nPhase, nRawId, dCustomMaxElev) -- distanza dal pezzo successivo local dDistToNextPiece = BL.GetDistanceToNextPart( nRawId, nPhase) -- calcolo l'elevazione dal punto medio @@ -3540,11 +3540,10 @@ local function MakePocket( Proc, nPartId, b3Solid, ptPs, tvtN, nFaceRef, sMchFin end end end - -- eventuale massima elevazione imposta dall'utente - local dMaxElev = EgtGetInfo( Proc.Id, Q_MAX_ELEVATION, 'd') - if dMaxElev and dMaxElev < 1 then dMaxElev = nil end + -- eventuale massima elevazione forzata + if dCustomMaxElev and dCustomMaxElev < 1 then dCustomMaxElev = nil end -- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente - dElev = dMaxElev or dElev + dElev = dCustomMaxElev or dElev local sWarn local dDepth = dElev if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then @@ -5887,6 +5886,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa if not BD.MAXDIAM_POCK_CORNER then BD.MAXDIAM_POCK_CORNER = 30 end + local nMGrpId = EgtGetCurrMachGroup() local sWarn -- recupero l'ingombro del grezzo di appartenenza local b3Raw = EgtGetRawPartBBox( nRawId) @@ -6473,6 +6473,32 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa dMaxTotLen = BD.GetBottomToolMaxTotLen( vtN) end local dUserMaxElev = EgtGetInfo( Proc.Id, Q_MAX_ELEVATION, 'd') + local dCustomMaxElev + -- se esistono tagli troncanti in testa o in coda, si calcola il MaxElev da applicare + if not dUserMaxElev then + local nTailCutId = EgtGetInfo( nPartId, 'TAILCUTID', 'i') + local nHeadCutId = EgtGetInfo( nPartId, 'HEADCUTID', 'i') + if nHeadCutId or nTailCutId then + local nSurfPartId = EgtCopyGlob( EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, 'Box'), nAddGrpId) + if nHeadCutId then + local ptCCutSurf, vtNCutSurf = EgtSurfTmFacetCenter( nHeadCutId, 0, GDB_ID.ROOT) + EgtCutSurfTmPlane( nSurfPartId, ptCCutSurf, vtNCutSurf, false, GDB_RT.GLOB) + local nSurfPartIdOld = nSurfPartId + nSurfPartId = EgtSurfTmBySewing( nAddGrpId, { nSurfPartId, nHeadCutId}, false) + EgtErase( nSurfPartIdOld) + end + -- in coda si usa il troncante solo se la feature è settata da lavorare dopo separazione (Tail), altrimenti si rischia che venga fatta prima del taglio + if nTailCutId and Proc.Tail then + local ptCCutSurf, vtNCutSurf = EgtSurfTmFacetCenter( nTailCutId, 0, GDB_ID.ROOT) + EgtCutSurfTmPlane( nSurfPartId, ptCCutSurf, vtNCutSurf, false, GDB_RT.GLOB) + local nSurfPartIdOld = nSurfPartId + nSurfPartId = EgtSurfTmBySewing( nAddGrpId, { nSurfPartId, nTailCutId}, false) + EgtErase( nSurfPartIdOld) + end + dCustomMaxElev = EgtSurfTmFacetElevationInClosedSurfTm( Proc.Id, nFacInd, nSurfPartId, true) + dCollSic + EgtErase( nSurfPartId) + end + end -- ricerca lavorazione local sPocketing local _, sMyPocketing, dMyTMaxDepth, dMyTDiam = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, dMaxTotLen, sMchFind, bMillUp, bMillDown) @@ -6480,14 +6506,20 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa _, sMyPocketing, dMyTMaxDepth, dMyTDiam = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, dMaxTotLen, sMchFind) bMillDown = false end - -- se l'utente ha definito un'elevazione custom dUserMaxElev si lavora sempre la faccia standard - if sMyPocketing and - ( dMyTMaxDepth > dFacElev + dCollSic - 10 * GEO.EPS_SMALL or ( dMyTMaxDepth > 0.8 * dFacElev + dCollSic and not bIsU) or - ( bIsL and nUseRoughTool == 0) or - ( bIsL and Proc.Prc == 20) or - ( Proc.Prc == 25 and not bIsU and not bIsL)) or - ( dUserMaxElev and dUserMaxElev > 10 * GEO.EPS_SMALL) then - sPocketing = sMyPocketing + -- se è presente un'elevazione custom dCustomMaxElev si lavora sempre la faccia standard + if sMyPocketing then + if dUserMaxElev then + dCustomMaxElev = dUserMaxElev + elseif dCustomMaxElev and ( dMyTMaxDepth < dCustomMaxElev + dCollSic - 10 * GEO.EPS_SMALL) then + dCustomMaxElev = nil + end + if ( dMyTMaxDepth > dFacElev + dCollSic - 10 * GEO.EPS_SMALL or ( dMyTMaxDepth > 0.8 * dFacElev + dCollSic and not bIsU) or + ( bIsL and nUseRoughTool == 0) or + ( bIsL and Proc.Prc == 20) or + ( Proc.Prc == 25 and not bIsU and not bIsL)) or + ( dCustomMaxElev and dCustomMaxElev > 10 * GEO.EPS_SMALL) then + sPocketing = sMyPocketing + end end if bMillDown then sMchFind = sMchFind ..'_H2' @@ -6713,7 +6745,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa dToolMaxDiam = dToolTargetDiam end local _, sPocketing = VerifyPocket( Proc, dToolMaxDiam, dFacElev, nil, sMyMchFind) - bOk, sWarn2, sTuuidPk, dDiamTool, dDepth = MakePocket( Proc, nPartId, b3Solid, ptPs, tvtNx, nFacInd, sMyMchFind, nUseRoughTool, sPocketing, dMachDepth, nil, nil, bAllWithEndCap, nil, nPhase, nRawId) + bOk, sWarn2, sTuuidPk, dDiamTool, dDepth = MakePocket( Proc, nPartId, b3Solid, ptPs, tvtNx, nFacInd, sMyMchFind, nUseRoughTool, sPocketing, dMachDepth, nil, nil, bAllWithEndCap, nil, nPhase, nRawId, dCustomMaxElev) if not bOk then return false, sWarn2 end if sWarn2 then if not sWarn then sWarn = '' end @@ -6935,7 +6967,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa if ( Proc.Fct == 4 and bTailOnSide) and ( dDistToNextPiece > dToolDiameter + 10 * GEO.EPS_SMALL) then sMchFind = EgtIf( bMillDown, 'OpenPocket_H2', 'OpenPocket') end - bOk, sWarn2, sTuuidPk, dDiamTool = MakePocket( Proc, nPartId, b3Solid, ptC, tvtNx, nFacInd, sMchFind, nUseRoughTool, sPocketing, dMachiningDepth, nil, nil, bAllWithEndCap, bLapJointAngTrasm, nPhase, nRawId) + bOk, sWarn2, sTuuidPk, dDiamTool = MakePocket( Proc, nPartId, b3Solid, ptC, tvtNx, nFacInd, sMchFind, nUseRoughTool, sPocketing, dMachiningDepth, nil, nil, bAllWithEndCap, bLapJointAngTrasm, nPhase, nRawId, dCustomMaxElev) if not bOk then return false, sWarn2 end if sWarn2 then if not sWarn then sWarn = '' end