diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index bfc88fe..17fee4b 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -320,6 +320,7 @@ local function Check2DBladeCollision( Edge, vtNFace, vtHead, Part, Tool, dDepthT ptMaxElev = ptMaxElev + vtNFace * Tool.dThickness end -- TODO qui sostituire con il valore reale letto dal SetupInfo + -- per Fast si dovrà aggiungere la lunghezza del massimo utensile utilizzabile con lama local dHeadDepth = 480 local dHeadWidth = 480 local ptOpposite = ptMaxElev + Edge.vtN * dHeadWidth @@ -328,12 +329,19 @@ local function Check2DBladeCollision( Edge, vtNFace, vtHead, Part, Tool, dDepthT -- flat region dal rettangolo local idHeadSurfFr = EgtSurfFlatRegion( idTempGroup, idHeadRectangle) - -- intersezione - --local idTestSurfFr = EgtCopyGlob( idPartSurfFr, idTempGroup) - -- TODO ritornare correttamente - local bCollisionFound = EgtSurfFrIntersect( idPartSurfFr, idHeadSurfFr) + -- intersezione (se fallisce si inverte la flat region del motore, probabile normale opposta) + local bIntersectSuccess = EgtSurfFrIntersect( idPartSurfFr, idHeadSurfFr) + if not bIntersectSuccess then + EgtInvertSurf( idHeadSurfFr) + bIntersectSuccess = EgtSurfFrIntersect( idPartSurfFr, idHeadSurfFr) + end + if not bIntersectSuccess then + error( 'Check2DBladeCollision : intersect fail') + end - return false + local bCollisionFound = EgtExistsObj( idPartSurfFr) + + return bCollisionFound end ------------------------------------------------------------------------------------------------------------- diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index 7b78014..f1a762e 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -273,7 +273,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if nToolIndex then Cutting.nToolIndex = nToolIndex - Cutting.bIsApplicable, Cutting.sBladeEngagement = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachine, Part, TOOLS[nToolIndex], dDepthToMachine, bCollisionCheckForDownUpOnly) + Cutting.bIsApplicable, Cutting.sBladeEngagement = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachine, Part, TOOLS[Cutting.nToolIndex], dDepthToMachine, bCollisionCheckForDownUpOnly) -- utensile da cercare: si prende la lama migliore che può effettuare questo taglio, senza particolari analisi else @@ -347,7 +347,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if OppositeToolDirectionMode ~= 'Disabled' then -- lavorando dalla direzione opposta si verifica come se si lavorasse il lato opposto - local bIsApplicableOpposite, sBladeEngagementOpposite = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachineOpposite, Part, TOOLS[nToolIndex], dDepthToMachine, bCollisionCheckForDownUpOnly) + local bIsApplicableOpposite, sBladeEngagementOpposite = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachineOpposite, Part, TOOLS[Cutting.nToolIndex], dDepthToMachine, bCollisionCheckForDownUpOnly) -- taglio opposto non fattibile if not bIsApplicableOpposite then @@ -416,9 +416,9 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar and FaceData.IsFaceRectangle( FaceToMachine) then -- TODO la lama sotto deve poter ridurre. Ghigliottina sì o no? - local bIsTopBlade = TOOLS[nToolIndex].SetupInfo.HeadType.bTop - Cutting.dMaxRadialOffset = TOOLS[nToolIndex].dMaxMaterial - Cutting.dDepthToMachine - BeamData.CUT_SIC - Cutting.dRadialOffsetGuillotine = FACEBYBLADE.GetRadialOffsetForGuillotine( nToolIndex, EdgeToMachine.dLength) + local bIsTopBlade = TOOLS[Cutting.nToolIndex].SetupInfo.HeadType.bTop + Cutting.dMaxRadialOffset = TOOLS[Cutting.nToolIndex].dMaxMaterial - Cutting.dDepthToMachine - BeamData.CUT_SIC + Cutting.dRadialOffsetGuillotine = FACEBYBLADE.GetRadialOffsetForGuillotine( Cutting.nToolIndex, EdgeToMachine.dLength) if Cutting.dMaxRadialOffset > 10 * GEO.EPS_SMALL then -- taglio a ghigliottina if bIsTopBlade and ( Cutting.dRadialOffsetGuillotine < Cutting.dMaxRadialOffset - 10 * GEO.EPS_SMALL) then @@ -437,7 +437,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if OppositeToolDirectionMode == 'Enabled' then EdgeToMachineForEngagement = EdgeToMachineOpposite end - local bIsApplicable, sBladeEngagement = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachineForEngagement, Part, TOOLS[nToolIndex], dDepthToMachine) + local bIsApplicable, sBladeEngagement = MachiningLib.GetBladeEngagement( FaceToMachine, EdgeToMachineForEngagement, Part, TOOLS[Cutting.nToolIndex], dDepthToMachine) if bIsApplicable then Cutting.sBladeEngagement = sBladeEngagement else