DataBeam :
- corretta segnalazione sezione troppo piccola in BatchProcess - minimo sovramateriale di testa che produce taglio di lama portato da 1mm a 0.1mm - FacesBySaw.MakeTwo ora gestisce anche le prime due facce di una superficie con più facce - in foratura corretta Split per il caso in cui non esista punta per il foro - LapJoint riconoscibile di testa o coda se non più lunga del relativo massimo o del 60% della trave - StepJoint ora gestisce i casi 2 e 4 facce - StepJointNotch ora gestisce i casi 2 e 4 facce (larghe come la faccia della trave).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
-- ProcessStepJoint.lua by Egaltech s.r.l. 2019/09/25
|
||||
-- ProcessStepJoint.lua by Egaltech s.r.l. 2019/10/21
|
||||
-- Gestione calcolo giunto a gradino per Travi
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
@@ -28,12 +28,12 @@ end
|
||||
function ProcessStepJoint.Classify( Proc)
|
||||
-- numero delle facce
|
||||
local nFacetCnt = EgtSurfTmFacetCount( Proc.Id)
|
||||
-- gestisco solo 2 facce
|
||||
if nFacetCnt ~= 2 then
|
||||
-- gestisco solo 2 o 3 facce
|
||||
if nFacetCnt ~= 2 and nFacetCnt ~= 3 then
|
||||
return false, false
|
||||
end
|
||||
-- se due facce, verifico se convesso
|
||||
local bConvex = true
|
||||
local bConvex = false
|
||||
if nFacetCnt == 2 then
|
||||
local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT)
|
||||
bConvex = not bAdj or ( dAng > 0)
|
||||
@@ -49,8 +49,8 @@ function ProcessStepJoint.Classify( Proc)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Applicazione della lavorazione
|
||||
function ProcessStepJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- Applicazione della lavorazione al caso due facce
|
||||
local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- ingombro del grezzo
|
||||
local b3Raw = EgtGetRawPartBBox( nRawId)
|
||||
-- ingombro del pezzo
|
||||
@@ -209,5 +209,178 @@ function ProcessStepJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Applicazione della lavorazione al caso tre facce
|
||||
local function MakeThreeFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- ingombro del grezzo
|
||||
local b3Raw = EgtGetRawPartBBox( nRawId)
|
||||
-- ingombro del pezzo
|
||||
local Ls = EgtGetFirstNameInGroup( nPartId, 'Box')
|
||||
local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
if not b3Solid then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- riduco a forma canonica ( concavo tra 0 e 1, faccia 2 oltre convesso)
|
||||
local bAdj12, _, _, dAng12 = EgtSurfTmFacetsContact( Proc.Id, 1, 2, GDB_ID.ROOT)
|
||||
local bAdj20, _, _, dAng20 = EgtSurfTmFacetsContact( Proc.Id, 2, 0, GDB_ID.ROOT)
|
||||
if bAdj12 then
|
||||
if dAng12 < 0 then
|
||||
EgtSurfTmSwapFacets( Proc.Id, 0, 2)
|
||||
end
|
||||
elseif bAdj20 then
|
||||
if dAng20 < 0 then
|
||||
EgtSurfTmSwapFacets( Proc.Id, 1, 2)
|
||||
end
|
||||
end
|
||||
-- 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)
|
||||
ptC[3], vtN[3] = EgtSurfTmFacetCenter( Proc.Id, 2, GDB_ID.ROOT)
|
||||
-- normale media per capire se taglio di testa o di coda
|
||||
local vtNm = ( vtN[1] + vtN[2]) ; vtNm:normalize()
|
||||
local bHead = ( vtNm:getX() > 0)
|
||||
-- angolo diedro per stabilire se taglio convesso
|
||||
local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT)
|
||||
local bConvex = true
|
||||
local bOnY = true
|
||||
local ptPs = ( ptC[1] + ptC[2]) / 2
|
||||
if bAdj then
|
||||
local vtDir = ptP1 - ptP2 ; vtDir:normalize()
|
||||
bOnY = abs( vtDir:getZ()) > 0.5 and ( abs( vtDir:getZ()) + abs( vtDir:getX()) > abs( vtDir:getY()))
|
||||
ptPs = ( ptP1 + ptP2) / 2
|
||||
bConvex = ( dAng > 0)
|
||||
end
|
||||
-- determino quale faccia è più grande
|
||||
local _, dB1, dH1 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0)
|
||||
local _, dB2, dH2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 1)
|
||||
local nBigInd = EgtIf( dB1 * dH1 >= dB2 * dH2, 1, 2)
|
||||
local nSmaInd = 3 - nBigInd
|
||||
-- recupero la lavorazione
|
||||
local sCutting = ML.FindCutting( EgtIf( bHead, 'HeadSide', 'TailSide'))
|
||||
if not sCutting then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero i dati dell'utensile
|
||||
local dSawDiam = 400
|
||||
local dMaxDepth = 0
|
||||
if EgtMdbSetCurrMachining( sCutting) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam
|
||||
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
|
||||
end
|
||||
end
|
||||
-- Taglio la faccia 2
|
||||
-- recupero gruppo per geometria addizionale
|
||||
local nAddGrpId = BL.GetAddGroup( nPartId)
|
||||
if not nAddGrpId then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- creo piano di taglio coincidente con la faccia 2 e lo lavoro
|
||||
local AddId = EgtSurfTmPlaneInBBox( EgtGetParent( Proc.Id), ptC[3], vtN[3], b3Solid, GDB_RT.GLOB)
|
||||
if AddId then
|
||||
EgtRelocate( AddId, nAddGrpId)
|
||||
EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id))
|
||||
-- applico lavorazione
|
||||
local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg}
|
||||
local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0)
|
||||
if not bOk then return bOk, sErr end
|
||||
end
|
||||
-- Taglio le facce 0 e 1 concave
|
||||
-- verifico se necessari tagli supplementari
|
||||
local vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[nBigInd], vtN[nBigInd], false, ptC[nSmaInd], vtN[nSmaInd])
|
||||
--DC.PrintOrderCut( vCuts)
|
||||
if #vCuts > 0 then
|
||||
-- recupero gruppo per geometria addizionale
|
||||
local nAddGrpId = BL.GetAddGroup( nPartId)
|
||||
if not nAddGrpId then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- sistemo posizione nel DB e nome
|
||||
for i = 1, #vCuts do
|
||||
for j = 1, #vCuts[i] do
|
||||
EgtRelocateGlob( vCuts[i][j], nAddGrpId)
|
||||
EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id))
|
||||
EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId)
|
||||
end
|
||||
end
|
||||
-- eseguo
|
||||
for i = 1, #vCuts do
|
||||
-- determino il modo di tagliare
|
||||
local k, l = nBigInd, nSmaInd
|
||||
if ( i % 2) == 1 then
|
||||
k, l = l, k
|
||||
end
|
||||
local nOrthoOpposite
|
||||
if bOnY then
|
||||
local bFront = ( ptC[k]:getY() < ptPs:getY())
|
||||
nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
|
||||
else
|
||||
local bOver = ( ptC[k]:getZ() > ptC[l]:getZ())
|
||||
nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP)
|
||||
end
|
||||
-- lavoro la faccia
|
||||
for j = 1, #vCuts[i] do
|
||||
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
|
||||
if not bOk then
|
||||
return bOk, sErr
|
||||
end
|
||||
end
|
||||
end
|
||||
-- altrimenti, tagli diretti delle facce
|
||||
else
|
||||
local bOk, sErr = Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, EgtIf( bHead, 'HeadSide', 'TailSide'))
|
||||
if not bOk then
|
||||
return bOk, sErr
|
||||
end
|
||||
end
|
||||
-- Eventuale segnalazione ingombro di testa o coda
|
||||
if Proc.Head then
|
||||
local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX()
|
||||
if vtNm:getZ() > 0.5 then
|
||||
dOffs = 0.5 * dOffs
|
||||
elseif abs( vtNm:getZ()) > 0.35 then
|
||||
dOffs = 0.75 * dOffs
|
||||
end
|
||||
BL.UpdateHCING( nRawId, dOffs)
|
||||
elseif Proc.Tail then
|
||||
local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX()
|
||||
if vtNm:getZ() > 0.5 then
|
||||
dOffs = 0.5 * dOffs
|
||||
elseif abs( vtNm:getZ()) > 0.35 then
|
||||
dOffs = 0.75 * dOffs
|
||||
end
|
||||
BL.UpdateTCING( nRawId, dOffs)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Applicazione della lavorazione
|
||||
function ProcessStepJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- se due facce
|
||||
if Proc.Fct == 2 then
|
||||
return MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- se altrimenti tre facce
|
||||
elseif Proc.Fct == 3 then
|
||||
return MakeThreeFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- altrimenti errore
|
||||
else
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' face number not allowed'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
return ProcessStepJoint
|
||||
|
||||
Reference in New Issue
Block a user