From 60486c46c9e46a6d9dad81a721e332ded36d081d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 21 Jul 2020 16:14:23 +0000 Subject: [PATCH] =?UTF-8?q?DataWall=20:=20-=20gestione=20modalit=C3=A0=20C?= =?UTF-8?q?loud=20(rototraslazione=20del=20grezzo=20per=20centrare=20il=20?= =?UTF-8?q?contorno=20della=20nuvola=20di=20punti=20ottenuta=20per=20scans?= =?UTF-8?q?ione=20in=20macchina).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BatchProcess.lua | 67 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/BatchProcess.lua b/BatchProcess.lua index e7aa57e..9c56ec1 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2020/07/07 +-- BatchProcess.lua by Egaltech s.r.l. 2020/07/21 -- Gestione calcolo batch disposizione e lavorazioni per Pareti @@ -25,6 +25,8 @@ elseif WALL.FLAG == 3 then sFlag = 'CHECK' elseif WALL.FLAG == 4 then sFlag = 'CHECK+GENERATE' +elseif WALL.FLAG == 5 then + sFlag = 'CLOUD' elseif WALL.FLAG == 11 then sFlag = 'TOOLS' elseif WALL.FLAG == 12 then @@ -57,7 +59,7 @@ end -- Funzione per gestire visualizzazione dopo errore local function PostErrView( nErr, sMsg) - if nErr ~= 0 and ( WALL.FLAG == 1 or WALL.FLAG == 2) then + if nErr ~= 0 and ( WALL.FLAG == 1 or WALL.FLAG == 2 or WALL.FLAG == 5) then EgtSetView( SCE_VD.ISO_SW, false) EgtZoom( SCE_ZM.ALL) EgtOutBox( sMsg, 'BatchProcess (err=' .. tostring( nErr) .. ')', 'ERRORS') @@ -66,7 +68,7 @@ end -- Funzione per gestire visualizzazione dopo warning local function PostWarnView( nWarn, sMsg) - if nWarn ~= 0 and ( WALL.FLAG == 1 or WALL.FLAG == 2) then + if nWarn ~= 0 and ( WALL.FLAG == 1 or WALL.FLAG == 2 or WALL.FLAG == 5) then EgtSetView( SCE_VD.ISO_SW, false) EgtZoom( SCE_ZM.ALL) EgtOutBox( sMsg, 'BatchProcess (wrn=' .. tostring( nWarn) .. ')', 'WARNINGS') @@ -134,6 +136,7 @@ local sDir, sTitle, sExt = EgtSplitPath( WALL.FILE) local bBtl = ( string.upper( sExt or '') ~= '.NGE') local sNgeFile = sDir..sTitle..'.nge' local sBtmFile = sDir..sTitle..'.btm' +local sPntFile = sDir..sTitle..'.pnt' -- In generale va completamente riprocessato local bToProcess = true @@ -488,7 +491,6 @@ end -- *** Eseguo stima tempi *** EgtOutLog( ' +++ Estimating T&L >>>') if not EgtEstimate( '', 'EgtCAM5 - ' .. sNgeFile) then - WALL.ERR = 21 local _, sName, _ = EgtSplitPath( WALL.FILE) WALL.MSG = 'Error estimating production time : ' .. sName @@ -500,9 +502,64 @@ local Ttot = EgtGetInfo( EgtGetCurrMachGroup(), 'Ttot') local sTime = 'Total Time = ' .. EgtNumToString( Ttot, 1) EgtOutLog( sTime) --- Imposto la vista ISO 3d, se richiesto +-- Se modalità Cloud, importo la nuvola di punti +if WALL.FLAG == 5 then + EgtOutLog( ' +++ Importing Point Cloud >>>') + -- Creo gruppo Cloud nel gruppo di lavorazione + local nMGrpId = EgtGetCurrMachGroup() + local nCloudId = EgtGetFirstNameInGroup( nMGrpId or GDB_ID.NULL, 'Cloud') + if nCloudId then + EgtEmptyGroup( nCloudId) + else + nCloudId = EgtGroup( nMGrpId) + EgtSetName( nCloudId, 'Cloud') + end + -- Recupero BBox della tavola + local b3Tab = EgtGetTableArea() + if not b3Tab or b3Tab:isEmpty() then + WALL.ERR = 22 + WALL.MSG = 'Machine table not found' + return + end + -- Recupero i punti della nuvola + local hFile = io.open( sPntFile, 'r') + if not hFile then + WALL.ERR = 23 + WALL.MSG = 'Missing point cloud file' + return + end + local vPoints = {} + local sLine = hFile:read( '*l') + while sLine do + local vCoord = EgtSplitString( sLine, ' ') + if vCoord and #vCoord >= 2 then + local dX = tonumber( vCoord[1]) + b3Tab:getMax():getX() + local dY = tonumber( vCoord[2]) + b3Tab:getMin():getY() + local dZ = b3Tab:getMax():getZ() + EgtOutLog( ' X='..EgtNumToString( dX, 3)..' Y='..EgtNumToString( dY, 3), 3) + table.insert( vPoints, { dX, dY, dZ}) + end + sLine = hFile:read( '*l') + end + hFile:close() + -- Inserisco la curva di contorno della nuvola + local nClCrvId = EgtCurveCompoFromPoints( nCloudId, vPoints, GDB_RT.GLOB) + if not nClCrvId then + WALL.ERR = 24 + WALL.MSG = 'Failed to create Point cloud Contour' + return + end + EgtCloseCurveCompo( nClCrvId) + EgtApproxCurve( nClCrvId, GDB_CA.LINES, 1.0) + EgtSetColor( nClCrvId, 'RED') +end + +-- Se modifica o simula, imposto la vista ISO 3d if WALL.FLAG == 1 or WALL.FLAG == 2 then EgtSetView( SCE_VD.ISO_SW, false) +-- se cloud, imposto la vista TOP +elseif WALL.FLAG == 5 then + EgtSetView( SCE_VD.TOP, false) end -- Completamento senza errori e avvisi