DataWall :

- aggiunte fresature su fessure di fianco
- l'elevazione delle facce viene calcolata rispetto al grezzo complessivo.
This commit is contained in:
Dario Sassi
2020-11-18 08:10:36 +00:00
parent 1e84898671
commit 7383e914cc
2 changed files with 194 additions and 25 deletions
+152 -20
View File
@@ -33,16 +33,15 @@ function WPL.Classify( Proc, b3Raw)
-- se 1 faccia
if Proc.Fct == 1 then
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, 0, GDB_ID.ROOT)
-- verifico se è lavorabile da sopra
return vtN:getZ() >= WD.NZ_MINA
-- se 2 facce
elseif Proc.Fct == 2 then
-- dati delle facce
local ptC = {}
local vtN = {}
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
vtN[1] = EgtSurfTmFacetNormVersor( Proc.Id, 0, GDB_ID.ROOT)
vtN[2] = EgtSurfTmFacetNormVersor( Proc.Id, 1, GDB_ID.ROOT)
-- verifico se è lavorabile da sopra
return vtN[1]:getZ() >= WD.NZ_MINA or vtN[2]:getZ() >= WD.NZ_MINA
-- se più di 2 facce
@@ -50,27 +49,35 @@ function WPL.Classify( Proc, b3Raw)
local nFacInd, dElev, nFacInd2, dElev2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId)
-- se trovata faccia di fondo
if nFacInd >= 0 then
-- determino componente Z della normale più diretta verso il basso
local dMinNz = 1
for i = 1, Proc.Fct do
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT)
if vtN:getZ() < dMinNz then
dMinNz = vtN:getZ()
end
end
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT)
local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
-- verifico se la faccia è lavorabile da sopra o di fianco se con sega a catena
if ( vtN:getZ() >= WD.NZ_MINA or ( dV < 19 and Proc.Fct > 4 and vtN:getZ() > - 0.01)) then
-- verifico se la faccia è lavorabile da sopra o di fianco
if ( vtN:getZ() >= WD.NZ_MINA or ( dMinNz < -0.866 and Proc.Fct >= 3 and vtN:getZ() > - 0.01)) then
Proc.Stype = 1
return true
-- altrimenti verifico la eventuale seconda faccia
elseif nFacInd2 then
-- dati della faccia
local ptC2, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd2, GDB_ID.ROOT)
local _, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd2, GDB_ID.ROOT)
-- restituisco se faccia lavorabile
Proc.Stype = 2
return ( vtN2:getZ() >= WD.NZ_MINA or ( dV2 < 19 and Proc.Fct > 4 and vtN2:getZ() > - 0.01))
return ( vtN2:getZ() >= WD.NZ_MINA or ( dMinNz < -0.866 and Proc.Fct >= 3 and vtN2:getZ() > - 0.01))
-- se tre facce
elseif Proc.Fct == 3 then
-- verifico se U da sopra
-- dati della faccia
local nFac2 = EgtIf( nFacInd == 0, 1, 0)
local ptC2, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFac2, GDB_ID.ROOT)
local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, nFac2, GDB_ID.ROOT)
Proc.Stype = 3
return ( abs( ( vtN ^ vtN2) * Z_AX()) >= WD.NZ_MINA)
-- altrimenti non lavorabile
@@ -80,11 +87,10 @@ function WPL.Classify( Proc, b3Raw)
-- se altrimenti tunnel
elseif nFacInd == -1 then
-- dati delle prime tre facce
local ptC = {}
local vtN = {}
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
ptC[3], vtN[3] = EgtSurfTmFacetCenter( Proc.Id, 2, GDB_ID.ROOT)
vtN[1] = EgtSurfTmFacetNormVersor( Proc.Id, 0, GDB_ID.ROOT)
vtN[2] = EgtSurfTmFacetNormVersor( Proc.Id, 1, GDB_ID.ROOT)
vtN[3] = EgtSurfTmFacetNormVersor( Proc.Id, 2, GDB_ID.ROOT)
-- verifico se è lavorabile da sopra
local vtAxN = vtN[1] ^ vtN[2]
if vtAxN:isSmall() then vtAxN = vtN[1] ^ vtN[3] end
@@ -212,11 +218,123 @@ local function MakeByChainSaw( Proc, nFacet, nRawId, b3Raw, dElev, dH, dV)
return true
end
---------------------------------------------------------------------
local function MakeByMill( Proc, nFacet, nOthFac, nRawId, b3Raw)
-- dati della faccia e dell'altra
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT)
local dElev = WL.GetFaceElevation( Proc.Id, nFacet, nRawId)
local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT)
local dDiam = min( dH, dV)
local _, vtRef = EgtSurfTmFacetCenter( Proc.Id, nOthFac, GDB_ID.ROOT)
-- recupero la lavorazione
local sMilling = WM.FindMilling( 'Side')
if not sMilling then return false end
-- recupero i dati dell'utensile
local dMillDiam = 20
local dMaxDepth = 0
local dThDiam = 100
if EgtMdbSetCurrMachining( sMilling) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
dThDiam = EgtTdbGetCurrToolThDiam() or dThDiam
end
end
if dMillDiam < dDiam or dMaxDepth < dElev then return false end
-- inserisco la lavorazione di contornatura
local sName = 'Mill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sMilling)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacet}})
-- imposto posizione braccio porta testa
local nSCC = MCH_SCC.ADIR_ZP
if AreSameVectorApprox( vtN, Z_AX()) then
nSCC = EgtIf( Proc.Box:getDimX() >= Proc.Box:getDimY(), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_XP)
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- imposto modo di lavorare la faccia
local nFaceUse = WL.GetNearestOrthoOpposite( vtRef, vtN)
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtRemoveOperation( nMchFId)
return false, sErr
end
return true
end
---------------------------------------------------------------------
local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw)
-- dati della faccia e dell'altra
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT)
local dElev = WL.GetFaceElevation( Proc.Id, nFacet, nRawId)
local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT)
local dThick = min( dH, dV)
-- recupero la lavorazione
local sMilling = WM.FindMilling( 'SideGroove')
if not sMilling then
local sErr = 'Error : SideGroove not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
local dMillDiam = 20
local dMaxMat = 0
if EgtMdbSetCurrMachining( sMilling) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat
end
end
if dElev > dMillDiam / 2 - 30 then
local sErr = 'Error : Side Elevation too big'
EgtOutLog( sErr)
return false, sErr
end
-- inserisco la lavorazione di contornatura
local sName = 'Mill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sMilling)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacet}})
-- imposto posizione braccio porta testa
local nSCC = MCH_SCC.ADIR_ZP
if AreSameVectorApprox( vtN, Z_AX()) then
nSCC = EgtIf( Proc.Box:getDimX() >= Proc.Box:getDimY(), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_XP)
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- imposto modo di lavorare la faccia
local nFaceUse = WL.GetNearestParalOpposite( Z_AX(), vtN)
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
-- imposto elevazione
local dMaxElev = 2 * ( dThick - dMaxMat)
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dMaxElev, 1) .. ';')
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtRemoveOperation( nMchFId)
return false, sErr
end
return true
end
---------------------------------------------------------------------
local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw)
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT)
local dElev = WL.GetFaceElevation( Proc.Id, nFacet, Proc.PartId)
local dElev = WL.GetFaceElevation( Proc.Id, nFacet, nRawId)
local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT)
local dDiam = min( dH, dV)
if Proc.Fct < 5 then dDiam = dDiam * 2 end
@@ -346,12 +464,20 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw)
end
-- recupero la lavorazione di taglio con lama e i suoi parametri
local sCutting, dSawDiam, dSawThick, dSawMaxDepth = WM.FindCutting( 'Standard')
-- se non inclinate o capacità di taglio non sufficiente, provo con svuotatura
-- se non inclinate o capacità di taglio non sufficiente, provo con contornatura o svuotatura
if not sCutting or vtN[1]:getZ() > 0.95 or vtN[2]:getZ() > 0.95 or dSawMaxDepth < dDimY[1] + WD.CUT_SIC or dSawMaxDepth < dDimY[2] + WD.CUT_SIC then
-- cerco la faccia con il maggior numero di adiacenze
-- cerco la faccia con il maggior numero di adiacenze (e minor elevazione)
local nFacInd, _, nFacInd2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId)
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT)
local nFacet = EgtIf( vtN:getZ() >= WD.NZ_MINA, nFacInd, nFacInd2)
-- se vicino al bordo del grezzo e non troppo larga, provo con fresatura di fianco
local ptMid = ( ptP1 + ptP2) / 2
if abs( ptMid:getX() - b3Raw:getMin():getX()) < 300 or abs( ptMid:getX() - b3Raw:getMax():getX()) < 300 or
abs( ptMid:getY() - b3Raw:getMin():getY()) < 300 or abs( ptMid:getY() - b3Raw:getMax():getY()) < 300 then
if MakeByMill( Proc, nFacet, 1 - nFacet, nRawId, b3Raw) then
return true
end
end
-- eseguo la svuotatura
return MakeByPocketing( Proc, nFacet, nRawId, b3Raw)
end
@@ -405,9 +531,15 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw)
end
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT)
local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
-- se necessaria sega a catena
if dV < 19 and Proc.Fct > 4 and vtN:getZ() > - 0.01 then
return MakeByChainSaw( Proc, nFacInd, nRawId, b3Raw, dElev, dH, dV)
-- se di fianco
if Proc.Fct >= 3 and vtN:getZ() < WD.NZ_MINA then
-- fresatura
if dV > 30 then
return MakeSideGrooveByMill( Proc, nFacInd, nRawId, b3Raw)
-- altrimenti sega a catena
else
return MakeByChainSaw( Proc, nFacInd, nRawId, b3Raw, dElev, dH, dV)
end
end
local nFacet = EgtIf( vtN:getZ() >= WD.NZ_MINA, nFacInd, nFacInd2)
-- eseguo la svuotatura