diff --git a/LuaLibs/DiceCut.lua b/LuaLibs/DiceCut.lua index 0389546..5332f14 100644 --- a/LuaLibs/DiceCut.lua +++ b/LuaLibs/DiceCut.lua @@ -453,7 +453,7 @@ function DiceCut.GetDice( Part, Face1, Face2, OptionalParameters) -- se piani non ortogonali, diminuisco la distanza di offset opportunamente local dOffsetParallelOriginal = dOffsetParallel if not bGetOrtoPlanes then - local dCoeff = ( vtNMainFace ^ vtNSubordinateFace):len() + local dCoeff = max( ( vtNMainFace ^ vtNSubordinateFace):len(), 0.5) dOffsetParallel = dOffsetParallel * dCoeff dOffsetOrthogonal = dOffsetOrthogonal * dCoeff end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 9b9efe0..05f173c 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -363,16 +363,22 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters) -- attacco perpendicolare local PerpendicularLeadInOut = LeadInOutLib.CalculateLeadInOut( 'Perpendicular', Parameters, LeadInOutOptionalParameters) -- check extracorsa nei punti di attacco - PointsOnToolTipCenter = { PreSimulationLib.GetPointOnToolTipCenter( PerpendicularLeadInOut.LeadIn.ptPoint, vtHead, Face.vtN, Edge.vtN, Tool), PreSimulationLib.GetPointOnToolTipCenter( PerpendicularLeadInOut.LeadOut.ptPoint, vtHead, Face.vtN, Edge.vtN, Tool) } local bOutOfStrokePerpendicular = PreSimulationLib.CheckOutOfStrokeFromPoints( PointsOnToolTipCenter, vtHead, nSCC, Tool) - -- se non è in extracorsa si aggiunge come attacco possibile + -- attacco perpendicolare non in extracorsa: si verifica se è in collisione if not bOutOfStrokePerpendicular then - LeadInOut.Perpendicular = PerpendicularLeadInOut - LeadInOut.Perpendicular.bMoveAfterSplit = bMoveAfterSplit + CheckCollisionOptionalParameters.PointsToCheck = {} + table.insert( CheckCollisionOptionalParameters.PointsToCheck, PerpendicularLeadInOut.LeadIn.ptPoint) + table.insert( CheckCollisionOptionalParameters.PointsToCheck, PerpendicularLeadInOut.LeadOut.ptPoint) + local bCollisionFoundPerpendicular, bMoveAfterSplitPerpendicular = PreSimulationLib.CheckCollision( sBladeEngagement, CheckCollisionParameters, CheckCollisionOptionalParameters) + -- attacco perpendicolare possibile + if not bCollisionFoundPerpendicular then + LeadInOut.Perpendicular = PerpendicularLeadInOut + LeadInOut.Perpendicular.bMoveAfterSplit = bMoveAfterSplitPerpendicular + end end -- se c'è almeno un lato chiuso l'unico attacco possibile è il perpendicolare if not ( Edge.bIsStartOpen and Edge.bIsEndOpen) then diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index d85970e..bbc110e 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -795,6 +795,7 @@ local function CalculateDiceMachinings( vCuts, Parameters) local bReduceBladePath = Parameters.bReduceBladePath local sRestLengthSideForPreSimulation = Parameters.sRestLengthSideForPreSimulation local bCannotSplitRestLength = Parameters.bCannotSplitRestLength + local bReduceDiceDepth = Parameters.bReduceDiceDepth -- eventuale inversione tagli ortogonali e aggiunta informazioni alla geometria local bAreOrthogonalCutsInverted = false @@ -884,8 +885,13 @@ local function CalculateDiceMachinings( vCuts, Parameters) -- caso standard (tagli perpendicolari o paralleli non accorpabili) if ( not bCanMergeParallelCuts) or ( not bIsDicingOk) then for j = 1, #vCuts[i] do - -- in generale sta sollevato di pochissimo - local dExtraCut = -0.1 + -- se abilitato, la lama sta sollevata per non rovinare le facce + local dExtraCut + if bReduceDiceDepth == false then + dExtraCut = 0 + else + dExtraCut = -0.1 + end -- se tagli paralleli if ( i % 2) == 0 then -- se non ci sono tagli ortogonali devo affondare @@ -964,6 +970,9 @@ local function CutWithDicing( Proc, Part, OptionalParameters) end end + -- angolo tra le facce, se più di una + local dAngleBetweenFaces = Proc.AdjacencyMatrix[1][2] + -- scelta lama da sopra o da sotto local sChosenBladeType = '' if not nToolIndex then @@ -1008,7 +1017,8 @@ local function CutWithDicing( Proc, Part, OptionalParameters) dExtendAfterTail = dExtendAfterTail, bReduceBladePath = bReduceBladePath, sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, - bCannotSplitRestLength = bCannotSplitRestLength + bCannotSplitRestLength = bCannotSplitRestLength, + bReduceDiceDepth = ( dAngleBetweenFaces < - 10) -- per facce molto aperte non si riduce l'affondamento della lama nei cubetti (rischio che non si stacchino) } bIsDicingOk, Machinings, bMoveAfterSplit = CalculateDiceMachinings( vCuts, Parameters)