- in BatchProcessNew e BeamExec, dove si salva il Box del Part si salva anche idBoxTm, id della trimesh del box
- in BeamLib rimosse funzioni GetPlaneOrientation e IsEdgeOnBox, non usate - in MachiningLib rivista completamente GetBladeEngagement e aggiunta Check2DBladeCollision
This commit is contained in:
+38
-102
@@ -284,104 +284,47 @@ local function IsFaceZOutOfRange ( vtNFace, Tool)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function IsBladeOrientationOkForDownUp( Face, Edge, b3Part)
|
||||
local function Check2DBladeCollision( Edge, vtHead, Part, Tool, dDepthToMachine)
|
||||
local idTempGroup = BeamLib.GetTempGroup()
|
||||
|
||||
-- se l'utensile lavora perpendicolarmente, l'orientamento è sempre valido per DownUp
|
||||
if AreSameVectorApprox( Face.vtN, Edge.vtN) then
|
||||
|
||||
return true
|
||||
end
|
||||
-- nel piano perpendicolare alla direzione di taglio, se c'è intersezione tra motore e trave c'è collisione
|
||||
|
||||
-- componente Z negativa di vtTool, ossia testa sotto alla trave e rischio collisione carro Z: non lavorabile in Downup
|
||||
-- TODO con lama da sopra il test è per Z > 0!!!
|
||||
if Edge.vtN:getZ() < - 10 * GEO.EPS_SMALL then
|
||||
|
||||
return false
|
||||
end
|
||||
-- riferimento perpendicolare al taglio, X nel verso della normale al lato e Y verso il motore
|
||||
local ptMid = Point3d( ( Edge.ptStart + Edge.ptEnd) / 2)
|
||||
local vtEdge = Edge.ptEnd - Edge.ptStart
|
||||
vtEdge:normalize()
|
||||
local frBlade = Frame3d( ptMid, vtEdge, Edge.vtN)
|
||||
|
||||
-- orientamento 3d della faccia: non lavorabile in DownUp
|
||||
-- TODO implementare gestione DownUp in 3d
|
||||
local FaceOrientation = BeamLib.GetPlaneOrientation( Face.vtN)
|
||||
if FaceOrientation[1].dRelativeMagnitude < 1 - 10 * GEO.EPS_SMALL then
|
||||
|
||||
return false
|
||||
-- silhouette del pezzo nel riferimento
|
||||
local idFirstCurve, nCurveCount = EgtGetSurfTmSilhouette( Part.idBoxTm, vtEdge, 10 * GEO.EPS_SMALL, idTempGroup)
|
||||
-- se più curve c'è qualcosa che non va: errore
|
||||
if nCurveCount > 1 then
|
||||
error( 'Check2DBladeCollision : error in part box')
|
||||
end
|
||||
|
||||
-- orientamento 2d: si determinano il piano della faccia e la direzione perpendicolare
|
||||
local sPlane = FaceOrientation[1].sPlane
|
||||
local vtPerpendicularToPlane
|
||||
if sPlane == 'XY' then
|
||||
vtPerpendicularToPlane = Z_AX()
|
||||
elseif sPlane == 'XZ' then
|
||||
vtPerpendicularToPlane = Y_AX()
|
||||
elseif sPlane == 'YZ' then
|
||||
vtPerpendicularToPlane = X_AX()
|
||||
end
|
||||
-- flat region del pezzo nel riferimento
|
||||
local idPartSurfFr = EgtSurfFlatRegion( idTempGroup, idFirstCurve)
|
||||
|
||||
-- se l'utensile è in direzione perpendicolare al piano, l'orientamento è sempre valido per DownUp
|
||||
if AreSameOrOppositeVectorApprox( Edge.vtN, vtPerpendicularToPlane) then
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- se tutte le condizioni precedenti sono soddisfatte, il DownUp si può fare se lungo l'asse in cui Face.vtN e Edge.vtN sono discordi il punto iniziale del lato è sul box
|
||||
-- in pratica, ciò significa che il braccio non entrerà in collisione con la trave
|
||||
-- TODO in realtà così si escludono dei casi di faccia non troncante in cui aumenterebbe l'elevation ma si potrebbe comunque lavorare
|
||||
local _, ptOnBox = EgtSurfTmFacetOppositeSide( Face.idTrimesh, Face.id, -Edge.vtN, GDB_ID.ROOT)
|
||||
-- Helper function: verifica se i vettori sono discordi lungo l'asse indicato e, se sì, se il punto iniziale della lavorazione è sul box oppure no, nella direzione dell'utensile
|
||||
local function IsDiscordantAndOnBox( sAxis)
|
||||
-- si compongono i metodi getX, getY, getZ in base all'asse in arrivo (Face.vtN[getX] equivale a Face.vtN:getX())
|
||||
local dFaceComponent = Face.vtN["get" .. sAxis](Face.vtN)
|
||||
local dEdgeComponent = Edge.vtN["get" .. sAxis](Edge.vtN)
|
||||
local dPtonboxComponent = ptOnBox["get" .. sAxis](ptOnBox)
|
||||
local dMaxb3PartComponent = b3Part:getMax()["get" .. sAxis](b3Part:getMax())
|
||||
local dMinb3PartComponent = b3Part:getMin()["get" .. sAxis](b3Part:getMin())
|
||||
|
||||
if dFaceComponent * dEdgeComponent < 10 * GEO.EPS_SMALL then
|
||||
if dEdgeComponent > GEO.EPS_SMALL then
|
||||
return dPtonboxComponent > dMaxb3PartComponent - 500 * GEO.EPS_SMALL
|
||||
else
|
||||
return dPtonboxComponent < dMinb3PartComponent + 500 * GEO.EPS_SMALL
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
-- in base all'orientamento, si verifica se il DownUp è fattibile
|
||||
if sPlane == 'XY' then
|
||||
if IsDiscordantAndOnBox( "X") then
|
||||
return true
|
||||
elseif IsDiscordantAndOnBox( "Y") then
|
||||
return true
|
||||
end
|
||||
elseif sPlane == 'XZ' then
|
||||
if IsDiscordantAndOnBox( "X") then
|
||||
return true
|
||||
elseif IsDiscordantAndOnBox( "Z") then
|
||||
return true
|
||||
end
|
||||
elseif sPlane == 'YZ' then
|
||||
if IsDiscordantAndOnBox( "Y") then
|
||||
return true
|
||||
elseif IsDiscordantAndOnBox( "Z") then
|
||||
return true
|
||||
end
|
||||
end
|
||||
-- flat region del motore nel riferimento
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- ritorna se la faccia e il lato sono lavorabili e, se sì, il modo di lavorare (standard/DownUp) e l'elevazione corretta (in DownUp può cambiare)
|
||||
function MachiningLib.GetBladeEngagement( Face, Edge, b3Part, Tool, dDepthToMachine, bAvoidCollisionCheckForStandardCut)
|
||||
-- ritorna se la faccia e il lato sono lavorabili e, se sì, il modo di lavorare (standard/DownUp)
|
||||
-- TODO si dovrà decidere come tagliare anche in base a lavorazione di coda (spostare dopo separazione?) o pezzo corto (il motore non deve ingombrare con il pinzaggio)
|
||||
-- valutare se restituire, se disponibili, entrambe le soluzioni e demandare la decisione alla FaceByBlade
|
||||
function MachiningLib.GetBladeEngagement( Face, Edge, Part, Tool, dDepthToMachine, bAvoidCollisionCheckForStandardCut)
|
||||
local sBladeEngagement = 'Standard'
|
||||
local dDownUpElevation = Edge.dElevation
|
||||
|
||||
-- la normale della faccia permette di lavorare in modo standard, ma potrebbero esserci altre condizioni che fanno fallire il taglio
|
||||
if not IsFaceZOutOfRange( Face.vtN, Tool) then
|
||||
|
||||
-- TODO verifica collisione carro Z, collisione traversa PF, collisione 'C' Fast... La riduzione percorso cambia questo test?
|
||||
if bAvoidCollisionCheckForStandardCut or not Check2DBladeCollision( Edge, Face.vtN, Part, Tool, dDepthToMachine) then
|
||||
|
||||
return true, sBladeEngagement
|
||||
return true, sBladeEngagement
|
||||
end
|
||||
end
|
||||
|
||||
-- faccia non lavorabile in modo standard: si verifica se il DownUp è fattibile
|
||||
@@ -391,26 +334,22 @@ function MachiningLib.GetBladeEngagement( Face, Edge, b3Part, Tool, dDepthToMach
|
||||
return false
|
||||
end
|
||||
|
||||
-- faccia non parallelogramma: non lavorabile in DownUp
|
||||
if not FaceData.IsFaceParallelogram( Face) then
|
||||
|
||||
-- rischio collisione carro Z: non lavorabile in Downup
|
||||
local bIsToolBelowWorkpiece = Edge.vtN:getZ() < - 10 * GEO.EPS_SMALL
|
||||
local bIsToolAboveWorkpiece = Edge.vtN:getZ() > 10 * GEO.EPS_SMALL
|
||||
|
||||
if Tool.SetupInfo.HeadType.bTop and bIsToolBelowWorkpiece
|
||||
or ( Tool.SetupInfo.HeadType.bBottom and bIsToolAboveWorkpiece) then
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- se il lato di approccio non è sul box e non è espressamente consentito (es: cubetti), non lavorabile in DownUp
|
||||
local EdgeOpposite = BeamLib.FindEdgeBestOrientedAsDirection( Face.Edges, -Edge.vtN)
|
||||
if not bAvoidCollisionCheckForStandardCut and not BeamLib.IsEdgeOnBox( Face, EdgeOpposite, b3Part) then
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- orientamento faccia / utensile compatibili con DownUp: lavorabile, si calcola l'elevazione reale per DownUp e si ritorna
|
||||
if IsBladeOrientationOkForDownUp( Face, Edge, b3Part) then
|
||||
-- orientamento faccia / utensile compatibili con DownUp: lavorabile
|
||||
if not Check2DBladeCollision( Edge, -Face.vtN, Part, Tool, dDepthToMachine) then
|
||||
|
||||
sBladeEngagement = 'DownUp'
|
||||
dDownUpElevation = FaceData.GetEdgeElevationInBBox( Face, Edge, b3Part)
|
||||
|
||||
return true, sBladeEngagement, dDownUpElevation
|
||||
return true, sBladeEngagement
|
||||
end
|
||||
|
||||
return false
|
||||
@@ -558,7 +497,7 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters)
|
||||
local dElevation = ToolSearchParameters.dElevation or 0
|
||||
local bForceLongcutBlade = ToolSearchParameters.bForceLongcutBlade or false
|
||||
local EdgeToMachine = ToolSearchParameters.EdgeToMachine
|
||||
local b3Part = ToolSearchParameters.b3Part
|
||||
local Part = ToolSearchParameters.Part
|
||||
local bAvoidCollisionCheckForStandardCut = ToolSearchParameters.bAvoidCollisionCheckForStandardCut or false
|
||||
|
||||
local nBestToolIndex
|
||||
@@ -578,13 +517,10 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters)
|
||||
|
||||
-- se dati sufficienti, si determina se con questo utensile il taglio è fattibile e il modo di lavorare della lama
|
||||
if bIsToolCompatible then
|
||||
if FaceToMachine and EdgeToMachine and dElevation and b3Part then
|
||||
local bIsBladeOk, sBladeEngagement, dDownUpElevation = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachine, b3Part, TOOLS[i], dElevation, bAvoidCollisionCheckForStandardCut)
|
||||
-- orientamento non raggiungibile o elevazione eccessiva per DownUp: non compatibile
|
||||
if not bIsBladeOk
|
||||
or ( sBladeEngagement == 'DownUp'
|
||||
and ( dDownUpElevation - ( EdgeToMachine.dElevation - dElevation)) > TOOLS[i].dMaxMaterial - 10 * GEO.EPS_SMALL) then
|
||||
|
||||
if FaceToMachine and EdgeToMachine and Part and dElevation then
|
||||
local bIsBladeOk = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachine, Part, TOOLS[i], dElevation, bAvoidCollisionCheckForStandardCut)
|
||||
-- orientamento non raggiungibile
|
||||
if not bIsBladeOk then
|
||||
bIsToolCompatible = false
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user