From ed658fffa6cb59f96b05247c081772d69334f328 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 23 Jul 2026 09:11:45 +0200 Subject: [PATCH 1/3] - in BLADETOWASTE corretta UpdateDiceRaw per funzionare anche con tagli obliqui --- StrategyLibs/BLADETOWASTE.lua | 92 +++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 32 deletions(-) diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index b8bb894..44277cc 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -786,42 +786,70 @@ end -- nel modo attuale funziona solo se i cubetti sono orientati come le direzioni principali local function UpdateDiceRaw( idRaw, idParallelTm, idPerpendicularTm, Part, MainFace, OtherFace) - -- frame solidale alla feature - local vtZ = MainFace.vtN - local vtX = OtherFace and OtherFace.vtN or nil - local frMainFace = Frame3d( MainFace.ptCenter, vtZ, vtX) + -- -- frame solidale alla feature + -- local vtZ = MainFace.vtN + -- local vtX = OtherFace and OtherFace.vtN or nil + -- local frMainFace = Frame3d( MainFace.ptCenter, vtZ, vtX) - -- box del cubetto in riferimento feature - local b3Surf = EgtGetBBoxRef( idParallelTm, GDB_BB.STANDARD, frMainFace) - if idPerpendicularTm then - local b3SurfPerpendicular = EgtGetBBoxRef( idPerpendicularTm, GDB_BB.STANDARD, frMainFace) - b3Surf:Add( b3SurfPerpendicular) - else - -- se non arriva la superficie perpendicolare è un solo taglio parallelo: si estende il box in Z in modo da uscire dal pezzo - local ptDeltaZ = b3Surf:getMax() + vtZ * ( MainFace.dElevation + 5) - b3Surf:Add( ptDeltaZ) - end + -- -- box del cubetto in riferimento feature + -- local b3Surf = EgtGetBBoxRef( idParallelTm, GDB_BB.STANDARD, frMainFace) + -- if idPerpendicularTm then + -- local b3SurfPerpendicular = EgtGetBBoxRef( idPerpendicularTm, GDB_BB.STANDARD, frMainFace) + -- b3Surf:Add( b3SurfPerpendicular) + -- else + -- -- se non arriva la superficie perpendicolare è un solo taglio parallelo: si estende il box in Z in modo da uscire dal pezzo + -- local ptDeltaZ = b3Surf:getMax() + vtZ * ( MainFace.dElevation + 5) + -- b3Surf:Add( ptDeltaZ) + -- end - -- estensione box per non avere problemi nella sottrazione booleana - if OtherFace and idPerpendicularTm then - local vtY = vtZ ^ vtX - local ptDeltaX = b3Surf:getMax() + vtX * 1 - local ptDeltaZ = b3Surf:getMax() + vtZ * 1 - local ptDeltaYplus = b3Surf:getMax() + vtY * 1 - local ptDeltaYminus = b3Surf:getMin() - vtY * 1 - b3Surf:Add( ptDeltaX) - b3Surf:Add( ptDeltaZ) - b3Surf:Add( ptDeltaYplus) - b3Surf:Add( ptDeltaYminus) - else - b3Surf:expand( 1) - end + -- -- estensione box per non avere problemi nella sottrazione booleana + -- if OtherFace and idPerpendicularTm then + -- local vtY = vtZ ^ vtX + -- local ptDeltaX = b3Surf:getMax() + vtX * 1 + -- local ptDeltaZ = b3Surf:getMax() + vtZ * 1 + -- local ptDeltaYplus = b3Surf:getMax() + vtY * 1 + -- local ptDeltaYminus = b3Surf:getMin() - vtY * 1 + -- b3Surf:Add( ptDeltaX) + -- b3Surf:Add( ptDeltaZ) + -- b3Surf:Add( ptDeltaYplus) + -- b3Surf:Add( ptDeltaYminus) + -- else + -- b3Surf:expand( 1) + -- end - -- si porta il box in riferimento globale - b3Surf:toGlob( frMainFace) + -- -- si porta il box in riferimento globale + -- b3Surf:toGlob( frMainFace) + + -- -- conversione box cubetto in superficie + -- local idSurfTmToSubtract = EgtSurfTmBBox( Part.idTempGroup, b3Surf, false, GDB_RT.GLOB) + + -- frame solidale alla feature + + local idAddGroup = BeamLib.GetAddGroup( Part.id) + + + -- contorno della faccia parallela + local vtNParallelFaceTm = EgtSurfTmFacetNormVersor( idParallelTm, 0, GDB_ID.ROOT) + local idParallelFaceCurveCompo = EgtExtractSurfTmLoops( idParallelTm, idAddGroup) --Part.idTempGroup + EgtModifyCurveExtrusion( idParallelFaceCurveCompo, vtNParallelFaceTm, GDB_RT.GLOB) + EgtOffsetCurve( idParallelFaceCurveCompo, 1000, GDB_OT.EXTEND) + + -- trimesh da sottrarre + local vtExtrusion = 1000 * vtNParallelFaceTm + local idSurfTmToSubtract = EgtSurfTmByRegionExtrusion( idAddGroup, idParallelFaceCurveCompo, vtExtrusion , 0.05, GDB_RT.GLOB) --Part.idTempGroup + local ptCenterPerpendicularTm, vtNPerpendicularTm = EgtSurfTmFacetCenter( idPerpendicularTm, 0, GDB_ID.ROOT) + if idPerpendicularTm then + EgtCutSurfTmPlane( idSurfTmToSubtract, ptCenterPerpendicularTm, -vtNPerpendicularTm, false, GDB_RT.GLOB) + end + + local idRemovedFaceCurveCompo = EgtExtractSurfTmLoops( idSurfTmToSubtract, idAddGroup) + local idRemovedFaceTm = EgtSurfTmByFlatContour( idAddGroup, idRemovedFaceCurveCompo) + local vtNRemovedFace = EgtSurfTmFacetNormVersor( idRemovedFaceTm, 0, GDB_ID.ROOT) + if AreSameVectorApprox( vtNPerpendicularTm, vtNRemovedFace) then + EgtInvertSurf( idRemovedFaceTm) + end + idSurfTmToSubtract = EgtSurfTmBySewing( idAddGroup, { idSurfTmToSubtract, idRemovedFaceTm}) - -- conversione box cubetto in superficie - local idSurfTmToSubtract = EgtSurfTmBBox( Part.idTempGroup, b3Surf, false, GDB_RT.GLOB) -- sottrazione del cubetto dal grezzo EgtSurfTmSubtract( idRaw, idSurfTmToSubtract) From 793aff4ffb58583f92715f6c8bb05a6d8e171e5f Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 23 Jul 2026 18:02:48 +0200 Subject: [PATCH 2/3] =?UTF-8?q?-=20in=20BLADETOWASTE.UpdateDiceRaw=20corre?= =?UTF-8?q?tto=20(rifatto)=20il=20calcolo=20del=20grezzo=20dinamico=20per?= =?UTF-8?q?=20cubetti=20-=20in=20PreSimulationLib=20se=20trovata=20collisi?= =?UTF-8?q?one=20i=20solidi=20interessati=20si=20copiano=20nel=20livello?= =?UTF-8?q?=20Mach=20(temporaneamente,=20sar=C3=A0=20da=20mettere=20in=20g?= =?UTF-8?q?ruppo=20apposito)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/PreSimulationLib.lua | 11 ++++- StrategyLibs/BLADETOWASTE.lua | 78 ++++++++--------------------------- 2 files changed, 26 insertions(+), 63 deletions(-) diff --git a/LuaLibs/PreSimulationLib.lua b/LuaLibs/PreSimulationLib.lua index c3bf666..f41acde 100644 --- a/LuaLibs/PreSimulationLib.lua +++ b/LuaLibs/PreSimulationLib.lua @@ -301,6 +301,8 @@ end ------------------------------------------------------------------------------------------------------------- local function CheckCollisionPoint( sAxis, ptOnToolTipCenter, vtHead, vtAux, Part, bCannotSplitRestLength, sRestLengthSideForPreSimulation, idCheckCollisionTm, idAddedCollisionSurfTm) + local idAddGroup = BeamLib.GetAddGroup( Part.id) + -- spostamento assi macchina in posizione local dDeltaXHeadOffset = MoveMachineAxesToPosition( ptOnToolTipCenter, vtHead, vtAux) @@ -350,6 +352,11 @@ local function CheckCollisionPoint( sAxis, ptOnToolTipCenter, vtHead, vtAux, Par end if EgtGetDebugLevel() >= 3 and bCollisionFoundPiece then EgtSetColor( CollisionSurfTmId[i], RED()) + local idBeamCopy = EgtCopyGlob( idCheckCollisionTm, idAddGroup) + EgtSetName( idBeamCopy, 'COLL_BEAM') + local idHeadCopy = EgtCopyGlob( CollisionSurfTmId[i], idAddGroup) + EgtSetName( idHeadCopy, 'COLL_' .. sAxis) + EgtVector( idAddGroup, vtHead, ptOnToolTipCenter, GDB_RT.GLOB) end if bCollisionFoundPiece then break @@ -430,8 +437,8 @@ local function CheckCollisionWithAxis( sAxis, MachiningParameters, OptionalParam if bCheckFlange and Tool.sType == 'SAW_FLAT' then local ptCenterFlange = PointsOnToolTipCenter[i] + vtHead * Tool.dThickness local frHead = Frame3d( ptCenterFlange, vtHead) - local dExtraSafety = 2 -- valore empirico che serve nei casi molto inclinati, ci potrebbero essere casi in cui va aumentato - local idFlangeCurve = EgtCircle( Part.idTempGroup, ORIG(), dExtraSafety + Tool.dDiameter / 2 - Tool.dMaxDepth, GDB_RT.GLOB) + local dFlangeRadius = Tool.ToolHolder.dDiameter / 2 + local idFlangeCurve = EgtCircle( Part.idTempGroup, ORIG(), dFlangeRadius, GDB_RT.GLOB) EgtTransform( idFlangeCurve, frHead, GDB_RT.GLOB) -- TODO verificare se questo controllo serve diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index 44277cc..c4a26ec 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -358,8 +358,8 @@ local function GetBestBlade( Proc, Part, Face, OptionalParameters) end -local function SetDiceFaceInfo( Proc, idDiceFace) - EgtSetName( idDiceFace, 'Face' .. tostring( Proc.idFeature or 'Add') .. '_Dice') +local function SetDiceFaceInfo( Proc, idDiceFace, sType) + EgtSetName( idDiceFace, 'Face' .. tostring( Proc.idFeature or 'Add') .. '_Dice_' .. sType) end @@ -782,75 +782,30 @@ local function CutWholeWaste( Proc, Part, OptionalParameters) end --- TODO da rivedere!! Si devono creare trimesh estruse nelle direzioni normali alle due facce, unirle e poi sottrarle al solido --- nel modo attuale funziona solo se i cubetti sono orientati come le direzioni principali local function UpdateDiceRaw( idRaw, idParallelTm, idPerpendicularTm, Part, MainFace, OtherFace) - -- -- frame solidale alla feature - -- local vtZ = MainFace.vtN - -- local vtX = OtherFace and OtherFace.vtN or nil - -- local frMainFace = Frame3d( MainFace.ptCenter, vtZ, vtX) - - -- -- box del cubetto in riferimento feature - -- local b3Surf = EgtGetBBoxRef( idParallelTm, GDB_BB.STANDARD, frMainFace) - -- if idPerpendicularTm then - -- local b3SurfPerpendicular = EgtGetBBoxRef( idPerpendicularTm, GDB_BB.STANDARD, frMainFace) - -- b3Surf:Add( b3SurfPerpendicular) - -- else - -- -- se non arriva la superficie perpendicolare è un solo taglio parallelo: si estende il box in Z in modo da uscire dal pezzo - -- local ptDeltaZ = b3Surf:getMax() + vtZ * ( MainFace.dElevation + 5) - -- b3Surf:Add( ptDeltaZ) - -- end - - -- -- estensione box per non avere problemi nella sottrazione booleana - -- if OtherFace and idPerpendicularTm then - -- local vtY = vtZ ^ vtX - -- local ptDeltaX = b3Surf:getMax() + vtX * 1 - -- local ptDeltaZ = b3Surf:getMax() + vtZ * 1 - -- local ptDeltaYplus = b3Surf:getMax() + vtY * 1 - -- local ptDeltaYminus = b3Surf:getMin() - vtY * 1 - -- b3Surf:Add( ptDeltaX) - -- b3Surf:Add( ptDeltaZ) - -- b3Surf:Add( ptDeltaYplus) - -- b3Surf:Add( ptDeltaYminus) - -- else - -- b3Surf:expand( 1) - -- end - - -- -- si porta il box in riferimento globale - -- b3Surf:toGlob( frMainFace) - - -- -- conversione box cubetto in superficie - -- local idSurfTmToSubtract = EgtSurfTmBBox( Part.idTempGroup, b3Surf, false, GDB_RT.GLOB) - - -- frame solidale alla feature - - local idAddGroup = BeamLib.GetAddGroup( Part.id) - - -- contorno della faccia parallela local vtNParallelFaceTm = EgtSurfTmFacetNormVersor( idParallelTm, 0, GDB_ID.ROOT) - local idParallelFaceCurveCompo = EgtExtractSurfTmLoops( idParallelTm, idAddGroup) --Part.idTempGroup + local idParallelFaceCurveCompo = EgtExtractSurfTmLoops( idParallelTm, Part.idTempGroup) EgtModifyCurveExtrusion( idParallelFaceCurveCompo, vtNParallelFaceTm, GDB_RT.GLOB) - EgtOffsetCurve( idParallelFaceCurveCompo, 1000, GDB_OT.EXTEND) + EgtOffsetCurve( idParallelFaceCurveCompo, 100, GDB_OT.EXTEND) - -- trimesh da sottrarre + -- trimesh da sottrarre, tagliata con il piano perpendicolare local vtExtrusion = 1000 * vtNParallelFaceTm - local idSurfTmToSubtract = EgtSurfTmByRegionExtrusion( idAddGroup, idParallelFaceCurveCompo, vtExtrusion , 0.05, GDB_RT.GLOB) --Part.idTempGroup - local ptCenterPerpendicularTm, vtNPerpendicularTm = EgtSurfTmFacetCenter( idPerpendicularTm, 0, GDB_ID.ROOT) + local idSurfTmToSubtract = EgtSurfTmByRegionExtrusion( Part.idTempGroup, idParallelFaceCurveCompo, vtExtrusion, 0.05, GDB_RT.GLOB) if idPerpendicularTm then + local ptCenterPerpendicularTm, vtNPerpendicularTm = EgtSurfTmFacetCenter( idPerpendicularTm, 0, GDB_ID.ROOT) EgtCutSurfTmPlane( idSurfTmToSubtract, ptCenterPerpendicularTm, -vtNPerpendicularTm, false, GDB_RT.GLOB) + -- dove la trimesh è stata tagliata mancherà la faccia: si riaggiunge + local idRemovedFaceCurveCompo = EgtExtractSurfTmLoops( idSurfTmToSubtract, Part.idTempGroup) + local idRemovedFaceTm = EgtSurfTmByFlatContour( Part.idTempGroup, idRemovedFaceCurveCompo) + local vtNRemovedFace = EgtSurfTmFacetNormVersor( idRemovedFaceTm, 0, GDB_ID.ROOT) + if AreSameVectorApprox( vtNPerpendicularTm, vtNRemovedFace) then + EgtInvertSurf( idRemovedFaceTm) + end + idSurfTmToSubtract = EgtSurfTmBySewing( Part.idTempGroup, { idSurfTmToSubtract, idRemovedFaceTm}) end - local idRemovedFaceCurveCompo = EgtExtractSurfTmLoops( idSurfTmToSubtract, idAddGroup) - local idRemovedFaceTm = EgtSurfTmByFlatContour( idAddGroup, idRemovedFaceCurveCompo) - local vtNRemovedFace = EgtSurfTmFacetNormVersor( idRemovedFaceTm, 0, GDB_ID.ROOT) - if AreSameVectorApprox( vtNPerpendicularTm, vtNRemovedFace) then - EgtInvertSurf( idRemovedFaceTm) - end - idSurfTmToSubtract = EgtSurfTmBySewing( idAddGroup, { idSurfTmToSubtract, idRemovedFaceTm}) - - -- sottrazione del cubetto dal grezzo EgtSurfTmSubtract( idRaw, idSurfTmToSubtract) @@ -886,7 +841,8 @@ local function CalculateDiceMachinings( vCuts, Parameters) local bAreOrthogonalCutsInverted = false for i = 1, #vCuts do for j = 1, #vCuts[i] do - SetDiceFaceInfo( Proc, vCuts[i][j]) + local sType = ( i % 2 == 0) and 'PARAL' or 'PERP' + SetDiceFaceInfo( Proc, vCuts[i][j], sType) end end -- calcolo lavorazioni From b10844beeda0e60ce1ea7b53543f7716fb9830ac Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 24 Jul 2026 14:37:03 +0200 Subject: [PATCH 3/3] - in BLADETOWASTE corretta UpdateDiceRaw - in FACEBYBLADE tutte le feature aperte sul retro e che occupano tutta la sezione diventano AfterTail --- LuaLibs/PreSimulationLib.lua | 1 + StrategyLibs/BLADETOWASTE.lua | 8 ++++---- StrategyLibs/FACEBYBLADE.lua | 11 ++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/LuaLibs/PreSimulationLib.lua b/LuaLibs/PreSimulationLib.lua index f41acde..e13804d 100644 --- a/LuaLibs/PreSimulationLib.lua +++ b/LuaLibs/PreSimulationLib.lua @@ -357,6 +357,7 @@ local function CheckCollisionPoint( sAxis, ptOnToolTipCenter, vtHead, vtAux, Par local idHeadCopy = EgtCopyGlob( CollisionSurfTmId[i], idAddGroup) EgtSetName( idHeadCopy, 'COLL_' .. sAxis) EgtVector( idAddGroup, vtHead, ptOnToolTipCenter, GDB_RT.GLOB) + EgtSetStatus( { idBeamCopy, idHeadCopy}, GDB_ST.OFF) end if bCollisionFoundPiece then break diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index c4a26ec..26036c8 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -782,7 +782,7 @@ local function CutWholeWaste( Proc, Part, OptionalParameters) end -local function UpdateDiceRaw( idRaw, idParallelTm, idPerpendicularTm, Part, MainFace, OtherFace) +local function UpdateDiceRaw( idRaw, idParallelTm, idPerpendicularTm, Part) -- contorno della faccia parallela local vtNParallelFaceTm = EgtSurfTmFacetNormVersor( idParallelTm, 0, GDB_ID.ROOT) @@ -841,7 +841,7 @@ local function CalculateDiceMachinings( vCuts, Parameters) local bAreOrthogonalCutsInverted = false for i = 1, #vCuts do for j = 1, #vCuts[i] do - local sType = ( i % 2 == 0) and 'PARAL' or 'PERP' + local sType = ( i % 2 == 0) and 'Paral' or 'Perp' SetDiceFaceInfo( Proc, vCuts[i][j], sType) end end @@ -908,7 +908,7 @@ local function CalculateDiceMachinings( vCuts, Parameters) end -- aggiornamento grezzo dinamico if i % 2 == 0 then - UpdateDiceRaw( idCheckCollisionTm, idSurfToCut, vCuts[i-1][#vCuts[i-1]], Part, MainFace, OtherFace) + UpdateDiceRaw( idCheckCollisionTm, idSurfToCut, nil, Part) end else EgtErase( idSurfToCut) @@ -972,7 +972,7 @@ local function CalculateDiceMachinings( vCuts, Parameters) end -- aggiornamento grezzo dinamico if i % 2 == 0 then - UpdateDiceRaw( idCheckCollisionTm, vCuts[i][j], vCuts[i-1][j], Part, MainFace, OtherFace) + UpdateDiceRaw( idCheckCollisionTm, vCuts[i][j], vCuts[i-1][j], Part) end end end diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index c46ed9f..c0e088d 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -603,14 +603,15 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- TODO già guardare se il box della faccia è aperto sulla coda, invece di tutta la trimesh, escluderebbe tanti casi Cutting.bMoveAfterSplit = Cutting.bMoveAfterSplit or Cutting.LeadIn.bMoveAfterSplit or Cutting.LeadOut.bMoveAfterSplit local bIsTruncatingCutOnTail = Proc.Topology and ( Proc.Topology.sName == 'Cut-1-Through' or Proc.Topology.sName == 'TailCut') and Proc.AffectedFaces.bLeft - if Cutting.bMoveAfterSplit or bIsTruncatingCutOnTail then + local bIsFeatureBigAsRawOnTail = ( Proc.b3Box:getDimY() > Part.b3Raw:getDimY() - 100 * GEO.EPS_SMALL) and + ( Proc.b3Box:getDimZ() > Part.b3Raw:getDimZ() - 100 * GEO.EPS_SMALL) and + Proc.AffectedFaces.bLeft + if Cutting.bMoveAfterSplit or bIsTruncatingCutOnTail or bIsFeatureBigAsRawOnTail then Cutting.sStage = 'AfterTail' elseif Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or - ( Cutting.vtToolDirection:getX() < 0.707 and - not ( Cutting.vtToolDirection:getX() > - 10 * GEO.EPS_SMALL and - ( AreSameOrOppositeVectorApprox( EdgeToMachine.vtEdge, Z_AX()) or - AreSameOrOppositeVectorApprox( EdgeToMachine.vtEdge, Y_AX()))))) then + ( Cutting.vtToolDirection:getX() < 0.707 and not ( Cutting.vtToolDirection:getX() > - 10 * GEO.EPS_SMALL and ( AreSameOrOppositeVectorApprox( EdgeToMachine.vtEdge, Z_AX()) or + AreSameOrOppositeVectorApprox( EdgeToMachine.vtEdge, Y_AX()))))) then local dLengthOnX = Cutting.dLengthOnX -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione