Refactoring/MoveSomeFunctionsToBeamLib:
spostate le funzioni GetTunnelDimension e CalcCollisionSafety da LapJoint a BeamLib
This commit is contained in:
+15
-88
@@ -444,62 +444,6 @@ local function VerifyBHSideMill( Proc, bIsU, bIsL, bSinglePart, bPrevBhSideMill)
|
||||
return bUseBHSideMill, bHead, bHeadDir, sMilling, dToolThick, dToolDiam
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetTunnelDimension( Proc, nPartId)
|
||||
-- sono necessarie almeno due facce
|
||||
if Proc.Fct < 2 then return 0, 0, 0 end
|
||||
-- recupero l'ingombro della trave
|
||||
local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
-- recupero centro e normale delle facce
|
||||
local ptC = {}
|
||||
local vtN = {}
|
||||
for i = 1, Proc.Fct do
|
||||
ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT)
|
||||
end
|
||||
-- calcolo l'orientamento del tunnel
|
||||
local vtOrtho
|
||||
local bAdj = EgtSurfTmFacetsContact( Proc.Id, 0, 1)
|
||||
if bAdj then
|
||||
vtOrtho = vtN[1] ^ vtN[2]
|
||||
else
|
||||
if Proc.Fct >= 3 then
|
||||
vtOrtho = vtN[1] ^ vtN[3]
|
||||
else
|
||||
return 0, 0, 0
|
||||
end
|
||||
end
|
||||
-- ottengo il boundingBox e prendo le dimensioni lungo la direzione (Z locale) che rappresenta la profondità della fessura
|
||||
local frFc = Frame3d( ptC[1], vtOrtho) ;
|
||||
local b3BoxLoc = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frFc)
|
||||
local dDepth = b3BoxLoc:getDimZ()
|
||||
-- recupero gruppo per geometria addizionale
|
||||
local nAddGrpId = BL.GetAddGroup( nPartId)
|
||||
if not nAddGrpId then
|
||||
EgtOutLog( 'Error : missing AddGroup')
|
||||
return 0, 0, 0
|
||||
end
|
||||
-- centro del bounding box locale
|
||||
local ptCen = b3BoxLoc:getCenter()
|
||||
ptCen:toGlob( frFc)
|
||||
-- creo superficie intermedia
|
||||
local nSurfInt = EgtSurfTmPlaneInBBox( nAddGrpId, ptCen, vtOrtho, b3Solid, GDB_ID.ROOT)
|
||||
if not nSurfInt then return 0, 0, 0 end
|
||||
-- ritaglio la superficie con le facce della fessura
|
||||
for i = 1, Proc.Fct do
|
||||
EgtCutSurfTmPlane( nSurfInt, ptC[i], -vtN[i], false, GDB_ID.ROOT)
|
||||
end
|
||||
local frSurfInt, dDimMax, dDimMin = EgtSurfTmFacetMinAreaRectangle( nSurfInt, 0, GDB_ID.ROOT)
|
||||
-- cerco la faccia con larghezza pari a dimensione massima della fessura
|
||||
local nLongIdFace = 0
|
||||
for i = 1, Proc.Fct do
|
||||
if abs( vtN[i] * frSurfInt:getVersX()) < 0.5 then
|
||||
nLongIdFace = i - 1
|
||||
break
|
||||
end
|
||||
end
|
||||
return dDimMin, dDimMax, dDepth, vtOrtho, nLongIdFace, nSurfInt
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetFaceAdj( Proc, nFacInd, dH, dV)
|
||||
|
||||
@@ -534,23 +478,6 @@ local function GetFaceAdj( Proc, nFacInd, dH, dV)
|
||||
return nFacAdj
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function CalcCollisionSafety( vtDir)
|
||||
local dCollSic = 10 * BD.COLL_SIC
|
||||
if abs( vtDir:getX()) > 0.999 or abs( vtDir:getY()) > 0.999 or abs( vtDir:getZ()) > 0.999 then
|
||||
dCollSic = 0
|
||||
elseif abs( vtDir:getX()) > 0.996 or abs( vtDir:getY()) > 0.996 or abs( vtDir:getZ()) > 0.996 then
|
||||
dCollSic = 1 * BD.COLL_SIC
|
||||
elseif abs( vtDir:getX()) > 0.89 or abs( vtDir:getY()) > 0.89 or abs( vtDir:getZ()) > 0.89 then
|
||||
dCollSic = 2.5 * BD.COLL_SIC
|
||||
elseif abs( vtDir:getX()) > 0.86 or abs( vtDir:getY()) > 0.86 or abs( vtDir:getZ()) > 0.86 then
|
||||
dCollSic = 4 * BD.COLL_SIC
|
||||
elseif abs( vtDir:getX()) > 0.707 or abs( vtDir:getY()) > 0.707 or abs( vtDir:getZ()) > 0.707 then
|
||||
dCollSic = 5.5 * BD.COLL_SIC
|
||||
end
|
||||
return dCollSic
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function UpdateEncumbrance( Proc, nRawId, b3Raw, b3Solid)
|
||||
-- verifico siano una o due facce
|
||||
@@ -758,7 +685,7 @@ function ProcessLapJoint.Classify( Proc, b3Raw)
|
||||
-- se facce formano un tunnel e sono ortogonali
|
||||
if bClosedOrthoFaces then
|
||||
-- ottengo le dimensioni del tunnel
|
||||
local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = BL.GetTunnelDimension( Proc, nPartId)
|
||||
EgtErase( nSurfInt)
|
||||
-- verifico se può essere fatto con svuotatura
|
||||
if VerifyPocket( Proc, dDimMin) then
|
||||
@@ -1728,7 +1655,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw,
|
||||
return false, sErr
|
||||
end
|
||||
-- distanza di sicurezza per evitare collisioni
|
||||
dCollSic = CalcCollisionSafety( vtN1)
|
||||
dCollSic = BL.CalcCollisionSafety( vtN1)
|
||||
-- elevazione massima della faccia
|
||||
dMaxElev = BL.GetFaceElevation( Proc.Id, nFacInd, nPartId)
|
||||
-- ciclo tutta la tabella
|
||||
@@ -1773,7 +1700,7 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw,
|
||||
nFirstId = EgtCopyGlob( nPathInt, nAddGrpId)
|
||||
nNumId = 1
|
||||
-- distanza di sicurezza per evitare collisioni
|
||||
dCollSic = CalcCollisionSafety( vtOrtho)
|
||||
dCollSic = BL.CalcCollisionSafety( vtOrtho)
|
||||
-- calcolo elevazione dalla faccia trasversale aggiunta
|
||||
local dSurfIntElev = BL.GetOtherFaceElevation( Proc.Id, nSurfInt, 0)
|
||||
if bDoubleSide then
|
||||
@@ -2666,7 +2593,7 @@ local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd,
|
||||
end
|
||||
if bOrthoFaces then
|
||||
-- ottengo le dimensioni del tunnel
|
||||
local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = BL.GetTunnelDimension( Proc, nPartId)
|
||||
end
|
||||
-- Recupero le facce adiacenti alla principale
|
||||
local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1]
|
||||
@@ -2827,7 +2754,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd,
|
||||
|
||||
if bOrthoFaces then
|
||||
-- ottengo le dimensioni del tunnel
|
||||
dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = BL.GetTunnelDimension( Proc, nPartId)
|
||||
-- verifico la direzione
|
||||
-- se devo inserire il chamfer
|
||||
if nChamfer > 0 then
|
||||
@@ -3575,7 +3502,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha
|
||||
-- se è un tunnel verifico se è possibile usare la svuotatura
|
||||
if bOrthoFaces then
|
||||
-- ottengo le dimensioni del tunnel
|
||||
dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = BL.GetTunnelDimension( Proc, nPartId)
|
||||
-- se due facce posso utilizzare utensile con diametro doppio della dimensione minima
|
||||
if Proc.Fct == 2 then
|
||||
dDimMin = 2 * dDimMin
|
||||
@@ -3625,7 +3552,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha
|
||||
local bOneShot
|
||||
local bComplete = true
|
||||
-- imposto altezza aggiuntiva di elevazione
|
||||
local dCollSic = CalcCollisionSafety( vtOrtho)
|
||||
local dCollSic = BL.CalcCollisionSafety( vtOrtho)
|
||||
-- se possibile svuotare completamente da una sola parte
|
||||
if dMaxDepth > ( dDepth + BD.CUT_EXTRA + dCollSic) then
|
||||
dMachDepth = ( dDepth / 2) + BD.CUT_EXTRA
|
||||
@@ -3824,7 +3751,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha
|
||||
end
|
||||
if bPock3rd then
|
||||
-- recupero la distanza di sicurezza aggiuntiva
|
||||
local dFacCollSic = CalcCollisionSafety( vtN)
|
||||
local dFacCollSic = BL.CalcCollisionSafety( vtN)
|
||||
-- scelgo se lavorare da sotto
|
||||
local bFacPocketDn = ( bMakePocketDn and vtN:getZ() < -0.174)
|
||||
-- inserisco la lavorazione di svuotatura
|
||||
@@ -4218,7 +4145,7 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw,
|
||||
end
|
||||
-- prendo il primo versore
|
||||
_, vtN1 = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
|
||||
dCollSic = CalcCollisionSafety( vtN1) or 0
|
||||
dCollSic = BL.CalcCollisionSafety( vtN1) or 0
|
||||
-- se direzione tende verso una delle alle 3 direzioni azzero l'altezza extra
|
||||
if abs( vtN1:getX()) > 0.7 or abs( vtN1:getY()) > 0.7 or abs( vtN1:getZ()) > 0.7 then dCollSic = 0 end
|
||||
|
||||
@@ -4275,7 +4202,7 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw,
|
||||
-- alrimenti ho la faccia aggiunta
|
||||
else
|
||||
|
||||
dCollSic = CalcCollisionSafety( vtOrtho)
|
||||
dCollSic = BL.CalcCollisionSafety( vtOrtho)
|
||||
nFirstId = EgtCopyGlob( nPathInt, nAddGrpId)
|
||||
nNumId = 1
|
||||
-- calcolo elevazione dalla faccia trasversale aggiunta
|
||||
@@ -4868,7 +4795,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
|
||||
if not bOk then return false, sErr end
|
||||
end
|
||||
-- imposto altezza aggiuntiva di elevazione
|
||||
local dCollSic = CalcCollisionSafety( vtN)
|
||||
local dCollSic = BL.CalcCollisionSafety( vtN)
|
||||
-- abilitazione lavorazione da sotto
|
||||
local bMillUp = ( BD.DOWN_HEAD and vtN:getZ() > -0.259)
|
||||
local bMillDown = ( BD.DOWN_HEAD and vtN:getZ() < 0.342)
|
||||
@@ -5135,7 +5062,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
|
||||
-- se devo inserire il chamfer
|
||||
if ( ( Proc.Fct == 3 and bIsU) or (Proc.Fct == 2 and bIsL)) and nChamfer > 0 then
|
||||
-- ottengo le dimensioni dello pseudotunnel
|
||||
local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
local _, _, _, vtOrtho, _, nSurfInt = BL.GetTunnelDimension( Proc, nPartId)
|
||||
local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham)
|
||||
if nOk < 0 then return false, sErr end
|
||||
end
|
||||
@@ -5184,7 +5111,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
|
||||
tvtNx[2] = vtN
|
||||
local ptPs = ptC
|
||||
dFacElev = BL.GetFaceElevation( Proc.Id, nFacInd)
|
||||
dCollSic = CalcCollisionSafety( tvtNx[2])
|
||||
dCollSic = BL.CalcCollisionSafety( tvtNx[2])
|
||||
local dMachDepth = dFacElev + dCollSic
|
||||
local frFacRec, dFacDim1, dFacDim2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT)
|
||||
-- limito il diametro utensile massimo a 100 per queste lavorazioni
|
||||
@@ -5371,7 +5298,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa
|
||||
-- se devo inserire il chamfer
|
||||
if ( ( Proc.Fct == 3 and bIsU) or (Proc.Fct == 2 and bIsL)) and nChamfer > 0 then
|
||||
-- ottengo le dimensioni dello pseudotunnel
|
||||
local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
local _, _, _, vtOrtho, _, nSurfInt = BL.GetTunnelDimension( Proc, nPartId)
|
||||
local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham)
|
||||
if nOk < 0 then return false, sErr end
|
||||
end
|
||||
@@ -5798,7 +5725,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
local nChamfer, dDepthCham, sErrCham = EvaluateQParam( Proc)
|
||||
-- se smusso da fare
|
||||
if nChamfer > 0 then
|
||||
local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
local _, _, _, vtOrtho, _, nSurfInt = BL.GetTunnelDimension( Proc, nPartId)
|
||||
local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham)
|
||||
if nOk < 0 then return false, sErr end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user