diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index ddf4a91..3b2f76e 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -277,39 +277,6 @@ function BeamLib.Is3EdgesApprox( Proc, idFace, nAddGrpId) return bResult end ---------------------------------------------------------------------- ---- ritorna il riferimento di tipo OCS della faccia *idFace* della trimesh *nSurfId* e le dimensioni orizzontale e verticale, eventualmente limitate dal grezzo *Part.RawBox* -function BeamLib.GetFaceHvRefDim( nSurfId, idFace, Part) - -- recupero centro e normale della faccia - local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, idFace, GDB_ID.ROOT) - if not ptC or not vtN then - return - end - -- riferimento tipo OCS della faccia (X orizz, Y max pendenza, Z normale) - local frHV = Frame3d( ptC, vtN) - if frHV:getVersY():getZ() < 0 then - frHV:rotate( ptC, vtN, 180) - end - -- determino l'ingombro in questo riferimento - local b3HV = EgtSurfTmGetFacetBBoxRef( nSurfId, idFace, GDB_BB.STANDARD, frHV) - local dDimH = b3HV:getDimX() - local dDimV = b3HV:getDimY() - -- se definito grezzo (o solido), applico eventuali limiti - if Part.b3Raw then - local dCoeffY = abs( frHV:getVersX():getY()) - if dCoeffY > GEO.EPS_SMALL then - dDimH = min( dDimH, Part.b3Raw:getDimY() / dCoeffY) - end - local dCoeffZ = abs( frHV:getVersY():getZ()) - if dCoeffZ > GEO.EPS_SMALL then - dDimV = min( dDimV, Part.b3Raw:getDimZ() / dCoeffZ) - end - end - - -- restituisco i valori calcolati - return frHV, dDimH, dDimV -end - ------------------------------------------------------------------------------------------------------------- -- sovrascrivo i parametri personalizzati salvati su Proc a quelli di default dalla strategia -- N.B. : I parametri personalizzati non più presenti tra i default della strategia, verranno ignorati. Quelli extra avranno valore di default diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index 82f17e2..6967a04 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -116,14 +116,8 @@ function FaceData.GetFacesInfo( Proc, Part) Faces[i].id = i - 1 Faces[i].ptCenter, Faces[i].vtN = EgtSurfTmFacetCenter( Proc.id, i - 1, GDB_ID.ROOT) if Proc.nFct < 6 then - local frHV, dFaceWidth, dFaceHeight = BeamLib.GetFaceHvRefDim( Proc.id, i - 1, Part) -- frame OCS faccia - Faces[i].vtFrameHV = frHV - -- TODO valutare se Width e Height si possono rimuovere - -- larghezza OCS faccia - Faces[i].dWidth = dFaceWidth - -- altezza OCS faccia - Faces[i].dHeight = dFaceHeight + Faces[i].vtFrameHV = Frame3d( Faces[i].ptCenter, Faces[i].vtN) -- elevazione calcolata rispetto al box della parte Faces[i].dElevation = EgtSurfTmFacetElevationInBBox( Proc.id, i - 1, Part.b3Solid, true, GDB_ID.ROOT) -- TODO qui sarebbe meglio l'area vera e non quella del rettangolo minimo @@ -195,9 +189,6 @@ local function GetTunnelFaces( Proc, Part) TunnelAddedFaces.MiddleFaceTm.Type = 'Tunnel' TunnelAddedFaces.MiddleFaceTm.nFct = 1 TunnelAddedFaces.MiddleFaceTm.Faces = FaceData.GetFacesInfo( TunnelAddedFaces.MiddleFaceTm, Part) - if TunnelAddedFaces.MiddleFaceTm.Faces[1].dHeight > TunnelAddedFaces.MiddleFaceTm.Faces[1].dWidth then - TunnelAddedFaces.MiddleFaceTm.Faces[1].dHeight, TunnelAddedFaces.MiddleFaceTm.Faces[1].dWidth = TunnelAddedFaces.MiddleFaceTm.Faces[1].dWidth, TunnelAddedFaces.MiddleFaceTm.Faces[1].dHeight - end return TunnelAddedFaces end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 8324884..bd5d02a 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -83,14 +83,7 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters) for i = 1, #TOOLS do -- prima verifico che utensile sia compatibile local bIsToolCompatible = true - if TOOLS[i].sType ~= ToolSearchParameters.sType then - -- se sto cercando una fresa che non può lavorare di testa, quelle che lavorano di testa sono comunque ammesse - if TOOLS[i].sType == 'MILL_STD' and ToolSearchParameters.sType == 'MILL_NOTIP' then - bIsToolCompatible = true - else - bIsToolCompatible = false - end - elseif TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then + if TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then bIsToolCompatible = false elseif TOOLS[i].SetupInfo.bIsTopHead and ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.dMaxNegativeAngle then bIsToolCompatible = false @@ -104,7 +97,13 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters) bIsToolCompatible = false elseif ToolSearchParameters.sMillShape == 'PEN' and not TOOLS[i].bIsPen then bIsToolCompatible = false - -- TODO controllare montaggio e verificare se direzione utensile raggiungibile. Serve funzione in BeamData + elseif TOOLS[i].sType ~= ToolSearchParameters.sType then + -- se sto cercando una fresa che non può lavorare di testa, quelle che lavorano di testa sono comunque ammesse + if TOOLS[i].sType == 'MILL_STD' and ToolSearchParameters.sType == 'MILL_NOTIP' then + bIsToolCompatible = true + else + bIsToolCompatible = false + end end -- scelgo il migliore diff --git a/Strategies/STR0002/STR0002.lua b/Strategies/STR0002/STR0002.lua index f2b62a1..9a59dea 100644 --- a/Strategies/STR0002/STR0002.lua +++ b/Strategies/STR0002/STR0002.lua @@ -47,11 +47,11 @@ local function CalcMachinedPercentage( Proc, Machining) elseif Machining.sTypeMachining == 'Side2' then dPercentage = dSide2Prercentage elseif Machining.sTypeMachining == 'Bottom-Side1-Side2' then - dPercentage = dBottomPrercentage + ( dBottomPrercentageLeft * ( dSide1Prercentage + dSide2Prercentage)) * 100 + dPercentage = dBottomPrercentage + ( dBottomPrercentageLeft * ( dSide1Prercentage + dSide2Prercentage)) elseif Machining.sTypeMachining == 'Bottom-Side1' then - dPercentage = dBottomPrercentage + ( dBottomPrercentageLeft * dSide1Prercentage) * 100 + dPercentage = dBottomPrercentage + ( dBottomPrercentageLeft * dSide1Prercentage) elseif Machining.sTypeMachining == 'Bottom-Side2' then - dPercentage = dBottomPrercentage + ( dBottomPrercentageLeft * dSide2Prercentage) * 100 + dPercentage = dBottomPrercentage + ( dBottomPrercentageLeft * dSide2Prercentage) elseif Machining.sTypeMachining == 'Side1-Side2' then dPercentage = dSide1Prercentage + dSide2Prercentage end @@ -70,20 +70,29 @@ local function GetBestPocketingStrategy( Proc) Machining.sTypeMachining = 'None' -- Bottom-Side1-Side2\ Bottom-Side1\ Bottom-Side2\ Side1-Side2\ Bottom\ Side1 \ Side2 \ None Strategy.Result.nQuality = FeatureData.GetFeatureQuality( 'Mill') - -- imposto dati per cercare la fresa migliore - if Proc.Topology.sName == 'Pocket-5-Blind' then + -- caso speciale Tunnel che non ha faccia bottom + if Proc.Topology.sName == 'Tunnel-4-Through' then + local dFaceHeight = Proc.MainFaces.SideFaces[1].MainEdges.OppositeEdges[1].dLength + local dFaceWidth = Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength ToolSearchParameters.sType = 'MILL_STD' - ToolSearchParameters.dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, Proc.MainFaces.BottomFace.dHeight, Proc.MainFaces.BottomFace.dWidth) - elseif Proc.Topology.sName == 'Tunnel-4-Through' then - ToolSearchParameters.sType = 'MILL_STD' - ToolSearchParameters.dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.Faces[1].dHeight, Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.Faces[1].dWidth) - -- cerco fresa che può anche non lavorare di testa - elseif Proc.Topology.sName == 'Groove-4-Blind' then - ToolSearchParameters.sType = 'MILL_NOTIP' - ToolSearchParameters.dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, Proc.MainFaces.BottomFace.dWidth) - elseif Proc.Topology.sName == 'Groove-3-Through' then - ToolSearchParameters.sType = 'MILL_NOTIP' - ToolSearchParameters.dMaxToolDiameter = Proc.MainFaces.BottomFace.dHeight + ToolSearchParameters.dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, dFaceHeight, dFaceWidth) + else + -- imposto dati per cercare la fresa migliore + if Proc.Topology.sName == 'Pocket-5-Blind' then + local dFaceWidth = Proc.MainFaces.BottomFace.MainEdges.LongEdges[1].dLength + local dFaceHeight = Proc.MainFaces.BottomFace.MainEdges.SideEdges[1].dLength + ToolSearchParameters.sType = 'MILL_STD' + ToolSearchParameters.dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, dFaceHeight, dFaceWidth) + -- cerco fresa che può anche non lavorare di testa + elseif Proc.Topology.sName == 'Groove-4-Blind' then + local dFaceWidth = Proc.MainFaces.BottomFace.MainEdges.LongEdges[1].dLength + ToolSearchParameters.sType = 'MILL_NOTIP' + ToolSearchParameters.dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, dFaceWidth) + elseif Proc.Topology.sName == 'Groove-3-Through' then + local dFaceWidth = Proc.MainFaces.BottomFace.MainEdges.SideEdges[1].dLength + ToolSearchParameters.sType = 'MILL_NOTIP' + ToolSearchParameters.dMaxToolDiameter = dFaceWidth + end end -- ===== RICERCA UTENSILE ===== @@ -143,26 +152,6 @@ local function GetBestPocketingStrategy( Proc) table.insert( Machining, Milling) -- ===== SCELTA LAVORAZIONI ===== - -- se lavorazione della faccia bottom è completa, non controllo le altre - if Machining[1].bIsApplicable then - Machining.sTypeMachining = 'Bottom' - -- se completo - if Machining[1].ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then - Strategy.Result.sStatus = 'Completed' - Strategy.Result.nCompletionIndex = FeatureData.GetFeatureCompletionIndex( 100) - else - Strategy.Result.sStatus = 'Not-Completed' - Strategy.Result.sInfo = 'Machining not complete, left ' .. tostring( Machining[1].ToolInfo.dResidualDepth) .. 'mm' - local dCompletionPercentage = min( 100, ( ( Proc.MainFaces.BottomFace.dElevation - Machining[1].ToolInfo.dResidualDepth) / Proc.MainFaces.BottomFace.dElevation) * 100) - Strategy.Result.nCompletionIndex = FeatureData.GetFeatureCompletionIndex( dCompletionPercentage) - end - -- se tasca, esco subito. Non ci sono altre possibilità - if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategy.Result.dMRR = Machining[1].dMRR - return Machining - end - end - -- se bottom completa tutto if Machining[1].bIsApplicable and Machining[1].ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then Machining.sTypeMachining = 'Bottom' @@ -351,7 +340,7 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters) Pocketing.nToolIndex = ToolInfo.nToolIndex Pocketing.nType = MCH_OY.POCKETING Pocketing.Steps.dStep = TOOLS[ToolInfo.nToolIndex].dStep - Pocketing.dDepth = min( 0, -ToolInfo.dResidualDepth) + Pocketing.sDepth = min( 0, -ToolInfo.dResidualDepth) Pocketing.Steps.dSideStep = TOOLS[ToolInfo.nToolIndex].dSideStep Pocketing.nSubType = MCH_POCK_SUB.SPIRALOUT Pocketing.LeadIn.nType = MCH_POCK_LI.ZIGZAG @@ -373,7 +362,7 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters) Pocketing.nToolIndex = Strategy.Machining[1].ToolInfo.nToolIndex Pocketing.nType = MCH_OY.POCKETING Pocketing.Steps.dStep = TOOLS[Strategy.Machining[1].ToolInfo.nToolIndex].dStep - Pocketing.dDepth = min( 0, -Strategy.Machining[1].ToolInfo.dResidualDepth) + Pocketing.sDepth = min( 0, -Strategy.Machining[1].ToolInfo.dResidualDepth) Pocketing.Steps.dSideStep = TOOLS[Strategy.Machining[1].ToolInfo.nToolIndex].dSideStep Pocketing.nSubType = MCH_POCK_SUB.SPIRALOUT Pocketing.LeadIn.nType = MCH_POCK_LI.ZIGZAG