From 17870b5deeadfe72e60d65acb0f3aa5097cab676 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sun, 5 Apr 2020 22:21:45 +0000 Subject: [PATCH] DataBeam : - correzioni varie. --- LuaLibs/BeamExec.lua | 6 +- LuaLibs/BeamLib.lua | 29 ++++-- LuaLibs/ProcessLongDoubleCut.lua | 168 ++++++++++++------------------- ShowSolid.lua | 3 +- 4 files changed, 88 insertions(+), 118 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 1a7d145..ab49133 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2020/04/02 +-- BeamExec.lua by Egaltech s.r.l. 2020/04/04 -- Libreria esecuzione lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/09/04 Corretto controllo feature di testa e coda con sovramateriale di testa elevato. @@ -656,10 +656,8 @@ local function AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3 bOk, sErr = LongCut.Make( Proc, nPhase, nRawId, nPartId) -- se doppio taglio longitudinale ( 0-012-X) elseif Long2Cut.Identify( Proc) then - -- determino il numero di facce longitudinali e limite - local nLongFct, nSideFct = Long2Cut.IdentifyFaces( Proc) -- se due facce longitudinali, eseguo doppio taglio longitudinale - if nLongFct == 2 then + if Long2Cut.GetLongFacesCount( Proc) == 2 then bOk, sErr = Long2Cut.Make( Proc, nPhase, nRawId, nPartId) -- altrimenti eseguo singolo taglio longitudinale else diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 1ff0bb9..e85a50d 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2020/03/20 +-- BeamLib.lua by Egaltech s.r.l. 2020/04/04 -- Libreria globale per Travi -- Tabella per definizione modulo @@ -342,6 +342,22 @@ function BeamLib.GetBoxFaceNorm( b3Box, ptP, vtV) end end +--------------------------------------------------------------------- +function BeamLib.GetFaceElevation( nSurfId, nFac, nPartId) + local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFac, GDB_ID.ROOT) + if not ptC or not vtN then return 0 end + local frOCS = Frame3d( ptC, vtN) ; + local b3Box = EgtGetBBoxRef( nSurfId, GDB_BB.STANDARD, frOCS) + local dElev = b3Box:getDimZ() + if nPartId then + local _, dCenElev = BeamLib.GetPointDirDepth( nPartId, ptC, vtN) + if dCenElev and dCenElev > dElev then + dElev = dCenElev + end + end + return dElev +end + --------------------------------------------------------------------- function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId, bCompare3Fc) -- recupero il numero di facce @@ -443,16 +459,7 @@ function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId, bCompare3Fc) local nFacOpt, nFacOpt2 local dMinElev, dMinElev2 = GEO.INFINITO, GEO.INFINITO for i = 1, #nFacInd do - local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacInd[i], GDB_ID.ROOT) - local frOCS = Frame3d( ptC, vtN) ; - local b3Box = EgtGetBBoxRef( nSurfId, GDB_BB.STANDARD, frOCS) - local dElev = b3Box:getDimZ() - if nPartId then - local _, dCenElev = BeamLib.GetPointDirDepth( nPartId, ptC, vtN) - if dCenElev and dCenElev > dElev then - dElev = dCenElev - end - end + local dElev = BeamLib.GetFaceElevation( nSurfId, nFacInd[i], nPartId) if dElev < dMinElev then if dMinElev < dMinElev2 then nFacOpt2 = nFacOpt diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index 2ee9f34..34b629a 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -1,4 +1,4 @@ --- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2020/02/02 +-- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2020/04/04 -- Gestione calcolo doppio taglio longitudinale per Travi -- Tabella per definizione modulo @@ -27,61 +27,50 @@ function ProcessLong2Cut.Classify( Proc) end --------------------------------------------------------------------- --- Classificazione della feature, calcolo il numero di facce longitudinali e limite. --- Ritorna due valori : --- il primo indica il numero di facce longitudinali --- il secondo indica quante e quali facce limite sono presenti con questa codifica --- 0: nessuna faccia limite; 1: faccia/e limite a destra (X-); 2: faccia/e limite a sinistra (X+); 3: due facce limite. -function ProcessLong2Cut.IdentifyFaces( Proc, bDefineFaces) - -- verifico le normali delle facce - local nFaceLong = 0 +function ProcessLong2Cut.GetLongFacesCount( Proc) + local nLongFaces = 0 + local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) + for i = 1, nFacetCnt do + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT) + if abs( vtN:getX()) < GEO.EPS_SMALL then + nLongFaces = nLongFaces + 1 + end + end + return nLongFaces +end + +--------------------------------------------------------------------- +-- Identificazione delle facce della feature. +-- Ritorna quattro valori : +-- flag delle facce limitanti (0= no, 1= a destra, 2= a sinistra, 3= entrambe) +-- vettore indici facce longitudinali +-- vettore dei centri delle facce longitudinali +-- vettore dei centri delle normali +function ProcessLong2Cut.IdentifyFaces( Proc) + local nFaceLimit = 0 local tFaceLong = {} - local tFaceLimit = {} local tptC = {} local tvtN = {} - local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) - local nLong = 0 - local nLimit = 0 - local bLimitPos - local bLimitNeg + -- verifico le normali delle facce + local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) for i = 1, nFacetCnt do local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT) -- se è una faccia limite a sinistra if vtN:getX() > GEO.EPS_SMALL then - if not bLimitPos then - nFaceLimit = nFaceLimit + 2 - bLimitPos = true - end - -- se devo restituire una tabella con le facce limite - if bDefineFaces then - nLimit = nLimit + 1 - tFaceLimit[nLimit] = i-1 - end + nFaceLimit = nFaceLimit + 2 -- se è una faccia limite a destra elseif vtN:getX() < -GEO.EPS_SMALL then - if not bLimitNeg then - nFaceLimit = nFaceLimit + 1 - bLimitNeg = true - end - -- se devo restituire una tabella con le facce limite - if bDefineFaces then - nLimit = nLimit + 1 - tFaceLimit[nLimit] = i-1 - end + nFaceLimit = nFaceLimit + 1 -- altrimenti è una faccia longitudinale else - nFaceLong = nFaceLong + 1 - -- se devo restituire una tabella con le facce longitudinali - if bDefineFaces then - nLong = nLong + 1 - tFaceLong[nLong] = i-1 - tptC[nLong], tvtN[nLong] = EgtSurfTmFacetCenter( Proc.Id, (i-1), GDB_ID.ROOT) - end + local nInd = #tFaceLong + 1 + tFaceLong[nInd] = i-1 + tptC[nInd], tvtN[nInd] = EgtSurfTmFacetCenter( Proc.Id, ( i-1), GDB_ID.ROOT) end end - return nFaceLong, nFaceLimit, tFaceLong, tFaceLimit, tptC, tvtN + return nFaceLimit, tFaceLong, tptC, tvtN end --------------------------------------------------------------------- @@ -97,15 +86,10 @@ local function MakeSideFace( nId, nFac, nSide, sMilling, dToolDiam) -- aggiungo geometria EgtSetMachiningGeometry( {{ nId, nFac}}) -- lato di lavoro e inversione - EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, false) EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) -- uso della faccia - local nFaceUse = MCH_MILL_FU.PARAL_DOWN - if nSide == -2 then - nFaceUse = MCH_MILL_FU.PARAL_BACK - elseif nSide == 2 then - nFaceUse = MCH_MILL_FU.PARAL_FRONT - end + local nFaceUse = EgtIf( nSide == 1, MCH_MILL_FU.ORTHO_RIGHT, MCH_MILL_FU.ORTHO_LEFT) EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- annullo offset radiale EgtSetMachiningParam( MCH_MP.OFFSR, 0) @@ -182,16 +166,11 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) - -- dati delle facce - local nFaceLimit = 0 - local tFaceLong = {} - local tFaceLimit = {} - local ptC = {} - local vtN = {} - -- carico i dati delle face già inserite nelle opportune tabelle - _, nFaceLimit, tFaceLong, tFaceLimit, ptC, vtN = ProcessLong2Cut.IdentifyFaces( Proc, true) - local dLen = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD):getDimX() + -- carico i dati delle face già inserite nelle opportune tabelle + local nFaceLimit, tFaceLong, ptC, vtN = ProcessLong2Cut.IdentifyFaces( Proc) + local dLen = Proc.Box:getDimX() + -- verifico posizione (+1=sopra, -1=sotto, 0=sui lati) local nSide = 0 if vtN[1]:getZ() > -10 * GEO.EPS_SMALL and vtN[2]:getZ() > -10 * GEO.EPS_SMALL then @@ -199,6 +178,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) elseif vtN[1]:getZ() < -10 * GEO.EPS_SMALL and vtN[2]:getZ() < -10 * GEO.EPS_SMALL then nSide = -1 end + -- angolo diedro per stabilire se taglio convesso local bInt, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, tFaceLong[1], tFaceLong[2], GDB_ID.ROOT) local bConvex @@ -238,8 +218,8 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) _, _, vWidth[2] = BL.GetFaceHvRefDim( Proc.Id, tFaceLong[2]) local sWarn - -- Se ho 2 face longitudinali e non limitato da altre facce e da sopra e richiesto con doppio taglio di lama - if #tFaceLong == 2 and Proc.Fct == 2 and nSide == 1 and EgtGetInfo( Proc.Id, 'Q01', 'i') == 1 then + -- Se senza facce limitanti, da sopra e richiesto con doppio taglio di lama + if nFaceLimit == 0 and nSide == 1 and EgtGetInfo( Proc.Id, 'Q01', 'i') == 1 then -- recupero la lavorazione local sCutting = ML.FindCutting( 'HeadSide') if not sCutting then @@ -425,22 +405,20 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) end -- se chiuso e corto, applico svuotatura con fresa opportuna if nFaceLimit == 3 and Proc.Box:getDimX() < 2 * dToolDiam then - -- ottengo le facce con il maggior numero di adiacenze e l'elevazione relativa - local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) - if nFacInd > 0 and dFacElev then - local bOk, sErr = MakeByPocketing( Proc, nPhase, nRawId, nPartId, nFacInd, dFacElev) - if not bOk then return bOk, sErr end - end - if nFacInd2 and nFacInd2 > 0 and dFacElev2 then - return MakeByPocketing( Proc, nPhase, nRawId, nPartId, nFacInd2, dFacElev2) - end + -- svuotatura della prima faccia longitudinale + local dFacElev = BL.GetFaceElevation( Proc.Id, tFaceLong[1], nPartId) + local bOk, sErr = MakeByPocketing( Proc, nPhase, nRawId, nPartId, tFaceLong[1], dFacElev) + -- svuotatura della seconda faccia longitudinale + if not bOk then return bOk, sErr end + local dFacElev2 = BL.GetFaceElevation( Proc.Id, tFaceLong[2], nPartId) + return MakeByPocketing( Proc, nPhase, nRawId, nPartId, tFaceLong[2], dFacElev2) end -- determino gli estremi local dStartDist = 0 local dStartAccDist = BD.LONGCUT_ENDLEN local bStartFixed = true - -- se ho facce limite a destra - if nFaceLimit % 2 == 1 then + -- se ho faccia limite a destra + if nFaceLimit == 1 or nFaceLimit == 3 then dStartDist = dToolDiam / 2 dStartAccDist = BD.LONGCUT_MAXLEN bStartFixed = false @@ -448,8 +426,8 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) local dEndDist = 0 local dEndAccDist = BD.LONGCUT_ENDLEN local bEndFixed = true - -- se ho facce limite a sinistra - if nFaceLimit >= 2 then + -- se ho faccia limite a sinistra + if nFaceLimit == 2 or nFaceLimit == 3 then dEndDist = dToolDiam / 2 dEndAccDist = BD.LONGCUT_MAXLEN bEndFixed = false @@ -491,18 +469,18 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) dEndAccDist = 0 end end + -- se facce ortogonali (concave), lavoro solo quella con versore maggiormente verso l'alto + local nIni, nFin = 1, 2 + if bOrtho then + if vtN[vOrd[1]]:getZ() >= vtN[vOrd[2]]:getZ() then + nFin = 1 + else + nIni = 2 + end + end -- ciclo sulle parti local nM = 0 for j = 1, nC do - -- se facce ortogonali (concave), lavoro solo quella con versore maggiormente verso l'alto - local nIni, nFin = 1, 2 - if bOrtho then - if vtN[vOrd[1]]:getZ() >= vtN[vOrd[2]]:getZ() then - nFin = 1 - else - nIni = 2 - end - end -- su entrambe le facce for i = nIni, nFin do -- Limitazioni della lavorazione @@ -565,25 +543,13 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) return false, sErr end end - end - -- se facce principali convesse, eventuale lavorazione della faccia limitante l'inizio (a destra) - if bConvex and j == 1 and not bStartFixed then - local vtIni = -X_AX() - for i = 1, #tFaceLimit do - local _, vtN = EgtSurfTmFacetCenter( Proc.Id, tFaceLimit[i], GDB_ID.ROOT) - if vtIni * vtN > 0 then - MakeSideFace( Proc.Id, tFaceLimit[i], nSide, sMilling, dToolDiam) - end + -- se facce principali convesse, eventuale lavorazione della faccia limitante l'inizio (a destra) + if bConvex and j == 1 and not bStartFixed then + MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], 1, sMilling, dToolDiam) end - end - end - -- se facce principali convesse, eventuale lavorazione della faccia limitante la fine (a sinistra) - if bConvex and not bEndFixed then - local vtFin = X_AX() - for i = 1, #tFaceLimit do - local _, vtN = EgtSurfTmFacetCenter( Proc.Id, tFaceLimit[i], GDB_ID.ROOT) - if vtFin * vtN > 0 then - MakeSideFace( Proc.Id, tFaceLimit[i], nSide, sMilling, dToolDiam) + -- se facce principali convesse, eventuale lavorazione della faccia limitante la fine (a sinistra) + if bConvex and j == nC and not bEndFixed then + MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], -1, sMilling, dToolDiam) end end end @@ -615,7 +581,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) local dStartAccDist = BD.LONGCUT_ENDLEN local bStartFixed = true -- se ho facce limite a destra - if nFaceLimit % 2 == 1 then + if nFaceLimit == 1 or nFaceLimit == 3 then dStartDist = dToolDiam / 2 dStartAccDist = BD.LONGCUT_MAXLEN bStartFixed = false @@ -624,7 +590,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) local dEndAccDist = BD.LONGCUT_ENDLEN local bEndFixed = true -- se ho facce limite a sinistra - if nFaceLimit >= 2 then + if nFaceLimit == 2 or nFaceLimit == 3 then dEndDist = dToolDiam / 2 dEndAccDist = BD.LONGCUT_MAXLEN bEndFixed = false diff --git a/ShowSolid.lua b/ShowSolid.lua index d8278d0..3a549b3 100644 --- a/ShowSolid.lua +++ b/ShowSolid.lua @@ -26,7 +26,7 @@ local function RegularizeTriMesh( SurfId, DestGrpId, dStep) end -- box della superficie local b3Surf = EgtGetBBox( SurfId, GDB_BB.STANDARD) - if b3Surf:getDimX() < 2 * dStep then + if not b3Surf or b3Surf:isEmpty() or b3Surf:getDimX() < 2 * dStep then return SurfId end -- recupero le facce e le divido in X @@ -88,7 +88,6 @@ if not SolidLy then end local SolidId = EgtGetFirstNameInGroup( SolidLy, 'Solid') if not SolidId then - --SolidId = EgtCopyGlob( BoxId, SolidLy) SolidId = EgtSurfTmBBox( SolidLy, EgtGetBBoxGlob( BoxId, GDB_BB.STANDARD), true, GDB_RT.GLOB) EgtSetName( SolidId, 'Solid') EgtSetColor( SolidId, Color3d( 228, 196, 64))