- in PreSimulationLib si gestiscono i due nuovi parametri sRestLengthSideForPreSimulation e bCannotSplitRestLength per tagli di testa e coda

This commit is contained in:
luca.mazzoleni
2026-01-27 12:15:30 +01:00
parent 267fc9daa3
commit 4521910c56
2 changed files with 37 additions and 24 deletions
+24 -21
View File
@@ -65,13 +65,21 @@ local function LogOutstroke( ptOnToolTipCenter, vtHead, OptionalParameters)
end
-------------------------------------------------------------------------------------------------------------
-- costruzione trimesh del grezzo restante (con leggera sovrapposizione)
local function GetRestlengthSurfTm( Part)
-- costruzione trimesh del grezzo restante in testa o in coda (con leggera sovrapposizione)
local function GetRestlengthSurfTm( Part, sRestLengthSideForPreSimulation)
-- si costruisce il box in globale
local ptRestLengthMax = Point3d( Part.b3Part:getMin()) + X_AX() * 500 * GEO.EPS_SMALL
local ptRestLengthMin = Point3d( Part.b3Part:getMin():getX() - Part.dRestLength, Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ())
local b3RestLength = BBox3d( ptRestLengthMin, ptRestLengthMax)
local b3RestLength = BBox3d()
if sRestLengthSideForPreSimulation == 'Tail' then
local ptRestLengthMax = Point3d( Part.b3Part:getMin()) + X_AX() * 500 * GEO.EPS_SMALL
local ptRestLengthMin = Point3d( Part.b3Part:getMin():getX() - Part.dRestLength, Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ())
b3RestLength = BBox3d( ptRestLengthMin, ptRestLengthMax)
elseif sRestLengthSideForPreSimulation == 'Head' then
local ptRestLengthMin = Point3d( Part.b3Part:getMax() - X_AX() * 500 * GEO.EPS_SMALL)
local ptRestLengthMax = Point3d( Part.b3Part:getMaX():getX() + Part.dHeadOverMaterial, Part.b3Part:getMin():getY(), Part.b3Part:getMin():getZ())
b3RestLength = BBox3d( ptRestLengthMin, ptRestLengthMax)
end
-- si crea la trimesh dal box
local idRestLengthBoxTm = EgtSurfTmBBox( Part.idTempGroup, b3RestLength , false, GDB_RT.GLOB)
@@ -263,7 +271,7 @@ function PreSimulationLib.CheckOutOfStrokeFromGeometry( idGeometry, vtHead, nSCC
end
-------------------------------------------------------------------------------------------------------------
local function CheckCollisionPoint( ptToolExitToCheck, vtC, vtHead, PreCollisionData, Part, bCheckOnlyRestlength)
local function CheckCollisionPoint( ptToolExitToCheck, vtC, vtHead, PreCollisionData, Part, sRestLengthSideForPreSimulation, bCheckOnlyRestlength)
local ptPivot = GetGlobalPivot( ptToolExitToCheck, vtC, vtHead, PreCollisionData.vtMovePivot)
@@ -311,7 +319,7 @@ local function CheckCollisionPoint( ptToolExitToCheck, vtC, vtHead, PreCollision
-- check collisione con grezzo restante, se con il pezzo non c'è collisione
local bCollisionFoundRestLength = false
if not bCollisionFoundPiece then
local idRestLengthSurfFr = GetRestlengthSurfTm( Part)
local idRestLengthSurfFr = GetRestlengthSurfTm( Part, sRestLengthSideForPreSimulation)
bCollisionFoundRestLength = EgtTestSurfaceSurface( idRestLengthSurfFr, idCollisionSurfTm, BeamData.COLL_SIC)
if not type( bCollisionFoundRestLength) == "boolean" then
error( 'EgtTestSurfaceSurface fail')
@@ -339,21 +347,14 @@ local function CheckCollisionWithAxis( sAxis, MachiningParameters, OptionalParam
-- parametri opzionali
OptionalParameters = OptionalParameters or {}
local bCheckOnlyRestlength = OptionalParameters.bCheckOnlyRestlength or false
local sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation or 'Tail'
local bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength or false
-- se normale faccia non parallela a direzione testa c'è qualcosa che non va
if not AreSameOrOppositeVectorApprox( vtNFace, vtHead) then
error( 'CheckCollisionWithAxis : invalid directions')
end
-- TODO modificare e rimettere (Hmax pezzo)
-- se direzione utensile parallela ad uno degli assi principali non serve alcuna verifica
-- if AreSameOrOppositeVectorApprox( Edge.vtN, X_AX())
-- or AreSameOrOppositeVectorApprox( Edge.vtN, Y_AX())
-- or AreSameOrOppositeVectorApprox( Edge.vtN, Z_AX()) then
-- return false
-- end
-- punti notevoli della lavorazione in cui fare il check
local PointsToCheck = OptionalParameters.PointsToCheck or GetCollisionPointsToCheck( Edge, dDepthToMachine)
@@ -384,10 +385,10 @@ local function CheckCollisionWithAxis( sAxis, MachiningParameters, OptionalParam
-- se non si trova collisione si ritorna se è necessario separare prima di effettuare la lavorazione (ossia non c'è collisione con il pezzo ma c'è con il grezzo restante)
for i = 1, #ToolExitPoints do
local bCollisionFoundPiece, bCollisionFoundRestLength = CheckCollisionPoint( ToolExitPoints[i], vtC, vtHead, PreCollisionData, Part, bCheckOnlyRestlength)
local bCollisionFoundPiece, bCollisionFoundRestLength = CheckCollisionPoint( ToolExitPoints[i], vtC, vtHead, PreCollisionData, Part, sRestLengthSideForPreSimulation, bCheckOnlyRestlength)
-- se trovata collisione con pezzo è inutile controllare gli altri punti
if bCollisionFoundPiece then
-- se trovata collisione con pezzo oppure non possibile separazione, è inutile controllare gli altri punti
if bCollisionFoundPiece or ( bCannotSplitRestLength and bCollisionFoundRestLength) then
return true
@@ -414,6 +415,8 @@ function PreSimulationLib.CheckCollision( sBladeEngagement, Parameters, Optional
local OptionalParametersCheckCollisionWithAxis = {}
OptionalParametersCheckCollisionWithAxis.bCheckOnlyRestlength = false
OptionalParametersCheckCollisionWithAxis.PointsToCheck = OptionalParameters.PointsToCheck or nil
OptionalParametersCheckCollisionWithAxis.sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation or 'Tail'
OptionalParametersCheckCollisionWithAxis.bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength or false
local bIsDicing = OptionalParameters.bIsDicing or false
local bCheckOnlyRestlengthForAxisABC = false