- in PartSimulationLib si usa solo il box del sovramateriale di coda/testa per il checlk collisione con rest length; il controllo con rest si fa solo se il pezzo è splittabile; in caso di pezzo non splittabile, il sovramateriale di testa/coda è aggiunto alla superficie del pezzo nel test di collisione principale

- in SPLITCUT, HEADCUT. TAILCUT se taglio non riuscito si prova con il riduci percorso
This commit is contained in:
luca.mazzoleni
2026-01-29 11:11:27 +01:00
parent ee4d443074
commit 8875fc4c68
4 changed files with 56 additions and 14 deletions
+34 -13
View File
@@ -70,14 +70,19 @@ local function GetRestlengthSurfTm( Part, sRestLengthSideForPreSimulation)
-- si costruisce il box in globale
local b3RestLength
if ( sRestLengthSideForPreSimulation == 'Head') or Part.bIsLastPart then
b3RestLength = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sRestLengthSideForPreSimulation)
if sRestLengthSideForPreSimulation == 'Head' then
local b3PartWithOvermaterial = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sRestLengthSideForPreSimulation)
local ptStartRestLength = Point3d( Part.b3Part:getX():getMax(), Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ())
local ptEndRestLength = Point3d( b3PartWithOvermaterial:getX():getMax(), Part.b3Part:getMin():getY(), Part.b3Part:getMin():getZ())
b3RestLength = BBox3d( ptStartRestLength, ptEndRestLength)
elseif sRestLengthSideForPreSimulation == 'Tail' then
b3RestLength = BBox3d( Part.b3Part)
local ptPointAtRestLength = Point3d( b3RestLength:getMin():getX() - Part.dRestLength, b3RestLength:getMin():getY(), b3RestLength:getMin():getZ())
b3RestLength:Add( ptPointAtRestLength)
local b3PartWithOvermaterial = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sRestLengthSideForPreSimulation)
local ptStartRestLength = Point3d( Part.b3Part:getX():getMin(), Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ())
local ptEndRestLength = Point3d( b3PartWithOvermaterial:getX():getMin(), Part.b3Part:getMin():getY(), Part.b3Part:getMin():getZ())
b3RestLength = BBox3d( ptStartRestLength, ptEndRestLength)
-- caso non testato, non dovrebbe mai finire qui (il default che arriva da fuori è Tail)
else
b3RestLength = BBox3d( Part.b3Part)
b3RestLength = BBox3d()
end
-- si crea la trimesh dal box
@@ -271,7 +276,7 @@ function PreSimulationLib.CheckOutOfStrokeFromGeometry( idGeometry, vtHead, nSCC
end
-------------------------------------------------------------------------------------------------------------
local function CheckCollisionPoint( ptToolExitToCheck, vtC, vtHead, PreCollisionData, Part, sRestLengthSideForPreSimulation, bCheckOnlyRestlength)
local function CheckCollisionPoint( ptToolExitToCheck, vtC, vtHead, PreCollisionData, Part, bCannotSplitRestLength, sRestLengthSideForPreSimulation, bCheckOnlyRestlength)
local ptPivot = GetGlobalPivot( ptToolExitToCheck, vtC, vtHead, PreCollisionData.vtMovePivot)
@@ -302,7 +307,13 @@ local function CheckCollisionPoint( ptToolExitToCheck, vtC, vtHead, PreCollision
-- check collisione con pezzo
local bCollisionFoundPiece = false
if not bCheckOnlyRestlength then
bCollisionFoundPiece = EgtTestSurfaceSurface( Part.idBoxTm, idCollisionSurfTm, BeamData.COLL_SIC)
local idCheckCollisionTm = Part.idBoxTm
-- se testa o coda attaccate, si considerano nella collisione
if bCannotSplitRestLength then
local b3CheckCollision = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sRestLengthSideForPreSimulation)
idCheckCollisionTm = EgtSurfTmBBox( Part.idTempGroup, b3CheckCollision, false, GDB_RT.GLOB)
end
bCollisionFoundPiece = EgtTestSurfaceSurface( idCheckCollisionTm, idCollisionSurfTm, BeamData.COLL_SIC)
if not type( bCollisionFoundPiece) == "boolean" then
error( 'EgtTestSurfaceSurface fail')
end
@@ -318,7 +329,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
if not ( bCollisionFoundPiece or bCannotSplitRestLength) then
local idRestLengthSurfFr = GetRestlengthSurfTm( Part, sRestLengthSideForPreSimulation)
bCollisionFoundRestLength = EgtTestSurfaceSurface( idRestLengthSurfFr, idCollisionSurfTm, BeamData.COLL_SIC)
if not type( bCollisionFoundRestLength) == "boolean" then
@@ -385,7 +396,7 @@ 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, sRestLengthSideForPreSimulation, bCheckOnlyRestlength)
local bCollisionFoundPiece, bCollisionFoundRestLength = CheckCollisionPoint( ToolExitPoints[i], vtC, vtHead, PreCollisionData, Part, bCannotSplitRestLength, sRestLengthSideForPreSimulation, bCheckOnlyRestlength)
-- se trovata collisione con pezzo oppure non possibile separazione, è inutile controllare gli altri punti
if bCollisionFoundPiece or ( bCannotSplitRestLength and bCollisionFoundRestLength) then
@@ -424,12 +435,22 @@ function PreSimulationLib.CheckCollision( sBladeEngagement, Parameters, Optional
-- se cubetti in modalità standard (no DownUp) gli assi AB e C si controllano solo con grezzo (ci sarebbe collisione con il materiale già rimosso controllando AB e C con pezzo)
if bIsDicing and ( sBladeEngagement == 'Standard') then
bCheckOnlyRestlengthForAxisABC = true
-- se l'elevazione reale (rispetto al pezzo) è maggiore del massimo materiale è sempre collisione
-- TODO funzione
-- se l'elevazione reale (rispetto al pezzo + eventuale materiale in testa/coda) è maggiore del massimo materiale è sempre collisione
-- TODO rifare con funzione
else
local Edge = Parameters.Edge
local vtNFace = Parameters.vtNFace
local dDepthToMachine = Parameters.dDepthToMachine
local b3BoxForElevationCheck = BBox3d( Parameters.Part.b3Part)
-- se è un taglio di testa o coda va aggiunto il sovramateriale
if OptionalParametersCheckCollisionWithAxis.bCannotSplitRestLength then
if ( OptionalParametersCheckCollisionWithAxis.sRestLengthSideForPreSimulation == 'Head') or Parameters.Part.bIsLastPart then
b3BoxForElevationCheck = BeamLib.GetPartBoxWithHeadTailOvermaterial( Parameters.Part, OptionalParametersCheckCollisionWithAxis.sRestLengthSideForPreSimulation)
elseif OptionalParametersCheckCollisionWithAxis.sRestLengthSideForPreSimulation == 'Tail' then
local ptPointAtRestLength = Point3d( b3BoxForElevationCheck:getMin():getX() - Parameters.Part.dRestLength, b3BoxForElevationCheck:getMin():getY(), b3BoxForElevationCheck:getMin():getZ())
b3BoxForElevationCheck:Add( ptPointAtRestLength)
end
end
-- trimesh rettangolare con un lato corrispondente al lato da lavorare e larghezza come spessore utensile
local idTrimesh = EgtSurfTmRectangle( Parameters.Part.idTempGroup, Edge.ptStart, Edge.ptEnd, Edge.ptEnd + vtNFace * Parameters.Tool.dThickness, GDB_RT.GLOB)
local vtNTrimesh = EgtSurfTmFacetNormVersor( idTrimesh, 0, GDB_ID.ROOT)
@@ -437,7 +458,7 @@ function PreSimulationLib.CheckCollision( sBladeEngagement, Parameters, Optional
if not AreSameVectorApprox( Edge.vtN, vtNTrimesh) then
EgtInvertSurf( idTrimesh)
end
local dRealElevation = EgtSurfTmFacetElevationInBBox( idTrimesh, 0, Parameters.Part.b3Part, true, GDB_ID.ROOT)
local dRealElevation = EgtSurfTmFacetElevationInBBox( idTrimesh, 0, b3BoxForElevationCheck, true, GDB_ID.ROOT)
local dRealDepthToMachine = ( dRealElevation - Parameters.Edge.dElevation + dDepthToMachine)
if dRealDepthToMachine > Parameters.Tool.dMaxDepth + 10 * GEO.EPS_SMALL then
return true