diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index de23e49..d1cdb11 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -257,9 +257,9 @@ local function IsCombinationAvailable( sCombination, nUnloadPos, bSquareSection) -- TODO scelta combinazione forzato DA RIMUOVERE!! Serve modifica al BEAM. BEAM.BeamWall = true BEAM.Rotation = {} - BEAM.Rotation.bBasic = true + BEAM.Rotation.bBasic = false BEAM.Rotation.bNoRotation = false - BEAM.Rotation.bAdvanced = false + BEAM.Rotation.bAdvanced = true -------------------------------------------------------------------------- -- BASIC : posizione di scarico come posizionamento iniziale diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index ff23201..71d5ac1 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -409,13 +409,13 @@ end ------------------------------------------------------------------------------------------------------------- -- funzione con valore di default in caso la GetSetupInfo della testa della macchina non avesse la funzione definita -function BeamLib.GetMinNzDefault( b3Raw, vtNFace, vtToolDirection) +function BeamLib.GetMinNzDefault( vtNFace, Tool) return 0 end ------------------------------------------------------------------------------------------------------------- -- funzione con valore di default in caso la GetSetupInfo della testa della macchina non avesse la funzione definita -function BeamLib.GetMaxNzDefault( b3Raw, vtNFace, vtToolDirection) +function BeamLib.GetMaxNzDefault( vtNFace, Tool) return 0 end diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index 4954559..0172baf 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -204,6 +204,30 @@ function FaceData.GetFacesInfo( Proc, Part) return Faces end +------------------------------------------------------------------------------------------------------------- +local function CompareEdges( EdgeA, EdgeB) + -- prima i lati con facce adiacenti + if EdgeA.idAdjacentFace and not ( EdgeB.idAdjacentFace) then + return true + elseif not ( EdgeA.idAdjacentFace) and EdgeB.idAdjacentFace then + return false + -- se entrambi con facce adiacenti, si sceglie quello convesso (non chiuso) + else + if EdgeA.bIsOpen and not ( EdgeB.bIsOpen) then + return true + elseif not ( EdgeA.bIsOpen) and EdgeB.bIsOpen then + return false + -- se entrambi aperti o entrambi chiusi, si sceglie quello più lungo + else + if EdgeA.dLength > EdgeB.dLength then + return true + elseif EdgeA.dLength < EdgeB.dLength then + return false + end + end + end +end + ------------------------------------------------------------------------------------------------------------- -- TODO valutare refactoring per mettere i calcoli del tunnel in una funzione -- TODO creare le facce tunnel solo se non ci sono già. Verirficare all'inizio se già presente in AddGrpId e nel caso riferire all'id di quella esistente e ricalcolare solo le informazioni della faccia. @@ -302,18 +326,18 @@ local function GetBottomFaces( Proc) BottomFaces[1].MainEdges.LongEdges = {} BottomFaces[1].MainEdges.SideEdges = {} - local ClosedEdgesSortedByGreatestLength = {} + local EdgesSorted = {} for i = 1, #BottomFaces[1].Edges do if not BottomFaces[1].Edges[i].bIsOpen then - table.insert( ClosedEdgesSortedByGreatestLength, {}) - ClosedEdgesSortedByGreatestLength[#ClosedEdgesSortedByGreatestLength].nIndex = i - ClosedEdgesSortedByGreatestLength[#ClosedEdgesSortedByGreatestLength].dLength = BottomFaces[1].Edges[i].dLength + table.insert( EdgesSorted, {}) + EdgesSorted[#EdgesSorted].nIndex = i + EdgesSorted[#EdgesSorted].dLength = BottomFaces[1].Edges[i].dLength end end - table.sort( ClosedEdgesSortedByGreatestLength, function (a, b) return a.dLength > b.dLength end) + table.sort( EdgesSorted, CompareEdges) local nFirstLongEdgeIndex - if #ClosedEdgesSortedByGreatestLength > 0 then - nFirstLongEdgeIndex = ClosedEdgesSortedByGreatestLength[1].nIndex + if #EdgesSorted > 0 then + nFirstLongEdgeIndex = EdgesSorted[1].nIndex end for i = 1, #BottomFaces[1].Edges do @@ -335,7 +359,6 @@ local function GetBottomFaces( Proc) CurrentEdge.bIsStartOpen = BottomFaces[1].Edges[i].bIsStartOpen CurrentEdge.bIsEndOpen = BottomFaces[1].Edges[i].bIsEndOpen - -- se non c'è un LongEdge significa che non ci sono lati chiusi (facce convesse): i MainEdges non si calcolano if nFirstLongEdgeIndex then if i == nFirstLongEdgeIndex then BottomFaces[1].MainEdges.LongEdges[1] = CurrentEdge @@ -362,8 +385,7 @@ local function GetLongFaces( Proc, MainFaces) if Proc.nFct > 5 then error( 'GetLongFaces : Topology not implemented') - elseif Proc.nFct == 1 - or Proc.Topology.sFamily == 'DoubleBevel' then + elseif Proc.nFct == 1 then return {} end @@ -461,8 +483,7 @@ local function GetSideFaces( Proc, MainFaces) if Proc.nFct > 5 then error( 'GetSideFaces : Topology not implemented') - elseif Proc.nFct == 1 - or Proc.Topology.sFamily == 'DoubleBevel' then + elseif Proc.nFct == 1 then return {} end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 89953ed..8c1cb05 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -249,9 +249,9 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters) -- controlli standard elseif ToolSearchParameters.dMaxToolDiameter and TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then bIsToolCompatible = false - elseif TOOLS[i].SetupInfo.HeadType.bTop and ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.GetMinNz( ToolSearchParameters.vtToolDirection) - GEO.EPS_ZERO then + elseif TOOLS[i].SetupInfo.HeadType.bTop and ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.GetMinNz( ToolSearchParameters.vtToolDirection, TOOLS[i]) - GEO.EPS_ZERO then bIsToolCompatible = false - elseif TOOLS[i].SetupInfo.HeadType.bBottom and ToolSearchParameters.vtToolDirection:getZ() > TOOLS[i].SetupInfo.GetMaxNz( ToolSearchParameters.vtToolDirection) + GEO.EPS_ZERO then + elseif TOOLS[i].SetupInfo.HeadType.bBottom and ToolSearchParameters.vtToolDirection:getZ() > TOOLS[i].SetupInfo.GetMaxNz( ToolSearchParameters.vtToolDirection, TOOLS[i]) + GEO.EPS_ZERO then bIsToolCompatible = false elseif ToolSearchParameters.sMillShape == 'STANDARD' and ( TOOLS[i].dSideAngle ~= 0 or TOOLS[i].bIsPen) then bIsToolCompatible = false @@ -367,10 +367,10 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) end -- check angolo limite lama - if TOOLS[i].SetupInfo.HeadType.bTop and ToolSearchParameters.vtN:getZ() < TOOLS[i].SetupInfo.GetMinNz( ToolSearchParameters.vtN) - GEO.EPS_ZERO then + if TOOLS[i].SetupInfo.HeadType.bTop and ToolSearchParameters.vtN:getZ() < TOOLS[i].SetupInfo.GetMinNz( ToolSearchParameters.vtN, TOOLS[i]) - GEO.EPS_ZERO then bIsToolCompatible = false end - if TOOLS[i].SetupInfo.HeadType.bBottom and ToolSearchParameters.vtN:getZ() > TOOLS[i].SetupInfo.GetMaxNz( ToolSearchParameters.vtN) + GEO.EPS_ZERO then + if TOOLS[i].SetupInfo.HeadType.bBottom and ToolSearchParameters.vtN:getZ() > TOOLS[i].SetupInfo.GetMaxNz( ToolSearchParameters.vtN, TOOLS[i]) + GEO.EPS_ZERO then bIsToolCompatible = false end diff --git a/Strategies/Standard/STR0001/STR0001.lua b/Strategies/Standard/STR0001/STR0001.lua index c45cdba..885e098 100644 --- a/Strategies/Standard/STR0001/STR0001.lua +++ b/Strategies/Standard/STR0001/STR0001.lua @@ -65,10 +65,15 @@ function GetTenonStrategy( Proc, Part) -- === ricerca utensile per svuotare taglio iniziale, se taglio non possibile === if Machining.bCuttingWithMill and ( not( Proc.AffectedFaces.bLeft) or Strategy.bCanMoveAfterSplit) then ToolSearchParameters = {} - ToolSearchParameters.dElevation = 0 + + -- TODO SISTEMARE!!! qui la svuotatura non deve limitare l'elevazione se aperta da tutti i lati. In futuro si deve passare 0 come elevazione + ToolSearchParameters.dElevation = EgtSurfTmFacetElevationInBBox( Strategy.idTenonCutPlane, 0, Part.b3Part, true, GDB_ID.ROOT) + ToolSearchParameters.vtToolDirection = Proc.FeatureInfo.vtTenonN Machining.Cutting.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) - if Machining.Cutting.ToolInfo.nToolIndex then + + -- TODO anche il test sul ResidualDepth va tolto + if Machining.Cutting.ToolInfo.nToolIndex and ( Machining.Cutting.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL) then Machining.Cutting.bIsApplicable = true local ParametersMRR = {} ParametersMRR.nToolIndex = Machining.Cutting.ToolInfo.nToolIndex diff --git a/StrategyLibs/BLADEKEEPWASTE.lua b/StrategyLibs/BLADEKEEPWASTE.lua index 7df2753..7a3379c 100644 --- a/StrategyLibs/BLADEKEEPWASTE.lua +++ b/StrategyLibs/BLADEKEEPWASTE.lua @@ -131,14 +131,19 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- controlli preventivi if Proc.nFct > 3 then error( 'BladeKeepWaste : max 3 faces supported') - -- per angolo tra le facce >= 90deg (feature convessa) non applicabile elseif Proc.nFct == 2 then + -- per angolo tra le facce >= 90deg (feature convessa) non applicabile if Proc.AdjacencyMatrix[1][2] > 10 * GEO.EPS_SMALL or Proc.AdjacencyMatrix[1][2] < -91 then Result = FeatureLib.GetStrategyResultNotApplicable( 'BladeKeepWaste : angle between faces must be concave and >= 90deg') return Machinings, Result end - -- caso speciale RidgeLap - per angolo tra le facce >= 90deg (feature convessa) non applicabile + -- Rabbet lungo X non gestito + if Proc.Topology.sName == 'Rabbet-2-Through' and Proc.AffectedFaces.bLeft and Proc.AffectedFaces.bRight then + Result = FeatureLib.GetStrategyResultNotApplicable( 'BladeKeepWaste : Rabbet along X not managed') + return Machinings, Result + end elseif Proc.nFct == 3 then + -- caso speciale RidgeLap - per angolo tra le facce >= 90deg (feature convessa) non applicabile if Proc.AdjacencyMatrix[1][2] > 10 * GEO.EPS_SMALL or Proc.AdjacencyMatrix[1][2] < -91 then Result = FeatureLib.GetStrategyResultNotApplicable( 'BladeKeepWaste : angle between faces must be concave and >= 90deg') return Machinings, Result diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index 57a0bee..860f596 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -180,10 +180,10 @@ local function GetBestBlade( Proc, Part, Face, OptionalParameters) dMinNzTopBlade = dMinNzTopBladeIfEqual -- lama sopra con aggregato - preferenza testa sopra elseif not TOOLS[nToolIndexTop].SetupInfo.bIsCSymmetrical then - dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexTop].SetupInfo.GetMinNz( Face.vtN) / 2 + dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexTop].SetupInfo.GetMinNz( Face.vtN, TOOLS[nToolIndexTop]) / 2 -- lama sotto con aggregato - preferenza testa sotto elseif not TOOLS[nToolIndexBottom].SetupInfo.bIsCSymmetrical then - dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexBottom].SetupInfo.GetMaxNz( Face.vtN) / 2 + dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexBottom].SetupInfo.GetMaxNz( Face.vtN, TOOLS[nToolIndexBottom]) / 2 else error( 'GetBestBlade : unknown blade type') end