diff --git a/LuaLibs/PreSimulationLib.lua b/LuaLibs/PreSimulationLib.lua index c3bf666..e13804d 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,12 @@ 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) + EgtSetStatus( { idBeamCopy, idHeadCopy}, GDB_ST.OFF) end if bCollisionFoundPiece then break @@ -430,8 +438,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 b8bb894..26036c8 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,47 +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) +local function UpdateDiceRaw( idRaw, idParallelTm, idPerpendicularTm, Part) - -- frame solidale alla feature - local vtZ = MainFace.vtN - local vtX = OtherFace and OtherFace.vtN or nil - local frMainFace = Frame3d( MainFace.ptCenter, vtZ, vtX) + -- contorno della faccia parallela + local vtNParallelFaceTm = EgtSurfTmFacetNormVersor( idParallelTm, 0, GDB_ID.ROOT) + local idParallelFaceCurveCompo = EgtExtractSurfTmLoops( idParallelTm, Part.idTempGroup) + EgtModifyCurveExtrusion( idParallelFaceCurveCompo, vtNParallelFaceTm, GDB_RT.GLOB) + EgtOffsetCurve( idParallelFaceCurveCompo, 100, GDB_OT.EXTEND) - -- box del cubetto in riferimento feature - local b3Surf = EgtGetBBoxRef( idParallelTm, GDB_BB.STANDARD, frMainFace) + -- trimesh da sottrarre, tagliata con il piano perpendicolare + local vtExtrusion = 1000 * vtNParallelFaceTm + local idSurfTmToSubtract = EgtSurfTmByRegionExtrusion( Part.idTempGroup, idParallelFaceCurveCompo, vtExtrusion, 0.05, GDB_RT.GLOB) 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) + 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 - -- 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) - -- sottrazione del cubetto dal grezzo EgtSurfTmSubtract( idRaw, idSurfTmToSubtract) @@ -858,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 @@ -924,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) @@ -988,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