- sistemati box aggiunti in testa e coda per preSimulation e calcolo attacchi

- in FACEBYBLADE corretti attacchi a ghigliottina (verificare)
This commit is contained in:
luca.mazzoleni
2026-01-30 18:58:15 +01:00
parent 7a84f2c396
commit 67a595e311
6 changed files with 103 additions and 60 deletions
+25 -29
View File
@@ -65,28 +65,27 @@ local function LogOutstroke( ptOnToolTipCenter, vtHead, OptionalParameters)
end
-------------------------------------------------------------------------------------------------------------
-- costruzione trimesh del grezzo restante in testa o in coda (con leggera sovrapposizione)
local function GetRestlengthSurfTm( Part, sRestLengthSideForPreSimulation)
-- costruzione trimesh del grezzo restante in testa o in coda
local function GetRestlengthSurfTm( Part, sSide)
-- si costruisce il box in globale
local b3RestLength
if sRestLengthSideForPreSimulation == 'Head' then
local b3PartWithOvermaterial = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sRestLengthSideForPreSimulation)
if sSide == 'Head' then
local b3PartWithOvermaterial = BeamLib.GetPartBoxWithHeadTail( Part, sSide)
local ptStartRestLength = Point3d( Part.b3Part:getMax():getX(), Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ())
local ptEndRestLength = Point3d( b3PartWithOvermaterial:getMax():getX(), Part.b3Part:getMin():getY(), Part.b3Part:getMin():getZ())
b3RestLength = BBox3d( ptStartRestLength, ptEndRestLength)
elseif sRestLengthSideForPreSimulation == 'Tail' then
local b3PartWithOvermaterial = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sRestLengthSideForPreSimulation)
local ptXMin = b3PartWithOvermaterial:getMin():getX()
if not Part.bIsLastPart then
ptXMin = Part.b3Part:getMin():getX() - 2000
end
elseif sSide == 'Tail' then
local b3PartWithOvermaterial = BeamLib.GetPartBoxWithHeadTail( Part, sSide)
local dXMin = b3PartWithOvermaterial:getMin():getX()
-- si evita sempre di lavorare col motore dietro la coda della barra (potrebbe succedere con barra restante molto corta): in quel caso si deve sempre separare prima
dXMin = min( dXMin, Part.b3Part:getMin():getX() - 2000)
local ptStartRestLength = Point3d( Part.b3Part:getMin():getX(), Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ())
local ptEndRestLength = Point3d( ptXMin, Part.b3Part:getMin():getY(), Part.b3Part:getMin():getZ())
local ptEndRestLength = Point3d( dXMin, 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()
return nil
end
-- si crea la trimesh dal box
@@ -312,14 +311,14 @@ local function CheckCollisionPoint( ptToolExitToCheck, vtC, vtHead, PreCollision
local bCollisionFoundPiece = false
if not bCheckOnlyRestlength then
local idCheckCollisionTm = Part.idBoxTm
-- se testa o coda attaccate, si considerano nella collisione
-- se testa o coda attaccate, si considerano nella superficie di collisione
if bCannotSplitRestLength then
local b3CheckCollision = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sRestLengthSideForPreSimulation)
local b3CheckCollision = BeamLib.GetPartBoxWithHeadTail( Part, sRestLengthSideForPreSimulation)
idCheckCollisionTm = EgtSurfTmBBox( Part.idTempGroup, b3CheckCollision, false, GDB_RT.GLOB)
end
bCollisionFoundPiece = EgtTestSurfaceSurface( idCheckCollisionTm, idCollisionSurfTm, BeamData.COLL_SIC)
bCollisionFoundPiece = EgtCDeSolidSolid( idCheckCollisionTm, idCollisionSurfTm, BeamData.COLL_SIC)
if not type( bCollisionFoundPiece) == "boolean" then
error( 'EgtTestSurfaceSurface fail')
error( 'Presimulation fail')
end
if EgtGetDebugLevel() >= 3 and bCollisionFoundPiece then
EgtSetColor( idCollisionSurfTm, RED())
@@ -331,16 +330,18 @@ local function CheckCollisionPoint( ptToolExitToCheck, vtC, vtHead, PreCollision
end
end
-- check collisione con grezzo restante, se con il pezzo non c'è collisione
-- check collisione con grezzo restante, se con il pezzo non c'è collisione e non è un taglio di testa o coda
local bCollisionFoundRestLength = false
if not ( bCollisionFoundPiece or bCannotSplitRestLength) then
local idRestLengthSurfFr = GetRestlengthSurfTm( Part, sRestLengthSideForPreSimulation)
bCollisionFoundRestLength = EgtTestSurfaceSurface( idRestLengthSurfFr, idCollisionSurfTm, BeamData.COLL_SIC)
if not type( bCollisionFoundRestLength) == "boolean" then
error( 'EgtTestSurfaceSurface fail')
end
if EgtGetDebugLevel() >= 3 and bCollisionFoundRestLength then
EgtSetColor( idCollisionSurfTm, ORANGE())
if idRestLengthSurfFr then
bCollisionFoundRestLength = EgtCDeSolidSolid( idRestLengthSurfFr, idCollisionSurfTm, BeamData.COLL_SIC)
if not type( bCollisionFoundRestLength) == "boolean" then
error( 'Presimulation fail')
end
if EgtGetDebugLevel() >= 3 and bCollisionFoundRestLength then
EgtSetColor( idCollisionSurfTm, ORANGE())
end
end
end
@@ -448,12 +449,7 @@ function PreSimulationLib.CheckCollision( sBladeEngagement, Parameters, Optional
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
b3BoxForElevationCheck = BeamLib.GetPartBoxWithHeadTail( Parameters.Part, OptionalParametersCheckCollisionWithAxis.sRestLengthSideForPreSimulation)
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)