diff --git a/LuaLibs/ProcessHeadCut.lua b/LuaLibs/ProcessHeadCut.lua index 7d0653f..a17856f 100644 --- a/LuaLibs/ProcessHeadCut.lua +++ b/LuaLibs/ProcessHeadCut.lua @@ -22,6 +22,7 @@ local Fbs = require( 'FacesBySaw') local Cut = require( 'ProcessCut') local Pocket = require( 'FaceByPocket') local Topology = require( 'FeatureTopology') +local Split = require( 'ProcessSplit') EgtOutLog( ' ProcessHeadCut started', 1) @@ -29,6 +30,10 @@ EgtOutLog( ' ProcessHeadCut started', 1) local BD = require( 'BeamData') local ML = require( 'MachiningLib') +if BD.PRECUT_HEAD == nil then + BD.PRECUT_HEAD = true +end + --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessHeadCut.Identify( Proc) @@ -176,12 +181,13 @@ local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw) bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dVerticalCutOffset, 0, 0, '', b3Raw, nil, nil, nil, bForceTangentLeadInOut) if not bOk then return bOk, sErr end end + return bOk, sErr end --------------------------------------------------------------------- -- tagli standard -local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCutType, Cutting1Data, Cutting2Data, dStartOffset) +local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCutType, Cutting1Data, Cutting2Data, dStartOffset, dOvmHead) local PrecutType = { bBigSectionCut = HeadCutType.bBigSectionCut, bHorizCut = HeadCutType.bHorizCut, bDoubleHorizCut = HeadCutType.bDoubleHorizCut, bDoubleCut = HeadCutType.bDoubleCut, bNeedVerticalAddedCuts = false, bNeedHorizontalAddedCuts = false} if not HeadCutType.bDoubleHorizCut then -- flag di lavorazione faccia @@ -218,9 +224,13 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCut -- per travi alte faccio dei tagli orizzontali aggiuntivi if HeadCutType.bNeedHorizontalAddedCuts then - local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) - if not bOkPrecut then - return false, sErrPrecut + -- taglio a zero (con lama) per evitare problemi con grezzo più lungo del previsto. Se BigSection il pretaglio è già stato fatto. + if not ( HeadCutType.bBigSectionCut) and BD.PRECUT_HEAD then + dStartOffset = dOvmHead + local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) + if not bOkPrecut then + return false, sErrPrecut + end end local nHorizontalCuts = ceil( Proc.Face[1].HeightTrimmed / BD.MAX_DIM_DICE) - 1 local dHorizontalSliceHeight = Proc.Face[1].HeightTrimmed / ( nHorizontalCuts + 1) @@ -248,6 +258,14 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCut return true, sWarn end + -- taglio a zero (con lama) per evitare problemi con grezzo più lungo del previsto. Se BigSection il pretaglio è già stato fatto. + if not ( HeadCutType.bBigSectionCut) and BD.PRECUT_HEAD and HeadCutType.bNeedVerticalAddedCuts then + dStartOffset = dOvmHead + local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) + if not bOkPrecut then + return false, sErrPrecut + end + end -- se necessari tagli in doppio, eseguo gli opposti if HeadCutType.bDoubleCut then -- gli accorciamenti vanno invertiti per il taglio opposto @@ -266,10 +284,6 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCut local dCutOffset = ( i - 1) * dOffsetBetweenCuts -- se trave larga effettuo tagli verticali aggiuntivi if HeadCutType.bNeedVerticalAddedCuts then - local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) - if not bOkPrecut then - return false, sErrPrecut - end local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw) if not bOk then return bOk, sErr end end @@ -301,6 +315,14 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCut local dAccStart = 0 local dVzLimDwnUp if BD.TURN then dVzLimDwnUp = -2 end + -- taglio a zero (con lama) per evitare problemi con grezzo più lungo del previsto. Se BigSection il pretaglio è già stato fatto. + if not ( HeadCutType.bBigSectionCut) and BD.PRECUT_HEAD and HeadCutType.bNeedVerticalAddedCuts then + dStartOffset = dOvmHead + local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) + if not bOkPrecut then + return false, sErrPrecut + end + end -- eseguo i tagli da sotto necessari for i = nCuts, 1, -1 do local dCutOffset = ( i - 1) * dOffsetBetweenCuts @@ -318,10 +340,6 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCut end -- se trave larga effettuo tagli verticali aggiuntivi if HeadCutType.bNeedVerticalAddedCuts then - local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) - if not bOkPrecut then - return false, sErrPrecut - end local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw) if not bOk then return bOk, sErr end end @@ -396,7 +414,6 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut local Cutting2Data = { sCutting = sCutting2, dSawDiam = dSawDiam2, dMaxDepth = dMaxDepth2, dSawThick = dSawThick2} -- dati sul taglio di testa da effettuare local HeadCutType = { bBigSectionCut = bBigSectionCut, bHorizCut = bHorizCut, bDoubleHorizCut = bDoubleHorizCut, bDoubleCut = bDoubleCut, bNeedVerticalAddedCuts = bNeedVerticalAddedCuts, bNeedHorizontalAddedCuts = bNeedHorizontalAddedCuts} - local PrecutType = { bBigSectionCut = HeadCutType.bBigSectionCut, bHorizCut = HeadCutType.bHorizCut, bDoubleHorizCut = HeadCutType.bDoubleHorizCut, bDoubleCut = HeadCutType.bDoubleCut, bNeedVerticalAddedCuts = false, bNeedHorizontalAddedCuts = false} -- dati geometrici del taglio local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) -- se non obbligatorio e coincide con inizio grezzo, non va fatto @@ -421,16 +438,32 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut else dMaxElev = Proc.Box:getMax():getX() - b3Raw:getMin():getX() end - -- controllo se è necessario un taglio con dicing o si deve proseguire ai casi standard - if dMaxElev > dSawThickCheck then - local bOk, sErr - -- taglio a zero (con sega a catena o mix catena + lama) per evitare problemi con grezzo più lungo del previsto - -- TODO qui mettere sega a catena - local dStartOffset = dOvmHead - local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) + -- taglio a zero (con sega a catena o mix catena + lama) per evitare problemi con grezzo più lungo del previsto + if BD.PRECUT_HEAD then + -- recupero dati utensile della sega a catena più lunga a disposizione + local sSawing = ML.FindSawing( 'SawingForSplitting', nil, nil, 'Longest') + if not sSawing then + sSawing = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + end + local dChainSawMaxMat = 0 + local dChainSawLen = 0 + if EgtMdbSetCurrMachining( sSawing or '') then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dChainSawMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dChainSawMaxMat + dChainSawLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dChainSawLen + end + end + local SawingData = { sSawing = sSawing, dChainSawMaxMat = dChainSawMaxMat, dChainSawLen = dChainSawLen, bInvert = true} + local dOffset = dOvmHead + local bOkPrecut, sErrPrecut = Split.MakeBigSectionSplitting( Proc, b3Raw, dOffset, SawingData, Cutting2Data) if not bOkPrecut then return false, sErrPrecut end + end + -- controllo se è necessario un taglio con dicing o si deve proseguire ai casi standard + if dMaxElev > dSawThickCheck then + local bOk, sErr -- se trave larga effettuo tagli verticali aggiuntivi if bNeedVerticalAddedCuts then -- ad ogni offset di taglio dovrò fare prima i tagli verticali e poi i cubetti @@ -485,7 +518,7 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut end end - local bOk, sErr = MakeStandardCuts( Proc, b3Raw, nCuts, dOffsL, HeadCutType, Cutting1Data, Cutting2Data) + local bOk, sErr = MakeStandardCuts( Proc, b3Raw, nCuts, dOffsL, HeadCutType, Cutting1Data, Cutting2Data, nil, dOvmHead) return bOk, sErr end diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index 829f68c..cacc585 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -38,6 +38,10 @@ EgtOutLog( ' ProcessSplit started', 1) local BD = require( 'BeamData') local ML = require( 'MachiningLib') +if BD.PRECUT_TAIL == nil then + BD.PRECUT_TAIL = true +end + --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessSplit.Identify( Proc) @@ -63,7 +67,7 @@ end --------------------------------------------------------------------- -- lavorazione smussi -local function MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmHead) +local function MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmTail) -- verifico che lo smusso sia richiesto local dDepth = EgtGetInfo( nOriId, 'Q06', 'd') or 0 if dDepth < 0.1 then return true end @@ -165,7 +169,7 @@ end --------------------------------------------------------------------- -- lavorazione con sega a catena per sezioni alte e larghe -local function MakeSplitByChainSaw( nSurfId, sSawing, nFaceUse, dDepth, sNotes, dOffs, bExtendStartEnd) +local function MakeCutByChainSaw( nSurfId, sSawing, nFaceUse, dDepth, sNotes, dRadialOffset, bExtendStartEnd, bInvert) -- Recupero i dati dell'utensile local dMaxMat = 0 local dSawCornerRad = 0 @@ -205,7 +209,7 @@ local function MakeSplitByChainSaw( nSurfId, sSawing, nFaceUse, dDepth, sNotes, local vtOrtho = BL.GetVersRef( nFaceUse) EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 1)) -- imposto offset radiale per mantenere il materiale in coda per la finitura - EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) + EgtSetMachiningParam( MCH_MP.OFFSR, dRadialOffset) -- imposto eventuale allungamento percorso iniziale local dStartAddLen = 0 local dEndAddLen = 0 @@ -217,7 +221,13 @@ local function MakeSplitByChainSaw( nSurfId, sSawing, nFaceUse, dDepth, sNotes, EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAddLen) -- faccio in modo che l'attacco della lama sia dal lato opposto rispetto al corpo macchina EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + if bInvert and bInvert == true then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, false) + end if dMaxMat >= dDepth then EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- se massimo affondamento utensile inferiore fessura, setto affondamento ed emetto warning @@ -253,12 +263,78 @@ local function MakeSplitByChainSaw( nSurfId, sSawing, nFaceUse, dDepth, sNotes, return true, sName, nMchFId end +--------------------------------------------------------------------- +-- split per sezioni grandi con sega a catena o mix catena + lama +function ProcessSplit.MakeBigSectionSplitting( Proc, b3Raw, dOffset, SawingData, Cutting2Data) + local bigSectionSplitType + -- se pezzo non troppo alto, taglio singolo da sopra + if b3Raw:getDimZ() + BD.CUT_EXTRA_MIN < SawingData.dChainSawMaxMat + 10 * GEO.EPS_SMALL then + bigSectionSplitType = "single horizontal" + -- se pezzo non troppo largo, taglio singolo da davanti + elseif b3Raw:getDimY() + BD.CUT_EXTRA_MIN < min( SawingData.dChainSawMaxMat, SawingData.dChainSawLen - BD.C_SIMM_ENC) + 10 * GEO.EPS_SMALL then + bigSectionSplitType = "single vertical" + -- se pezzo non troppo largo, tagli dai due fianchi (dietro e davanti) + elseif 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN < min( SawingData.dChainSawMaxMat, SawingData.dChainSawLen - BD.C_SIMM_ENC) + 10 * GEO.EPS_SMALL then + bigSectionSplitType = "double vertical" + -- altrimenti taglio con sega a catena da sopra e con lama da sotto + elseif BD.DOWN_HEAD and ( b3Raw:getDimZ() + BD.CUT_EXTRA_MIN < Cutting2Data.dMaxDepth + SawingData.dChainSawMaxMat + 10 * GEO.EPS_SMALL) then + bigSectionSplitType = "double horizontal" + end + + -- in base alle scelte precedenti, applico le lavorazioni + if bigSectionSplitType == "single horizontal" then + local dCutDepth = b3Raw:getDimZ() + BD.CUT_EXTRA_MIN + local sNotesSplit = EgtIf( SawingData.bSplit, 'Split;', '') + -- verifico se sega a catena lunga e devo quindi estendere ingresso e uscita perchè è probabile che non riesca a ruotare sopra al pezzo + local bExtendStartEnd + local dMinLengthLongChainSaw = 630 + if SawingData.dChainSawLen > dMinLengthLongChainSaw - 10 * GEO.EPS_SMALL then + bExtendStartEnd = true + end + local bOk, sErr = MakeCutByChainSaw( Proc.Id, SawingData.sSawing, MCH_MILL_FU.PARAL_TOP, dCutDepth, sNotesSplit, dOffset, bExtendStartEnd, SawingData.bInvert) + if not bOk then return bOk, sErr end + elseif bigSectionSplitType == "single vertical" then + local dCutDepth = b3Raw:getDimY() + BD.CUT_EXTRA_MIN + local sNotesSplit = EgtIf( SawingData.bSplit, 'Split;', '') + local bOk, sErr = MakeCutByChainSaw( Proc.Id, SawingData.sSawing, MCH_MILL_FU.PARAL_FRONT, dCutDepth, sNotesSplit, dOffset, nil, SawingData.bInvert) + if not bOk then return bOk, sErr end + elseif bigSectionSplitType == "double vertical" then + local dCutDepth = 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN + local sNotesSplit = EgtIf( SawingData.bSplit, 'Presplit;', '') + local bOk, sErr = MakeCutByChainSaw( Proc.Id, SawingData.sSawing, MCH_MILL_FU.PARAL_BACK, dCutDepth, sNotesSplit, dOffset, nil, SawingData.bInvert) + if not bOk then return bOk, sErr end + sNotesSplit = EgtIf( SawingData.bSplit, 'Split;', '') + bOk, sErr = MakeCutByChainSaw( Proc.Id, SawingData.sSawing, MCH_MILL_FU.PARAL_FRONT, dCutDepth, sNotesSplit, dOffset, nil, SawingData.bInvert) + if not bOk then return bOk, sErr end + elseif bigSectionSplitType == "double horizontal" then + -- sega a catena da sopra + local dChainSawCutDepth = b3Raw:getDimZ() + BD.CUT_EXTRA_MIN - Cutting2Data.dMaxDepth + local sNotesSplit = EgtIf( SawingData.bSplit, 'Presplit;', '') + local bOk, sErr = MakeCutByChainSaw( Proc.Id, SawingData.sSawing, MCH_MILL_FU.PARAL_TOP, dChainSawCutDepth, sNotesSplit, dOffset, nil, SawingData.bInvert) + if not bOk then return bOk, sErr end + -- lama da sotto + local dCutExtra = -dChainSawCutDepth + BD.CUT_EXTRA_MIN + local dVzLimDwnUp + if BD.TURN then dVzLimDwnUp = -2 end + local sNotes = EgtIf( SawingData.bSplit, 'Split;', '') + local bMaximizeVerticalDepth = true + bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting2Data.sCutting, Cutting2Data.dSawDiam, MCH_MILL_FU.ORTHO_TOP, dVzLimDwnUp, dCutExtra, BD.CUT_SIC, dOffset, 0, 0, sNotes, b3Raw, nil, bMaximizeVerticalDepth) + if not bOk then return false, sErr end + -- se è comunque troppo grande per essere separato, esco + else + local sErr = 'Error : section too big for splitting' + EgtOutLog( sErr) + return false, sErr, -1 + end + + return true +end + --------------------------------------------------------------------- -- tagli verticali aggiuntivi local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw, sNotes) - local _, dimH = BL.GetFaceHvRefDim( Proc.Id, 0, b3Raw) - local nVerticalCuts = ceil( dimH / ( BD.MAX_LEN_DICE)) - 1 - local dVerticalSliceHeight = dimH / ( nVerticalCuts + 1) + local nVerticalCuts = ceil( Proc.Face[1].WidthTrimmed / ( BD.MAX_LEN_DICE)) - 1 + local dVerticalSliceHeight = Proc.Face[1].WidthTrimmed / ( nVerticalCuts + 1) -- recupero il diametro dell'utensile local dSawDiam = 400 if EgtMdbSetCurrMachining( sCutting) then @@ -276,9 +352,203 @@ local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw, sNotes) bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dVerticalCutOffset, 0, 0, sNotes, b3Raw, nil, nil, nil, bForceTangentLeadInOut) if not bOk then return bOk, sErr end end + return bOk, sErr end +--------------------------------------------------------------------- +-- tagli standard +local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, TailCutType, Cutting1Data, Cutting2Data, dStartOffset, dLenEndRaw) + local PrecutType = { bBigSectionCut = TailCutType.bBigSectionCut, bHorizCut = TailCutType.bHorizCut, bDoubleHorizCut = TailCutType.bDoubleHorizCut, bDoubleCut = TailCutType.bDoubleCut, bSplit = TailCutType.bSplit, bNeedVerticalAddedCuts = false, bNeedHorizontalAddedCuts = false} + if not TailCutType.bDoubleHorizCut then + -- flag di lavorazione faccia + local nOrthoOpposite = EgtIf( TailCutType.bHorizCut, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_BACK) + -- calcolo extra taglio ed accorciamento + local dCutExtra = 0 + local dAccStart = 0 + local dAccEnd = 0 + if TailCutType.bBigSectionCut and BD.C_SIMM then + -- qui arrivano sezioni molto grandi su macchine tipo PF con materiale da asportare inferiore allo spessore lama + local dSawRad = Cutting1Data.dSawDiam / 2 + dCutExtra = - ( b3Raw:getDimY() - dSawRad) + dAccEnd = dSawRad + elseif b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then + dCutExtra = EgtIf( TailCutType.bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA) + else + dCutExtra = - ( b3Raw:getDimY() - Cutting1Data.dMaxDepth) + local dSawRad = Cutting1Data.dSawDiam / 2 + -- distanza in Y tra il centro della lama e l'intersezione tra la lama stessa e la massima Z della trave, + extra + -- se taglio doppio l'intersezione sarà in mezzeria, se taglio singolo sarà all'estremo opposto della trave + local dKL = dSawRad - Cutting1Data.dMaxDepth + EgtIf( TailCutType.bDoubleCut, b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN, b3Raw:getDimY() + BD.CUT_EXTRA) + -- lunghezza minima del percorso di lavorazione, in caso accorciamento porti a lunghezza negativa + local dMinSawingLength = 5 + if BD.C_SIMM then + dAccEnd = sqrt( max( dSawRad * dSawRad - dKL * dKL, 0)) + -- non posso comunque accorciare più della dimensione della geometria, quindi in caso allungo entrata + if dAccEnd > b3Raw:getDimZ() - 100 * GEO.EPS_SMALL then + dAccStart = b3Raw:getDimZ() - dAccEnd - dMinSawingLength + end + else + dAccStart = sqrt( max( dSawRad * dSawRad - dKL * dKL, 0)) + -- non posso comunque accorciare più della dimensione della geometria, quindi in caso allungo uscita + if dAccStart > b3Raw:getDimZ() - 100 * GEO.EPS_SMALL then + dAccEnd = b3Raw:getDimZ() - dAccStart - dMinSawingLength + end + end + end + + -- per travi alte faccio faccio dei tagli orizzontali aggiuntivi + if TailCutType.bNeedHorizontalAddedCuts then + -- taglio a zero (con lama) per evitare problemi con grezzo più lungo del previsto. Se BigSection il pretaglio è già stato fatto. + if not TailCutType.bBigSectionCut and BD.PRECUT_TAIL then + dStartOffset = dLenEndRaw + local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) + if not bOkPrecut then + return false, sErrPrecut + end + end + local nHorizontalCuts = ceil ( Proc.Face[1].HeightTrimmed / BD.MAX_DIM_DICE) - 1 + local dHorizontalSliceHeight = Proc.Face[1].HeightTrimmed / ( nHorizontalCuts + 1) + for i = nCuts, 1, -1 do + local dCutXOffset = ( i - 1) * dOffsetBetweenCuts + -- tagli orizzontali + for j = nHorizontalCuts, 1, -1 do + local nFaceUse = MCH_MILL_FU.PARAL_DOWN + local dHorizontalCutOffset = dHorizontalSliceHeight * -j + local bForceTangentLeadInOut = BD.PRESS_ROLLER + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0 , Cutting1Data.sCutting, Cutting1Data.dSawDiam, nFaceUse, nil, -0.1 - dCutXOffset, BD.CUT_SIC, dHorizontalCutOffset, 0, 0, 'Precut;', b3Raw, nil, nil, nil, bForceTangentLeadInOut) + if not bOk then return false, sErr end + end + -- se necessario taglio verticale doppio, eseguo l'opposto + if TailCutType.bDoubleCut then + -- gli accorciamenti vanno invertiti per il taglio opposto + local dAccStartDoubleCut, dAccEndDoubleCut = dAccEnd, dAccStart + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting1Data.sCutting, Cutting1Data.dSawDiam, MCH_MILL_FU.ORTHO_FRONT, nil, dCutExtra, BD.CUT_SIC, dCutXOffset, dAccStartDoubleCut, dAccEndDoubleCut, 'Precut;', b3Raw, true) + if not bOk then return false, sErr end + end + -- taglio verticale + local sInfo = 'PreCut;' + if i == 1 then sInfo = 'Cut;' end + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting1Data.sCutting, Cutting1Data.dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutXOffset, dAccStart, dAccEnd, sInfo, b3Raw) + if not bOk then return false, sErr end + end + return true, sWarn + end + + -- taglio a zero (con lama) per evitare problemi con grezzo più lungo del previsto. Se BigSection il pretaglio è già stato fatto. + if not TailCutType.bBigSectionCut and BD.PRECUT_TAIL and TailCutType.bNeedVerticalAddedCuts then + dStartOffset = dLenEndRaw + local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) + if not bOkPrecut then + return false, sErrPrecut + end + end + -- se necessari tagli in doppio, eseguo gli opposti + if TailCutType.bDoubleCut then + -- gli accorciamenti vanno invertiti per il taglio opposto + local dAccStartDoubleCut, dAccEndDoubleCut = dAccEnd, dAccStart + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsetBetweenCuts + if i == 1 and dStartOffset then + dCutOffset = dStartOffset + end + local sNotes = EgtIf( TailCutType.bSplit, 'Presplit;', 'Precut;') + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting1Data.sCutting, Cutting1Data.dSawDiam, MCH_MILL_FU.ORTHO_FRONT, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStartDoubleCut, dAccEndDoubleCut, sNotes, b3Raw, true) + if not bOk then return false, sErr end + end + end + -- eseguo i tagli necessari + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsetBetweenCuts + -- se trave larga effettuo tagli verticali aggiuntivi + if TailCutType.bNeedVerticalAddedCuts then + local sSpecNotes = EgtIf( TailCutType.bSplit, 'Presplit;', 'Precut;') + local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw, sSpecNotes) + if not bOk then return bOk, sErr end + end + if i == 1 and dStartOffset then + dCutOffset = dStartOffset + end + local sNotes + if TailCutType.bSplit then + sNotes = EgtIf( i == 1, 'Split;', 'Presplit;') + else + sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') + end + -- se primo taglio da sopra e PF o ONE richiedo risalita preliminare a Zmax + if i == nCuts and TailCutType.bHorizCut and BD.C_SIMM and not BD.DOWN_HEAD then + sNotes = EgtSetValInNotes( sNotes, 'StartZmax', 2) + end + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting1Data.sCutting, Cutting1Data.dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw) + if not bOk then return false, sErr end + end + -- altrimenti necessari tagli da sopra e sotto con testa opportuna + else + -- verifico esistenza della lavorazione con lama da sotto + if not Cutting2Data.sCutting then + local sErr = 'Error : cutting H2 not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- verifico che le due lame riescano a lavorare la sezione + local dDimZ = b3Raw:getDimZ() + local dExtra = Cutting1Data.dMaxVertDepth + Cutting2Data.dMaxDepth - dDimZ + if ( dExtra - 2 * BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL < 0) and not TailCutType.bBigSectionCut then + local sErr = 'Error : section too big for tail cut' + EgtOutLog( sErr) + return false, sErr + end + -- calcolo extra taglio ed accorciamento + local dCutExtra = -Cutting2Data.dMaxDepth + dExtra / 2 + BD.CUT_EXTRA_MIN + local dCutExtra2 = -Cutting1Data.dMaxVertDepth + dExtra / 2 + BD.CUT_EXTRA_MIN + local dAccStart = 0 + -- limiti da sotto + local dVzLimDwnUp + if BD.TURN then dVzLimDwnUp = -2 end + -- taglio a zero (con lama) per evitare problemi con grezzo più lungo del previsto. Se BigSection il pretaglio è già stato fatto. + if not TailCutType.bBigSectionCut and BD.PRECUT_TAIL and TailCutType.bNeedVerticalAddedCuts then + dStartOffset = dLenEndRaw + local bOkPrecut, sErrPrecut = MakeStandardCuts( Proc, b3Raw, 1, 0, PrecutType, Cutting1Data, Cutting2Data, dStartOffset) + if not bOkPrecut then + return false, sErrPrecut + end + end + -- eseguo i tagli da sotto necessari + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsetBetweenCuts + if i == 1 and dStartOffset then + dCutOffset = dStartOffset + end + local sNotes = EgtIf( TailCutType.bSplit, 'Presplit;', 'Precut;') + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting2Data.sCutting, Cutting2Data.dSawDiam, MCH_MILL_FU.ORTHO_TOP, dVzLimDwnUp, dCutExtra2, BD.CUT_SIC, dCutOffset, dAccStart, 0, sNotes, b3Raw, nil, true) + if not bOk then return false, sErr end + end + -- eseguo i tagli da sopra necessari + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsetBetweenCuts + if i == 1 and dStartOffset then + dCutOffset = dStartOffset + end + -- se trave larga effettuo tagli verticali aggiuntivi + if TailCutType.bNeedVerticalAddedCuts then + local sSpecNotes = EgtIf( TailCutType.bSplit, 'Presplit;', 'Precut;') + local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw, sSpecNotes) + if not bOk then return bOk, sErr end + end + local sNotes + if TailCutType.bSplit then + sNotes = EgtIf( i == 1, 'Split;', 'Presplit;') + else + sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') + end + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting1Data.sCutting, Cutting1Data.dSawDiam, MCH_MILL_FU.ORTHO_DOWN, dVzLimDwnUp, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, 0, sNotes, b3Raw) + if not bOk then return false, sErr end + end + end + + return true +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrStd, bPreMove, vtMove, dOvmTail) @@ -290,7 +560,7 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt -- inserimento smussi local nOriId = EgtGetInfo( Proc.Id, 'ORI', 'i') if nOriId then - local bOkc, sErrC = MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmHead) + local bOkc, sErrC = MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmTail) if not bOkc then return bOkc, sErrC end end -- recupero la lavorazione @@ -327,6 +597,20 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt dSawThick2 = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dSawThick2 end end + -- recupero dati utensile della sega a catena più lunga a disposizione + local sSawing = ML.FindSawing( 'SawingForSplitting', nil, nil, 'Longest') + if not sSawing then + sSawing = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + end + local dChainSawMaxMat = 0 + local dChainSawLen = 0 + if EgtMdbSetCurrMachining( sSawing or '') then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dChainSawMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dChainSawMaxMat + dChainSawLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dChainSawLen + end + end -- caratteristiche taglio local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, dSawMaxDepth, abs( BD.MAX_DIM_HTCUT_HBEAM)) local bBigSectionCut = ( b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) and @@ -336,8 +620,6 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt local bDoubleCut = ( not bHorizCut and not bDoubleHorizCut and b3Raw:getDimY() > dDimYRef - BD.CUT_EXTRA + 10 * GEO.EPS_SMALL) -- dati geometrici del taglio local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) - -- flag di lavorazione faccia - local nOrthoOpposite = EgtIf( bHorizCut, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_BACK) -- separazione solo se esiste grezzo successivo con pezzi o scaricabile local nNextRawId = EgtGetNextRawPart( nRawId) local bSplit = ( nNextRawId and ( EgtGetPartInRawPartCount( nNextRawId) > 0 or EgtGetRawPartBBox( nNextRawId):getDimX() >= BD.MinRaw)) @@ -345,8 +627,6 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt local dLenEndRaw = dOvmTail local nCuts = 1 local dOffsL = 0 - local _, dimH, dimV = BL.GetFaceHvRefDim( Proc.Id, 0, b3Raw) - local dMinTailScrapForAdditionalCuts = 10.123 if not bSplit then -- cerco grezzo successivo che sia nella fase if nNextRawId and EgtVerifyRawPartPhase( nNextRawId, nPhase) then @@ -356,94 +636,38 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt dOffsL = dLenEndRaw / nCuts -- aggiorno ingombro del grezzo corrente con quello del successivo b3Raw:Add( b3NextRaw) + else + dLenEndRaw = 0 end end + -- determino la necessità di tagli aggiuntivi + local dMinTailScrapForAdditionalCuts = 10.123 + local bNeedVerticalAddedCuts = not bSplit and ( Proc.Face[1].WidthTrimmed > BD.MAX_LEN_DICE) and ( dLenEndRaw > dMinTailScrapForAdditionalCuts - 10 * GEO.EPS_SMALL) + local bNeedHorizontalAddedCuts = not bSplit and ( Proc.Face[1].HeightTrimmed > BD.MAX_LEN_DICE) and not bBigSectionCut and ( dLenEndRaw > dMinTailScrapForAdditionalCuts - 10 * GEO.EPS_SMALL) + -- dati lavorazioni sopra e sotto + local Cutting1Data = { sCutting = sCutting, dSawDiam = dSawDiam, dMaxDepth = dSawMaxDepth, dSawThick = dSawThick, dMaxVertDepth = dMaxVertDepth} + local Cutting2Data = { sCutting = sCutting2, dSawDiam = dSawDiam2, dMaxDepth = dSawMaxDepth2, dSawThick = dSawThick2} + local SawingData = { sSawing = sSawing, dChainSawMaxMat = dChainSawMaxMat, dChainSawLen = dChainSawLen, bSplit = bSplit} + -- dati sul taglio di coda da effettuare + local TailCutType = { bBigSectionCut = bBigSectionCut, bHorizCut = bHorizCut, bDoubleHorizCut = bDoubleHorizCut, bDoubleCut = bDoubleCut, bSplit = bSplit, bNeedVerticalAddedCuts = bNeedVerticalAddedCuts, bNeedHorizontalAddedCuts = bNeedHorizontalAddedCuts} -- se taglio per pezzi alti e larghi local nNewPhase = 0 if bBigSectionCut then local bFinishingNeeded = false if bSplit then - -- recupero dati utensile della sega a catena più lunga a disposizione - local sSawing = ML.FindSawing( 'SawingForSplitting', nil, nil, 'Longest') - if not sSawing then - sSawing = ML.FindSawing( 'Sawing', nil, nil, 'Longest') - end - local dChainSawMaxMat = 0 - local dChainSawLen = 0 - if EgtMdbSetCurrMachining( sSawing or '') then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dChainSawMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dChainSawMaxMat - dChainSawLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dChainSawLen - end - end - - local bigSectionSplitType - -- se pezzo non troppo alto, taglio singolo da sopra - if b3Raw:getDimZ() + BD.CUT_EXTRA_MIN < dChainSawMaxMat + 10 * GEO.EPS_SMALL then - bigSectionSplitType = "single horizontal" - -- se pezzo non troppo largo, taglio singolo da davanti - elseif b3Raw:getDimY() + BD.CUT_EXTRA_MIN < min( dChainSawMaxMat, dChainSawLen - BD.C_SIMM_ENC) + 10 * GEO.EPS_SMALL then - bigSectionSplitType = "single vertical" - -- se pezzo non troppo largo, tagli dai due fianchi (dietro e davanti) - elseif 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN < min( dChainSawMaxMat, dChainSawLen - BD.C_SIMM_ENC) + 10 * GEO.EPS_SMALL then - bigSectionSplitType = "double vertical" - -- altrimenti taglio con sega a catena da sopra e con lama da sotto - elseif BD.DOWN_HEAD and ( b3Raw:getDimZ() + BD.CUT_EXTRA_MIN < dSawMaxDepth2 + dChainSawMaxMat + 10 * GEO.EPS_SMALL) then - bigSectionSplitType = "double horizontal" - end - - -- assegno offset in lunghezza - local dOffs = 0 + -- assegno offset in lunghezza + local dTailOffset = 0 if dOvmTail > BD.OVM_CHAIN_HBEAM then - dOffs = dOvmTail - BD.OVM_CHAIN_HBEAM + dTailOffset = dOvmTail - BD.OVM_CHAIN_HBEAM bFinishingNeeded = true end - - -- in base alle scelte precedenti, applico le lavorazioni - if bigSectionSplitType == "single horizontal" then - local dCutDepth = b3Raw:getDimZ() + BD.CUT_EXTRA_MIN - local sNotesSplit = 'Split;' - -- verifico se sega a catena lunga e devo quindi estendere ingresso e uscita perchè è probabile che non riesca a ruotare sopra al pezzo - local bExtendStartEnd - local dMinLengthLongChainSaw = 630 - if dChainSawLen > dMinLengthLongChainSaw - 10 * GEO.EPS_SMALL then - bExtendStartEnd = true - end - local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_TOP, dCutDepth, sNotesSplit, dOffs, bExtendStartEnd) - if not bOk then return bOk, sErr, nNewPhase end - elseif bigSectionSplitType == "single vertical" then - local dCutDepth = b3Raw:getDimY() + BD.CUT_EXTRA_MIN - local sNotesSplit = 'Split;' - local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_FRONT, dCutDepth, sNotesSplit, dOffs) - if not bOk then return bOk, sErr, nNewPhase end - elseif bigSectionSplitType == "double vertical" then - local dCutDepth = 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN - local sNotesSplit = 'Presplit;' - local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_BACK, dCutDepth, sNotesSplit, dOffs) - if not bOk then return bOk, sErr, nNewPhase end - sNotesSplit = 'Split;' - bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_FRONT, dCutDepth, sNotesSplit, dOffs) - if not bOk then return bOk, sErr, nNewPhase end - elseif bigSectionSplitType == "double horizontal" then - -- sega a catena da sopra - local dChainSawCutDepth = b3Raw:getDimZ() + BD.CUT_EXTRA_MIN - dSawMaxDepth2 - local sNotesSplit = 'Presplit;' - local bOk, sErr = MakeSplitByChainSaw( Proc.Id, sSawing, MCH_MILL_FU.PARAL_TOP, dChainSawCutDepth, sNotesSplit, dOffs) - if not bOk then return bOk, sErr, nNewPhase end - -- lama da sotto - local dCutExtra = -dChainSawCutDepth + BD.CUT_EXTRA_MIN - local dVzLimDwnUp - if BD.TURN then dVzLimDwnUp = -2 end - local sNotes = 'Split;' - local bMaximizeVerticalDepth = true - bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting2, dSawDiam2, MCH_MILL_FU.ORTHO_TOP, dVzLimDwnUp, dCutExtra, BD.CUT_SIC, dOffs, 0, 0, sNotes, b3Raw, nil, bMaximizeVerticalDepth) - if not bOk then return false, sErr end - -- se è comunque troppo grande per essere separato, esco - else - local sErr = 'Error : section too big for splitting' - EgtOutLog( sErr) - return false, sErr, -1 + -- split per grande sezione + local bOk, sErr, nNewPhase2 = ProcessSplit.MakeBigSectionSplitting( Proc, b3Raw, dTailOffset, SawingData, Cutting2Data) + if nNewPhase2 then + nNewPhase = nNewPhase2 + end + if not bOk then + return bOk, sErr, nNewPhase end -- se necessaria finitura, creo nuova fase if bFinishingNeeded then @@ -491,12 +715,20 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt else dMaxElev = Proc.Box:getMax():getX() - b3Raw:getMin():getX() end + -- taglio a zero (con sega a catena o mix catena + lama) per evitare problemi con grezzo più lungo del previsto + if BD.PRECUT_TAIL and not bSplit then + local dTailOffset = dLenEndRaw + local bOkPrecut, sErrPrecut = ProcessSplit.MakeBigSectionSplitting( Proc, b3Raw, dTailOffset, SawingData, Cutting2Data) + if not bOkPrecut then + return false, sErrPrecut + end + end -- se finitura con lama if nQ05 < 2 or ( not bSplit and dMaxElev > dSawThickCheck) then -- controllo se è necessario un taglio con dicing o si deve proseguire ai casi standard if bSplit or dMaxElev > dSawThickCheck then local bOk, sErr - if not bSplit and ( dimH > BD.MAX_LEN_DICE) and ( dLenEndRaw > dMinTailScrapForAdditionalCuts - 10 * GEO.EPS_SMALL) then + if bNeedVerticalAddedCuts then -- ad ogni offset di taglio dovrò fare prima i tagli verticali e poi i cubetti for i = nCuts, 1, -1 do local nAddGrpId = BL.GetAddGroup( Proc.PartId) @@ -561,157 +793,11 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt return true, nil, nNewPhase end end - -- se tagli standard - if not bDoubleHorizCut then - -- calcolo extra taglio ed accorciamento - local dCutExtra = 0 - local dAccStart = 0 - local dAccEnd = 0 - if bBigSectionCut and BD.C_SIMM then - -- qui arrivano sezioni molto grandi su macchine tipo PF con materiale da asportare inferiore allo spessore lama - local dSawRad = dSawDiam / 2 - dCutExtra = - ( b3Raw:getDimY() - dSawRad) - dAccEnd = dSawRad - elseif b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then - dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA) - else - dCutExtra = - ( b3Raw:getDimY() - dSawMaxDepth) - local dSawRad = dSawDiam / 2 - -- distanza in Y tra il centro della lama e l'intersezione tra la lama stessa e la massima Z della trave, + extra - -- se taglio doppio l'intersezione sarà in mezzeria, se taglio singolo sarà all'estremo opposto della trave - local dKL = dSawRad - dSawMaxDepth + EgtIf( bDoubleCut, b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN, b3Raw:getDimY() + BD.CUT_EXTRA) - -- lunghezza minima del percorso di lavorazione, in caso accorciamento porti a lunghezza negativa - local dMinSawingLength = 5 - if BD.C_SIMM then - dAccEnd = sqrt( max( dSawRad * dSawRad - dKL * dKL, 0)) - -- non posso comunque accorciare più della dimensione della geometria, quindi in caso allungo entrata - if dAccEnd > b3Raw:getDimZ() - 100 * GEO.EPS_SMALL then - dAccStart = b3Raw:getDimZ() - dAccEnd - dMinSawingLength - end - else - dAccStart = sqrt( max( dSawRad * dSawRad - dKL * dKL, 0)) - -- non posso comunque accorciare più della dimensione della geometria, quindi in caso allungo uscita - if dAccStart > b3Raw:getDimZ() - 100 * GEO.EPS_SMALL then - dAccEnd = b3Raw:getDimZ() - dAccStart - dMinSawingLength - end - end - end - -- per travi alte faccio faccio dei tagli orizzontali aggiuntivi - local bAreHorizontalCutsNeeded = not bSplit and ( dimV > BD.MAX_LEN_DICE) and not bBigSectionCut and ( dLenEndRaw > dMinTailScrapForAdditionalCuts - 10 * GEO.EPS_SMALL) - if bAreHorizontalCutsNeeded then - local nHorizontalCuts = ceil ( dimV / BD.MAX_DIM_DICE) - 1 - local dHorizontalSliceHeight = dimV / ( nHorizontalCuts + 1) - for i = nCuts, 1, -1 do - local dCutXOffset = ( i - 1) * dOffsL - -- tagli orizzontali - for j = nHorizontalCuts, 1, -1 do - local nFaceUse = MCH_MILL_FU.PARAL_DOWN - local dHorizontalCutOffset = dHorizontalSliceHeight * -j - local bForceTangentLeadInOut = BD.PRESS_ROLLER - local bOk, sErr = Fbs.MakeOne( Proc.Id, 0 , sCutting, dSawDiam, nFaceUse, nil, -0.1 - dCutXOffset, BD.CUT_SIC, dHorizontalCutOffset, 0, 0, 'Precut;', b3Raw, nil, nil, nil, bForceTangentLeadInOut) - if not bOk then return false, sErr end - end - -- se necessario taglio verticale doppio, eseguo l'opposto - if bDoubleCut then - -- gli accorciamenti vanno invertiti per il taglio opposto - local dAccStartDoubleCut, dAccEndDoubleCut = dAccEnd, dAccStart - local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_FRONT, nil, dCutExtra, BD.CUT_SIC, dCutXOffset, dAccStartDoubleCut, dAccEndDoubleCut, 'Precut;', b3Raw, true) - if not bOk then return false, sErr end - end - -- taglio verticale - local sInfo = 'PreCut;' - if i == 1 then sInfo = 'Cut;' end - local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutXOffset, dAccStart, dAccEnd, sInfo, b3Raw) - if not bOk then return false, sErr end - end - return true, sWarn, nNewPhase - end + local bOk, sErr = MakeStandardCuts( Proc, b3Raw, nCuts, dOffsL, TailCutType, Cutting1Data, Cutting2Data, nil, dLenEndRaw) - -- se necessari tagli in doppio, eseguo gli opposti - if bDoubleCut then - -- gli accorciamenti vanno invertiti per il taglio opposto - local dAccStartDoubleCut, dAccEndDoubleCut = dAccEnd, dAccStart - for i = nCuts, 1, -1 do - local dCutOffset = ( i - 1) * dOffsL - local sNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') - local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_FRONT, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStartDoubleCut, dAccEndDoubleCut, sNotes, b3Raw, true) - if not bOk then return false, sErr end - end - end - -- eseguo i tagli necessari - for i = nCuts, 1, -1 do - local dCutOffset = ( i - 1) * dOffsL - -- se trave larga effettuo tagli verticali aggiuntivi - if not bSplit and ( dimH > BD.MAX_LEN_DICE) and ( dLenEndRaw > dMinTailScrapForAdditionalCuts - 10 * GEO.EPS_SMALL) then - local sSpecNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') - local bOk, sErr = AddVerticalPreCuts( Proc, sCutting, dCutOffset, b3Raw, sSpecNotes) - if not bOk then return bOk, sErr end - end - local sNotes - if bSplit then - sNotes = EgtIf( i == 1, 'Split;', 'Presplit;') - else - sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') - end - -- se primo taglio da sopra e PF o ONE richiedo risalita preliminare a Zmax - if i == nCuts and bHorizCut and BD.C_SIMM and not BD.DOWN_HEAD then - sNotes = EgtSetValInNotes( sNotes, 'StartZmax', 2) - end - local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw) - if not bOk then return false, sErr end - end - -- altrimenti necessari tagli da sopra e sotto con testa opportuna - else - -- verifico esistenza della lavorazione con lama da sotto - if not sCutting2 then - local sErr = 'Error : cutting H2 not found in library' - EgtOutLog( sErr) - return false, sErr - end - -- verifico che le due lame riescano a lavorare la sezione - local dDimZ = b3Raw:getDimZ() - local dExtra = dMaxVertDepth + dSawMaxDepth2 - dDimZ - if ( dExtra - 2 * BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL < 0) and not bBigSectionCut then - local sErr = 'Error : section too big for tail cut' - EgtOutLog( sErr) - return false, sErr - end - -- calcolo extra taglio ed accorciamento - local dCutExtra = -dSawMaxDepth2 + dExtra / 2 + BD.CUT_EXTRA_MIN - local dCutExtra2 = -dMaxVertDepth + dExtra / 2 + BD.CUT_EXTRA_MIN - local dAccStart = 0 - -- limiti da sotto - local dVzLimDwnUp - if BD.TURN then dVzLimDwnUp = -2 end - -- eseguo i tagli da sotto necessari - for i = nCuts, 1, -1 do - local dCutOffset = ( i - 1) * dOffsL - local sNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') - local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting2, dSawDiam2, MCH_MILL_FU.ORTHO_TOP, dVzLimDwnUp, dCutExtra2, BD.CUT_SIC, dCutOffset, dAccStart, 0, sNotes, b3Raw, nil, true) - if not bOk then return false, sErr end - end - -- eseguo i tagli da sopra necessari - for i = nCuts, 1, -1 do - local dCutOffset = ( i - 1) * dOffsL - -- se trave larga effettuo tagli verticali aggiuntivi - if not bSplit and ( dimH > BD.MAX_LEN_DICE) and ( dLenEndRaw > dMinTailScrapForAdditionalCuts - 10 * GEO.EPS_SMALL) then - local sSpecNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') - local bOk, sErr = AddVerticalPreCuts( Proc, sCutting, dCutOffset, b3Raw, sSpecNotes) - if not bOk then return bOk, sErr end - end - local sNotes - if bSplit then - sNotes = EgtIf( i == 1, 'Split;', 'Presplit;') - else - sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') - end - local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_DOWN, dVzLimDwnUp, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, 0, sNotes, b3Raw) - if not bOk then return false, sErr end - end - end - return true, nil, nNewPhase -end + return bOk, sErr, nNewPhase +end --------------------------------------------------------------------- return ProcessSplit