DataBeam :

- correzioni varie.
This commit is contained in:
Dario Sassi
2020-04-05 22:21:45 +00:00
parent 511201107e
commit 17870b5dee
4 changed files with 88 additions and 118 deletions
+67 -101
View File
@@ -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