From 7b12eaf33122075e6a0ea02eaf73702cc9cf02fe Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 6 Mar 2026 12:42:53 +0100 Subject: [PATCH 1/3] =?UTF-8?q?-=20in=20BatchProcessNew=20->=20GET=5FTOPOL?= =?UTF-8?q?OGY=20si=20legge=20anche=20nParts=20(serve=20nel=20Classify=20T?= =?UTF-8?q?opology)=20-=20in=20STR0005=20si=20ammettono=20feature=20a=20pi?= =?UTF-8?q?=C3=B9=20di=203=20lati=20se=20la=20topologia=20=C3=A8=20DoubleB?= =?UTF-8?q?evel=20-=20in=20BLADEKEEPWASTE=20si=20gestisce=20topologia=20Do?= =?UTF-8?q?ubleBevel=20e=20migliorie=20varie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BatchProcessNew.lua | 1 + Strategies/Standard/STR0005/STR0005.lua | 2 +- Strategies/Standard/STR0010/STR0010.lua | 5 +- StrategyLibs/BLADEKEEPWASTE.lua | 307 ++++++++++++++---------- 4 files changed, 179 insertions(+), 136 deletions(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 5a0947c..db886c6 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -250,6 +250,7 @@ elseif BEAM.FLAG == 9 then local Proc = FeatureLib.GetProcFromTrimesh( BEAM.FEATUREID, Part) Proc.nGrp = EgtGetInfo( Proc.id, 'GRP', 'i') Proc.nPrc = EgtGetInfo( Proc.id, 'PRC', 'i') + Proc.nParts = EgtSurfTmPartCount( Proc.id) or 1 Proc.Topology = {} if FeatureLib.NeedTopologyFeature( Proc, Part) then diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index df2c704..62b0764 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -66,7 +66,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) local dQualityAddedFace = 0 -- più di 3 facce non supportate - if Proc.nFct > 3 then + if Proc.nFct > 3 and ( not Proc.Topology.sFamily == 'DoubleBevel') then Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'More than 3 faces not supported') end diff --git a/Strategies/Standard/STR0010/STR0010.lua b/Strategies/Standard/STR0010/STR0010.lua index fbaf928..e415f2d 100644 --- a/Strategies/Standard/STR0010/STR0010.lua +++ b/Strategies/Standard/STR0010/STR0010.lua @@ -238,8 +238,9 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) local bAreAllMachiningsAdded = true - -- per prima si lavora sempre la BottomFace (deve avere 4 lati esatti) + -- ricerca delle Bottom (la principale deve avere 4 lati esatti) local BottomFace1 = Proc.MainFaces.BottomFaces[1] + local BottomFace2 = Proc.MainFaces.BottomFaces[2] if #BottomFace1.Edges ~= 4 then Strategy.Result = FeatureLib.GetStrategyResultNotApplicable() return false, Strategy.Result @@ -274,7 +275,6 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) table.insert( CalculatedMachinings, Milling1) -- se necessario si lavora la seconda Bottom (solo se ha 4 lati esatti) - local BottomFace2 = Proc.MainFaces.BottomFaces[2] local Milling2 local BottomEdgeToMachine2 if BottomFace2 then @@ -405,7 +405,6 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) end end - -- calcolo completamento, serve la lista di lavorazioni che comprende le non applicabili Strategy.Result.dCompletionPercentage = GetStrategyCompletionPercentage( CalculatedMachinings) Strategy.Result.dCompletionIndex = FeatureLib.GetFeatureCompletionIndex( Strategy.Result.dCompletionPercentage) diff --git a/StrategyLibs/BLADEKEEPWASTE.lua b/StrategyLibs/BLADEKEEPWASTE.lua index 521d5ba..4fb1333 100644 --- a/StrategyLibs/BLADEKEEPWASTE.lua +++ b/StrategyLibs/BLADEKEEPWASTE.lua @@ -19,40 +19,57 @@ local FaceByMill = require('FACEBYMILL') -- tabelle per definizione modulo ------------------------------------------------------------------------------------------------------------- -local function CompareEdges( EdgeA, EdgeB) - -- prima i lati orientati lungo X - if abs( EdgeA.vtN:getX()) < abs( EdgeB.vtN:getX()) - 10 * GEO.EPS_SMALL then +local function CompareEdgesLongestTop( EdgeA, EdgeB) + -- si preferiscono i lati più lunghi + if EdgeA.dLength > EdgeB.dLength + 10 * GEO.EPS_SMALL then return true - elseif abs( EdgeA.vtN:getX()) > abs( EdgeB.vtN:getX()) + 10 * GEO.EPS_SMALL then + elseif EdgeA.dLength < EdgeB.dLength - 10 * GEO.EPS_SMALL then return false - -- se stessa X si preferiscono i lati più lunghi (nel caso di 5 lati è quello non spezzato) + -- se stessa lunghezza si preferiscono i lati più in basso else - if EdgeA.dLength > EdgeB.dLength + 10 * GEO.EPS_SMALL then + if EdgeA.vtN:getZ() > EdgeB.vtN:getZ() + 10 * GEO.EPS_SMALL then return true - elseif EdgeA.dLength < EdgeB.dLength - 10 * GEO.EPS_SMALL then + elseif EdgeA.vtN:getZ() < EdgeB.vtN:getZ() - 10 * GEO.EPS_SMALL then return false - -- se stessa lunghezza si preferiscono i lati più in basso - -- TODO qui dipenderà dalla lama scelta + -- se stessa Z si preferiscono i lati verso il fronte della trave else - if EdgeA.vtN:getZ() > EdgeB.vtN:getZ() + 10 * GEO.EPS_SMALL then + if EdgeA.vtN:getY() > EdgeB.vtN:getY() + 10 * GEO.EPS_SMALL then return true - elseif EdgeA.vtN:getZ() < EdgeB.vtN:getZ() - 10 * GEO.EPS_SMALL then + elseif EdgeA.vtN:getY() < EdgeB.vtN:getY() - 10 * GEO.EPS_SMALL then return false - -- se stessa Z si preferiscono i lati verso il fronte della trave else - if EdgeA.vtN:getY() > EdgeB.vtN:getY() + 10 * GEO.EPS_SMALL then - return true - elseif EdgeA.vtN:getY() < EdgeB.vtN:getY() - 10 * GEO.EPS_SMALL then - return false - else - return false - end + return false end end end end +local function GetLongEdgeToMachine( Face, bHeadType) + local Edge = {} + + local EdgesSorted = {} + for i = 1, #Face.Edges do + table.insert( EdgesSorted, Face.Edges[i]) + end + table.sort( EdgesSorted, CompareEdgesLongestTop) + + -- se il lato migliore è accessibile si sceglie questo, altrimenti il lato opposto; se entrambi non accessibili (faccia chiusa da due lati) la lavorazione non è applicabile + Edge = EdgesSorted[1] + local EdgeOpposite = BeamLib.FindEdgeBestOrientedAsDirection( Face.Edges, -Edge.vtN) + if not EdgeOpposite.bIsOpen then + if Edge.bIsOpen then + Edge = EdgeOpposite + -- entrambi i lati non accessibili: codolo non applicabile + else + return nil + end + end + + return Edge +end + + local function SortMachiningsBySegment( MachiningA, MachiningB) if MachiningA.nFeatureSegment > MachiningB.nFeatureSegment then return false @@ -118,6 +135,76 @@ local function GetStrategyCompletionPercentage( Machinings) end +local function MakeBottomFace( Proc, Part, BottomFace, EdgeToMachine, Parameters) + local Cuttings = {} + local Cutting1 = {} + local Cutting2 = {} + + -- parametri dal chiamante + local bIsSplitFeature = Parameters.bIsSplitFeature + local dExtendAfterTail = Parameters.dExtendAfterTail + local nToolIndex = Parameters.nToolIndex + local dStripWidth = Parameters.dStripWidth + local OtherBottomFace = Parameters.OtherBottomFace + + local dDepthToMachine = EdgeToMachine.dElevation / 2 - dStripWidth / 2 + local OptionalParametersFaceByBlade1 = { dDepthToMachine = dDepthToMachine, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, nToolIndex = nToolIndex} + local EdgeToMachineOpposite = BeamLib.FindEdgeBestOrientedAsDirection( BottomFace.Edges, -EdgeToMachine.vtN) + + -- primo lato + if EdgeToMachineOpposite.bIsOpen then + Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade1) + end + Cutting1.nInternalSortingPriority = 3 + Cutting1.dResultWeight = 0.3 + + -- secondo lato + local OptionalParametersFaceByBlade2 = BeamLib.TableCopyDeep( OptionalParametersFaceByBlade1) + OptionalParametersFaceByBlade2.OppositeToolDirectionMode = 'Enabled' + if EdgeToMachine.bIsOpen then + Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade2) + end + Cutting2.nInternalSortingPriority = 3 + Cutting2.dResultWeight = 0.3 + + -- se uno dei due lati non è riuscito, si estende il più possibile il lato rimasto + if not Cutting1.bIsApplicable and Cutting2.bIsApplicable then + + -- se si lavora il lato in comune con l'altra BottomFace significa ci si deve fermare piú indietro + if EdgeToMachine.idAdjacentFace == OtherBottomFace.id then + dStripWidth = TOOLS[Cutting2.nToolIndex].dThickness + 2 * dStripWidth + end + dDepthToMachine = min( TOOLS[Cutting2.nToolIndex].dMaxMaterial, EdgeToMachine.dElevation - dStripWidth) + OptionalParametersFaceByBlade2.dDepthToMachine = dDepthToMachine + + Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade2) + Cutting2.nInternalSortingPriority = 3 + Cutting2.dResultWeight = 0.3 + table.insert( Cuttings, Cutting2) + + elseif not Cutting2.bIsApplicable and Cutting1.bIsApplicable then + + -- se si lavora il lato in comune con l'altra BottomFace significa ci si deve fermare piú indietro + if EdgeToMachine.idAdjacentFace == OtherBottomFace.id then + dStripWidth = TOOLS[Cutting1.nToolIndex].dThickness + 2 * dStripWidth + end + dDepthToMachine = min( TOOLS[Cutting1.nToolIndex].dMaxMaterial, EdgeToMachine.dElevation - dStripWidth) + OptionalParametersFaceByBlade1.dDepthToMachine = dDepthToMachine + + Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade1) + Cutting1.nInternalSortingPriority = 3 + Cutting1.dResultWeight = 0.3 + table.insert( Cuttings, Cutting1) + + else + table.insert( Cuttings, Cutting1) + table.insert( Cuttings, Cutting2) + end + + return Cuttings +end + + function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- TODO verificare funzionamento con lama da sotto -- TODO scelta utensile è corretto lasciarla a FaceByBlade? @@ -126,12 +213,11 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) local Result = {} local Machinings = {} local CalculatedMachinings = {} - local Cutting1 = {} - local Cutting2 = {} -- controlli preventivi - if Proc.nFct > 3 then - error( 'BladeKeepWaste : max 3 faces supported') + if Proc.nFct > 3 and ( not Proc.Topology.sFamily == 'DoubleBevel') then + Result = FeatureLib.GetStrategyResultNotApplicable( 'BladeKeepWaste : max 3 faces supported') + return Machinings, Result 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 @@ -160,12 +246,7 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) end local nToolIndex = OptionalParameters.nToolIndex local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 - local bFinishWithMill - if OptionalParameters.bFinishWithMill == nil then - bFinishWithMill = true - else - bFinishWithMill = OptionalParameters.bFinishWithMill - end + local bFinishWithMill = ( OptionalParameters.bFinishWithMill ~= false) local dMillingOffsetFromSide = OptionalParameters.dMillingOffsetFromSide or 1 local dStripWidth = OptionalParameters.dStripWidth or 5 local bForced = OptionalParameters.bForced or false @@ -173,28 +254,22 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- volume della feature local dFeatureVolume = Proc.dVolume - -- si trovano le facce da lavorare - local BottomFace = {} - local LongFaces = {} + -- si trovano le facce da lavorare (solo 4 lati esatti) + local BottomFace1 + local BottomFace2 if Proc.nFct == 1 then - BottomFace = Proc.Faces[1] + BottomFace1 = Proc.Faces[1] else if not Proc.MainFaces then Proc.MainFaces = FaceData.GetMainFaces( Proc, Part) end - BottomFace = Proc.MainFaces.BottomFaces[1] - LongFaces = Proc.MainFaces.LongFaces + BottomFace1 = Proc.MainFaces.BottomFaces[1] + BottomFace2 = Proc.MainFaces.BottomFaces[2] end - - - -- si trova il lato della faccia di fondo da lavorare - local BottomEdgeToMachine = {} - local BottomEdgesSorted = {} - for i = 1, #BottomFace.Edges do - table.insert( BottomEdgesSorted, BottomFace.Edges[i]) + if #BottomFace1.Edges ~= 4 then + Result = FeatureLib.GetStrategyResultNotApplicable() + return Machinings, Result end - table.sort( BottomEdgesSorted, CompareEdges) - BottomEdgeToMachine = BottomEdgesSorted[1] -- eventuali punti di spezzatura local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) @@ -203,98 +278,66 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) bIsSplitFeature = true end - -- calcolo lavorazioni - -- taglio eventuali facce di chiusura o seconda faccia - for i = 1, #LongFaces do - local Cutting = {} - local OptionalParametersFaceByBlade = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, nToolIndex = nToolIndex} - Cutting = FaceByBlade.Make( Proc, Part, LongFaces[i], LongFaces[i].MainEdges.BottomEdge, OptionalParametersFaceByBlade) - Cutting.nInternalSortingPriority = 1 - Cutting.dResultWeight = 0.15 - table.insert( CalculatedMachinings, Cutting) - end - - -- taglio con codolo faccia di fondo; si provano solo i lati a cui si può accedere (lato opposto aperto) - -- TODO il check del lato opposto aperto andrà messo nella FaceByBlade - -- TODO verificare se il calcolo del completamento (aggiunta lavorazioni applicabili/non) é corretto - local dDepthToMachine = BottomEdgeToMachine.dElevation / 2 - dStripWidth / 2 - local OptionalParametersFaceByBlade1 = { dDepthToMachine = dDepthToMachine, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, nToolIndex = nToolIndex} - local BottomEdgeToMachineOpposite = BeamLib.FindEdgeBestOrientedAsDirection( BottomFace.Edges, -BottomEdgeToMachine.vtN) - -- primo lato - if BottomEdgeToMachineOpposite.bIsOpen then - Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade1) - end - Cutting1.nInternalSortingPriority = 3 - Cutting1.dResultWeight = 0.3 - - -- secondo lato - local OptionalParametersFaceByBlade2 = BeamLib.TableCopyDeep( OptionalParametersFaceByBlade1) - OptionalParametersFaceByBlade2.OppositeToolDirectionMode = 'Enabled' - if BottomEdgeToMachine.bIsOpen then - Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade2) - end - Cutting2.nInternalSortingPriority = 3 - Cutting2.dResultWeight = 0.3 - - -- se uno dei due lati non è riuscito, si estende il più possibile il lato rimasto - if not Cutting1.bIsApplicable and Cutting2.bIsApplicable then - - -- se si lavora il lato in comune con la LongFace significa che la LongFace non é di chiusura ma un'altra faccia vera e propria - -- ci si deve quindi fermare piú indietro - for i = 1, #LongFaces do - if BottomEdgeToMachine.idAdjacentFace == LongFaces[i].id then - dStripWidth = TOOLS[Cutting2.nToolIndex].dThickness + 2 * dStripWidth - break - end - end - dDepthToMachine = min( TOOLS[Cutting2.nToolIndex].dMaxMaterial, BottomEdgeToMachine.dElevation - dStripWidth) - OptionalParametersFaceByBlade2.dDepthToMachine = dDepthToMachine - - Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade2) - Cutting2.nInternalSortingPriority = 3 - Cutting2.dResultWeight = 0.3 - table.insert( CalculatedMachinings, Cutting2) - - elseif not Cutting2.bIsApplicable and Cutting1.bIsApplicable then - - -- se si lavora il lato in comune con la LongFace significa che la LongFace non é di chiusura ma un'altra faccia vera e propria - -- ci si deve quindi fermare piú indietro - for i = 1, #LongFaces do - if BottomEdgeToMachine.idAdjacentFace == LongFaces[i].id then - dStripWidth = TOOLS[Cutting1.nToolIndex].dThickness + 2 * dStripWidth - break - end - end - dDepthToMachine = min( TOOLS[Cutting1.nToolIndex].dMaxMaterial, BottomEdgeToMachine.dElevation - dStripWidth) - OptionalParametersFaceByBlade1.dDepthToMachine = dDepthToMachine - - Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, BottomEdgeToMachine, OptionalParametersFaceByBlade1) - Cutting1.nInternalSortingPriority = 3 - Cutting1.dResultWeight = 0.3 - table.insert( CalculatedMachinings, Cutting1) - - else - table.insert( CalculatedMachinings, Cutting1) - table.insert( CalculatedMachinings, Cutting2) + -- calcolo lavorazioni faccia principale + -- ricerca lato da lavorare + local BottomEdgeToMachine1 = GetLongEdgeToMachine( BottomFace1, { bTop = true}) + -- calcolo lavorazione + local Parameters1 = { + bIsSplitFeature = bIsSplitFeature, + dExtendAfterTail = dExtendAfterTail, + nToolIndex = nToolIndex, + dStripWidth = dStripWidth, + OtherBottomFace = BottomFace2 + } + local Cuttings1 = MakeBottomFace( Proc, Part, BottomFace1, BottomEdgeToMachine1, Parameters1) + -- aggiunta lavorazioni alla lista principale + for i = 1, #Cuttings1 do + table.insert( CalculatedMachinings, Cuttings1[i]) end - -- fresatura eventuali facce di chiusura - if bFinishWithMill then - for i = 1, #LongFaces do - if BottomEdgeToMachine.idAdjacentFace ~= LongFaces[i].id then - local dDepthToMachineMill = BottomFace.MainEdges.LongEdges[i].dElevation - dMillingOffsetFromSide - local dToolMarkLength = max( Cutting1.dToolMarkLength or 0, Cutting2.dToolMarkLength or 0) - local OptionalParametersFaceByMill = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, - dRadialStepSpan = dToolMarkLength, dDepthToMachine = dDepthToMachineMill - } - local Milling = FaceByMill.Make( Proc, Part, BottomFace, BottomFace.MainEdges.LongEdges[i], OptionalParametersFaceByMill) - Milling.nInternalSortingPriority = 2 - Milling.dResultWeight = 0.05 - table.insert( CalculatedMachinings, Milling) - end + -- calcolo lavorazioni faccia secondaria, solo se lato convesso; se concavo, sarà lavorato come antisplint + local Cuttings2 + local bConvexAngle = ( Proc.AdjacencyMatrix[BottomFace1.id + 1][BottomFace2.id + 1]) > 0 + if BottomFace2 and bConvexAngle then + -- ricerca lato da lavorare + local BottomEdgeToMachine2 = GetLongEdgeToMachine( BottomFace2, { bTop = true}) + -- calcolo lavorazione + local Parameters2 = BeamLib.TableCopyDeep( Parameters1) + Parameters2.OtherBottomFace = BottomFace1 + Cuttings2 = MakeBottomFace( Proc, Part, BottomFace2, BottomEdgeToMachine2, Parameters2) + for i = 1, #Cuttings2 do + table.insert( CalculatedMachinings, Cuttings2[i]) end end + + -- -- taglio eventuali facce di chiusura o seconda faccia + -- for i = 1, #LongFaces do + -- local Cutting = {} + -- local OptionalParametersFaceByBlade = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, nToolIndex = nToolIndex} + -- Cutting = FaceByBlade.Make( Proc, Part, LongFaces[i], LongFaces[i].MainEdges.BottomEdge, OptionalParametersFaceByBlade) + -- Cutting.nInternalSortingPriority = 1 + -- Cutting.dResultWeight = 0.15 + -- table.insert( CalculatedMachinings, Cutting) + -- end + + -- -- fresatura eventuali facce di chiusura + -- if bFinishWithMill then + -- for i = 1, #LongFaces do + -- if BottomEdgeToMachine.idAdjacentFace ~= LongFaces[i].id then + -- local dDepthToMachineMill = BottomFace1.MainEdges.LongEdges[i].dElevation - dMillingOffsetFromSide + -- local dToolMarkLength = max( Cutting1.dToolMarkLength or 0, Cutting2.dToolMarkLength or 0) + -- local OptionalParametersFaceByMill = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, + -- dRadialStepSpan = dToolMarkLength, dDepthToMachine = dDepthToMachineMill + -- } + -- local Milling = FaceByMill.Make( Proc, Part, BottomFace1, BottomFace1.MainEdges.LongEdges[i], OptionalParametersFaceByMill) + -- Milling.nInternalSortingPriority = 2 + -- Milling.dResultWeight = 0.05 + -- table.insert( CalculatedMachinings, Milling) + -- end + -- end + -- end + -- lavorazioni da applicare spostate in lista finale for i = 1, #CalculatedMachinings do if CalculatedMachinings[i].bIsApplicable then @@ -317,7 +360,7 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) table.sort( Machinings, SortMachiningsBySegment) -- calcolo risultati - if Cutting1.bIsApplicable or Cutting2.bIsApplicable then + if Cuttings1[1].bIsApplicable or Cuttings1[2].bIsApplicable then Result.dQuality = FeatureLib.GetStrategyQuality( Machinings) Result.dTimeToMachine = FeatureLib.GetStrategyTimeToMachine( Machinings) Result.dMRR = ( dFeatureVolume / Result.dTimeToMachine) / pow( 10, 6) From 2c77277c85eab1a2368c4523350014391e9413e1 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 6 Mar 2026 18:23:24 +0100 Subject: [PATCH 2/3] =?UTF-8?q?-=20alle=20StrategyLibs=20aggiunta=20ANTISP?= =?UTF-8?q?LINTONFACE=20per=20calcolare=20le=20lavorazioni=20antischeggia?= =?UTF-8?q?=20passando=20una=20faccia;=20STR0010=20e=20BLADEKEEPWASTE=20mo?= =?UTF-8?q?dificate=20di=20conseguenza=20-=20in=20BLADEKEEPWASTE=20miglior?= =?UTF-8?q?ie=20e=20correzioni;=20manca=20ancora=20la=20pulitura=20con=20f?= =?UTF-8?q?resa=20-=20in=20FACEBYBLADE=20rimossa=20dimensione=20minima=20l?= =?UTF-8?q?ato=20maggiore=20del=20diametro=20lama.=20Si=20pu=C3=B2=20avere?= =?UTF-8?q?=20un=20accorciamento=20massimo=20pari=20alla=20lunghezza=20lat?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Strategies/Standard/STR0010/STR0010.lua | 60 ++++++------------------- StrategyLibs/ANTISPLINTONFACE.lua | 53 ++++++++++++++++++++++ StrategyLibs/BLADEKEEPWASTE.lua | 59 +++++++++++++++--------- StrategyLibs/FACEBYBLADE.lua | 25 +++++++---- 4 files changed, 120 insertions(+), 77 deletions(-) create mode 100644 StrategyLibs/ANTISPLINTONFACE.lua diff --git a/Strategies/Standard/STR0010/STR0010.lua b/Strategies/Standard/STR0010/STR0010.lua index e415f2d..a8f3a06 100644 --- a/Strategies/Standard/STR0010/STR0010.lua +++ b/Strategies/Standard/STR0010/STR0010.lua @@ -11,6 +11,7 @@ local FeatureLib = require( 'FeatureLib') -- strategie di base local FaceByMill = require( 'FACEBYMILL') local FaceByBlade = require( 'FACEBYBLADE') +local AntiSplintOnFace = require( 'ANTISPLINTONFACE') -- Tabella per definizione modulo local STR0010 = {} @@ -351,56 +352,23 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) end end - -- taglio eventuali facce di chiusura controvena, per ogni faccia bottom lavorata + -- antischeggia sulle facce di chiusura delle facce lavorate if Strategy.Parameters.bAntiSplintWithBlade then - if Milling1 then - local ClosingFacesAgainstGrain1 = {} - for i = 1, #BottomFace1.Edges do - local CurrentFace = Proc.Faces[BottomFace1.Edges[i].idAdjacentFace + 1] - if ( not BottomFace1.Edges[i].bIsOpen) and abs( CurrentFace.vtN:getX()) > 0.707 then - table.insert( ClosingFacesAgainstGrain1, CurrentFace) - end - end - for i = 1, #ClosingFacesAgainstGrain1 do - local EdgeToMachine = {} - for j = 1, #ClosingFacesAgainstGrain1[i].Edges do - if ClosingFacesAgainstGrain1[i].Edges[j].idAdjacentFace == BottomFace1.id then - EdgeToMachine = ClosingFacesAgainstGrain1[i].Edges[j] - break - end - end - local Cutting = {} - local OptionalParametersFaceByBlade = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail} - Cutting = FaceByBlade.Make( Proc, Part, ClosingFacesAgainstGrain1[i], EdgeToMachine, OptionalParametersFaceByBlade) - Cutting.nInternalSortingPriority = 1 - Cutting.dResultWeight = 0.15 - table.insert( CalculatedMachinings, Cutting) - end + local OptionalParametersAntiSplint = { + bIsSplitFeature = bIsSplitFeature, + dExtendAfterTail = dExtendAfterTail, + nInternalSortingPriority = 1, + dResultWeight = 0.15 + } + local AntiSplints1 = AntiSplintOnFace.Make( Proc, Part, BottomFace1, OptionalParametersAntiSplint) + for i = 1, #AntiSplints1 do + table.insert( CalculatedMachinings, AntiSplints1[i]) end - if Milling2 then - local ClosingFacesAgainstGrain2 = {} - for i = 1, #BottomFace2.Edges do - local CurrentFace = Proc.Faces[BottomFace2.Edges[i].idAdjacentFace + 1] - if ( not BottomFace2.Edges[i].bIsOpen) and abs( CurrentFace.vtN:getX()) > 0.707 then - table.insert( ClosingFacesAgainstGrain2, CurrentFace) - end - end - for i = 1, #ClosingFacesAgainstGrain2 do - local EdgeToMachine = {} - for j = 1, #ClosingFacesAgainstGrain2[i].Edges do - if ClosingFacesAgainstGrain2[i].Edges[j].idAdjacentFace == BottomFace2.id then - EdgeToMachine = ClosingFacesAgainstGrain2[i].Edges[j] - break - end - end - local Cutting = {} - local OptionalParametersFaceByBlade = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail} - Cutting = FaceByBlade.Make( Proc, Part, ClosingFacesAgainstGrain2[i], EdgeToMachine, OptionalParametersFaceByBlade) - Cutting.nInternalSortingPriority = 1 - Cutting.dResultWeight = 0.15 - table.insert( CalculatedMachinings, Cutting) + local AntiSplints2 = AntiSplintOnFace.Make( Proc, Part, BottomFace2, OptionalParametersAntiSplint) + for i = 1, #AntiSplints2 do + table.insert( CalculatedMachinings, AntiSplints2[i]) end end end diff --git a/StrategyLibs/ANTISPLINTONFACE.lua b/StrategyLibs/ANTISPLINTONFACE.lua new file mode 100644 index 0000000..8cca442 --- /dev/null +++ b/StrategyLibs/ANTISPLINTONFACE.lua @@ -0,0 +1,53 @@ +-- Strategia: FACEBYBLADE +-- Descrizione +-- Strategia di base per la lavorazione delle facce con lama + +-- carico librerie +local FaceByBlade = require( 'FACEBYBLADE') + +-- Tabella per definizione modulo +local ANTISPLINTONFACE = {} + +------------------------------------------------------------------------------------------------------------- +function ANTISPLINTONFACE.Make( Proc, Part, Face, OptionalParameters) + local Machinings = {} + + -- parametri opzionali + if not OptionalParameters then + OptionalParameters = {} + end + local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false + local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 + local nInternalSortingPriority = OptionalParameters.nInternalSortingPriority or 1 + local dResultWeight = OptionalParameters.dResultWeight or 0.15 + local bIgnoreGrainDirection = OptionalParameters.bIgnoreGrainDirection or false + + local ClosingFacesAgainstGrain1 = {} + for i = 1, #Face.Edges do + local CurrentFace = Proc.Faces[Face.Edges[i].idAdjacentFace + 1] + if ( not Face.Edges[i].bIsOpen) and ( ( abs( CurrentFace.vtN:getX()) > 0.707) or bIgnoreGrainDirection) then + table.insert( ClosingFacesAgainstGrain1, CurrentFace) + end + end + for i = 1, #ClosingFacesAgainstGrain1 do + local EdgeToMachine = {} + for j = 1, #ClosingFacesAgainstGrain1[i].Edges do + if ClosingFacesAgainstGrain1[i].Edges[j].idAdjacentFace == Face.id then + EdgeToMachine = ClosingFacesAgainstGrain1[i].Edges[j] + break + end + end + local Cutting = {} + local OptionalParametersFaceByBlade = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail} + Cutting = FaceByBlade.Make( Proc, Part, ClosingFacesAgainstGrain1[i], EdgeToMachine, OptionalParametersFaceByBlade) + Cutting.nInternalSortingPriority = nInternalSortingPriority + Cutting.dResultWeight = dResultWeight + table.insert( Machinings, Cutting) + end + + return Machinings +end + +------------------------------------------------------------------------------------------------------------- + + return ANTISPLINTONFACE \ No newline at end of file diff --git a/StrategyLibs/BLADEKEEPWASTE.lua b/StrategyLibs/BLADEKEEPWASTE.lua index 4fb1333..784df03 100644 --- a/StrategyLibs/BLADEKEEPWASTE.lua +++ b/StrategyLibs/BLADEKEEPWASTE.lua @@ -14,7 +14,8 @@ local MachiningLib = require( 'MachiningLib') local BeamLib = require('BeamLib') -- strategie di base local FaceByBlade = require('FACEBYBLADE') -local FaceByMill = require('FACEBYMILL') +local FaceByMill = require( 'FACEBYMILL') +local AntiSplintOnFace = require( 'ANTISPLINTONFACE') -- tabelle per definizione modulo @@ -270,6 +271,10 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) Result = FeatureLib.GetStrategyResultNotApplicable() return Machinings, Result end + local bConvexAngle + if BottomFace2 then + bConvexAngle = ( Proc.AdjacencyMatrix[BottomFace1.id + 1][BottomFace2.id + 1]) > 0 + end -- eventuali punti di spezzatura local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) @@ -297,29 +302,39 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- calcolo lavorazioni faccia secondaria, solo se lato convesso; se concavo, sarà lavorato come antisplint local Cuttings2 - local bConvexAngle = ( Proc.AdjacencyMatrix[BottomFace1.id + 1][BottomFace2.id + 1]) > 0 - if BottomFace2 and bConvexAngle then - -- ricerca lato da lavorare - local BottomEdgeToMachine2 = GetLongEdgeToMachine( BottomFace2, { bTop = true}) - -- calcolo lavorazione - local Parameters2 = BeamLib.TableCopyDeep( Parameters1) - Parameters2.OtherBottomFace = BottomFace1 - Cuttings2 = MakeBottomFace( Proc, Part, BottomFace2, BottomEdgeToMachine2, Parameters2) - for i = 1, #Cuttings2 do - table.insert( CalculatedMachinings, Cuttings2[i]) + if BottomFace2 then + if bConvexAngle then + -- ricerca lato da lavorare + local BottomEdgeToMachine2 = GetLongEdgeToMachine( BottomFace2, { bTop = true}) + -- calcolo lavorazione + local Parameters2 = BeamLib.TableCopyDeep( Parameters1) + Parameters2.OtherBottomFace = BottomFace1 + Cuttings2 = MakeBottomFace( Proc, Part, BottomFace2, BottomEdgeToMachine2, Parameters2) + for i = 1, #Cuttings2 do + table.insert( CalculatedMachinings, Cuttings2[i]) + end end end - - -- -- taglio eventuali facce di chiusura o seconda faccia - -- for i = 1, #LongFaces do - -- local Cutting = {} - -- local OptionalParametersFaceByBlade = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, nToolIndex = nToolIndex} - -- Cutting = FaceByBlade.Make( Proc, Part, LongFaces[i], LongFaces[i].MainEdges.BottomEdge, OptionalParametersFaceByBlade) - -- Cutting.nInternalSortingPriority = 1 - -- Cutting.dResultWeight = 0.15 - -- table.insert( CalculatedMachinings, Cutting) - -- end + -- antischeggia sulle facce di chiusura delle facce lavorate + local OptionalParametersAntiSplint = { + bIsSplitFeature = bIsSplitFeature, + dExtendAfterTail = dExtendAfterTail, + nInternalSortingPriority = 1, + dResultWeight = 0.15, + bIgnoreGrainDirection = true + } + local AntiSplints1 = AntiSplintOnFace.Make( Proc, Part, BottomFace1, OptionalParametersAntiSplint) + for i = 1, #AntiSplints1 do + table.insert( CalculatedMachinings, AntiSplints1[i]) + end + if BottomFace2 and bConvexAngle then + OptionalParametersAntiSplint.bIgnoreGrainDirection = false + local AntiSplints2 = AntiSplintOnFace.Make( Proc, Part, BottomFace2, OptionalParametersAntiSplint) + for i = 1, #AntiSplints2 do + table.insert( CalculatedMachinings, AntiSplints2[i]) + end + end -- -- fresatura eventuali facce di chiusura -- if bFinishWithMill then @@ -360,7 +375,7 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) table.sort( Machinings, SortMachiningsBySegment) -- calcolo risultati - if Cuttings1[1].bIsApplicable or Cuttings1[2].bIsApplicable then + if Cuttings1[1].bIsApplicable or Cuttings1[2].bIsApplicable or Cuttings2 and ( Cuttings2[1].bIsApplicable or Cuttings2[2].bIsApplicable) then Result.dQuality = FeatureLib.GetStrategyQuality( Machinings) Result.dTimeToMachine = FeatureLib.GetStrategyTimeToMachine( Machinings) Result.dMRR = ( dFeatureVolume / Result.dTimeToMachine) / pow( 10, 6) diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index b34e7ee..299523b 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -72,6 +72,12 @@ local function GetLeadInOut( Machining, EdgeToMachine, bIsSplitFeature) LeadOut.dTotalLength = sqrt( LeadOut.dPerpDistance ^ 2 + LeadOut.dTangentDistance ^ 2) end + -- se accorciamenti maggiori della lunghezza lato, la lavorazione non è fattibile + if LeadIn.dStartAddLength + LeadOut.dEndAddLength + EdgeToMachine.dLength < 1 then + + return + end + -- se lavorazione con OppositeToolDirection o ridotta l'attacco va corretto if not AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then LeadIn.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset @@ -285,16 +291,18 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar return Cutting, EdgeToMachine.dElevation end + + -- TODO vedere se la rimozione di questo crea problemi -- se tasca chiusa da entrambi i lati e più stretta della lama la lavorazione non è applicabile - if not ( EdgeToMachine.bIsStartOpen or EdgeToMachine.bIsEndOpen) then - if TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then - Cutting.sMessage = 'Pocket too narrow for blade diameter' - Cutting.bIsApplicable = false - EgtOutLog( Cutting.sMessage) + -- if not ( EdgeToMachine.bIsStartOpen or EdgeToMachine.bIsEndOpen) then + -- if TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then + -- Cutting.sMessage = 'Pocket too narrow for blade diameter' + -- Cutting.bIsApplicable = false + -- EgtOutLog( Cutting.sMessage) - return Cutting, EdgeToMachine.dElevation - end - end + -- return Cutting, EdgeToMachine.dElevation + -- end + -- end -- parametri della lavorazione @@ -320,7 +328,6 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.bInvert = not Cutting.bInvert end - -- TODO al momento commentato per trovare i casi in cui nei riposizionamenti scende sul pezzo; poi valutare se lasciare o togliere -- se dicing, lato di lavoro e inversione per avere taglio sempre verso l'alto if bIsDicing and ( Cutting.bInvert and Cutting.vtEdgeDirection:getZ() > 100 * GEO.EPS_SMALL) From bddaf91fb77755514b01cd2f7e77e9fc0a31b340 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 12 Mar 2026 17:08:07 +0100 Subject: [PATCH 3/3] - in STR0003 si evita caso con Groove-3 passante e pareti oblique - in STR0010 migliorie - in BLADEKEEPWASTE aggiunta pulizia lati chiusi con sistema nuovo --- Strategies/Standard/STR0003/STR0003.lua | 27 +++++- Strategies/Standard/STR0010/STR0010.lua | 7 +- StrategyLibs/BLADEKEEPWASTE.lua | 110 ++++++++++++++++++------ 3 files changed, 112 insertions(+), 32 deletions(-) diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index b923f09..8d72218 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -35,12 +35,19 @@ Chainsaw.Result = {} local function IsTopologyOk( Proc) if Proc.Topology.bAllRightAngles and ( Proc.Topology.sName == 'Pocket-5-Blind' or - Proc.Topology.sName == 'Groove-3-Through' or Proc.Topology.sName == 'Groove-4-Blind' or Proc.Topology.sName == 'Tunnel-4-Through') then return true + + -- canale ammesso solo se lati paralleli a 2 a 2 + elseif Proc.Topology.sName == 'Groove-3-Through' + and ( AreOppositeVectorApprox( Proc.MainFaces.BottomFaces[1].MainEdges.LongEdges[1].vtN, Proc.MainFaces.BottomFaces[1].MainEdges.LongEdges[2].vtN)) then + + return true + else + return false end end @@ -195,11 +202,20 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) return false, Strategy.Result end + -- se canale e lati non a 90deg la strategia non è applicabile + -- TODO questo è temporaneo finchè non si gestiscono correttamente i lati obliqui per le groove-3-through + -- la dPocketHeight è già gestita, ma va allungato il percorso dove c'è l'angolo > 90 + if Proc.Topology.sName == 'Groove-3-Through' then + local BottomFace = Proc.MainFaces.BottomFaces[1] + if abs( BottomFace.Edges[1].vtEdge * BottomFace.Edges[2].vtEdge) > 10 * GEO.EPS_SMALL then + Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'Topology') + return false, Strategy.Result + end + end + -- se tasca su faccia sotto la strategia non è applicabile (la sega a catena in generale non può lavorare da sotto) -- TODO se OnlySaw questo test è da rimuovere ma bisogna considerare anche la lama da sotto if Proc.AffectedFaces.bBottom and ( Proc.nFct > 3 or not Proc.AffectedFaces.bTop) then - local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket on bottom face' - EgtOutLog( sErr) Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'Direction') return false, Strategy.Result end @@ -223,6 +239,11 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) local dPocketHeight = 0 if Proc.Topology.sFamily == 'Tunnel' then dPocketHeight = Proc.MainFaces.SideFaces[1].MainEdges.OppositeEdges[1].dLength + elseif Proc.Topology.sName == 'Groove-3-Through' then + local BottomFace = Proc.MainFaces.BottomFaces[1] + local frFrame = Frame3d( BottomFace.ptCenter, BottomFace.vtN, BottomFace.MainEdges.LongEdges[1].vtEdge) + local b3BottomFace = EgtSurfTmGetFacetBBoxRef( Proc.id, BottomFace.id, GDB_BB.STANDARD, frFrame) + dPocketHeight = b3BottomFace:getDimY() else dPocketHeight = Proc.MainFaces.BottomFaces[1].MainEdges.SideEdges[1].dLength end diff --git a/Strategies/Standard/STR0010/STR0010.lua b/Strategies/Standard/STR0010/STR0010.lua index a8f3a06..63a779f 100644 --- a/Strategies/Standard/STR0010/STR0010.lua +++ b/Strategies/Standard/STR0010/STR0010.lua @@ -299,6 +299,7 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) end -- fresatura eventuali facce di chiusura (se non già lavorate) + -- TODO funzione if Strategy.Parameters.bFinishWithMill then if Milling1 then @@ -311,7 +312,8 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) end -- su ognuno si fa la fresatura di pulizia for i = 1, #EdgesClosedNotMachined do - local dDepthToMachine = EdgesClosedNotMachined[i].dElevation - Strategy.Parameters.dMillingOffsetFromSide + local dMillingOffsetFromSide = Strategy.Parameters.bAntiSplintWithBlade and Strategy.Parameters.dMillingOffsetFromSide or 0 + local dDepthToMachine = EdgesClosedNotMachined[i].dElevation - dMillingOffsetFromSide local dToolMarkLength = Milling1.dToolMarkLength or 0 local OptionalParameters = { bIsSplitFeature = bIsSplitFeature, @@ -336,7 +338,8 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) end -- su ognuno si fa la fresatura di pulizia for i = 1, #EdgesClosedNotMachined do - local dDepthToMachine = EdgesClosedNotMachined[i].dElevation - Strategy.Parameters.dMillingOffsetFromSide + local dMillingOffsetFromSide = Strategy.Parameters.bAntiSplintWithBlade and Strategy.Parameters.dMillingOffsetFromSide or 0 + local dDepthToMachine = EdgesClosedNotMachined[i].dElevation - dMillingOffsetFromSide local dToolMarkLength = Milling2.dToolMarkLength or 0 local OptionalParameters = { bIsSplitFeature = bIsSplitFeature, diff --git a/StrategyLibs/BLADEKEEPWASTE.lua b/StrategyLibs/BLADEKEEPWASTE.lua index 784df03..6ee9291 100644 --- a/StrategyLibs/BLADEKEEPWASTE.lua +++ b/StrategyLibs/BLADEKEEPWASTE.lua @@ -156,7 +156,7 @@ local function MakeBottomFace( Proc, Part, BottomFace, EdgeToMachine, Parameters if EdgeToMachineOpposite.bIsOpen then Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade1) end - Cutting1.nInternalSortingPriority = 3 + Cutting1.nInternalSortingPriority = 2 Cutting1.dResultWeight = 0.3 -- secondo lato @@ -165,7 +165,7 @@ local function MakeBottomFace( Proc, Part, BottomFace, EdgeToMachine, Parameters if EdgeToMachine.bIsOpen then Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade2) end - Cutting2.nInternalSortingPriority = 3 + Cutting2.nInternalSortingPriority = 2 Cutting2.dResultWeight = 0.3 -- se uno dei due lati non è riuscito, si estende il più possibile il lato rimasto @@ -179,7 +179,7 @@ local function MakeBottomFace( Proc, Part, BottomFace, EdgeToMachine, Parameters OptionalParametersFaceByBlade2.dDepthToMachine = dDepthToMachine Cutting2 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade2) - Cutting2.nInternalSortingPriority = 3 + Cutting2.nInternalSortingPriority = 2 Cutting2.dResultWeight = 0.3 table.insert( Cuttings, Cutting2) @@ -193,7 +193,7 @@ local function MakeBottomFace( Proc, Part, BottomFace, EdgeToMachine, Parameters OptionalParametersFaceByBlade1.dDepthToMachine = dDepthToMachine Cutting1 = FaceByBlade.Make( Proc, Part, BottomFace, EdgeToMachine, OptionalParametersFaceByBlade1) - Cutting1.nInternalSortingPriority = 3 + Cutting1.nInternalSortingPriority = 2 Cutting1.dResultWeight = 0.3 table.insert( Cuttings, Cutting1) @@ -286,6 +286,10 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- calcolo lavorazioni faccia principale -- ricerca lato da lavorare local BottomEdgeToMachine1 = GetLongEdgeToMachine( BottomFace1, { bTop = true}) + if not BottomEdgeToMachine1 then + Result = FeatureLib.GetStrategyResultNotApplicable() + return Machinings, Result + end -- calcolo lavorazione local Parameters1 = { bIsSplitFeature = bIsSplitFeature, @@ -302,16 +306,19 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) -- calcolo lavorazioni faccia secondaria, solo se lato convesso; se concavo, sarà lavorato come antisplint local Cuttings2 + local BottomEdgeToMachine2 if BottomFace2 then if bConvexAngle then -- ricerca lato da lavorare - local BottomEdgeToMachine2 = GetLongEdgeToMachine( BottomFace2, { bTop = true}) - -- calcolo lavorazione - local Parameters2 = BeamLib.TableCopyDeep( Parameters1) - Parameters2.OtherBottomFace = BottomFace1 - Cuttings2 = MakeBottomFace( Proc, Part, BottomFace2, BottomEdgeToMachine2, Parameters2) - for i = 1, #Cuttings2 do - table.insert( CalculatedMachinings, Cuttings2[i]) + BottomEdgeToMachine2 = GetLongEdgeToMachine( BottomFace2, { bTop = true}) + if BottomEdgeToMachine2 then + -- calcolo lavorazione + local Parameters2 = BeamLib.TableCopyDeep( Parameters1) + Parameters2.OtherBottomFace = BottomFace1 + Cuttings2 = MakeBottomFace( Proc, Part, BottomFace2, BottomEdgeToMachine2, Parameters2) + for i = 1, #Cuttings2 do + table.insert( CalculatedMachinings, Cuttings2[i]) + end end end end @@ -336,22 +343,71 @@ function BLADEKEEPWASTE.Make( Proc, Part, OptionalParameters) end end - -- -- fresatura eventuali facce di chiusura - -- if bFinishWithMill then - -- for i = 1, #LongFaces do - -- if BottomEdgeToMachine.idAdjacentFace ~= LongFaces[i].id then - -- local dDepthToMachineMill = BottomFace1.MainEdges.LongEdges[i].dElevation - dMillingOffsetFromSide - -- local dToolMarkLength = max( Cutting1.dToolMarkLength or 0, Cutting2.dToolMarkLength or 0) - -- local OptionalParametersFaceByMill = { bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail, - -- dRadialStepSpan = dToolMarkLength, dDepthToMachine = dDepthToMachineMill - -- } - -- local Milling = FaceByMill.Make( Proc, Part, BottomFace1, BottomFace1.MainEdges.LongEdges[i], OptionalParametersFaceByMill) - -- Milling.nInternalSortingPriority = 2 - -- Milling.dResultWeight = 0.05 - -- table.insert( CalculatedMachinings, Milling) - -- end - -- end - -- end + -- pulitura con fresa dei lati chiusi non lavorati + -- TODO funzione + if bFinishWithMill then + + if Cuttings1 then + -- si recuperano i lati chiusi non lavorati + local EdgesClosedNotMachined = {} + for i = 1, #BottomFace1.Edges do + if not( ( BottomFace1.Edges[i].id == BottomEdgeToMachine1.id) or BottomFace1.Edges[i].bIsOpen) then + table.insert( EdgesClosedNotMachined, BottomFace1.Edges[i]) + end + end + -- su ognuno si fa la fresatura di pulizia + for i = 1, #EdgesClosedNotMachined do + local dDepthToMachine = EdgesClosedNotMachined[i].dElevation - dMillingOffsetFromSide + local dToolMarkLength = 0 + -- si prende l'impronta dell'utensile più grande + for j = 1, #Cuttings1 do + if Cuttings1[j].dToolMarkLength > dToolMarkLength + 10 * GEO.EPS_SMALL then + dToolMarkLength = Cuttings1[j].dToolMarkLength + end + end + local OptionalParametersMilling = { + bIsSplitFeature = bIsSplitFeature, + dExtendAfterTail = dExtendAfterTail, + dRadialStepSpan = dToolMarkLength, + dDepthToMachine = dDepthToMachine + } + local Milling = FaceByMill.Make( Proc, Part, BottomFace1, EdgesClosedNotMachined[i], OptionalParametersMilling) + Milling.nInternalSortingPriority = 3 + Milling.dResultWeight = 0.05 + table.insert( CalculatedMachinings, Milling) + end + end + if Cuttings2 and BottomEdgeToMachine2 then + -- si recuperano i lati chiusi non lavorati + local EdgesClosedNotMachined = {} + for i = 1, #BottomFace2.Edges do + if not( ( BottomFace2.Edges[i].id == BottomEdgeToMachine2.id) or BottomFace2.Edges[i].bIsOpen) then + table.insert( EdgesClosedNotMachined, BottomFace2.Edges[i]) + end + end + -- su ognuno si fa la fresatura di pulizia + for i = 1, #EdgesClosedNotMachined do + local dDepthToMachine = EdgesClosedNotMachined[i].dElevation - dMillingOffsetFromSide + local dToolMarkLength = 0 + -- si prende l'impronta dell'utensile più grande + for j = 1, #Cuttings2 do + if Cuttings2[j].dToolMarkLength > dToolMarkLength + 10 * GEO.EPS_SMALL then + dToolMarkLength = Cuttings2[j].dToolMarkLength + end + end + local OptionalParametersMilling = { + bIsSplitFeature = bIsSplitFeature, + dExtendAfterTail = dExtendAfterTail, + dRadialStepSpan = dToolMarkLength, + dDepthToMachine = dDepthToMachine + } + local Milling = FaceByMill.Make( Proc, Part, BottomFace2, EdgesClosedNotMachined[i], OptionalParametersMilling) + Milling.nInternalSortingPriority = 3 + Milling.dResultWeight = 0.05 + table.insert( CalculatedMachinings, Milling) + end + end + end -- lavorazioni da applicare spostate in lista finale for i = 1, #CalculatedMachinings do