From 3287420f4181b6dfa6928e3ad9687edda22e5044 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 7 Jan 2025 15:27:25 +0100 Subject: [PATCH 01/21] - in FaceData -> GetFacesInfo contemplato il caso in cui arrivi una Proc senza nFct --- LuaLibs/FaceData.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index 25a5aee..23d74dc 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -109,6 +109,10 @@ function FaceData.GetFacesInfo( Proc, Part) vAdj = FaceData.GetAdjacencyMatrix( Proc) end + if not Proc.nFct then + Proc.nFct = EgtSurfTmFacetCount( Proc.id) or 0 + end + -- reset eventuali visualizzazioni facce a due colori EgtSurfTmResetTwoColors( Proc.id) From cf96eb7bc3ec4c1a1bb95ec1a33ca46659b69d38 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 7 Jan 2025 17:30:47 +0100 Subject: [PATCH 02/21] - aggiunta STR0005 - BladeToWaste --- Strategies/Standard/STR0005/STR0005.lua | 58 +++++++++++++++++++ Strategies/Standard/STR0005/STR0005Config.lua | 15 +++++ 2 files changed, 73 insertions(+) create mode 100644 Strategies/Standard/STR0005/STR0005.lua create mode 100644 Strategies/Standard/STR0005/STR0005Config.lua diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua new file mode 100644 index 0000000..7e026ce --- /dev/null +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -0,0 +1,58 @@ +-- Strategia: STR0005 +-- Descrizione +-- lama per taglio facce con cubetti se necessario +-- Feature: tagli singoli / doppi + +-- carico librerie +local BeamLib = require( 'BeamLib') +local BeamData = require( 'BeamData') +local MachiningLib = require( 'MachiningLib') +local FeatureLib = require( 'FeatureLib') +-- strategie di base +local FaceByBlade = require( 'FACEBYBLADE') + +-- Tabella per definizione modulo +local STR0005 = {} +local Strategy = {} + +------------------------------------------------------------------------------------------------------------- + +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 + else + return false + end +end + + +function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) + -- TODO da implementare gestione feature lunghe e spezzatura + -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) + local StrategyLib = {} + StrategyLib.Config = require( 'STR0005\\STR0005Config') + Strategy.sName = StrategyLib.Config.sStrategyId + CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) + Strategy.Result = {} + Strategy.Result.sInfo = '' + + if not IsTopologyOk( Proc) then + local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not implemented' + EgtOutLog( sErr) + Strategy.Result.sStatus = 'Not-Applicable' + Strategy.Result.sInfo = 'Topology' + return false, Strategy.Result + end + + return bAreAllMachiningsAdded, Strategy.Result +end + +------------------------------------------------------------------------------------------------------------- + + return STR0005 \ No newline at end of file diff --git a/Strategies/Standard/STR0005/STR0005Config.lua b/Strategies/Standard/STR0005/STR0005Config.lua new file mode 100644 index 0000000..133f644 --- /dev/null +++ b/Strategies/Standard/STR0005/STR0005Config.lua @@ -0,0 +1,15 @@ +-- Parametri configurabili da cliente per strategia: STR0004 + +local STR0005Data = { + sStrategyId = 'STR0005', + Parameters = { + { sName = 'bForceLongcutBlade', sNameNge = 'USE_LONGCUT_BLADE', sValue = 'false', sDescriptionShort = 'Force ripping blade', sDescriptionLong = 'Force the use of ripping blade, designed for cuts parallel to the grain', sType = 'b', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dExtendAfterTail', sNameNge = 'EXTEND_AFTER_TAIL', sValue = 'false', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'sCanDamageNextPiece', sNameNge = 'DAMAGE_NEXT_PIECE', sValue = 'NEVER', sType = 'combo', sMinUserLevel = '1', + Choices = { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + { sValue = 'ONLY_IF_RAWPART', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}} + } +} + +return STR0005Data \ No newline at end of file From 3835f6f6e0ea77c1cf01246f677c95def8a2d7da Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 8 Jan 2025 09:15:44 +0100 Subject: [PATCH 03/21] - in Strategies.ini e BasicCustomerStrategies aggiunta STR0005 --- LuaLibs/BasicCustomerStrategies.lua | 1 + Strategies/Strategies.ini | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index f0a2a80..8bba58d 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -49,6 +49,7 @@ local function GetStrategies_Egalware( Proc) --------------------------------------------------------------------- -- Feature : Cut elseif ID.IsCut( Proc) then + Strategies = { { sStrategyId = 'STR0005'}} --------------------------------------------------------------------- -- Feature : Longitudinal Cut elseif ID.IsLongitudinalCut( Proc) then diff --git a/Strategies/Strategies.ini b/Strategies/Strategies.ini index 23343ee..f1a4f58 100644 --- a/Strategies/Strategies.ini +++ b/Strategies/Strategies.ini @@ -3,11 +3,13 @@ STR0001 = Tenone a coda di rondine. Lama + fresa a coda di rondine STR0002 = Topologia tipo LapJoint. Svuotatura con fresa STR0003 = Topologia tipo LapJoint. Lama + motosega +STR0004 = Topologia tipo LapJoint. Motosega +STR0005 = Faccia singola o doppia. Lama, se necessario cubetti. [Strategies] ; Processing , Gruppo , Topologia , Strategie ;Feature : Cut -10,1,Feature, +10,1,Feature,STR0005 ;Feature : Longitudinal Cut 10,0,Feature, ;Feature : Double Cut From cc8410b0c5b7d341d7df2e014a9c9f53e9bfd804 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 10 Jan 2025 18:13:39 +0100 Subject: [PATCH 04/21] - in BeamExec -> CollectFeatures inserito calcolo riduzione lunghezza pinzabile - in FeatureLib aggiunte funzioni GetFeatureVolume e CalculateFeatureNotClampableLengths - in STR0005 aggiunta scelta strategie di taglio; al momento non contemplato massimo materiale lama - aggiunta BLADETOWASTE, solo intestazione --- LuaLibs/BeamExec.lua | 2 + LuaLibs/BeamLib.lua | 1 + LuaLibs/FeatureLib.lua | 107 +++++++++++++++++- LuaLibs/MachiningLib.lua | 2 +- Strategies/Standard/STR0002/STR0002.lua | 2 +- Strategies/Standard/STR0003/STR0003.lua | 11 +- Strategies/Standard/STR0004/STR0004.lua | 11 +- Strategies/Standard/STR0005/STR0005.lua | 51 ++++++--- Strategies/Standard/STR0005/STR0005Config.lua | 11 +- StrategyLibs/BLADETOWASTE.lua | 17 +++ 10 files changed, 187 insertions(+), 28 deletions(-) create mode 100644 StrategyLibs/BLADETOWASTE.lua diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 91efe82..94fef1e 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -650,6 +650,8 @@ local function CollectFeatures( Part) else EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' : NO available strategies') end + -- calcolo riduzione lunghezza pinzabile testa/coda + Proc.NotClampableLength = FeatureLib.CalculateFeatureNotClampableLengths( Proc, Part) -- altrimenti errore (serviva riconoscimento topologico, ma non è stato possibile farlo) else EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' : NO available strategies') diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index d266227..6661f23 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -626,5 +626,6 @@ do return MergeSort( List, Compare) end end + ------------------------------------------------------------------------------------------------------------- return BeamLib diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index 0ae6034..cdc9205 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -293,8 +293,8 @@ function FeatureLib.CalculateCompositeRating( StrategyResult) end ------------------------------------------------------------------------------------------------------------- -function FeatureLib.MachiningNeedsSplitting( dMachiningLengthOnX, Part, OptionalParameters) - local bMachiningNeedsSplitting +function FeatureLib.IsMachiningLong( dMachiningLengthOnX, Part, OptionalParameters) + local bIsMachiningLong -- parametri opzionali if not OptionalParameters then @@ -302,10 +302,10 @@ function FeatureLib.MachiningNeedsSplitting( dMachiningLengthOnX, Part, Optional end local dMaxSegmentLength = OptionalParameters.dMaxSegmentLength or BeamData.LONGCUT_MAXLEN - bMachiningNeedsSplitting = ( dMachiningLengthOnX > dMaxSegmentLength + 10 * GEO.EPS_SMALL) - or ( dMachiningLengthOnX > 0.7 * Part.b3Part:getDimX() + 10 * GEO.EPS_SMALL) + bIsMachiningLong = ( dMachiningLengthOnX > dMaxSegmentLength + 10 * GEO.EPS_SMALL) + or ( dMachiningLengthOnX > 0.7 * Part.b3Part:getDimX() + 10 * GEO.EPS_SMALL) - return bMachiningNeedsSplitting + return bIsMachiningLong end ------------------------------------------------------------------------------------------------------------- @@ -327,7 +327,7 @@ function FeatureLib.GetFeatureSplittingPoints( Proc, Part, OptionalParameters) local dToolOverlapBetweenSegments = OptionalParameters.dToolOverlapBetweenSegments or BeamData.MILL_OVERLAP -- verifica spezzatura necessaria - if not FeatureLib.MachiningNeedsSplitting( Proc.b3Box:getDimX(), Part) then + if not FeatureLib.IsMachiningLong( Proc.b3Box:getDimX(), Part) then return {} end @@ -405,5 +405,100 @@ function FeatureLib.GetAdditionalInfo( Proc, Part) return Proc end +------------------------------------------------------------------------------------------------------------- +function FeatureLib.GetFeatureVolume( Proc, Part) + local dProcVolume = 0 + + local nAddGrpId = BeamLib.GetAddGroup( Proc.idPart) + if not nAddGrpId then + -- TODO gestire meglio questo errore. Non conviene creare e verificare all'inizio se il gruppo esiste? + EgtOutLog( 'Error : missing AddGroup') + return 0 + end + + local idProcCopy = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL + local b3PartCopy = BBox3d( Part.b3Part) + b3PartCopy:expand( -100 * GEO.EPS_SMALL) + local idPartCopy = EgtSurfTmBBox( nAddGrpId, b3PartCopy , false, GDB_RT.GLOB) + + EgtSurfTmSubtract( idPartCopy, idProcCopy) + dProcVolume = EgtSurfVolume( idPartCopy) + + EgtErase( { idProcCopy, idPartCopy}) + + return dProcVolume +end + +------------------------------------------------------------------------------------------------------------- +-- TODO bisogna calcolarla per tutte le rotazioni; funzione copiata direttamente da automatismo vecchio, da migliorare / completare +function FeatureLib.CalculateFeatureNotClampableLengths( Proc, Part) + local NotClampableLength = {} + + -- verifico siano una o due facce + if Proc.nFct > 2 then return end + + -- eventuale segnalazione ingombro di testa o coda + local dMinHIng = min( 0.5 * BeamData.VICE_MINH, 0.5 * Part.b3Raw:getDimZ()) + local dMinZ = max( BeamData.MIN_HEIGHT, 0.35 * Part.b3Raw:getDimZ()) + -- calcolo punto massimo in Z fino a dove considerare il pinzaggio. Minimo tra pinzaggio massimo e altezza pezzo + local dMaxHZ = Part.b3Raw:getMin():getZ() + min( BeamData.VICE_MAXH or BeamData.MAX_HEIGHT, Part.b3Raw:getDimZ()) + -- punto massimo in Z considerando anche la Z della feature + local dMaxHZFeat = min( dMaxHZ, Proc.b3Box:getMax():getZ()) + -- dimensione Z del pinzaggio (differenza massima Z pinzabile e box feature) + local dDeltaZClamp = ( ( dMaxHZ - Part.b3Raw:getMin():getZ()) - max( 0, dMaxHZFeat - Proc.b3Box:getMin():getZ())) + -- se pinzaggio minimo è come il massimo (oppure come l'altezza massima del pezzo) significa che è verticale + local bIsVertClamps = BeamData.VICE_MINH > BeamData.MAX_HEIGHT - 100 * GEO.EPS_SMALL + + -- condizioni per limitare pinzaggio testa/coda + local bUpdateIng = true + -- se dimensione del box della feature maggiore di metà pinzaggio minimo o metà spessore pezzo + bUpdateIng = bUpdateIng and Proc.b3Box:getDimZ() > dMinHIng + -- se la feature si trova più in basso del minimo pinzabile in Z o il 35% dello spessore pezzo + bUpdateIng = bUpdateIng and Proc.b3Box:getMin():getZ() < Part.b3Raw:getMin():getZ() + dMinZ + -- se feature è al di sotto del pinzaggio massimo + bUpdateIng = bUpdateIng and Proc.b3Box:getMin():getZ() < dMaxHZ + -- se ho le morse verticali, o se la feature è in centro o verso alto, controllo se non prendo abbastanza. + if bIsVertClamps or ( Proc.b3Box:getMin():getZ() - Part.b3Raw:getMin():getZ()) > BeamData.MIN_HEIGHT then + bUpdateIng = bUpdateIng and dDeltaZClamp < BeamData.VICE_MINH + end + + local dNotClampableLengthHead = 0 + local dNotClampableLengthTail = 0 + + if bUpdateIng then + if Proc.AffectedFaces.bRight then + local dOffs = Part.b3Part:getMax():getX() - Proc.b3Box:getMin():getX() + -- se pinze a 45° e pinza abbastanza materiale, compenso comunque, ma solo inclinazione morse + if not bIsVertClamps and dDeltaZClamp > BeamData.VICE_MINH and BeamData.VICE_MAXH then + dOffs = min( dOffs, BeamData.VICE_MAXH - BeamData.VICE_MINH) + end + dNotClampableLengthHead = dOffs + elseif Proc.AffectedFaces.bLeft then + local dOffs = Proc.b3Box:getMax():getX() - Part.b3Part:getMin():getX() + -- se pinze a 45° e pinza abbastanza materiale, compenso comunque, ma solo inclinazione morse + if not bIsVertClamps and dDeltaZClamp > BeamData.VICE_MINH and BeamData.VICE_MAXH then + dOffs = min( dOffs, BeamData.VICE_MAXH - BeamData.VICE_MINH) + end + dNotClampableLengthTail = dOffs + elseif Proc.b3Box:getCenter():getX() > Part.b3Part:getCenter():getX() then + local dOffs = Part.b3Part:getMax():getX() - Proc.b3Box:getMin():getX() + local dDist = Part.b3Part:getMax():getX() - Proc.b3Box:getMax():getX() + -- se pinze a 45° e pinza abbastanza materiale, compenso comunque, ma solo inclinazione morse + if not bIsVertClamps and dDeltaZClamp > BeamData.VICE_MINH and BeamData.VICE_MAXH then + dOffs = min( dOffs, BeamData.VICE_MAXH - BeamData.VICE_MINH) + end + -- dDist serve?? + dNotClampableLengthHead = dOffs + end + end + + NotClampableLength.Rot0 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} + NotClampableLength.Rot90 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} + NotClampableLength.Rot180 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} + NotClampableLength.Rot270 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} + + return NotClampableLength +end + ------------------------------------------------------------------------------------------------------------- return FeatureLib \ No newline at end of file diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index b1b92ee..751d981 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -116,7 +116,7 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part ) end local dOriginalStartAddLength = Machinings[i].LeadIn.dStartAddLength local dOriginalEndAddLength = Machinings[i].LeadOut.dEndAddLength - if FeatureLib.MachiningNeedsSplitting( Machinings[i].dLengthOnX, Part) then + if FeatureLib.IsMachiningLong( Machinings[i].dLengthOnX, Part) then local nCurrentMachiningIndex = i -- lo spezzone attivo è quello precedente al punto di spezzatura corrente for j = 1, nParts do diff --git a/Strategies/Standard/STR0002/STR0002.lua b/Strategies/Standard/STR0002/STR0002.lua index 247a40b..f3cb106 100644 --- a/Strategies/Standard/STR0002/STR0002.lua +++ b/Strategies/Standard/STR0002/STR0002.lua @@ -1,7 +1,7 @@ -- Strategia: STR0002 -- Descrizione -- Svuotatura tasca --- Feature tipo LapJpint +-- Feature tipo LapJoint ------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------- diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index 042aa6e..205921c 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -3,6 +3,16 @@ -- Lama + motosega per slot -- Feature: tipo lapjoint +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- +-- TODO +-- 1 - Gestire lavorazioni da sotto +-- 2 - Inserire antischeggia (fresa o lama) +-- 3 - Smusso a V +-- 4 - Implementare lavorazione di geometrie inclinate +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- + -- carico librerie local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') @@ -233,7 +243,6 @@ end function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) - -- TODO da implementare gestione feature lunghe e spezzatura -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} StrategyLib.Config = require( 'STR0003\\STR0003Config') diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua index 9c9429e..84a2d9f 100644 --- a/Strategies/Standard/STR0004/STR0004.lua +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -3,6 +3,16 @@ -- motosega per slot -- Feature: tipo lapjoint +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- +-- TODO +-- 1 - Inserire antischeggia (fresa o lama) +-- 2 - Smusso a V +-- 3 - Implementare lavorazione di geometrie inclinate +-- 4 - Gestire lavorazioni da sotto (ove possibile, in generale la motosega non lavora da sotto) +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- + -- carico librerie local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') @@ -122,7 +132,6 @@ end function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) - -- TODO da implementare gestione feature lunghe e spezzatura -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} StrategyLib.Config = require( 'STR0004\\STR0004Config') diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 7e026ce..6096092 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -1,7 +1,7 @@ -- Strategia: STR0005 -- Descrizione -- lama per taglio facce con cubetti se necessario --- Feature: tagli singoli / doppi +-- Feature: tagli singoli con eventuali cubetti -- carico librerie local BeamLib = require( 'BeamLib') @@ -9,7 +9,7 @@ local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base -local FaceByBlade = require( 'FACEBYBLADE') +local BladeToWaste = require( 'BLADETOWASTE') -- Tabella per definizione modulo local STR0005 = {} @@ -17,22 +17,28 @@ local Strategy = {} ------------------------------------------------------------------------------------------------------------- -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 +local function GetBestCuttingStrategy( Proc, Part, StrategyParameters) + local sCuttingStrategy = '' + local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part) + local dFeatureMaxDimension = max( Proc.b3Box:getDimX(), Proc.b3Box:getDimY(), Proc.b3Box:getDimZ()) + local dFeatureMaxNotClampableLengthHead = max( Proc.NotClampableLength.Rot0.Head, Proc.NotClampableLength.Rot90.Head, Proc.NotClampableLength.Rot180.Head, Proc.NotClampableLength.Rot270.Head) + local dFeatureMaxNotClampableLengthTail = max( Proc.NotClampableLength.Rot0.Tail, Proc.NotClampableLength.Rot90.Tail, Proc.NotClampableLength.Rot180.Tail, Proc.NotClampableLength.Rot270.Tail) - return true + if dFeatureVolume < StrategyParameters.dMaxWasteVolume + 10 * GEO.EPS_SMALL + and dFeatureMaxDimension < StrategyParameters.dMaxWasteLength + 10 * GEO.EPS_SMALL then + -- TODO non sto considerando se l'utensile (non ancora scelto) ci arriva o no! + sCuttingStrategy = 'DROP_WHOLE_WASTE' + elseif FeatureLib.IsMachiningLong( max( dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN}) then + sCuttingStrategy = 'LEAVE_WASTE_ATTACHED' else - return false + sCuttingStrategy = 'DICE_CUT' end + + return sCuttingStrategy end function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) - -- TODO da implementare gestione feature lunghe e spezzatura -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} StrategyLib.Config = require( 'STR0005\\STR0005Config') @@ -42,12 +48,23 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Result = {} Strategy.Result.sInfo = '' - if not IsTopologyOk( Proc) then - local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not implemented' - EgtOutLog( sErr) - Strategy.Result.sStatus = 'Not-Applicable' - Strategy.Result.sInfo = 'Topology' - return false, Strategy.Result + local Cutting = {} + local sCuttingStrategy = '' + + if Strategy.Parameters.sCuttingStrategy == 'AUTO' then + sCuttingStrategy = GetBestCuttingStrategy( Proc, Part, Strategy.Parameters) + else + sCuttingStrategy = Strategy.Parameters.sCuttingStrategy + end + + if sCuttingStrategy == 'DROP_WHOLE_WASTE' then + + elseif sCuttingStrategy == 'LEAVE_WASTE_ATTACHED' then + + elseif sCuttingStrategy == 'DICE_CUT' then + + else + -- strategia di taglio non riconosciuta end return bAreAllMachiningsAdded, Strategy.Result diff --git a/Strategies/Standard/STR0005/STR0005Config.lua b/Strategies/Standard/STR0005/STR0005Config.lua index 133f644..895b570 100644 --- a/Strategies/Standard/STR0005/STR0005Config.lua +++ b/Strategies/Standard/STR0005/STR0005Config.lua @@ -1,5 +1,7 @@ -- Parametri configurabili da cliente per strategia: STR0004 +-- TODO - sostituire dMaxWasteVolume con dMaxWasteWeight? Dove prendere la densità del materiale? + local STR0005Data = { sStrategyId = 'STR0005', Parameters = { @@ -8,7 +10,14 @@ local STR0005Data = { { sName = 'sCanDamageNextPiece', sNameNge = 'DAMAGE_NEXT_PIECE', sValue = 'NEVER', sType = 'combo', sMinUserLevel = '1', Choices = { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, { sValue = 'ONLY_IF_RAWPART', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, - { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}} + { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}, + { sName = 'sCuttingStrategy', sNameNge = 'CUTTING_STRATEGY', sValue = 'AUTO', sType = 'combo', sMinUserLevel = '1', + Choices = { sValue = 'AUTO', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + { sValue = 'DROP_WHOLE_WASTE', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + { sValue = 'LEAVE_WASTE_ATTACHED', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + { sValue = 'DICE_CUT', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}, + { sName = 'dMaxWasteLength', sNameNge = 'MAX_WASTE_LENGTH', sValue = '300', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dMaxWasteVolume', sNameNge = 'MAX_WASTE_VOLUME', sValue = '6000000', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'} } } diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua new file mode 100644 index 0000000..b40f145 --- /dev/null +++ b/StrategyLibs/BLADETOWASTE.lua @@ -0,0 +1,17 @@ +-- BLADETOWASTE.lua by Egalware s.r.l. 2025/01/08 +-- Libreria di supporto a strategie con funzioni comune a strategie diverse. + +-- Tabella per definizione modulo +local BLADETOWASTE = {} + +-- Include +require( 'EgtBase') + +-- Carico i dati globali +local BeamData = require( 'BeamData') +local FeatureLib = require( 'FeatureLib') +local MachiningLib = require( 'MachiningLib') +-- strategie di base +local FaceByBlade = require('FACEBYBLADE') + +EgtOutLog( ' BLADETOWASTE started', 1) From d76ecbc9f6a0def1a0b2b4b29b201f5caa367dda Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 14 Jan 2025 15:17:18 +0100 Subject: [PATCH 05/21] - in Process require di BeamExec spostato dopo la dichiarazione delle variabili globali - in BeamExec -> CollectFeatures si salva l'indice della Proc nel vProc - in FeatureLib aggiunta funzione GetFeatureMaxNotClampableLengths - correzioni e migliorie GetFeatureMaxNotClampableLengths --- LuaLibs/BeamExec.lua | 11 +++- LuaLibs/FeatureLib.lua | 29 +++++++-- Process.lua | 6 +- Strategies/Standard/STR0005/STR0005.lua | 61 ++++++++----------- Strategies/Standard/STR0005/STR0005Config.lua | 3 +- StrategyLibs/BLADETOWASTE.lua | 9 +++ 6 files changed, 70 insertions(+), 49 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 94fef1e..ef73b42 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -588,6 +588,7 @@ end ------------------------------------------------------------------------------------------------------------- local function CollectFeatures( Part) -- recupero le feature + local nProcCount = 0 local vProc = {} local LayerId = {} LayerId[1] = BeamLib.GetAddGroup( Part.id) @@ -645,6 +646,8 @@ local function CollectFeatures( Part) end -- se ci sono strategie disponibili, aggiungo a lista delle feature da lavorare if Proc.AvailableStrategies and #Proc.AvailableStrategies > 0 then + nProcCount = nProcCount + 1 + Proc.nIndexInVProc = nProcCount table.insert( vProc, Proc) -- altrimenti errore (non ci sono strategie per lavorare la topologia riconosciuta) else @@ -658,6 +661,8 @@ local function CollectFeatures( Part) end else Proc.nFlg = 0 + nProcCount = nProcCount + 1 + Proc.nIndexInVProc = nProcCount table.insert( vProc, Proc) EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' is empty (no geometry)') end @@ -1022,9 +1027,6 @@ function BeamExec.GetProcessings( PROCESSINGS, PARTS) -- recupero informazioni ausiliarie feature e dipendenze tra feature stesse -- TODO le dipendenze cambiano in base alla rotazione del pezzo? probabilmente no vProcRot[dRotIndex] = GetFeatureInfoAndDependency( vProcRot[dRotIndex], PARTS[nPart]) - - -- calcola le strategie applicabili ( presenti nella tabella vProcRot[dRotIndex].AvailableStrategies) - vProcRot[dRotIndex] = CalculateStrategies( vProcRot[dRotIndex], PARTS[nPart]) else -- inserisco una tabella vuota table.insert( vProcRot, {}) @@ -1307,6 +1309,9 @@ function BeamExec.ProcessMachinings( PROCESSINGS, PARTS) for nPart = 1, #PARTS do -- calcolo della migliore strategia per ogni rotazione del pezzo for dRotIndex = 1, 4 do + -- calcola le strategie applicabili + PROCESSINGS[nPart].Rotation[dRotIndex] = CalculateStrategies( PROCESSINGS[nPart].Rotation[dRotIndex], PARTS[nPart]) + -- tra le calcolate, sceglie la migliore PROCESSINGS[nPart].Rotation[dRotIndex] = GetBestStrategy( PROCESSINGS[nPart].Rotation[dRotIndex]) end diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index cdc9205..6b24761 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -430,7 +430,7 @@ function FeatureLib.GetFeatureVolume( Proc, Part) end ------------------------------------------------------------------------------------------------------------- --- TODO bisogna calcolarla per tutte le rotazioni; funzione copiata direttamente da automatismo vecchio, da migliorare / completare +-- TODO funzione copiata direttamente da automatismo vecchio, da migliorare / completare function FeatureLib.CalculateFeatureNotClampableLengths( Proc, Part) local NotClampableLength = {} @@ -492,13 +492,32 @@ function FeatureLib.CalculateFeatureNotClampableLengths( Proc, Part) end end - NotClampableLength.Rot0 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} - NotClampableLength.Rot90 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} - NotClampableLength.Rot180 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} - NotClampableLength.Rot270 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} + NotClampableLength.dNotClampableLengthHead = dNotClampableLengthHead + NotClampableLength.dNotClampableLengthTail = dNotClampableLengthTail return NotClampableLength end +------------------------------------------------------------------------------------------------------------- +function FeatureLib.GetFeatureMaxNotClampableLengths( Proc, Part) + local nPartIndex = Part.nIndexInParts + local nProcIndex = Proc.nIndexInVProc + local Rotations = PROCESSINGS[nPartIndex].Rotation + + local dMaxOnHead = 0 + local dMaxOnTail = 0 + for i = 1, #Part.CombinationList do + for j = 1, 4 do + -- controllo che la rotazione sia attiva + if string.sub( Part.CombinationList[i].sBitIndexCombination, j, j) == '1' then + dMaxOnHead = max( Rotations[j][nProcIndex].NotClampableLength.dNotClampableLengthHead, dMaxOnHead) + dMaxOnTail = max( Rotations[j][nProcIndex].NotClampableLength.dNotClampableLengthTail, dMaxOnTail) + end + end + end + + return dMaxOnHead, dMaxOnTail +end + ------------------------------------------------------------------------------------------------------------- return FeatureLib \ No newline at end of file diff --git a/Process.lua b/Process.lua index 8147f6a..26f273d 100644 --- a/Process.lua +++ b/Process.lua @@ -74,14 +74,14 @@ for i = 1, #vtCoreStrategiesNames do end -local BeamExec = require( 'BeamExec') - -- Variabili globali PARTS = {} -- tabella contenente tutte le informazioni di ogni pezzo PROCESSINGS = {} -- tabella contenente tutte le informazioni di ogni feature, processate per ogni rotazione -- Carico i dati globali local BeamData = require( 'BeamData') +-- carico librerie +local BeamExec = require( 'BeamExec') -- Variabili di modulo local dRawW @@ -307,7 +307,7 @@ end -- *** Inserimento delle lavorazioni nelle travi *** ------------------------------------------------------------------------------------------------------------- local function MyProcessFeatures() - local PROCESSINGS = BeamExec.GetProcessings( PROCESSINGS, PARTS) + PROCESSINGS = BeamExec.GetProcessings( PROCESSINGS, PARTS) local bOk, Stats = BeamExec.ProcessMachinings( PROCESSINGS, PARTS) local nErrCnt = 0 local nWarnCnt = 0 diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 6096092..e0dc35b 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -10,34 +10,15 @@ local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base local BladeToWaste = require( 'BLADETOWASTE') +local FaceByBlade = require( 'FACEBYBLADE') -- Tabella per definizione modulo local STR0005 = {} local Strategy = {} +local Cutting = {} +Cutting.Result = {} ------------------------------------------------------------------------------------------------------------- - -local function GetBestCuttingStrategy( Proc, Part, StrategyParameters) - local sCuttingStrategy = '' - local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part) - local dFeatureMaxDimension = max( Proc.b3Box:getDimX(), Proc.b3Box:getDimY(), Proc.b3Box:getDimZ()) - local dFeatureMaxNotClampableLengthHead = max( Proc.NotClampableLength.Rot0.Head, Proc.NotClampableLength.Rot90.Head, Proc.NotClampableLength.Rot180.Head, Proc.NotClampableLength.Rot270.Head) - local dFeatureMaxNotClampableLengthTail = max( Proc.NotClampableLength.Rot0.Tail, Proc.NotClampableLength.Rot90.Tail, Proc.NotClampableLength.Rot180.Tail, Proc.NotClampableLength.Rot270.Tail) - - if dFeatureVolume < StrategyParameters.dMaxWasteVolume + 10 * GEO.EPS_SMALL - and dFeatureMaxDimension < StrategyParameters.dMaxWasteLength + 10 * GEO.EPS_SMALL then - -- TODO non sto considerando se l'utensile (non ancora scelto) ci arriva o no! - sCuttingStrategy = 'DROP_WHOLE_WASTE' - elseif FeatureLib.IsMachiningLong( max( dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN}) then - sCuttingStrategy = 'LEAVE_WASTE_ATTACHED' - else - sCuttingStrategy = 'DICE_CUT' - end - - return sCuttingStrategy -end - - function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} @@ -47,26 +28,34 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) Strategy.Result = {} Strategy.Result.sInfo = '' + Cutting.Result = {} - local Cutting = {} - local sCuttingStrategy = '' + local dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail = FeatureLib.GetFeatureMaxNotClampableLengths( Proc, Part) + local bLeaveWasteAttached = Strategy.Parameters.sCuttingStrategy == 'LEAVE_WASTE_ATTACHED' + local bFeatureHindersClamping = FeatureLib.IsMachiningLong( max( dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN}) + if bFeatureHindersClamping or bLeaveWasteAttached then + -- TODO Lavorazione con codolo + -- verificare se basta una lavorazione o ne servono due. Servirà cercare l'utensile e stabilire dove lasciare il codolo. + -- La FaceByBlade (o altra??) dovrà accettare opzionalmente di fermarsi prima (basta l'Offset??) e accettare l'utensile forzato. + -- attenzione perchè se l'inclinazione della faccia la fa finire oltre lo spigolo questo riduce il massimo calcolare (come calcolare????) + --Cutting = FaceByBlade.Make( ) + --Cutting.AddResult( Cutting) - if Strategy.Parameters.sCuttingStrategy == 'AUTO' then - sCuttingStrategy = GetBestCuttingStrategy( Proc, Part, Strategy.Parameters) - else - sCuttingStrategy = Strategy.Parameters.sCuttingStrategy + -- se la lavorazione con codolo fallisce o non è possibile si proseguirà a quella con cubetti + + -- TODO gestione lavorazioni spezzate + + -- TODO ordinamento lavorazioni (se necessario) end - if sCuttingStrategy == 'DROP_WHOLE_WASTE' then - - elseif sCuttingStrategy == 'LEAVE_WASTE_ATTACHED' then - - elseif sCuttingStrategy == 'DICE_CUT' then - - else - -- strategia di taglio non riconosciuta + if #Cutting.Result == 0 and not bLeaveWasteAttached then + -- BladeToWaste end + -- aggiunta lavorazioni alla lista. Vanno gestiti anche eventuali stepXY? + + -- output risultati + return bAreAllMachiningsAdded, Strategy.Result end diff --git a/Strategies/Standard/STR0005/STR0005Config.lua b/Strategies/Standard/STR0005/STR0005Config.lua index 895b570..4b9b856 100644 --- a/Strategies/Standard/STR0005/STR0005Config.lua +++ b/Strategies/Standard/STR0005/STR0005Config.lua @@ -14,8 +14,7 @@ local STR0005Data = { { sName = 'sCuttingStrategy', sNameNge = 'CUTTING_STRATEGY', sValue = 'AUTO', sType = 'combo', sMinUserLevel = '1', Choices = { sValue = 'AUTO', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, { sValue = 'DROP_WHOLE_WASTE', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, - { sValue = 'LEAVE_WASTE_ATTACHED', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, - { sValue = 'DICE_CUT', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}, + { sValue = 'LEAVE_WASTE_ATTACHED', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}, { sName = 'dMaxWasteLength', sNameNge = 'MAX_WASTE_LENGTH', sValue = '300', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, { sName = 'dMaxWasteVolume', sNameNge = 'MAX_WASTE_VOLUME', sValue = '6000000', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'} } diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index b40f145..2926b65 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -15,3 +15,12 @@ local MachiningLib = require( 'MachiningLib') local FaceByBlade = require('FACEBYBLADE') EgtOutLog( ' BLADETOWASTE started', 1) + + + + + +-- if dFeatureVolume < StrategyParameters.dMaxWasteVolume + 10 * GEO.EPS_SMALL +-- and dFeatureMaxDimension < StrategyParameters.dMaxWasteLength + 10 * GEO.EPS_SMALL then + +-- end \ No newline at end of file From 2be4a3fe0bf916eb8de82c539ba04c0d4fd7262b Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 16 Jan 2025 12:52:15 +0100 Subject: [PATCH 06/21] - PROCESSINGS spostata in BeamExec - aggiunte a STR0005, da completare --- LuaLibs/BeamExec.lua | 7 +- Process.lua | 5 +- Strategies/Standard/STR0005/STR0005.lua | 133 ++++++++++++++++++++++-- StrategyLibs/FACEBYBLADE.lua | 1 + 4 files changed, 129 insertions(+), 17 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index ef73b42..d8ef29a 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -31,6 +31,7 @@ EgtMdbSave() TOOLS = {} -- tabella contenente tutti gli utensili STRATEGIES = nil -- tabella contenente le strategie disponibili per ogni feature MACHININGS = {} -- tabella contenente le lavorazioni da applicare +PROCESSINGS = {} -- tabella contenente tutte le informazioni di ogni feature, processate per ogni rotazione ------------------------------------------------------------------------------------------------------------- -- *** COSTANTI *** TODO -> DA SPOSTARE IN BEAMDATA??? @@ -883,7 +884,7 @@ local function CalculateStrategies( vProcSingleRot, Part) Proc.AvailableStrategies[nIndexCurrentStrategy].Result = FeatureLib.CalculateCompositeRating( Proc.AvailableStrategies[nIndexCurrentStrategy].Result) -- se scelta strategia in modalità base o standard, esco subito alla prima che trovo completa - -- TODO serve paraemtro da Beam&Wall ( oppure da confirgurazione) !!!!!!!! + -- TODO serve parametro da Beam&Wall ( oppure da confirgurazione) !!!!!!!! if BEAM.GetFirstCompletedStrategy and Proc.AvailableStrategies[nIndexCurrentStrategy].Result.sStatus == 'Complete' then break end @@ -1008,7 +1009,7 @@ local function PrintFeatures( vProc, Part) end ------------------------------------------------------------------------------------------------------------- -function BeamExec.GetProcessings( PROCESSINGS, PARTS) +function BeamExec.GetProcessings( PARTS) -- recupero tutti i processing di tutti i pezzi in tutte le rotazioni -- TODO calcolo tempi da rimuovere o lasciare solo per debug -- if EgtGetDebugLevel() >= 3 then @@ -1274,7 +1275,7 @@ local function GetBestResultFromCombinationsMatrix( ProcessingsOnPart, PartInfo) end ------------------------------------------------------------------------------------------------------------- -function BeamExec.ProcessMachinings( PROCESSINGS, PARTS) +function BeamExec.ProcessMachinings( PARTS) -- ciclo sui pezzi local nTotErr = 0 local Stats = {} diff --git a/Process.lua b/Process.lua index 26f273d..a8e5ef1 100644 --- a/Process.lua +++ b/Process.lua @@ -76,7 +76,6 @@ end -- Variabili globali PARTS = {} -- tabella contenente tutte le informazioni di ogni pezzo -PROCESSINGS = {} -- tabella contenente tutte le informazioni di ogni feature, processate per ogni rotazione -- Carico i dati globali local BeamData = require( 'BeamData') @@ -307,8 +306,8 @@ end -- *** Inserimento delle lavorazioni nelle travi *** ------------------------------------------------------------------------------------------------------------- local function MyProcessFeatures() - PROCESSINGS = BeamExec.GetProcessings( PROCESSINGS, PARTS) - local bOk, Stats = BeamExec.ProcessMachinings( PROCESSINGS, PARTS) + BeamExec.GetProcessings( PARTS) + local bOk, Stats = BeamExec.ProcessMachinings( PARTS) local nErrCnt = 0 local nWarnCnt = 0 local sOutput = '' diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index e0dc35b..b67d628 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -15,10 +15,43 @@ local FaceByBlade = require( 'FACEBYBLADE') -- Tabella per definizione modulo local STR0005 = {} local Strategy = {} -local Cutting = {} -Cutting.Result = {} +local Blade = {} +Blade.Result = {} ------------------------------------------------------------------------------------------------------------- +local function CompareEdges( EdgeA, EdgeB) + -- prima i lati orientati lungo X + if abs( EdgeA.Norm:getX()) < abs( EdgeB.Norm:getX()) - 10 * GEO.EPS_SMALL then + return true + elseif abs( EdgeA.Norm:getX()) > abs( EdgeB.Norm:getX()) + 10 * GEO.EPS_SMALL then + return false + -- se stessa X si preferiscono i lati più in basso + else + if EdgeA.Norm:getZ() > EdgeB.Norm:getZ() + 10 * GEO.EPS_SMALL then + return true + elseif EdgeA.Norm:getZ() < EdgeB.Norm:getZ() - 10 * GEO.EPS_SMALL then + return false + -- se stessa Z si preferiscono i lati verso il fronte della trave + else + if EdgeA.Norm:getY() > EdgeB.Norm:getY() + 10 * GEO.EPS_SMALL then + return true + elseif EdgeA.Norm:getY() < EdgeB.Norm:getY() - 10 * GEO.EPS_SMALL then + return false + else + return false + end + end + end +end + + +function Blade.AddResult( Cutting) + table.insert( Blade.Result, Cutting) + + return Blade.Result +end + + function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} @@ -28,33 +61,111 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) Strategy.Result = {} Strategy.Result.sInfo = '' - Cutting.Result = {} + Blade.Result = {} local dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail = FeatureLib.GetFeatureMaxNotClampableLengths( Proc, Part) local bLeaveWasteAttached = Strategy.Parameters.sCuttingStrategy == 'LEAVE_WASTE_ATTACHED' local bFeatureHindersClamping = FeatureLib.IsMachiningLong( max( dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN}) + local Cutting = {} if bFeatureHindersClamping or bLeaveWasteAttached then -- TODO Lavorazione con codolo - -- verificare se basta una lavorazione o ne servono due. Servirà cercare l'utensile e stabilire dove lasciare il codolo. -- La FaceByBlade (o altra??) dovrà accettare opzionalmente di fermarsi prima (basta l'Offset??) e accettare l'utensile forzato. -- attenzione perchè se l'inclinazione della faccia la fa finire oltre lo spigolo questo riduce il massimo calcolare (come calcolare????) - --Cutting = FaceByBlade.Make( ) + -- il FindBlade dovrà restituire di utilizzare sempre la lama sopra se l'angolo lo permette, ma avendo un'altezza massima (da macchina) oltre cui il DownUp non sarà fattibile (evita collisioni tra asse e pezzo) + --Cutting = FaceByBlade.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalParameters) --Cutting.AddResult( Cutting) + + -- si trovano i lati da lavorare + local EdgesSorted = {} + for i = 1, #Proc.Faces[1].Edges do + table.insert( EdgesSorted, Proc.Faces[1].Edges[i]) + end + table.sort( EdgesSorted, CompareEdges) - -- se la lavorazione con codolo fallisce o non è possibile si proseguirà a quella con cubetti + local dDepthToMachine = EdgesSorted[1].Elevation / 2 + BeamData.CUT_EXTRA - -- TODO gestione lavorazioni spezzate + -- ricerca utensile + local ToolSearchParameters = {} + ToolSearchParameters.dElevation = dDepthToMachine + ToolSearchParameters.vtToolDirection = EdgesSorted[1].Norm + ToolSearchParameters.bAllowTopHead = true + ToolSearchParameters.bAllowBottomHead = true + ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade + local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) + Cutting.nToolIndex = ToolInfo.nToolIndex + Cutting.nType = MCH_OY.MILLING + if not TOOLS[Cutting.nToolIndex].sName then + Cutting.sMessage = 'Blade not found' + Cutting.bIsApplicable = false + EgtOutLog( Cutting.sMessage) + return Cutting, EdgeToMachine.dElevation + end + + + + -- si lavora il primo lato + local OptionalParameters = { dRadialOffset = 100} + Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[1], OptionalParameters) + Blade.AddResult( Cutting) + + -- lavorazioni raggruppate in unica lista + Blade.Result.Sorted = {} + for i = 1, #Blade.Result do + if Blade.Result[i].bIsApplicable then + table.insert( Blade.Result.Sorted, Blade.Result[i]) + end + end -- TODO ordinamento lavorazioni (se necessario) + + -- aggiunta eventuali lavorazioni splittate + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + if #FeatureSplittingPoints > 0 then + Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result, FeatureSplittingPoints, Part) + end + + -- se la lavorazione con codolo fallisce o non è possibile si proseguirà a quella con cubetti end - if #Cutting.Result == 0 and not bLeaveWasteAttached then + if #Blade.Result == 0 and not bLeaveWasteAttached then -- BladeToWaste end - -- aggiunta lavorazioni alla lista. Vanno gestiti anche eventuali stepXY? - - -- output risultati + -- aggiunta lavorazioni + local nIsApplicableCount = 0 + local dFinalCompletionPercentage = 100 + local bAreAllMachiningsAdded = true + for i = 1, #Blade.Result.Sorted do + if Blade.Result.Sorted[i].bIsApplicable then + nIsApplicableCount = nIsApplicableCount + 1 + if bAddMachining then + local bIsMachiningAdded = Blade.AddMachiningAllSteps( Proc, Blade.Result.Sorted[i]) + if not bIsMachiningAdded then + bAreAllMachiningsAdded = false + end + end + Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Blade.Result.Sorted[i].sMessage + end + end + if nIsApplicableCount > 0 then + if Cutting.dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then + Strategy.Result.sStatus = 'Completed' + else + Strategy.Result.sStatus = 'Not-Completed' + -- TODO al momento si assume che la percentuale di completamento dell'ultima lavorazione sia quella rilevante + dFinalCompletionPercentage = Cutting.dCompletionPercentage + end + else + Strategy.Result.sStatus = 'Not-Applicable' + end + Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dFinalCompletionPercentage) + Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Blade') + local MRRParametersBlade = { + dStep = min( TOOLS[Cutting.nToolIndex].dStep, Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength), + dSideStep = TOOLS[Cutting.nToolIndex].dThickness, + dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed} + local dMRRBlade = MachiningLib.GetToolMRR( MRRParametersBlade) + Strategy.Result.dMRR = dMRRBlade return bAreAllMachiningsAdded, Strategy.Result end diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index c06c725..0375d40 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -79,6 +79,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.id = Proc.id Cutting.vtToolDirection = vtMachiningDirection + -- TODO se l'utensile non arriva dai parametri opzionali va cercato!! -- ===== calcolo LeadIn/out ===== if OptionalParameters.LeadIn and OptionalParameters.LeadOut then From 87aa2a7ce6c10ab557676fb36dbc0816e0b359b9 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 16 Jan 2025 18:28:52 +0100 Subject: [PATCH 07/21] - in SLOTBYCHAINSAW e SLOTBYBLADE spostato calcolo altezza tasca fuori; si deve passare come parametro opzionale: se non presente, si lavora la faccia senza step verticali - STR0003 modificata per rispecchiare le modifiche sopra; STR0004 DA FARE --- Strategies/Standard/STR0003/STR0003.lua | 56 ++++++++++++++----------- StrategyLibs/SLOTBYBLADE.lua | 16 ++----- StrategyLibs/SLOTBYCHAINSAW.lua | 15 +------ 3 files changed, 37 insertions(+), 50 deletions(-) diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index 205921c..9a6ed77 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -277,9 +277,17 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) dExtendAfterTail = 10000 end + -- altezza tasca + local dPocketHeight = 0 + if Proc.Topology.sFamily == 'Tunnel' then + dPocketHeight = Proc.MainFaces.SideFaces[1].MainEdges.OppositeEdges[1].dLength + else + dPocketHeight = Proc.MainFaces.BottomFaces[1].MainEdges.SideEdges[1].dLength + end + -- lama - calcolo lavorazioni local Cutting = {} - local OptionalParameters = { bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} if Proc.Topology.sFamily == 'Tunnel' then Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) else @@ -363,18 +371,18 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.dLength > 3 * Blade.Result.Bottom[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then if not Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then - local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) end if not Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then - local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) end -- si lavora tutto il fondo else - local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) end @@ -383,10 +391,10 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- si lavora solamente l'impronta lama sul fondo if ( #Blade.Result.Side > 0) and Blade.Result.Side[1].dResidualDepth < 10 * GEO.EPS_SMALL then if ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end -- si lavora tutto il lato @@ -398,10 +406,10 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) dBladeResidualDepth = Blade.Result.Bottom[1].dResidualDepth end if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then - local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then - local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end end @@ -410,7 +418,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) elseif Proc.Topology.sName == 'Groove-3-Through' then if Blade.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL then -- si lavora tutto il fondo - local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavorano i lati @@ -419,16 +427,16 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if ( Blade.Result.Side[1].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) and ( Blade.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then - local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può eliminare la lavorazione del fondo @@ -438,17 +446,17 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end -- si lavora tutto il lato else - local OptionalParameters = { dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Side[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo @@ -464,43 +472,43 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if ( Blade.Result.Opposite[1].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1].dLength > 3 * Blade.Result.Opposite[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) and ( Blade.Result.Opposite[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2].dLength > 3 * Blade.Result.Opposite[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL or Chainsaw.Result.Opposite[2].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false Chainsaw.Result.Opposite[2].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end else - local OptionalParameters = { dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail} + OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua index cfcd5e6..e433ba1 100644 --- a/StrategyLibs/SLOTBYBLADE.lua +++ b/StrategyLibs/SLOTBYBLADE.lua @@ -101,6 +101,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar end local bForceLongcutBlade = OptionalParameters.bForceLongcutBlade or false local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 + local dPocketHeight = OptionalParameters.dPocketHeight or 0 -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Cutting.dLengthToMachine = EdgeToMachine.dLength @@ -114,17 +115,6 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.vtEdgeDirection = EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN end - local dPocketHeight = 0 - if Proc.Topology.sFamily == 'Tunnel' then - dPocketHeight = Proc.MainFaces.SideFaces[1].MainEdges.OppositeEdges[1].dLength - else - if FaceToMachine.sType == 'Long' then - dPocketHeight = Proc.MainFaces.BottomFaces[1].MainEdges.SideEdges[1].dLength - elseif FaceToMachine.sType == 'Side' then - dPocketHeight = Proc.MainFaces.BottomFaces[1].MainEdges.LongEdges[1].dLength - end - end - -- ricerca utensile local ToolSearchParameters = {} ToolSearchParameters.dElevation = abs( EdgeToMachine.dElevation) @@ -150,7 +140,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar EgtOutLog( Cutting.sMessage) return Cutting, EdgeToMachine.dElevation end - if #( Proc.MainFaces.SideFaces) > 1 then + if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della lama la strategia non è applicabile if TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then Cutting.sMessage = 'Pocket too narrow for blade diameter' @@ -247,7 +237,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.dBladeMarkLength = abs( Cutting.LeadOut.dEndAddLength) end -- geometria - Cutting.Geometry = {{Proc.id, FaceToMachine.id}} + Cutting.Geometry = {{Cutting.idProc, FaceToMachine.id}} -- nome operazione Cutting.sOperationName = 'Cut_' .. ( EgtGetName( Cutting.idProc) or tostring( Cutting.idProc)) .. '_' .. tostring( FaceToMachine.id + 1) diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/SLOTBYCHAINSAW.lua index 5329b59..9db0999 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/SLOTBYCHAINSAW.lua @@ -68,6 +68,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional local dCustomMaxElev = OptionalParameters.dMaxElev or abs( EdgeToMachine.dElevation) local bStopAtHalfElevation = OptionalParameters.bStopAtHalfElevation or false local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 + local dPocketHeight = OptionalParameters.dPocketHeight or 0 -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Mortising.dLengthToMachine = dLengthToMachine @@ -81,18 +82,6 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional Mortising.vtEdgeDirection = EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN end - -- altezza tasca, in base alla topologia - local dPocketHeight = 0 - if Proc.Topology.sFamily == 'Tunnel' then - dPocketHeight = Proc.MainFaces.SideFaces[1].MainEdges.OppositeEdges[1].dLength - else - if FaceToMachine.sType == 'Long' then - dPocketHeight = Proc.MainFaces.BottomFaces[1].MainEdges.SideEdges[1].dLength - elseif FaceToMachine.sType == 'Side' then - dPocketHeight = Proc.MainFaces.BottomFaces[1].MainEdges.LongEdges[1].dLength - end - end - -- ricerca utensile local bExtendWithCornerRadius = false if not bStopAtHalfElevation then @@ -133,7 +122,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional EgtOutLog( Mortising.sMessage) return Mortising end - if #( Proc.MainFaces.SideFaces) > 1 then + if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della sega a catena la strategia non è applicabile if TOOLS[Mortising.nToolIndex].dWidth > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then Mortising.sMessage = 'Pocket too narrow for chainsaw width' From 8d2a9955ba38c507e16b9ef8c3766208393d63dc Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 17 Jan 2025 13:05:35 +0100 Subject: [PATCH 08/21] =?UTF-8?q?-=20in=20MachiningLib=20GetMachiningSteps?= =?UTF-8?q?=20il=20numero=20minimo=20di=20step=20=C3=A8=20sempre=201=20-?= =?UTF-8?q?=20STR0004=20corretta=20per=20passare=20altezza=20tasca=20alla?= =?UTF-8?q?=20SlotByChainsaw=20-=20in=20SLOTBYBLADE=20e=20SLOTBYCHAINSAW?= =?UTF-8?q?=20si=20controlla=20se=20la=20tasca=20=C3=A8=20meno=20spessa=20?= =?UTF-8?q?della=20lama=20solo=20nel=20caso=20in=20cui=20venga=20passata?= =?UTF-8?q?=20un'altezza=20tasca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/MachiningLib.lua | 2 ++ Strategies/Standard/STR0003/STR0003.lua | 1 + Strategies/Standard/STR0004/STR0004.lua | 27 +++++++++++++++---------- StrategyLibs/SLOTBYBLADE.lua | 2 +- StrategyLibs/SLOTBYCHAINSAW.lua | 2 +- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 751d981..4289fce 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -99,6 +99,8 @@ function MachiningLib.GetMachiningSteps( dMachiningDepth, dStep) MachiningSteps.nCount = ceil( ( dMachiningDepth - 10 * GEO.EPS_SMALL) / dStep) if MachiningSteps.nCount > 1 then MachiningSteps.dStep = ( dMachiningDepth - dStep) / ( MachiningSteps.nCount - 1) + else + MachiningSteps.nCount = 1 end return MachiningSteps diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index 9a6ed77..b62e1d2 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -325,6 +325,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result.Sorted, FeatureSplittingPoints, Part) end -- lama - nessuna lavorazione successiva - aggiunta lavorazioni e calcolo risultati + -- TODO bisogna uscire se la lama non può fare alcuna lavorazione; non ha senso che STR0003 lama+catena sia scelta se la lama non può lavorare, in quel caso deve essere scelta la STR0004 solo catena if not Strategy.Parameters.bFinishWithChainSaw then -- ordinamento if Strategy.Parameters.bSortBySegment then diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua index 84a2d9f..89f34cb 100644 --- a/Strategies/Standard/STR0004/STR0004.lua +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -164,43 +164,48 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) dExtendAfterTail = 10000 end + -- altezza tasca + local dPocketHeight = 0 + if Proc.Topology.sFamily == 'Tunnel' then + dPocketHeight = Proc.MainFaces.SideFaces[1].MainEdges.OppositeEdges[1].dLength + else + dPocketHeight = Proc.MainFaces.BottomFaces[1].MainEdges.SideEdges[1].dLength + end + -- calcolo lavorazioni local Mortising = {} - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} if Proc.Topology.sName == 'Groove-4-Blind' or Proc.Topology.sName == 'Pocket-5-Blind' then -- si lavora tutto il fondo - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) -- materiale residuo - se possibile si lavora dal lato if ( Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].dResidualDepth > 10 * GEO.EPS_SMALL or not Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].bIsApplicable) and #Proc.MainFaces.SideFaces == 1 then if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end Chainsaw.AddResult( Mortising) end elseif Proc.Topology.sName == 'Groove-3-Through' then -- si lavora tutto il fondo - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) -- materiale residuo - si lavorano i lati if ( Chainsaw.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL or not Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].bIsApplicable) then - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Side[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail} + OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo @@ -210,16 +215,16 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) end end elseif Proc.Topology.sName == 'Tunnel-4-Through' then - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail} + local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail} + OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua index e433ba1..9175bc7 100644 --- a/StrategyLibs/SLOTBYBLADE.lua +++ b/StrategyLibs/SLOTBYBLADE.lua @@ -134,7 +134,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- verifica dimensioni tasca compatibili -- se tasca meno spessa della lama la strategia non è applicabile - if TOOLS[Cutting.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL then + if OptionalParameters.dPocketHeight and ( TOOLS[Cutting.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL) then Cutting.sMessage = 'Pocket too narrow for blade thickness' Cutting.bIsApplicable = false EgtOutLog( Cutting.sMessage) diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/SLOTBYCHAINSAW.lua index 9db0999..18fe907 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/SLOTBYCHAINSAW.lua @@ -116,7 +116,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional -- verifica dimensioni tasca compatibili -- se tasca meno spessa della sega a catena la strategia non è applicabile - if TOOLS[Mortising.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL then + if OptionalParameters.dPocketHeight and ( TOOLS[Mortising.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL) then Mortising.sMessage = 'Pocket too narrow for chainsaw thickness' Mortising.bIsApplicable = false EgtOutLog( Mortising.sMessage) From fc6b50b34580f8bfade7e3caceab9a1531f520b2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 17 Jan 2025 18:06:37 +0100 Subject: [PATCH 09/21] - in FaceData struttura dati degli Edges della faccia uniformata a quella degli Edges della MainFaces - tutte le chiamate a Edges aggiornate di conseguenza --- LuaLibs/FaceData.lua | 95 ++++++++++++++++--------- Strategies/Standard/HEADCUT/HEADCUT.lua | 8 +-- Strategies/Standard/STR0005/STR0005.lua | 16 ++--- StrategyLibs/FACEBYBLADE.lua | 8 +-- StrategyLibs/SPLITCUT.lua | 8 +-- 5 files changed, 83 insertions(+), 52 deletions(-) diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index 23d74dc..b9c2c72 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -97,6 +97,37 @@ function FaceData.GetFacesByAdjacencyNumber( Proc) return FacesByAdjacencyNumber end +------------------------------------------------------------------------------------------------------------- +local function GetEdgesInfo( Proc, idFace ) + local Edges = {} + local nFaceType, EdgesEgt = EgtSurfTmGetFacetOutlineInfo( Proc.id, idFace, GDB_ID.ROOT) + + for i = 1, #EdgesEgt do + local nPreviousEdgeIndex = i - 1 + if i == 1 then + nPreviousEdgeIndex = #EdgesEgt + end + local nNextEdgeIndex = i + 1 + if i == #EdgesEgt then + nNextEdgeIndex = 1 + end + + local CurrentEdge = {} + CurrentEdge.idAdjacentFace = EdgesEgt[i].Adj + CurrentEdge.vtToolDirection = Vector3d( EdgesEgt[i].Norm) + CurrentEdge.dLength = EdgesEgt[i].Len + CurrentEdge.dLengthOnX = abs( CurrentEdge.dLength * CurrentEdge.vtToolDirection:getY()) + CurrentEdge.dElevation = EdgesEgt[i].Elev + CurrentEdge.bIsOpen = EdgesEgt[i].Open + CurrentEdge.bIsStartOpen = EdgesEgt[nPreviousEdgeIndex].Open + CurrentEdge.bIsEndOpen = EdgesEgt[nNextEdgeIndex].Open + + table.insert( Edges, CurrentEdge) + end + + return nFaceType, Edges +end + ------------------------------------------------------------------------------------------------------------- function FaceData.GetFacesInfo( Proc, Part) EgtOutLog( '---Faces START---') @@ -129,9 +160,9 @@ function FaceData.GetFacesInfo( Proc, Part) local _, dLongEdgeDimension, dShortEdgeDimension = EgtSurfTmFacetMinAreaRectangle( Proc.id, i - 1, GDB_ID.ROOT) Faces[i].dArea = dShortEdgeDimension * dLongEdgeDimension - local nFaceType, vEdges = EgtSurfTmGetFacetOutlineInfo( Proc.id, i - 1, GDB_ID.ROOT) + local nFaceType, Edges = GetEdgesInfo( Proc, i - 1) Faces[i].bIsOkForMachining = nFaceType < 1 - Faces[i].Edges = vEdges + Faces[i].Edges = Edges -- TODO valutare se fare un output unico alla fine o gestire log in altro modo EgtOutLog( 'Facet ' .. Faces[i].id .. ' of ' .. Proc.nFct - 1) @@ -246,10 +277,10 @@ local function GetBottomFaces( Proc) local ClosedEdgesSortedByGreatestLength = {} for i = 1, #BottomFaces[1].Edges do - if not BottomFaces[1].Edges[i].Open then + if not BottomFaces[1].Edges[i].bIsOpen then table.insert( ClosedEdgesSortedByGreatestLength, {}) ClosedEdgesSortedByGreatestLength[#ClosedEdgesSortedByGreatestLength].nIndex = i - ClosedEdgesSortedByGreatestLength[#ClosedEdgesSortedByGreatestLength].dLength = BottomFaces[1].Edges[i].Len + ClosedEdgesSortedByGreatestLength[#ClosedEdgesSortedByGreatestLength].dLength = BottomFaces[1].Edges[i].dLength end end table.sort( ClosedEdgesSortedByGreatestLength, function (a, b) return a.dLength > b.dLength end) @@ -266,14 +297,14 @@ local function GetBottomFaces( Proc) end local CurrentEdge = {} - CurrentEdge.idAdjacentFace = BottomFaces[1].Edges[i].Adj - CurrentEdge.vtToolDirection = Vector3d( BottomFaces[1].Edges[i].Norm) - CurrentEdge.dLength = BottomFaces[1].Edges[i].Len - CurrentEdge.dLengthOnX = abs( CurrentEdge.dLength * CurrentEdge.vtToolDirection:getY()) - CurrentEdge.dElevation = BottomFaces[1].Edges[i].Elev - CurrentEdge.bIsOpen = BottomFaces[1].Edges[i].Open - CurrentEdge.bIsStartOpen = BottomFaces[1].Edges[nPreviousEdgeIndex].Open - CurrentEdge.bIsEndOpen = BottomFaces[1].Edges[nNextEdgeIndex].Open + CurrentEdge.idAdjacentFace = BottomFaces[1].Edges[i].idAdjacentFace + CurrentEdge.vtToolDirection = BottomFaces[1].Edges[i].vtToolDirection + CurrentEdge.dLength = BottomFaces[1].Edges[i].dLength + CurrentEdge.dLengthOnX = BottomFaces[1].Edges[i].dLengthOnX + CurrentEdge.dElevation = BottomFaces[1].Edges[i].dElevation + CurrentEdge.bIsOpen = BottomFaces[1].Edges[i].bIsOpen + CurrentEdge.bIsStartOpen = BottomFaces[1].Edges[i].bIsStartOpen + CurrentEdge.bIsEndOpen = BottomFaces[1].Edges[i].bIsEndOpen if i == nFirstLongEdgeIndex then BottomFaces[1].MainEdges.LongEdges[1] = CurrentEdge @@ -352,14 +383,14 @@ local function GetLongFaces( Proc, MainFaces) end local CurrentEdge = {} - CurrentEdge.idAdjacentFace = LongFaces[i].Edges[j].Adj - CurrentEdge.vtToolDirection = Vector3d( LongFaces[i].Edges[j].Norm) - CurrentEdge.dLength = LongFaces[i].Edges[j].Len - CurrentEdge.dLengthOnX = abs( CurrentEdge.dLength * CurrentEdge.vtToolDirection:getY()) - CurrentEdge.dElevation = LongFaces[i].Edges[j].Elev - CurrentEdge.bIsOpen = LongFaces[i].Edges[j].Open - CurrentEdge.bIsStartOpen = LongFaces[i].Edges[nPreviousEdgeIndex].Open - CurrentEdge.bIsEndOpen = LongFaces[i].Edges[nNextEdgeIndex].Open + CurrentEdge.idAdjacentFace = LongFaces[i].Edges[j].idAdjacentFace + CurrentEdge.vtToolDirection = LongFaces[i].Edges[j].vtToolDirection + CurrentEdge.dLength = LongFaces[i].Edges[j].dLength + CurrentEdge.dLengthOnX = LongFaces[i].Edges[j].dLengthOnX + CurrentEdge.dElevation = LongFaces[i].Edges[j].dElevation + CurrentEdge.bIsOpen = LongFaces[i].Edges[j].bIsOpen + CurrentEdge.bIsStartOpen = LongFaces[i].Edges[j].bIsStartOpen + CurrentEdge.bIsEndOpen = LongFaces[i].Edges[j].bIsEndOpen if Proc.Topology.sFamily == 'Tunnel' then if CurrentEdge.idAdjacentFace > -1 then @@ -373,10 +404,10 @@ local function GetLongFaces( Proc, MainFaces) if CurrentEdge.idAdjacentFace == BottomFace.id then LongFaces[i].MainEdges.BottomEdge = CurrentEdge LongFaces[i].MainEdges.BottomEdge.sType = 'Bottom' - elseif LongFaces[i].Edges[nNextEdgeIndex].Adj == BottomFace.id then + elseif LongFaces[i].Edges[nNextEdgeIndex].idAdjacentFace == BottomFace.id then LongFaces[i].MainEdges.SideEdges[1] = CurrentEdge LongFaces[i].MainEdges.SideEdges[1].sType = 'Side' - elseif LongFaces[i].Edges[nPreviousEdgeIndex].Adj == BottomFace.id then + elseif LongFaces[i].Edges[nPreviousEdgeIndex].idAdjacentFace == BottomFace.id then LongFaces[i].MainEdges.SideEdges[2] = CurrentEdge LongFaces[i].MainEdges.SideEdges[2].sType = 'Side' else @@ -439,14 +470,14 @@ local function GetSideFaces( Proc, MainFaces) end local CurrentEdge = {} - CurrentEdge.idAdjacentFace = SideFaces[i].Edges[j].Adj - CurrentEdge.vtToolDirection = Vector3d( SideFaces[i].Edges[j].Norm) - CurrentEdge.dLength = SideFaces[i].Edges[j].Len - CurrentEdge.dLengthOnX = abs( CurrentEdge.dLength * CurrentEdge.vtToolDirection:getY()) - CurrentEdge.dElevation = SideFaces[i].Edges[j].Elev - CurrentEdge.bIsOpen = SideFaces[i].Edges[j].Open - CurrentEdge.bIsStartOpen = SideFaces[i].Edges[nPreviousEdgeIndex].Open - CurrentEdge.bIsEndOpen = SideFaces[i].Edges[nNextEdgeIndex].Open + CurrentEdge.idAdjacentFace = SideFaces[i].Edges[j].idAdjacentFace + CurrentEdge.vtToolDirection = SideFaces[i].Edges[j].vtToolDirection + CurrentEdge.dLength = SideFaces[i].Edges[j].dLength + CurrentEdge.dLengthOnX = SideFaces[i].Edges[j].dLengthOnX + CurrentEdge.dElevation = SideFaces[i].Edges[j].dElevation + CurrentEdge.bIsOpen = SideFaces[i].Edges[j].bIsOpen + CurrentEdge.bIsStartOpen = SideFaces[i].Edges[j].bIsStartOpen + CurrentEdge.bIsEndOpen = SideFaces[i].Edges[j].bIsEndOpen if Proc.Topology.sFamily == 'Tunnel' then if CurrentEdge.idAdjacentFace > -1 then @@ -458,10 +489,10 @@ local function GetSideFaces( Proc, MainFaces) if CurrentEdge.idAdjacentFace == BottomFace.id then SideFaces[i].MainEdges.BottomEdge = CurrentEdge SideFaces[i].MainEdges.BottomEdge.sType = 'Bottom' - elseif SideFaces[i].Edges[nNextEdgeIndex].Adj == BottomFace.id then + elseif SideFaces[i].Edges[nNextEdgeIndex].idAdjacentFace == BottomFace.id then SideFaces[i].MainEdges.LongEdges[1] = CurrentEdge SideFaces[i].MainEdges.LongEdges[1].sType = 'Long' - elseif SideFaces[i].Edges[nPreviousEdgeIndex].Adj == BottomFace.id then + elseif SideFaces[i].Edges[nPreviousEdgeIndex].idAdjacentFace == BottomFace.id then SideFaces[i].MainEdges.LongEdges[2] = CurrentEdge SideFaces[i].MainEdges.LongEdges[2].sType = 'Long' else diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index 09bcb2e..7d9bd60 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -46,9 +46,9 @@ local function CalculateLeadInOut( Machining, EdgeToMachine) LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 -- elevazione sempre in negativo - if EdgeToMachine.Elev < 10 * GEO.EPS_SMALL then - LeadIn.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.Elev - LeadOut.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.Elev + if EdgeToMachine.dElevation < 10 * GEO.EPS_SMALL then + LeadIn.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation + LeadOut.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation else LeadIn.dPerpDistance = BeamData.CUT_SIC LeadOut.dPerpDistance = BeamData.CUT_SIC @@ -72,7 +72,7 @@ end local function GetEdgeToMachine( Proc, vtEdge) local Edge for i = 1, #Proc.Faces[1].Edges do - if AreSameVectorApprox( Proc.Faces[1].Edges[i].Norm, vtEdge) then + if AreSameVectorApprox( Proc.Faces[1].Edges[i].vtToolDirection, vtEdge) then Edge = Proc.Faces[1].Edges[i] end end diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index b67d628..3d4ca22 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -21,21 +21,21 @@ Blade.Result = {} ------------------------------------------------------------------------------------------------------------- local function CompareEdges( EdgeA, EdgeB) -- prima i lati orientati lungo X - if abs( EdgeA.Norm:getX()) < abs( EdgeB.Norm:getX()) - 10 * GEO.EPS_SMALL then + if abs( EdgeA.vtToolDirection:getX()) < abs( EdgeB.vtToolDirection:getX()) - 10 * GEO.EPS_SMALL then return true - elseif abs( EdgeA.Norm:getX()) > abs( EdgeB.Norm:getX()) + 10 * GEO.EPS_SMALL then + elseif abs( EdgeA.vtToolDirection:getX()) > abs( EdgeB.vtToolDirection:getX()) + 10 * GEO.EPS_SMALL then return false -- se stessa X si preferiscono i lati più in basso else - if EdgeA.Norm:getZ() > EdgeB.Norm:getZ() + 10 * GEO.EPS_SMALL then + if EdgeA.vtToolDirection:getZ() > EdgeB.vtToolDirection:getZ() + 10 * GEO.EPS_SMALL then return true - elseif EdgeA.Norm:getZ() < EdgeB.Norm:getZ() - 10 * GEO.EPS_SMALL then + elseif EdgeA.vtToolDirection:getZ() < EdgeB.vtToolDirection:getZ() - 10 * GEO.EPS_SMALL then return false -- se stessa Z si preferiscono i lati verso il fronte della trave else - if EdgeA.Norm:getY() > EdgeB.Norm:getY() + 10 * GEO.EPS_SMALL then + if EdgeA.vtToolDirection:getY() > EdgeB.vtToolDirection:getY() + 10 * GEO.EPS_SMALL then return true - elseif EdgeA.Norm:getY() < EdgeB.Norm:getY() - 10 * GEO.EPS_SMALL then + elseif EdgeA.vtToolDirection:getY() < EdgeB.vtToolDirection:getY() - 10 * GEO.EPS_SMALL then return false else return false @@ -82,12 +82,12 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) end table.sort( EdgesSorted, CompareEdges) - local dDepthToMachine = EdgesSorted[1].Elevation / 2 + BeamData.CUT_EXTRA + local dDepthToMachine = EdgesSorted[1].dElevation / 2 + BeamData.CUT_EXTRA -- ricerca utensile local ToolSearchParameters = {} ToolSearchParameters.dElevation = dDepthToMachine - ToolSearchParameters.vtToolDirection = EdgesSorted[1].Norm + ToolSearchParameters.vtToolDirection = EdgesSorted[1].vtToolDirection ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = true ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index 0375d40..1d093e8 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -23,9 +23,9 @@ local function CalculateLeadInOut( EdgeToMachine) LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 -- elevazione sempre in negativo - if EdgeToMachine.Elev < 10 * GEO.EPS_SMALL then - LeadIn.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.Elev - LeadOut.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.Elev + if EdgeToMachine.dElevation < 10 * GEO.EPS_SMALL then + LeadIn.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation + LeadOut.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation else LeadIn.dPerpDistance = BeamData.CUT_SIC LeadOut.dPerpDistance = BeamData.CUT_SIC @@ -67,7 +67,7 @@ end function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalParameters) local Cutting = {} - local vtMachiningDirection = EdgeToMachine.Norm + local vtMachiningDirection = EdgeToMachine.vtToolDirection local vtN = Proc.Faces[FaceToMachine.id+1].vtN Cutting.sDepth = OptionalParameters.sDepth or 0 Cutting.dLongitudinalOffset = OptionalParameters.dLongitudinalOffset or 0 diff --git a/StrategyLibs/SPLITCUT.lua b/StrategyLibs/SPLITCUT.lua index a0862c6..8d68db5 100644 --- a/StrategyLibs/SPLITCUT.lua +++ b/StrategyLibs/SPLITCUT.lua @@ -185,7 +185,7 @@ function SPLITCUT.GetStrategy( Proc, Part, OptionalParameters) function SPLITCUT.GetEdgeToMachine( Proc, vtEdge) local Edge for i = 1, #Proc.Faces[1].Edges do - if AreSameVectorApprox( Proc.Faces[1].Edges[i].Norm, vtEdge) then + if AreSameVectorApprox( Proc.Faces[1].Edges[i].vtToolDirection, vtEdge) then Edge = Proc.Faces[1].Edges[i] end end @@ -204,9 +204,9 @@ function SPLITCUT.CalculateLeadInOut( EdgeToMachine) LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 -- elevazione sempre in negativo - if EdgeToMachine.Elev < 10 * GEO.EPS_SMALL then - LeadIn.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.Elev - LeadOut.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.Elev + if EdgeToMachine.dElevation < 10 * GEO.EPS_SMALL then + LeadIn.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation + LeadOut.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation else LeadIn.dPerpDistance = BeamData.CUT_SIC LeadOut.dPerpDistance = BeamData.CUT_SIC From 40e76a23c9e6b160a0b8f2a08f2819fcb427e2fe Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 21 Jan 2025 15:27:33 +0100 Subject: [PATCH 10/21] =?UTF-8?q?-=20in=20FaceData=20Elevation=20=C3=A8=20?= =?UTF-8?q?sempre=20positiva=20nelle=20facce=20standard=20(non=20MainFaces?= =?UTF-8?q?)=20-=20in=20MachiningLib=20in=20GetSplitMachinings=20correzion?= =?UTF-8?q?i=20alla=20definizione=20dello=20stage=20della=20lavorazione;?= =?UTF-8?q?=20correzione=20a=20FindBlade=20-=20in=20SLOTBYBLADE=20e=20SLOT?= =?UTF-8?q?BYCHAINSAW=20correzioni=20per=20poter=20passare=20la=20profondi?= =?UTF-8?q?t=C3=A0=20di=20lavoro=20-=20in=20STR0005=20primo=20implemento?= =?UTF-8?q?=20di=20lavorazione=20con=20codolo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/FaceData.lua | 22 ++++-- LuaLibs/MachiningLib.lua | 5 ++ Strategies/Standard/STR0005/STR0005.lua | 74 +++++++++++++++---- Strategies/Standard/STR0005/STR0005Config.lua | 3 +- StrategyLibs/SLOTBYBLADE.lua | 28 ++++--- StrategyLibs/SLOTBYCHAINSAW.lua | 19 +++-- 6 files changed, 112 insertions(+), 39 deletions(-) diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index b9c2c72..fa426fa 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -116,11 +116,11 @@ local function GetEdgesInfo( Proc, idFace ) CurrentEdge.idAdjacentFace = EdgesEgt[i].Adj CurrentEdge.vtToolDirection = Vector3d( EdgesEgt[i].Norm) CurrentEdge.dLength = EdgesEgt[i].Len - CurrentEdge.dLengthOnX = abs( CurrentEdge.dLength * CurrentEdge.vtToolDirection:getY()) - CurrentEdge.dElevation = EdgesEgt[i].Elev + CurrentEdge.dElevation = abs( EdgesEgt[i].Elev) CurrentEdge.bIsOpen = EdgesEgt[i].Open CurrentEdge.bIsStartOpen = EdgesEgt[nPreviousEdgeIndex].Open CurrentEdge.bIsEndOpen = EdgesEgt[nNextEdgeIndex].Open + CurrentEdge.sType = 'Standard' table.insert( Edges, CurrentEdge) end @@ -300,9 +300,11 @@ local function GetBottomFaces( Proc) CurrentEdge.idAdjacentFace = BottomFaces[1].Edges[i].idAdjacentFace CurrentEdge.vtToolDirection = BottomFaces[1].Edges[i].vtToolDirection CurrentEdge.dLength = BottomFaces[1].Edges[i].dLength - CurrentEdge.dLengthOnX = BottomFaces[1].Edges[i].dLengthOnX - CurrentEdge.dElevation = BottomFaces[1].Edges[i].dElevation CurrentEdge.bIsOpen = BottomFaces[1].Edges[i].bIsOpen + CurrentEdge.dElevation = BottomFaces[1].Edges[i].dElevation + if CurrentEdge.bIsOpen then + CurrentEdge.dElevation = -CurrentEdge.dElevation + end CurrentEdge.bIsStartOpen = BottomFaces[1].Edges[i].bIsStartOpen CurrentEdge.bIsEndOpen = BottomFaces[1].Edges[i].bIsEndOpen @@ -386,9 +388,11 @@ local function GetLongFaces( Proc, MainFaces) CurrentEdge.idAdjacentFace = LongFaces[i].Edges[j].idAdjacentFace CurrentEdge.vtToolDirection = LongFaces[i].Edges[j].vtToolDirection CurrentEdge.dLength = LongFaces[i].Edges[j].dLength - CurrentEdge.dLengthOnX = LongFaces[i].Edges[j].dLengthOnX - CurrentEdge.dElevation = LongFaces[i].Edges[j].dElevation CurrentEdge.bIsOpen = LongFaces[i].Edges[j].bIsOpen + CurrentEdge.dElevation = LongFaces[i].Edges[j].dElevation + if CurrentEdge.bIsOpen then + CurrentEdge.dElevation = -CurrentEdge.dElevation + end CurrentEdge.bIsStartOpen = LongFaces[i].Edges[j].bIsStartOpen CurrentEdge.bIsEndOpen = LongFaces[i].Edges[j].bIsEndOpen @@ -473,9 +477,11 @@ local function GetSideFaces( Proc, MainFaces) CurrentEdge.idAdjacentFace = SideFaces[i].Edges[j].idAdjacentFace CurrentEdge.vtToolDirection = SideFaces[i].Edges[j].vtToolDirection CurrentEdge.dLength = SideFaces[i].Edges[j].dLength - CurrentEdge.dLengthOnX = SideFaces[i].Edges[j].dLengthOnX - CurrentEdge.dElevation = SideFaces[i].Edges[j].dElevation CurrentEdge.bIsOpen = SideFaces[i].Edges[j].bIsOpen + CurrentEdge.dElevation = SideFaces[i].Edges[j].dElevation + if CurrentEdge.bIsOpen then + CurrentEdge.dElevation = -CurrentEdge.dElevation + end CurrentEdge.bIsStartOpen = SideFaces[i].Edges[j].bIsStartOpen CurrentEdge.bIsEndOpen = SideFaces[i].Edges[j].bIsEndOpen diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 4289fce..33e88af 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -118,6 +118,7 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part ) end local dOriginalStartAddLength = Machinings[i].LeadIn.dStartAddLength local dOriginalEndAddLength = Machinings[i].LeadOut.dEndAddLength + local sOriginalStage = Machinings[i].sStage if FeatureLib.IsMachiningLong( Machinings[i].dLengthOnX, Part) then local nCurrentMachiningIndex = i -- lo spezzone attivo è quello precedente al punto di spezzatura corrente @@ -158,6 +159,8 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part ) end if not bIsLastSegment then Machinings[nCurrentMachiningIndex].sStage = '' + else + Machinings[nCurrentMachiningIndex].sStage = sOriginalStage end Machinings[nCurrentMachiningIndex].nFeatureSegment = j end @@ -317,6 +320,8 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) bIsToolCompatible = TOOLS[i].SetupInfo.bIsTopHead elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then bIsToolCompatible = TOOLS[i].SetupInfo.bIsBottomHead + else + bIsToolCompatible = true end end diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 3d4ca22..26e98e4 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -10,7 +10,7 @@ local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base local BladeToWaste = require( 'BLADETOWASTE') -local FaceByBlade = require( 'FACEBYBLADE') +local SlotByBlade = require( 'SLOTBYBLADE') -- Tabella per definizione modulo local STR0005 = {} @@ -52,6 +52,31 @@ function Blade.AddResult( Cutting) end +function Blade.AddMachiningAllSteps( Proc, Cutting, AuxiliaryData) + local bMachiningAdded = false + if not AuxiliaryData then + AuxiliaryData = {} + end + AuxiliaryData.Clones = {} + + local dOriginalRadialOffset = Cutting.dRadialOffset + local dOriginalLeadInPerpDistance = Cutting.LeadIn.dPerpDistance + local dOriginalLeadOutPerpDistance = Cutting.LeadOut.dPerpDistance + for i = 1, Cutting.HorizontalSteps.nCount do + AuxiliaryData.Clones[i] = {} + AuxiliaryData.Clones[i].LeadIn = {} + AuxiliaryData.Clones[i].LeadOut = {} + AuxiliaryData.Clones[i].dRadialOffset = dOriginalRadialOffset + Cutting.HorizontalSteps.dStep * ( Cutting.HorizontalSteps.nCount - i) + -- update distanza perpendicolare attacco per contemplare l'offset applicato + AuxiliaryData.Clones[i].LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - Cutting.dRadialOffset + AuxiliaryData.Clones[i].LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - Cutting.dRadialOffset + end + bMachiningAdded = MachiningLib.AddNewMachining( Proc, Cutting, AuxiliaryData) + + return bMachiningAdded +end + + function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} @@ -63,10 +88,17 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Result.sInfo = '' Blade.Result = {} + local dExtendAfterTail = Strategy.Parameters.dExtendAfterTail or max( Part.dDistanceToNextPiece - BeamData.CUT_EXTRA, 0) + if MachiningLib.CanExtendAfterTail( Strategy.Parameters.sCanDamageNextPiece, Part) then + dExtendAfterTail = 10000 + end + local dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail = FeatureLib.GetFeatureMaxNotClampableLengths( Proc, Part) local bLeaveWasteAttached = Strategy.Parameters.sCuttingStrategy == 'LEAVE_WASTE_ATTACHED' local bFeatureHindersClamping = FeatureLib.IsMachiningLong( max( dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN}) local Cutting = {} + local MRRParametersBlade = {} + if bFeatureHindersClamping or bLeaveWasteAttached then -- TODO Lavorazione con codolo -- La FaceByBlade (o altra??) dovrà accettare opzionalmente di fermarsi prima (basta l'Offset??) e accettare l'utensile forzato. @@ -82,7 +114,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) end table.sort( EdgesSorted, CompareEdges) - local dDepthToMachine = EdgesSorted[1].dElevation / 2 + BeamData.CUT_EXTRA + local dDepthToMachine = abs( EdgesSorted[1].dElevation) / 2 - Strategy.Parameters.dStripWidth / 2 -- ricerca utensile local ToolSearchParameters = {} @@ -98,15 +130,30 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Cutting.sMessage = 'Blade not found' Cutting.bIsApplicable = false EgtOutLog( Cutting.sMessage) - return Cutting, EdgeToMachine.dElevation + return Cutting, abs( EdgesSorted[1].dElevation) end + -- parametri per il calcolo della velocità di asportazione + MRRParametersBlade = { + dStep = min( TOOLS[Cutting.nToolIndex].dStep, abs( EdgesSorted[1].dElevation)), + dSideStep = TOOLS[Cutting.nToolIndex].dThickness, + dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed + } + + -- eventuali punti di spezzatura + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + local bIsSplitFeature = false + if #FeatureSplittingPoints then + bIsSplitFeature = true + end - - -- si lavora il primo lato - local OptionalParameters = { dRadialOffset = 100} - Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[1], OptionalParameters) + -- primo lato + local OptionalParameters = { dDepthToMachine = dDepthToMachine, nToolIndex = Cutting.nToolIndex, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail} + Cutting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[1], OptionalParameters) Blade.AddResult( Cutting) + -- secondo lato + Cutting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[2], OptionalParameters) + --Blade.AddResult( Cutting) -- lavorazioni raggruppate in unica lista Blade.Result.Sorted = {} @@ -116,14 +163,13 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) end end - -- TODO ordinamento lavorazioni (se necessario) - -- aggiunta eventuali lavorazioni splittate - local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) - if #FeatureSplittingPoints > 0 then - Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result, FeatureSplittingPoints, Part) + if bIsSplitFeature then + Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result.Sorted, FeatureSplittingPoints, Part) end + -- TODO ordinamento lavorazioni (se necessario) + -- se la lavorazione con codolo fallisce o non è possibile si proseguirà a quella con cubetti end @@ -160,10 +206,6 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) end Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dFinalCompletionPercentage) Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Blade') - local MRRParametersBlade = { - dStep = min( TOOLS[Cutting.nToolIndex].dStep, Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength), - dSideStep = TOOLS[Cutting.nToolIndex].dThickness, - dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed} local dMRRBlade = MachiningLib.GetToolMRR( MRRParametersBlade) Strategy.Result.dMRR = dMRRBlade diff --git a/Strategies/Standard/STR0005/STR0005Config.lua b/Strategies/Standard/STR0005/STR0005Config.lua index 4b9b856..85edf67 100644 --- a/Strategies/Standard/STR0005/STR0005Config.lua +++ b/Strategies/Standard/STR0005/STR0005Config.lua @@ -16,7 +16,8 @@ local STR0005Data = { { sValue = 'DROP_WHOLE_WASTE', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, { sValue = 'LEAVE_WASTE_ATTACHED', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}, { sName = 'dMaxWasteLength', sNameNge = 'MAX_WASTE_LENGTH', sValue = '300', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, - { sName = 'dMaxWasteVolume', sNameNge = 'MAX_WASTE_VOLUME', sValue = '6000000', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'} + { sName = 'dMaxWasteVolume', sNameNge = 'MAX_WASTE_VOLUME', sValue = '6000000', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dStripWidth', sNameNge = 'STRIP_WIDTH', sValue = '5', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'} } } diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua index 9175bc7..7a7b595 100644 --- a/StrategyLibs/SLOTBYBLADE.lua +++ b/StrategyLibs/SLOTBYBLADE.lua @@ -102,12 +102,17 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar local bForceLongcutBlade = OptionalParameters.bForceLongcutBlade or false local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 local dPocketHeight = OptionalParameters.dPocketHeight or 0 + local dDepthToMachine = min( OptionalParameters.dDepthToMachine or abs( EdgeToMachine.dElevation), abs( EdgeToMachine.dElevation)) + local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Cutting.dLengthToMachine = EdgeToMachine.dLength - Cutting.dLengthOnX = abs( EdgeToMachine.dLength * EdgeToMachine.vtToolDirection:getY()) Cutting.dEdgeLength = EdgeToMachine.dLength + -- TODO conviene spostare questi calcoli nel FaceData? Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtToolDirection, GDB_ID.ROOT) + local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2) + Cutting.dLengthOnX = b3BoxEdge:getDimX() + -- Cutting.vtToolDirection = EdgeToMachine.vtToolDirection if EdgeToMachine.bIsOpen then Cutting.vtEdgeDirection = -EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN @@ -140,7 +145,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar EgtOutLog( Cutting.sMessage) return Cutting, EdgeToMachine.dElevation end - if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then + if #( Proc.MainFaces) > 0 and #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della lama la strategia non è applicabile if TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then Cutting.sMessage = 'Pocket too narrow for blade diameter' @@ -175,14 +180,14 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.bToolInvert = false end -- profondità da lavorare e offset radiale - if TOOLS[Cutting.nToolIndex].dMaxDepth > abs( EdgeToMachine.dElevation) - 10 * GEO.EPS_SMALL then + if TOOLS[Cutting.nToolIndex].dMaxDepth > dDepthToMachine - 10 * GEO.EPS_SMALL then -- TODO la depth dovrebbe essere quella del machining - Cutting.dDepthToMachine = abs( EdgeToMachine.dElevation) + Cutting.dDepthToMachine = dDepthToMachine Cutting.dResidualDepth = 0 if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then - Cutting.dRadialOffset = 0 + Cutting.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine else - Cutting.dRadialOffset = EdgeToMachine.dElevation + Cutting.dRadialOffset = -dDepthToMachine end else Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].dMaxDepth - 1 @@ -243,7 +248,12 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- se lavorazione aperta sulla coda, eventuali aggiustamenti -- TODO valutare se fare funzione a parte - if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 10 * GEO.EPS_SMALL)) then + if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 0.707)) then + local dLengthOnX = Cutting.dLengthOnX + -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione + if bIsSplitFeature then + dLengthOnX = 0 + end local bStartLeft = MachiningLib.StartsLeftSide( Cutting) local dAddLengthLeftSide = Cutting.LeadOut.dEndAddLength local dAddLengthToReduce = sqrt( Cutting.dDepthToMachine * TOOLS[Cutting.nToolIndex].dDiameter - Cutting.dDepthToMachine * Cutting.dDepthToMachine) @@ -251,13 +261,13 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar dAddLengthLeftSide = Cutting.LeadIn.dStartAddLength end if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtToolDirection, Y_AX()) then - if MachiningLib.CanMoveAfterSplitcut( Cutting.dLengthOnX, Part) then + if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Cutting.sStage = 'AfterTail' else Cutting.bIsApplicable = false end elseif dAddLengthLeftSide + dAddLengthToReduce > dExtendAfterTail then - if MachiningLib.CanMoveAfterSplitcut( Cutting.dLengthOnX, Part) then + if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Cutting.sStage = 'AfterTail' else if bStartLeft then diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/SLOTBYCHAINSAW.lua index 18fe907..1fc8210 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/SLOTBYCHAINSAW.lua @@ -69,12 +69,16 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional local bStopAtHalfElevation = OptionalParameters.bStopAtHalfElevation or false local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 local dPocketHeight = OptionalParameters.dPocketHeight or 0 + local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Mortising.dLengthToMachine = dLengthToMachine - Mortising.dLengthOnX = abs( dLengthToMachine * EdgeToMachine.vtToolDirection:getY()) Mortising.dEdgeLength = EdgeToMachine.dLength + -- TODO conviene spostare questi calcoli nel FaceData? Mortising.ptEdge1, _, Mortising.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtToolDirection, GDB_ID.ROOT) + local b3BoxEdge = BBox3d( Mortising.ptEdge1, Mortising.ptEdge2) + Mortising.dLengthOnX = b3BoxEdge:getDimX() + -- TODO conviene spostare questi calcoli nel FaceData? Mortising.vtToolDirection = EdgeToMachine.vtToolDirection if EdgeToMachine.bIsOpen then Mortising.vtEdgeDirection = -EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN @@ -122,7 +126,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional EgtOutLog( Mortising.sMessage) return Mortising end - if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then + if #( Proc.MainFaces) > 0 and #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della sega a catena la strategia non è applicabile if TOOLS[Mortising.nToolIndex].dWidth > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then Mortising.sMessage = 'Pocket too narrow for chainsaw width' @@ -218,20 +222,25 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional -- se lavorazione aperta sulla coda, eventuali aggiustamenti -- TODO valutare se fare funzione a parte - if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 10 * GEO.EPS_SMALL)) then + if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 0.707)) then + local dLengthOnX = Mortising.dLengthOnX + -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione + if bIsSplitFeature then + dLengthOnX = 0 + end local bStartLeft = MachiningLib.StartsLeftSide( Mortising) local dAddLengthLeftSide = Mortising.LeadOut.dEndAddLength if bStartLeft then dAddLengthLeftSide = Mortising.LeadIn.dStartAddLength end if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtToolDirection, Y_AX()) then - if MachiningLib.CanMoveAfterSplitcut( Mortising.dLengthOnX, Part) then + if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Mortising.sStage = 'AfterTail' else Mortising.bIsApplicable = false end elseif dAddLengthLeftSide + TOOLS[Mortising.nToolIndex].dDiameter / 2 > dExtendAfterTail then - if MachiningLib.CanMoveAfterSplitcut( Mortising.dLengthOnX, Part) then + if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Mortising.sStage = 'AfterTail' else if bStartLeft then From e3ab0b8f351bd397e3bd11c9a7c3f90dac6f2966 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 21 Jan 2025 16:03:19 +0100 Subject: [PATCH 11/21] - correzione in SLOTBYCHAINSAW --- StrategyLibs/SLOTBYCHAINSAW.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/SLOTBYCHAINSAW.lua index 1fc8210..5ce1e26 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/SLOTBYCHAINSAW.lua @@ -73,12 +73,10 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Mortising.dLengthToMachine = dLengthToMachine + -- TODO serve un modo migliore di calcolare la lunghezza lungo X; attenzione che serve la lunghezza reale di lavoro, non quella del lato + Mortising.dLengthOnX = abs( dLengthToMachine * EdgeToMachine.vtToolDirection:getY()) Mortising.dEdgeLength = EdgeToMachine.dLength - -- TODO conviene spostare questi calcoli nel FaceData? Mortising.ptEdge1, _, Mortising.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtToolDirection, GDB_ID.ROOT) - local b3BoxEdge = BBox3d( Mortising.ptEdge1, Mortising.ptEdge2) - Mortising.dLengthOnX = b3BoxEdge:getDimX() - -- TODO conviene spostare questi calcoli nel FaceData? Mortising.vtToolDirection = EdgeToMachine.vtToolDirection if EdgeToMachine.bIsOpen then Mortising.vtEdgeDirection = -EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN From 89c315cdd863e63680e3cac69b2bccaeea784fe2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 22 Jan 2025 12:33:19 +0100 Subject: [PATCH 12/21] - in MachiningLib corretta l'assegnazione del nFeatureSegment nei casi in cui la lavorazione non ha quasi componenti in X --- LuaLibs/MachiningLib.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 33e88af..3c1692a 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -166,10 +166,16 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part ) end -- anche le lavorazioni non splittate necessitano del segmento assegnato else - local dRightAddLength = dOriginalStartAddLength - local dLeftAddLength = dOriginalEndAddLength - if MachiningLib.StartsLeftSide( Machinings[i]) then - dRightAddLength, dLeftAddLength = dLeftAddLength, dRightAddLength + local dRightAddLength = 0 + local dLeftAddLength = 0 + -- si considerano allungamenti e accorciamenti solo se la feature è orientata principalmente lungo X + -- TODO il modo corretto è proiettare tutto, allungamenti e accorciamenti compresi, sulla faccia frontale + if abs( Machinings[i].vtToolDirection:getX()) < 0.707 then + dRightAddLength = dOriginalStartAddLength + dLeftAddLength = dOriginalEndAddLength + if MachiningLib.StartsLeftSide( Machinings[i]) then + dRightAddLength, dLeftAddLength = dLeftAddLength, dRightAddLength + end end for j = 1, nParts do local dNextSplitX = dEdgeMinX From ffe2d07918280cca1674d50fe55ed23d5f6476e0 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 23 Jan 2025 12:13:30 +0100 Subject: [PATCH 13/21] - negli egde vtToolDirection sostituita con vtN --- LuaLibs/FaceData.lua | 8 +++---- LuaLibs/MachiningLib.lua | 8 +++---- Strategies/Standard/HEADCUT/HEADCUT.lua | 2 +- Strategies/Standard/STR0005/STR0005.lua | 14 ++++++------- StrategyLibs/FACEBYBLADE.lua | 2 +- StrategyLibs/SLOTBYBLADE.lua | 20 +++++++++--------- StrategyLibs/SLOTBYCHAINSAW.lua | 28 ++++++++++++------------- StrategyLibs/SPLITCUT.lua | 2 +- 8 files changed, 42 insertions(+), 42 deletions(-) diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index fa426fa..bae8104 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -114,7 +114,7 @@ local function GetEdgesInfo( Proc, idFace ) local CurrentEdge = {} CurrentEdge.idAdjacentFace = EdgesEgt[i].Adj - CurrentEdge.vtToolDirection = Vector3d( EdgesEgt[i].Norm) + CurrentEdge.vtN = Vector3d( EdgesEgt[i].Norm) CurrentEdge.dLength = EdgesEgt[i].Len CurrentEdge.dElevation = abs( EdgesEgt[i].Elev) CurrentEdge.bIsOpen = EdgesEgt[i].Open @@ -298,7 +298,7 @@ local function GetBottomFaces( Proc) local CurrentEdge = {} CurrentEdge.idAdjacentFace = BottomFaces[1].Edges[i].idAdjacentFace - CurrentEdge.vtToolDirection = BottomFaces[1].Edges[i].vtToolDirection + CurrentEdge.vtN = BottomFaces[1].Edges[i].vtN CurrentEdge.dLength = BottomFaces[1].Edges[i].dLength CurrentEdge.bIsOpen = BottomFaces[1].Edges[i].bIsOpen CurrentEdge.dElevation = BottomFaces[1].Edges[i].dElevation @@ -386,7 +386,7 @@ local function GetLongFaces( Proc, MainFaces) local CurrentEdge = {} CurrentEdge.idAdjacentFace = LongFaces[i].Edges[j].idAdjacentFace - CurrentEdge.vtToolDirection = LongFaces[i].Edges[j].vtToolDirection + CurrentEdge.vtN = LongFaces[i].Edges[j].vtN CurrentEdge.dLength = LongFaces[i].Edges[j].dLength CurrentEdge.bIsOpen = LongFaces[i].Edges[j].bIsOpen CurrentEdge.dElevation = LongFaces[i].Edges[j].dElevation @@ -475,7 +475,7 @@ local function GetSideFaces( Proc, MainFaces) local CurrentEdge = {} CurrentEdge.idAdjacentFace = SideFaces[i].Edges[j].idAdjacentFace - CurrentEdge.vtToolDirection = SideFaces[i].Edges[j].vtToolDirection + CurrentEdge.vtN = SideFaces[i].Edges[j].vtN CurrentEdge.dLength = SideFaces[i].Edges[j].dLength CurrentEdge.bIsOpen = SideFaces[i].Edges[j].bIsOpen CurrentEdge.dElevation = SideFaces[i].Edges[j].dElevation diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 3c1692a..9f2f937 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -362,16 +362,16 @@ function MachiningLib.FindChainSaw( Proc, ToolSearchParameters) -- parametri obbligatori if type( ToolSearchParameters.vtToolDirection) ~= 'table' then - error( 'FindBlade : missing tool direction') + error( 'FindChainSaw : missing tool direction') end if type( ToolSearchParameters.bAllowTopHead) ~= 'boolean' then - error( 'FindBlade : missing top head info') + error( 'FindChainSaw : missing top head info') end if type( ToolSearchParameters.bAllowBottomHead) ~= 'boolean' then - error( 'FindBlade : missing bottom head info') + error( 'FindChainSaw : missing bottom head info') end if not ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then - error( 'FindBlade : wrong head info') + error( 'FindChainSaw : wrong head info') end -- parametri opzionali diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index 7d9bd60..7f2a524 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -72,7 +72,7 @@ end local function GetEdgeToMachine( Proc, vtEdge) local Edge for i = 1, #Proc.Faces[1].Edges do - if AreSameVectorApprox( Proc.Faces[1].Edges[i].vtToolDirection, vtEdge) then + if AreSameVectorApprox( Proc.Faces[1].Edges[i].vtN, vtEdge) then Edge = Proc.Faces[1].Edges[i] end end diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 26e98e4..6424be7 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -21,21 +21,21 @@ Blade.Result = {} ------------------------------------------------------------------------------------------------------------- local function CompareEdges( EdgeA, EdgeB) -- prima i lati orientati lungo X - if abs( EdgeA.vtToolDirection:getX()) < abs( EdgeB.vtToolDirection:getX()) - 10 * GEO.EPS_SMALL then + if abs( EdgeA.vtN:getX()) < abs( EdgeB.vtN:getX()) - 10 * GEO.EPS_SMALL then return true - elseif abs( EdgeA.vtToolDirection:getX()) > abs( EdgeB.vtToolDirection:getX()) + 10 * GEO.EPS_SMALL then + elseif abs( EdgeA.vtN:getX()) > abs( EdgeB.vtN:getX()) + 10 * GEO.EPS_SMALL then return false -- se stessa X si preferiscono i lati più in basso else - if EdgeA.vtToolDirection:getZ() > EdgeB.vtToolDirection:getZ() + 10 * GEO.EPS_SMALL then + if EdgeA.vtN:getZ() > EdgeB.vtN:getZ() + 10 * GEO.EPS_SMALL then return true - elseif EdgeA.vtToolDirection:getZ() < EdgeB.vtToolDirection:getZ() - 10 * GEO.EPS_SMALL then + elseif EdgeA.vtN:getZ() < EdgeB.vtN:getZ() - 10 * GEO.EPS_SMALL then return false -- se stessa Z si preferiscono i lati verso il fronte della trave else - if EdgeA.vtToolDirection:getY() > EdgeB.vtToolDirection:getY() + 10 * GEO.EPS_SMALL then + if EdgeA.vtN:getY() > EdgeB.vtN:getY() + 10 * GEO.EPS_SMALL then return true - elseif EdgeA.vtToolDirection:getY() < EdgeB.vtToolDirection:getY() - 10 * GEO.EPS_SMALL then + elseif EdgeA.vtN:getY() < EdgeB.vtN:getY() - 10 * GEO.EPS_SMALL then return false else return false @@ -119,7 +119,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) -- ricerca utensile local ToolSearchParameters = {} ToolSearchParameters.dElevation = dDepthToMachine - ToolSearchParameters.vtToolDirection = EdgesSorted[1].vtToolDirection + ToolSearchParameters.vtToolDirection = EdgesSorted[1].vtN ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = true ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index 1d093e8..07dbdca 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -67,7 +67,7 @@ end function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalParameters) local Cutting = {} - local vtMachiningDirection = EdgeToMachine.vtToolDirection + local vtMachiningDirection = EdgeToMachine.vtN local vtN = Proc.Faces[FaceToMachine.id+1].vtN Cutting.sDepth = OptionalParameters.sDepth or 0 Cutting.dLongitudinalOffset = OptionalParameters.dLongitudinalOffset or 0 diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua index 7a7b595..0b1beb2 100644 --- a/StrategyLibs/SLOTBYBLADE.lua +++ b/StrategyLibs/SLOTBYBLADE.lua @@ -109,21 +109,21 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.dLengthToMachine = EdgeToMachine.dLength Cutting.dEdgeLength = EdgeToMachine.dLength -- TODO conviene spostare questi calcoli nel FaceData? - Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtToolDirection, GDB_ID.ROOT) + Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtN, GDB_ID.ROOT) local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2) Cutting.dLengthOnX = b3BoxEdge:getDimX() -- - Cutting.vtToolDirection = EdgeToMachine.vtToolDirection + Cutting.vtToolDirection = EdgeToMachine.vtN if EdgeToMachine.bIsOpen then - Cutting.vtEdgeDirection = -EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN + Cutting.vtEdgeDirection = -EdgeToMachine.vtN ^ FaceToMachine.vtN else - Cutting.vtEdgeDirection = EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN + Cutting.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN end -- ricerca utensile local ToolSearchParameters = {} ToolSearchParameters.dElevation = abs( EdgeToMachine.dElevation) - ToolSearchParameters.vtToolDirection = EdgeToMachine.vtToolDirection + ToolSearchParameters.vtToolDirection = EdgeToMachine.vtN ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = false ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade @@ -215,12 +215,12 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.dOverlap = 0 -- faceuse if EdgeToMachine.dElevation > - 10 * GEO.EPS_SMALL then - Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( EdgeToMachine.vtToolDirection) + Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( EdgeToMachine.vtN) else - Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( -EdgeToMachine.vtToolDirection) + Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( -EdgeToMachine.vtN) end -- SCC - Cutting.nSCC = GetSCC( EdgeToMachine.vtToolDirection) + Cutting.nSCC = GetSCC( EdgeToMachine.vtN) -- asse bloccato Cutting.sBlockedAxis = BeamLib.GetBlockedAxis( Cutting.nToolIndex, 'perpendicular', Part.b3Raw, FaceToMachine.vtN, EgtIf( FaceToMachine.vtN:getX() > 0, X_AX(), -X_AX())) -- approccio e retrazione @@ -248,7 +248,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- se lavorazione aperta sulla coda, eventuali aggiustamenti -- TODO valutare se fare funzione a parte - if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 0.707)) then + if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtN:getX() < 0.707)) then local dLengthOnX = Cutting.dLengthOnX -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione if bIsSplitFeature then @@ -260,7 +260,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if bStartLeft then dAddLengthLeftSide = Cutting.LeadIn.dStartAddLength end - if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtToolDirection, Y_AX()) then + if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtN, Y_AX()) then if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Cutting.sStage = 'AfterTail' else diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/SLOTBYCHAINSAW.lua index 5ce1e26..dbf2bff 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/SLOTBYCHAINSAW.lua @@ -74,14 +74,14 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Mortising.dLengthToMachine = dLengthToMachine -- TODO serve un modo migliore di calcolare la lunghezza lungo X; attenzione che serve la lunghezza reale di lavoro, non quella del lato - Mortising.dLengthOnX = abs( dLengthToMachine * EdgeToMachine.vtToolDirection:getY()) + Mortising.dLengthOnX = abs( dLengthToMachine * EdgeToMachine.vtN:getY()) Mortising.dEdgeLength = EdgeToMachine.dLength - Mortising.ptEdge1, _, Mortising.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtToolDirection, GDB_ID.ROOT) - Mortising.vtToolDirection = EdgeToMachine.vtToolDirection + Mortising.ptEdge1, _, Mortising.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtN, GDB_ID.ROOT) + Mortising.vtToolDirection = EdgeToMachine.vtN if EdgeToMachine.bIsOpen then - Mortising.vtEdgeDirection = -EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN + Mortising.vtEdgeDirection = -EdgeToMachine.vtN ^ FaceToMachine.vtN else - Mortising.vtEdgeDirection = EdgeToMachine.vtToolDirection ^ FaceToMachine.vtN + Mortising.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN end -- ricerca utensile @@ -101,7 +101,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional end local ToolSearchParameters = {} local ToolInfo = {} - ToolSearchParameters.vtToolDirection = EdgeToMachine.vtToolDirection + ToolSearchParameters.vtToolDirection = EdgeToMachine.vtN ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = true ToolSearchParameters.dElevation = Mortising.dDepthToMachine @@ -194,20 +194,20 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional Mortising.Steps.dStep = TOOLS[Mortising.nToolIndex].dStep -- faceuse if EdgeToMachine.dElevation > - 10 * GEO.EPS_SMALL then - Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( EdgeToMachine.vtToolDirection) + Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( EdgeToMachine.vtN) else - Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( -EdgeToMachine.vtToolDirection) + Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( -EdgeToMachine.vtN) end -- SCC Mortising.SCC = MCH_SCC.NONE -- asse bloccato e angoli suggeriti - local vtRes = FaceToMachine.vtN ^ EdgeToMachine.vtToolDirection + local vtRes = FaceToMachine.vtN ^ EdgeToMachine.vtN if abs( vtRes:getZ()) < 10 * GEO.EPS_SMALL then Mortising.sBlockedAxis = BeamLib.GetBlockedAxis( Mortising.nToolIndex, 'perpendicular', Part.b3Raw, FaceToMachine.vtN) - Mortising.sSuggestedAngles = BeamLib.GetChainSawInitAngs( FaceToMachine.vtN, EdgeToMachine.vtToolDirection, 1) - elseif EdgeToMachine.vtToolDirection:getZ() < 10 * GEO.EPS_SMALL then + Mortising.sSuggestedAngles = BeamLib.GetChainSawInitAngs( FaceToMachine.vtN, EdgeToMachine.vtN, 1) + elseif EdgeToMachine.vtN:getZ() < 10 * GEO.EPS_SMALL then Mortising.sBlockedAxis = BeamLib.GetBlockedAxis( Mortising.nToolIndex, 'parallel', Part.b3Raw, FaceToMachine.vtN) - Mortising.sSuggestedAngles = BeamLib.GetChainSawInitAngs( FaceToMachine.vtN, EdgeToMachine.vtToolDirection, 2) + Mortising.sSuggestedAngles = BeamLib.GetChainSawInitAngs( FaceToMachine.vtN, EdgeToMachine.vtN, 2) end -- approccio e retrazione Mortising.LeadIn, Mortising.LeadOut = CalculateLeadInOut( Mortising, EdgeToMachine, sSideToMachine, dLengthToMachine) @@ -220,7 +220,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional -- se lavorazione aperta sulla coda, eventuali aggiustamenti -- TODO valutare se fare funzione a parte - if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtToolDirection:getX() < 0.707)) then + if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtN:getX() < 0.707)) then local dLengthOnX = Mortising.dLengthOnX -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione if bIsSplitFeature then @@ -231,7 +231,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional if bStartLeft then dAddLengthLeftSide = Mortising.LeadIn.dStartAddLength end - if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtToolDirection, Y_AX()) then + if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtN, Y_AX()) then if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then Mortising.sStage = 'AfterTail' else diff --git a/StrategyLibs/SPLITCUT.lua b/StrategyLibs/SPLITCUT.lua index 8d68db5..d56cab5 100644 --- a/StrategyLibs/SPLITCUT.lua +++ b/StrategyLibs/SPLITCUT.lua @@ -185,7 +185,7 @@ function SPLITCUT.GetStrategy( Proc, Part, OptionalParameters) function SPLITCUT.GetEdgeToMachine( Proc, vtEdge) local Edge for i = 1, #Proc.Faces[1].Edges do - if AreSameVectorApprox( Proc.Faces[1].Edges[i].vtToolDirection, vtEdge) then + if AreSameVectorApprox( Proc.Faces[1].Edges[i].vtN, vtEdge) then Edge = Proc.Faces[1].Edges[i] end end From c64aaade13fd99cb104933ae8709bc1c23246a51 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 23 Jan 2025 12:28:48 +0100 Subject: [PATCH 14/21] =?UTF-8?q?-=20in=20FaceData=20MainFaces=20non=20si?= =?UTF-8?q?=20crea=20se=20=C3=A8=20vuota=20-=20in=20SLOTBYBLADE=20e=20SLOT?= =?UTF-8?q?BYCHAINSAW=20piccole=20correzioni?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/FaceData.lua | 1 + StrategyLibs/SLOTBYBLADE.lua | 2 +- StrategyLibs/SLOTBYCHAINSAW.lua | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index bae8104..3fe713b 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -535,6 +535,7 @@ function FaceData.GetMainFaces( Proc, Part) Logs.WriteMainFacesLog( Proc, MainFaces) end else + MainFaces = nil EgtOutLog( '---MainFaces NOT NEEDED---') end diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua index 0b1beb2..d49fb1c 100644 --- a/StrategyLibs/SLOTBYBLADE.lua +++ b/StrategyLibs/SLOTBYBLADE.lua @@ -145,7 +145,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar EgtOutLog( Cutting.sMessage) return Cutting, EdgeToMachine.dElevation end - if #( Proc.MainFaces) > 0 and #( Proc.MainFaces.SideFaces) > 1 then + if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della lama la strategia non è applicabile if TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then Cutting.sMessage = 'Pocket too narrow for blade diameter' diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/SLOTBYCHAINSAW.lua index dbf2bff..92608a5 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/SLOTBYCHAINSAW.lua @@ -124,7 +124,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional EgtOutLog( Mortising.sMessage) return Mortising end - if #( Proc.MainFaces) > 0 and #( Proc.MainFaces.SideFaces) > 1 then + if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della sega a catena la strategia non è applicabile if TOOLS[Mortising.nToolIndex].dWidth > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then Mortising.sMessage = 'Pocket too narrow for chainsaw width' From e553197d61aa1b60ef0cc23e2596d8f9b815984a Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 23 Jan 2025 16:39:43 +0100 Subject: [PATCH 15/21] =?UTF-8?q?-=20in=20Edges=20l'elevazione=20si=20tien?= =?UTF-8?q?e=20sempre=20positiva=20e=20la=20normale=20guarda=20sempre=20ve?= =?UTF-8?q?rso=20il=20centro.=20-=20alle=20funzioni=20di=20base=20si=20pu?= =?UTF-8?q?=C3=B2=20passare=20il=20parametro=20opzionale=20bOppositeToolDi?= =?UTF-8?q?rection=20per=20invertire=20la=20direzione=20di=20lavoro=20dell?= =?UTF-8?q?'utensile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/FaceData.lua | 16 +++----- Strategies/Standard/HEADCUT/HEADCUT.lua | 10 +---- Strategies/Standard/STR0003/STR0003.lua | 42 ++++++++++--------- Strategies/Standard/STR0004/STR0004.lua | 14 ++++--- Strategies/Standard/STR0005/STR0005.lua | 6 +-- StrategyLibs/FACEBYBLADE.lua | 9 +---- StrategyLibs/SLOTBYBLADE.lua | 41 ++++++++++--------- StrategyLibs/SLOTBYCHAINSAW.lua | 54 +++++++++++++------------ StrategyLibs/SPLITCUT.lua | 10 +---- 9 files changed, 95 insertions(+), 107 deletions(-) diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index 3fe713b..f78957c 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -112,12 +112,17 @@ local function GetEdgesInfo( Proc, idFace ) nNextEdgeIndex = 1 end + -- l'elevazione si tiene sempre positiva e la normale sempre diretta verso l'interno della faccia + -- per sapere se il lato è aperto c'è la proprietà apposita bIsOpen local CurrentEdge = {} CurrentEdge.idAdjacentFace = EdgesEgt[i].Adj - CurrentEdge.vtN = Vector3d( EdgesEgt[i].Norm) CurrentEdge.dLength = EdgesEgt[i].Len CurrentEdge.dElevation = abs( EdgesEgt[i].Elev) CurrentEdge.bIsOpen = EdgesEgt[i].Open + CurrentEdge.vtN = Vector3d( EdgesEgt[i].Norm) + if CurrentEdge.bIsOpen then + CurrentEdge.vtN = -CurrentEdge.vtN + end CurrentEdge.bIsStartOpen = EdgesEgt[nPreviousEdgeIndex].Open CurrentEdge.bIsEndOpen = EdgesEgt[nNextEdgeIndex].Open CurrentEdge.sType = 'Standard' @@ -302,9 +307,6 @@ local function GetBottomFaces( Proc) CurrentEdge.dLength = BottomFaces[1].Edges[i].dLength CurrentEdge.bIsOpen = BottomFaces[1].Edges[i].bIsOpen CurrentEdge.dElevation = BottomFaces[1].Edges[i].dElevation - if CurrentEdge.bIsOpen then - CurrentEdge.dElevation = -CurrentEdge.dElevation - end CurrentEdge.bIsStartOpen = BottomFaces[1].Edges[i].bIsStartOpen CurrentEdge.bIsEndOpen = BottomFaces[1].Edges[i].bIsEndOpen @@ -390,9 +392,6 @@ local function GetLongFaces( Proc, MainFaces) CurrentEdge.dLength = LongFaces[i].Edges[j].dLength CurrentEdge.bIsOpen = LongFaces[i].Edges[j].bIsOpen CurrentEdge.dElevation = LongFaces[i].Edges[j].dElevation - if CurrentEdge.bIsOpen then - CurrentEdge.dElevation = -CurrentEdge.dElevation - end CurrentEdge.bIsStartOpen = LongFaces[i].Edges[j].bIsStartOpen CurrentEdge.bIsEndOpen = LongFaces[i].Edges[j].bIsEndOpen @@ -479,9 +478,6 @@ local function GetSideFaces( Proc, MainFaces) CurrentEdge.dLength = SideFaces[i].Edges[j].dLength CurrentEdge.bIsOpen = SideFaces[i].Edges[j].bIsOpen CurrentEdge.dElevation = SideFaces[i].Edges[j].dElevation - if CurrentEdge.bIsOpen then - CurrentEdge.dElevation = -CurrentEdge.dElevation - end CurrentEdge.bIsStartOpen = SideFaces[i].Edges[j].bIsStartOpen CurrentEdge.bIsEndOpen = SideFaces[i].Edges[j].bIsEndOpen diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index 7f2a524..17fd160 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -45,14 +45,8 @@ local function CalculateLeadInOut( Machining, EdgeToMachine) LeadOut.nType = MCH_MILL_LI.LINEAR LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 - -- elevazione sempre in negativo - if EdgeToMachine.dElevation < 10 * GEO.EPS_SMALL then - LeadIn.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation - LeadOut.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation - else - LeadIn.dPerpDistance = BeamData.CUT_SIC - LeadOut.dPerpDistance = BeamData.CUT_SIC - end + LeadIn.dPerpDistance = BeamData.CUT_SIC + EdgeToMachine.dElevation + LeadOut.dPerpDistance = BeamData.CUT_SIC + EdgeToMachine.dElevation LeadIn.dElevation = 0 LeadOut.dElevation = 0 LeadIn.dCompLength = 0 diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index b62e1d2..6a813ca 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -289,6 +289,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) local Cutting = {} local OptionalParameters = { bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} if Proc.Topology.sFamily == 'Tunnel' then + OptionalParameters.bOppositeToolDirection = true Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) else Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) @@ -296,6 +297,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) Blade.AddResult( Cutting) -- lato opposto del tunnel if Proc.Topology.sFamily == 'Tunnel' then + OptionalParameters.bOppositeToolDirection = true Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Blade.AddResult( Cutting) else @@ -303,11 +305,13 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if Blade.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL then -- eventuale lavorazione di lama - lato della tasca da cui inizia la lavorazione if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then + OptionalParameters.bOppositeToolDirection = true Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Blade.AddResult( Cutting) end -- eventuale lavorazione di lama - lato della tasca in cui finisce la lavorazione if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then + OptionalParameters.bOppositeToolDirection = true Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Blade.AddResult( Cutting) end @@ -392,10 +396,10 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- si lavora solamente l'impronta lama sul fondo if ( #Blade.Result.Side > 0) and Blade.Result.Side[1].dResidualDepth < 10 * GEO.EPS_SMALL then if ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end -- si lavora tutto il lato @@ -407,10 +411,10 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) dBladeResidualDepth = Blade.Result.Bottom[1].dResidualDepth end if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then - local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then - local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end end @@ -428,16 +432,16 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if ( Blade.Result.Side[1].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) and ( Blade.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then - local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può eliminare la lavorazione del fondo @@ -447,17 +451,17 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end -- si lavora tutto il lato else - local OptionalParameters = { dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Side[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo @@ -473,43 +477,43 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if ( Blade.Result.Opposite[1].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1].dLength > 3 * Blade.Result.Opposite[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) and ( Blade.Result.Opposite[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2].dLength > 3 * Blade.Result.Opposite[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL or Chainsaw.Result.Opposite[2].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false Chainsaw.Result.Opposite[2].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end else - local OptionalParameters = { dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua index 89f34cb..3885da2 100644 --- a/Strategies/Standard/STR0004/STR0004.lua +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -182,8 +182,10 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) -- materiale residuo - se possibile si lavora dal lato if ( Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].dResidualDepth > 10 * GEO.EPS_SMALL or not Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].bIsApplicable) and #Proc.MainFaces.SideFaces == 1 then if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then + OptionalParameters.bOppositeToolDirection = true Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then + OptionalParameters.bOppositeToolDirection = true Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end Chainsaw.AddResult( Mortising) @@ -195,17 +197,17 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) Chainsaw.AddResult( Mortising) -- materiale residuo - si lavorano i lati if ( Chainsaw.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL or not Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].bIsApplicable) then - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Side[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo @@ -215,16 +217,16 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) end end elseif Proc.Topology.sName == 'Tunnel-4-Through' then - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 6424be7..1123ed4 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -114,7 +114,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) end table.sort( EdgesSorted, CompareEdges) - local dDepthToMachine = abs( EdgesSorted[1].dElevation) / 2 - Strategy.Parameters.dStripWidth / 2 + local dDepthToMachine = EdgesSorted[1].dElevation / 2 - Strategy.Parameters.dStripWidth / 2 -- ricerca utensile local ToolSearchParameters = {} @@ -130,12 +130,12 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Cutting.sMessage = 'Blade not found' Cutting.bIsApplicable = false EgtOutLog( Cutting.sMessage) - return Cutting, abs( EdgesSorted[1].dElevation) + return Cutting, EdgesSorted[1].dElevation end -- parametri per il calcolo della velocità di asportazione MRRParametersBlade = { - dStep = min( TOOLS[Cutting.nToolIndex].dStep, abs( EdgesSorted[1].dElevation)), + dStep = min( TOOLS[Cutting.nToolIndex].dStep, EdgesSorted[1].dElevation), dSideStep = TOOLS[Cutting.nToolIndex].dThickness, dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed } diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index 07dbdca..d1c4e15 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -23,13 +23,8 @@ local function CalculateLeadInOut( EdgeToMachine) LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 -- elevazione sempre in negativo - if EdgeToMachine.dElevation < 10 * GEO.EPS_SMALL then - LeadIn.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation - LeadOut.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation - else - LeadIn.dPerpDistance = BeamData.CUT_SIC - LeadOut.dPerpDistance = BeamData.CUT_SIC - end + LeadIn.dPerpDistance = BeamData.CUT_SIC + EdgeToMachine.dElevation + LeadOut.dPerpDistance = BeamData.CUT_SIC + EdgeToMachine.dElevation LeadIn.dElevation = 0 LeadOut.dElevation = 0 LeadIn.dCompLength = 0 diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua index d49fb1c..bff4dfa 100644 --- a/StrategyLibs/SLOTBYBLADE.lua +++ b/StrategyLibs/SLOTBYBLADE.lua @@ -31,7 +31,7 @@ local function CalculateLeadInOut( Machining, EdgeToMachine) LeadOut.nType = MCH_MILL_LI.LINEAR LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 - if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then + if AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC else @@ -90,7 +90,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.dDepthToMachine = 0 Cutting.sMessage = '' Cutting.idProc = Proc.id - Cutting.dResidualDepth = abs( EdgeToMachine.dElevation) + Cutting.dResidualDepth = EdgeToMachine.dElevation Cutting.dBladeMarkLength = 0 Cutting.sEdgeType = EdgeToMachine.sType Cutting.nFeatureSegment = 1 @@ -102,8 +102,9 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar local bForceLongcutBlade = OptionalParameters.bForceLongcutBlade or false local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 local dPocketHeight = OptionalParameters.dPocketHeight or 0 - local dDepthToMachine = min( OptionalParameters.dDepthToMachine or abs( EdgeToMachine.dElevation), abs( EdgeToMachine.dElevation)) + local dDepthToMachine = min( OptionalParameters.dDepthToMachine or EdgeToMachine.dElevation, EdgeToMachine.dElevation) local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false + local bOppositeToolDirection = OptionalParameters.bOppositeToolDirection or false -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Cutting.dLengthToMachine = EdgeToMachine.dLength @@ -113,17 +114,17 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2) Cutting.dLengthOnX = b3BoxEdge:getDimX() -- - Cutting.vtToolDirection = EdgeToMachine.vtN - if EdgeToMachine.bIsOpen then - Cutting.vtEdgeDirection = -EdgeToMachine.vtN ^ FaceToMachine.vtN + if bOppositeToolDirection then + Cutting.vtToolDirection = -EdgeToMachine.vtN else - Cutting.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN + Cutting.vtToolDirection = EdgeToMachine.vtN end + Cutting.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN -- ricerca utensile local ToolSearchParameters = {} - ToolSearchParameters.dElevation = abs( EdgeToMachine.dElevation) - ToolSearchParameters.vtToolDirection = EdgeToMachine.vtN + ToolSearchParameters.dElevation = EdgeToMachine.dElevation + ToolSearchParameters.vtToolDirection = Cutting.vtToolDirection ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = false ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade @@ -169,7 +170,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.nWorkside = MCH_MILL_WS.LEFT Cutting.bInvert = false end - if EdgeToMachine.dElevation < -10 * GEO.EPS_SMALL then + if bOppositeToolDirection then Cutting.bInvert = not Cutting.bInvert end -- TODO gestire lama da sotto e lama downUp @@ -184,18 +185,18 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- TODO la depth dovrebbe essere quella del machining Cutting.dDepthToMachine = dDepthToMachine Cutting.dResidualDepth = 0 - if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then - Cutting.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine - else + if bOppositeToolDirection then Cutting.dRadialOffset = -dDepthToMachine + else + Cutting.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine end else Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].dMaxDepth - 1 - Cutting.dResidualDepth = abs( EdgeToMachine.dElevation) - Cutting.dDepthToMachine - if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then - Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine - else + Cutting.dResidualDepth = EdgeToMachine.dElevation - Cutting.dDepthToMachine + if bOppositeToolDirection then Cutting.dRadialOffset = -Cutting.dDepthToMachine + else + Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine end end -- completamento @@ -214,10 +215,10 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- overlap Cutting.dOverlap = 0 -- faceuse - if EdgeToMachine.dElevation > - 10 * GEO.EPS_SMALL then - Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( EdgeToMachine.vtN) - else + if bOppositeToolDirection then Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( -EdgeToMachine.vtN) + else + Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( EdgeToMachine.vtN) end -- SCC Cutting.nSCC = GetSCC( EdgeToMachine.vtN) diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/SLOTBYCHAINSAW.lua index 92608a5..6b931fc 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/SLOTBYCHAINSAW.lua @@ -52,7 +52,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional local Mortising = {} Mortising.bIsApplicable = true Mortising.dDepthToMachine = 0 - Mortising.dResidualDepth = abs( EdgeToMachine.dElevation) + Mortising.dResidualDepth = EdgeToMachine.dElevation Mortising.sMessage = '' Mortising.idProc = Proc.id Mortising.sEdgeType = EdgeToMachine.sType @@ -65,11 +65,12 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional local bUseZigZagMortising = OptionalParameters.bUseZigZagMortising or false local sSideToMachine = OptionalParameters.sSideToMachine or '' local dLengthToMachine = OptionalParameters.dLengthToMachine or EdgeToMachine.dLength - local dCustomMaxElev = OptionalParameters.dMaxElev or abs( EdgeToMachine.dElevation) + local dCustomMaxElev = OptionalParameters.dMaxElev or EdgeToMachine.dElevation local bStopAtHalfElevation = OptionalParameters.bStopAtHalfElevation or false local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 local dPocketHeight = OptionalParameters.dPocketHeight or 0 local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false + local bOppositeToolDirection = OptionalParameters.bOppositeToolDirection or false -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Mortising.dLengthToMachine = dLengthToMachine @@ -77,12 +78,13 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional Mortising.dLengthOnX = abs( dLengthToMachine * EdgeToMachine.vtN:getY()) Mortising.dEdgeLength = EdgeToMachine.dLength Mortising.ptEdge1, _, Mortising.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtN, GDB_ID.ROOT) - Mortising.vtToolDirection = EdgeToMachine.vtN - if EdgeToMachine.bIsOpen then - Mortising.vtEdgeDirection = -EdgeToMachine.vtN ^ FaceToMachine.vtN + + if bOppositeToolDirection then + Mortising.vtToolDirection = -EdgeToMachine.vtN else - Mortising.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN + Mortising.vtToolDirection = EdgeToMachine.vtN end + Mortising.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN -- ricerca utensile local bExtendWithCornerRadius = false @@ -91,17 +93,17 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional ( EdgeToMachine.sType == 'Opposite' and Proc.Topology.sFamily == 'Tunnel') then bExtendWithCornerRadius = true - Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) + BeamData.CUT_EXTRA + Mortising.dDepthToMachine = EdgeToMachine.dElevation + BeamData.CUT_EXTRA else - Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) + Mortising.dDepthToMachine = EdgeToMachine.dElevation end else bExtendWithCornerRadius = true - Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) / 2 + BeamData.CUT_EXTRA_MIN + Mortising.dDepthToMachine = EdgeToMachine.dElevation / 2 + BeamData.CUT_EXTRA_MIN end local ToolSearchParameters = {} local ToolInfo = {} - ToolSearchParameters.vtToolDirection = EdgeToMachine.vtN + ToolSearchParameters.vtToolDirection = Mortising.vtToolDirection ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = true ToolSearchParameters.dElevation = Mortising.dDepthToMachine @@ -143,12 +145,12 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional Mortising.bIsEndClosed = not EdgeToMachine.bIsEndOpen -- lato di lavoro e inversioni Mortising.bInvert = false - if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then - Mortising.nWorkside = MCH_MILL_WS.RIGHT - Mortising.bToolInvert = false - else + if bOppositeToolDirection then Mortising.nWorkside = MCH_MILL_WS.LEFT Mortising.bToolInvert = true + else + Mortising.nWorkside = MCH_MILL_WS.RIGHT + Mortising.bToolInvert = false end -- profondità e offset longitudinale if bExtendWithCornerRadius then @@ -156,19 +158,19 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional end if TOOLS[Mortising.nToolIndex].dMaxMaterial > Mortising.dDepthToMachine - 10 * GEO.EPS_SMALL then Mortising.dResidualDepth = 0 - if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then - Mortising.dLongitudinalOffset = 0 - else - Mortising.dLongitudinalOffset = abs( EdgeToMachine.dElevation) - Mortising.dDepthToMachine - end - else - Mortising.dDepthToMachine = TOOLS[Mortising.nToolIndex].dMaxMaterial - 1 - Mortising.dResidualDepth = abs( EdgeToMachine.dElevation) - Mortising.dDepthToMachine - if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then + if bOppositeToolDirection then Mortising.dLongitudinalOffset = EdgeToMachine.dElevation - Mortising.dDepthToMachine else Mortising.dLongitudinalOffset = 0 end + else + Mortising.dDepthToMachine = TOOLS[Mortising.nToolIndex].dMaxMaterial - 1 + Mortising.dResidualDepth = EdgeToMachine.dElevation - Mortising.dDepthToMachine + if bOppositeToolDirection then + Mortising.dLongitudinalOffset = 0 + else + Mortising.dLongitudinalOffset = EdgeToMachine.dElevation - Mortising.dDepthToMachine + end Mortising.sMessage = 'Feature '.. Proc.idFeature .. ' : chainsaw elevation (' .. EgtNumToString( EdgeToMachine.dElevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Mortising.dDepthToMachine, 1) .. ')' EgtOutLog( Mortising.sMessage) end @@ -193,10 +195,10 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional end Mortising.Steps.dStep = TOOLS[Mortising.nToolIndex].dStep -- faceuse - if EdgeToMachine.dElevation > - 10 * GEO.EPS_SMALL then - Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( EdgeToMachine.vtN) - else + if bOppositeToolDirection then Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( -EdgeToMachine.vtN) + else + Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( EdgeToMachine.vtN) end -- SCC Mortising.SCC = MCH_SCC.NONE diff --git a/StrategyLibs/SPLITCUT.lua b/StrategyLibs/SPLITCUT.lua index d56cab5..833f7b5 100644 --- a/StrategyLibs/SPLITCUT.lua +++ b/StrategyLibs/SPLITCUT.lua @@ -203,14 +203,8 @@ function SPLITCUT.CalculateLeadInOut( EdgeToMachine) LeadOut.nType = MCH_MILL_LI.LINEAR LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 - -- elevazione sempre in negativo - if EdgeToMachine.dElevation < 10 * GEO.EPS_SMALL then - LeadIn.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation - LeadOut.dPerpDistance = BeamData.CUT_SIC - EdgeToMachine.dElevation - else - LeadIn.dPerpDistance = BeamData.CUT_SIC - LeadOut.dPerpDistance = BeamData.CUT_SIC - end + LeadIn.dPerpDistance = BeamData.CUT_SIC + EdgeToMachine.dElevation + LeadOut.dPerpDistance = BeamData.CUT_SIC + EdgeToMachine.dElevation LeadIn.dElevation = 0 LeadOut.dElevation = 0 LeadIn.dCompLength = 0 From 098244b1092c9050acb4b3dacf0f4de883a525df Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 24 Jan 2025 12:26:22 +0100 Subject: [PATCH 16/21] - in SLOTBYBLADE e SLOTBYCHAINSAW corrette direzioni utensile --- StrategyLibs/SLOTBYBLADE.lua | 18 +++++++++--------- StrategyLibs/SLOTBYCHAINSAW.lua | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua index bff4dfa..205f892 100644 --- a/StrategyLibs/SLOTBYBLADE.lua +++ b/StrategyLibs/SLOTBYBLADE.lua @@ -109,17 +109,17 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Cutting.dLengthToMachine = EdgeToMachine.dLength Cutting.dEdgeLength = EdgeToMachine.dLength - -- TODO conviene spostare questi calcoli nel FaceData? - Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtN, GDB_ID.ROOT) - local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2) - Cutting.dLengthOnX = b3BoxEdge:getDimX() - -- if bOppositeToolDirection then Cutting.vtToolDirection = -EdgeToMachine.vtN else Cutting.vtToolDirection = EdgeToMachine.vtN end Cutting.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN + -- TODO conviene spostare questi calcoli nel FaceData? + Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -Cutting.vtToolDirection, GDB_ID.ROOT) + local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2) + Cutting.dLengthOnX = b3BoxEdge:getDimX() + -- -- ricerca utensile local ToolSearchParameters = {} @@ -216,12 +216,12 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.dOverlap = 0 -- faceuse if bOppositeToolDirection then - Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( -EdgeToMachine.vtN) + Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( -Cutting.vtToolDirection) else - Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( EdgeToMachine.vtN) + Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( Cutting.vtToolDirection) end -- SCC - Cutting.nSCC = GetSCC( EdgeToMachine.vtN) + Cutting.nSCC = GetSCC( Cutting.vtToolDirection) -- asse bloccato Cutting.sBlockedAxis = BeamLib.GetBlockedAxis( Cutting.nToolIndex, 'perpendicular', Part.b3Raw, FaceToMachine.vtN, EgtIf( FaceToMachine.vtN:getX() > 0, X_AX(), -X_AX())) -- approccio e retrazione @@ -249,7 +249,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- se lavorazione aperta sulla coda, eventuali aggiustamenti -- TODO valutare se fare funzione a parte - if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtN:getX() < 0.707)) then + if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( Cutting.vtToolDirection:getX() < 0.707)) then local dLengthOnX = Cutting.dLengthOnX -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione if bIsSplitFeature then diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/SLOTBYCHAINSAW.lua index 6b931fc..d450cf3 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/SLOTBYCHAINSAW.lua @@ -75,16 +75,16 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Mortising.dLengthToMachine = dLengthToMachine -- TODO serve un modo migliore di calcolare la lunghezza lungo X; attenzione che serve la lunghezza reale di lavoro, non quella del lato + -- TODO andrà aggiornata dopo il calcolo LeadIn/Out Mortising.dLengthOnX = abs( dLengthToMachine * EdgeToMachine.vtN:getY()) Mortising.dEdgeLength = EdgeToMachine.dLength - Mortising.ptEdge1, _, Mortising.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -EdgeToMachine.vtN, GDB_ID.ROOT) - if bOppositeToolDirection then Mortising.vtToolDirection = -EdgeToMachine.vtN else Mortising.vtToolDirection = EdgeToMachine.vtN end Mortising.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN + Mortising.ptEdge1, _, Mortising.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -Mortising.vtToolDirection, GDB_ID.ROOT) -- ricerca utensile local bExtendWithCornerRadius = false @@ -196,9 +196,9 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional Mortising.Steps.dStep = TOOLS[Mortising.nToolIndex].dStep -- faceuse if bOppositeToolDirection then - Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( -EdgeToMachine.vtN) + Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( -Mortising.vtToolDirection) else - Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( EdgeToMachine.vtN) + Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( Mortising.vtToolDirection) end -- SCC Mortising.SCC = MCH_SCC.NONE @@ -222,7 +222,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional -- se lavorazione aperta sulla coda, eventuali aggiustamenti -- TODO valutare se fare funzione a parte - if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( EdgeToMachine.vtN:getX() < 0.707)) then + if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( Mortising.vtToolDirection:getX() < 0.707)) then local dLengthOnX = Mortising.dLengthOnX -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione if bIsSplitFeature then From 0c5373700eb5ed66011a7cb2adec4c0892792743 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 24 Jan 2025 15:17:10 +0100 Subject: [PATCH 17/21] - in STR0003, 4 e 5 corretta gestione spezzatura --- Strategies/Standard/STR0003/STR0003.lua | 60 ++++++++++++++----------- Strategies/Standard/STR0004/STR0004.lua | 27 ++++++----- Strategies/Standard/STR0005/STR0005.lua | 2 +- 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index 6a813ca..1af1510 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -277,6 +277,13 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) dExtendAfterTail = 10000 end + -- eventuali punti di spezzatura + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + local bIsSplitFeature = false + if #FeatureSplittingPoints > 0 then + bIsSplitFeature = true + end + -- altezza tasca local dPocketHeight = 0 if Proc.Topology.sFamily == 'Tunnel' then @@ -287,7 +294,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- lama - calcolo lavorazioni local Cutting = {} - local OptionalParameters = { bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} if Proc.Topology.sFamily == 'Tunnel' then OptionalParameters.bOppositeToolDirection = true Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) @@ -324,8 +331,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- lama - lavorazioni raggruppate in unica lista Blade.Result.Sorted = MergeResults( Blade.Result) -- lama - aggiunta eventuali lavorazioni splittate - local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) - if #FeatureSplittingPoints > 0 then + if bIsSplitFeature then Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result.Sorted, FeatureSplittingPoints, Part) end -- lama - nessuna lavorazione successiva - aggiunta lavorazioni e calcolo risultati @@ -376,18 +382,18 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.dLength > 3 * Blade.Result.Bottom[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then if not Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then - local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) end if not Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then - local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) end -- si lavora tutto il fondo else - local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) end @@ -396,10 +402,10 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- si lavora solamente l'impronta lama sul fondo if ( #Blade.Result.Side > 0) and Blade.Result.Side[1].dResidualDepth < 10 * GEO.EPS_SMALL then if ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end -- si lavora tutto il lato @@ -411,10 +417,10 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) dBladeResidualDepth = Blade.Result.Bottom[1].dResidualDepth end if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then - local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then - local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end end @@ -423,7 +429,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) elseif Proc.Topology.sName == 'Groove-3-Through' then if Blade.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL then -- si lavora tutto il fondo - local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavorano i lati @@ -432,16 +438,16 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if ( Blade.Result.Side[1].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) and ( Blade.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then - local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può eliminare la lavorazione del fondo @@ -451,17 +457,17 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end -- si lavora tutto il lato else - local OptionalParameters = { dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Side[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo @@ -477,43 +483,43 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if ( Blade.Result.Opposite[1].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1].dLength > 3 * Blade.Result.Opposite[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) and ( Blade.Result.Opposite[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2].dLength > 3 * Blade.Result.Opposite[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then - local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL or Chainsaw.Result.Opposite[2].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false Chainsaw.Result.Opposite[2].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end else - local OptionalParameters = { dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end @@ -522,7 +528,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- sega a catena - lavorazioni raggruppate in unica lista Chainsaw.Result.Sorted = MergeResults( Chainsaw.Result) -- sega a catena - aggiunta eventuali lavorazioni splittate - if #FeatureSplittingPoints > 0 then + if bIsSplitFeature then Chainsaw.Result.Sorted = MachiningLib.GetSplitMachinings( Chainsaw.Result.Sorted, FeatureSplittingPoints, Part) end diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua index 3885da2..7691488 100644 --- a/Strategies/Standard/STR0004/STR0004.lua +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -159,11 +159,19 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) return false, Strategy.Result end + -- calcolo estensione oltre la coda local dExtendAfterTail = Strategy.Parameters.dExtendAfterTail or max( Part.dDistanceToNextPiece - BeamData.CUT_EXTRA, 0) if MachiningLib.CanExtendAfterTail( Strategy.Parameters.sCanDamageNextPiece, Part) then dExtendAfterTail = 10000 end + -- eventuali punti di spezzatura + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + local bIsSplitFeature = false + if #FeatureSplittingPoints > 0 then + bIsSplitFeature = true + end + -- altezza tasca local dPocketHeight = 0 if Proc.Topology.sFamily == 'Tunnel' then @@ -174,7 +182,7 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) -- calcolo lavorazioni local Mortising = {} - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} if Proc.Topology.sName == 'Groove-4-Blind' or Proc.Topology.sName == 'Pocket-5-Blind' then -- si lavora tutto il fondo Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) @@ -192,22 +200,22 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) end elseif Proc.Topology.sName == 'Groove-3-Through' then -- si lavora tutto il fondo - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) -- materiale residuo - si lavorano i lati if ( Chainsaw.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL or not Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].bIsApplicable) then - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Side[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo @@ -217,16 +225,16 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) end end elseif Proc.Topology.sName == 'Tunnel-4-Through' then - local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false - local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} - OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true} + OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end @@ -251,8 +259,7 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) end -- aggiunta eventuali lavorazioni splittate - local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) - if #FeatureSplittingPoints > 0 then + if bIsSplitFeature then Chainsaw.Result.Sorted = MachiningLib.GetSplitMachinings( Chainsaw.Result.Sorted, FeatureSplittingPoints, Part) end diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 1123ed4..e80bea3 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -143,7 +143,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) -- eventuali punti di spezzatura local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) local bIsSplitFeature = false - if #FeatureSplittingPoints then + if #FeatureSplittingPoints > 0 then bIsSplitFeature = true end From 9edd39305f12a39bbf1d078ec2df9011c8679c43 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 24 Jan 2025 17:21:19 +0100 Subject: [PATCH 18/21] - STR0005 con codolo funzionante e con ordinamento lavorazioni --- Strategies/Standard/STR0005/STR0005.lua | 38 ++++++++++++++++++++----- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index e80bea3..98498a1 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -45,6 +45,33 @@ local function CompareEdges( EdgeA, EdgeB) end +local function SortMachiningsBySegment( MachiningA, MachiningB) + if MachiningA.nFeatureSegment > MachiningB.nFeatureSegment then + return false + elseif MachiningB.nFeatureSegment > MachiningA.nFeatureSegment then + return true + -- se segmento uguale, si minimizzano i cambi di lato + else + local bIsOddSegment = ( MachiningA.nFeatureSegment % 2 ~= 0) + if MachiningA.vtToolDirection:getY() < MachiningB.vtToolDirection:getY() - 10 * GEO.EPS_SMALL then + if bIsOddSegment then + return true + else + return false + end + elseif MachiningA.vtToolDirection:getY() > MachiningB.vtToolDirection:getY() + 10 * GEO.EPS_SMALL then + if bIsOddSegment then + return false + else + return true + end + else + return false + end + end +end + + function Blade.AddResult( Cutting) table.insert( Blade.Result, Cutting) @@ -101,11 +128,8 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) if bFeatureHindersClamping or bLeaveWasteAttached then -- TODO Lavorazione con codolo - -- La FaceByBlade (o altra??) dovrà accettare opzionalmente di fermarsi prima (basta l'Offset??) e accettare l'utensile forzato. - -- attenzione perchè se l'inclinazione della faccia la fa finire oltre lo spigolo questo riduce il massimo calcolare (come calcolare????) + -- attenzione perchè se l'inclinazione della faccia la fa finire oltre lo spigolo questo riduce il massimo calcolare (come calcolare????) -- il FindBlade dovrà restituire di utilizzare sempre la lama sopra se l'angolo lo permette, ma avendo un'altezza massima (da macchina) oltre cui il DownUp non sarà fattibile (evita collisioni tra asse e pezzo) - --Cutting = FaceByBlade.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalParameters) - --Cutting.AddResult( Cutting) -- si trovano i lati da lavorare local EdgesSorted = {} @@ -122,7 +146,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) ToolSearchParameters.vtToolDirection = EdgesSorted[1].vtN ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = true - ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade + ToolSearchParameters.bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) Cutting.nToolIndex = ToolInfo.nToolIndex Cutting.nType = MCH_OY.MILLING @@ -153,7 +177,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Blade.AddResult( Cutting) -- secondo lato Cutting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[2], OptionalParameters) - --Blade.AddResult( Cutting) + Blade.AddResult( Cutting) -- lavorazioni raggruppate in unica lista Blade.Result.Sorted = {} @@ -168,7 +192,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result.Sorted, FeatureSplittingPoints, Part) end - -- TODO ordinamento lavorazioni (se necessario) + table.sort( Blade.Result.Sorted, SortMachiningsBySegment) -- se la lavorazione con codolo fallisce o non è possibile si proseguirà a quella con cubetti end From e37486db1da4b27f868ca3f9c5a30565589b7e35 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 27 Jan 2025 15:57:12 +0100 Subject: [PATCH 19/21] - in STR0003 correzione nel calcolo LeadIn/Out per i cloni --- LuaLibs/MachiningLib.lua | 1 + Strategies/Standard/HEADCUT/HEADCUT.lua | 1 + Strategies/Standard/STR0003/STR0003.lua | 4 ++-- Strategies/Standard/STR0005/STR0005.lua | 5 +++-- StrategyLibs/SLOTBYBLADE.lua | 5 +++-- StrategyLibs/SLOTBYCHAINSAW.lua | 1 + 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 9f2f937..a9a4417 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -296,6 +296,7 @@ end ------------------------------------------------------------------------------------------------------------- -- funzione per cercare utensile tipo LAMA con certe caratteristiche -- TODO da completare +-- TODO il FindBlade dovrà restituire di utilizzare sempre la lama sopra se l'angolo lo permette, ma avendo un'altezza massima (da macchina) oltre cui il DownUp non sarà fattibile (evita collisioni tra asse e pezzo) function MachiningLib.FindBlade( Proc, ToolSearchParameters) local ToolInfo = {} diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index 17fd160..86e5964 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -16,6 +16,7 @@ local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base local FaceByBlade = require('FACEBYBLADE') +local SlotByBlade = require('SLOTBYBLADE') -- Tabella per definizione modulo local HEADCUT = {} diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index 1af1510..955d69a 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -210,8 +210,8 @@ function Blade.AddMachiningAllSteps( Proc, Cutting, AuxiliaryData) AuxiliaryData.Clones[i].LeadOut = {} AuxiliaryData.Clones[i].dRadialOffset = dOriginalRadialOffset + Cutting.HorizontalSteps.dStep * ( Cutting.HorizontalSteps.nCount - i) -- update distanza perpendicolare attacco per contemplare l'offset applicato - AuxiliaryData.Clones[i].LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - Cutting.dRadialOffset - AuxiliaryData.Clones[i].LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - Cutting.dRadialOffset + AuxiliaryData.Clones[i].LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - AuxiliaryData.Clones[i].dRadialOffset + AuxiliaryData.Clones[i].LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - AuxiliaryData.Clones[i].dRadialOffset end bMachiningAdded = MachiningLib.AddNewMachining( Proc, Cutting, AuxiliaryData) diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 98498a1..3a9df84 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -115,6 +115,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Result.sInfo = '' Blade.Result = {} + -- estensione oltre la coda local dExtendAfterTail = Strategy.Parameters.dExtendAfterTail or max( Part.dDistanceToNextPiece - BeamData.CUT_EXTRA, 0) if MachiningLib.CanExtendAfterTail( Strategy.Parameters.sCanDamageNextPiece, Part) then dExtendAfterTail = 10000 @@ -127,8 +128,8 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) local MRRParametersBlade = {} if bFeatureHindersClamping or bLeaveWasteAttached then - -- TODO Lavorazione con codolo - -- attenzione perchè se l'inclinazione della faccia la fa finire oltre lo spigolo questo riduce il massimo calcolare (come calcolare????) + -- TODO valutare se estrapolare in funzione a sè stante in StrategyLibs + -- attenzione perchè se l'inclinazione della faccia la fa finire oltre lo spigolo questo riduce il massimo (come calcolare????) -- il FindBlade dovrà restituire di utilizzare sempre la lama sopra se l'angolo lo permette, ma avendo un'altezza massima (da macchina) oltre cui il DownUp non sarà fattibile (evita collisioni tra asse e pezzo) -- si trovano i lati da lavorare diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua index 205f892..f7ca131 100644 --- a/StrategyLibs/SLOTBYBLADE.lua +++ b/StrategyLibs/SLOTBYBLADE.lua @@ -105,6 +105,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar local dDepthToMachine = min( OptionalParameters.dDepthToMachine or EdgeToMachine.dElevation, EdgeToMachine.dElevation) local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false local bOppositeToolDirection = OptionalParameters.bOppositeToolDirection or false + local sDepth = OptionalParameters.sDepth or 0 -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Cutting.dLengthToMachine = EdgeToMachine.dLength @@ -157,8 +158,8 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar end -- parametri della lavorazione - -- profondità (parametro DEPTH) non usata - Cutting.sDepth = 0 + -- profondità (parametro DEPTH) + Cutting.sDepth = sDepth -- inizio e fine aperti o chiusi Cutting.bIsStartClosed = not EdgeToMachine.bIsStartOpen Cutting.bIsEndClosed = not EdgeToMachine.bIsEndOpen diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/SLOTBYCHAINSAW.lua index d450cf3..fcd3dc3 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/SLOTBYCHAINSAW.lua @@ -71,6 +71,7 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional local dPocketHeight = OptionalParameters.dPocketHeight or 0 local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false local bOppositeToolDirection = OptionalParameters.bOppositeToolDirection or false + local sDepth = OptionalParameters.sDepth or 'TH' -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Mortising.dLengthToMachine = dLengthToMachine From a8c2e2fe9861db3ad95c696dd71364a7edfc49f5 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 27 Jan 2025 18:03:47 +0100 Subject: [PATCH 20/21] =?UTF-8?q?-=20in=20HEADCUT=20si=20chiama=20la=20SLO?= =?UTF-8?q?TBYBLADE=20e=20non=20pi=C3=B9=20la=20FACEBYBLADE=20-=20in=20STR?= =?UTF-8?q?0003=20e=20SLOTBYBLADE=20modifiche=20al=20calcolo=20LeadIn=20/?= =?UTF-8?q?=20LeadOut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Strategies/Standard/HEADCUT/HEADCUT.lua | 50 +++++++------------------ Strategies/Standard/STR0003/STR0003.lua | 4 +- Strategies/Standard/STR0005/STR0005.lua | 1 + StrategyLibs/SLOTBYBLADE.lua | 29 ++++++++------ 4 files changed, 33 insertions(+), 51 deletions(-) diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index 86e5964..adbd9d3 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -265,32 +265,24 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) if Strategy.sSplitStrategy.sTypeMachining == 'BladeSideSingle' then OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_BACK - OptionalParameters.sDepth = 0 -- TODO gestire lavorazione a cubetti local EdgeToMachine = GetEdgeToMachine( Proc, -Y_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) - Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeSideDouble' then + -- Taglio lato frontale OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex - -- Taglio lato frontale - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_BACK - OptionalParameters.sDepth = 0 - OptionalParameters.dRadialOffset = ( Part.dWidth - BeamData.CUT_EXTRA) / 2 + OptionalParameters.dDepthToMachine = Part.dWidth / 2 + BeamData.CUT_EXTRA_MIN -- TODO gestire lavorazione a cubetti local EdgeToMachine = GetEdgeToMachine( Proc, -Y_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) - Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) @@ -299,50 +291,38 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) Splitting = {} AuxiliaryData = {} OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_FRONT - OptionalParameters.sDepth = 0 - OptionalParameters.dRadialOffset = ( Part.dWidth - BeamData.CUT_EXTRA) / 2 + OptionalParameters.dDepthToMachine = Part.dWidth / 2 + BeamData.CUT_EXTRA_MIN -- TODO gestire lavorazione a cubetti EdgeToMachine = GetEdgeToMachine( Proc, Y_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) - Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeHorizontalSingle' then OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_DOWN - OptionalParameters.sDepth = 0 - OptionalParameters.dRadialOffset = -BeamData.CUT_EXTRA + OptionalParameters.dDepthToMachine = Part.dHeight + BeamData.CUT_EXTRA -- TODO gestire lavorazione a cubetti local EdgeToMachine = GetEdgeToMachine( Proc, Z_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) - Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeHorizontalDouble' then + -- Taglio lato frontale OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex - -- Taglio lato frontale - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_DOWN - OptionalParameters.sDepth = 0 local dExtraMaxMat = ( Strategy.sSplitStrategy[1].ToolInfo.dMaxMatBladeFromTop + Strategy.sSplitStrategy[2].ToolInfo.dMaxMatBladeFromDown - Part.dHeight - BeamData.CUT_EXTRA) / 2 - OptionalParameters.dRadialOffset = Part.dHeight - Strategy.sSplitStrategy[1].ToolInfo.dMaxMatBladeFromTop + dExtraMaxMat + OptionalParameters.dDepthToMachine = Strategy.sSplitStrategy[1].ToolInfo.dMaxMatBladeFromTop - dExtraMaxMat -- TODO gestire lavorazione a cubetti local EdgeToMachine = GetEdgeToMachine( Proc, Z_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) - Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) @@ -351,16 +331,12 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) Splitting = {} AuxiliaryData = {} OptionalParameters.nToolIndex = Strategy.sSplitStrategy[2].ToolInfo.nToolIndex - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_TOP - OptionalParameters.sDepth = 0 - OptionalParameters.dRadialOffset = Part.dHeight - Strategy.sSplitStrategy[2].ToolInfo.dMaxMatBladeFromDown + dExtraMaxMat + OptionalParameters.dDepthToMachine = Strategy.sSplitStrategy[2].ToolInfo.dMaxMatBladeFromDown - dExtraMaxMat -- TODO gestire lavorazione a cubetti EdgeToMachine = GetEdgeToMachine( Proc, -Z_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) - Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index 955d69a..af49780 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -210,8 +210,8 @@ function Blade.AddMachiningAllSteps( Proc, Cutting, AuxiliaryData) AuxiliaryData.Clones[i].LeadOut = {} AuxiliaryData.Clones[i].dRadialOffset = dOriginalRadialOffset + Cutting.HorizontalSteps.dStep * ( Cutting.HorizontalSteps.nCount - i) -- update distanza perpendicolare attacco per contemplare l'offset applicato - AuxiliaryData.Clones[i].LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - AuxiliaryData.Clones[i].dRadialOffset - AuxiliaryData.Clones[i].LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - AuxiliaryData.Clones[i].dRadialOffset + AuxiliaryData.Clones[i].LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - AuxiliaryData.Clones[i].dRadialOffset + dOriginalRadialOffset + AuxiliaryData.Clones[i].LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - AuxiliaryData.Clones[i].dRadialOffset + dOriginalRadialOffset end bMachiningAdded = MachiningLib.AddNewMachining( Proc, Cutting, AuxiliaryData) diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 3a9df84..7dd786a 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -129,6 +129,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) if bFeatureHindersClamping or bLeaveWasteAttached then -- TODO valutare se estrapolare in funzione a sè stante in StrategyLibs + -- TODO verificare funzionamento con lama da sotto -- attenzione perchè se l'inclinazione della faccia la fa finire oltre lo spigolo questo riduce il massimo (come calcolare????) -- il FindBlade dovrà restituire di utilizzare sempre la lama sopra se l'angolo lo permette, ma avendo un'altezza massima (da macchina) oltre cui il DownUp non sarà fattibile (evita collisioni tra asse e pezzo) diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua index f7ca131..7df816a 100644 --- a/StrategyLibs/SLOTBYBLADE.lua +++ b/StrategyLibs/SLOTBYBLADE.lua @@ -32,11 +32,11 @@ local function CalculateLeadInOut( Machining, EdgeToMachine) LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 if AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then - LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC + LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset + LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset else - LeadIn.dPerpDistance = BeamData.CUT_SIC - LeadOut.dPerpDistance = BeamData.CUT_SIC + LeadIn.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset + LeadOut.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset end LeadIn.dElevation = 0 LeadOut.dElevation = 0 @@ -106,6 +106,7 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false local bOppositeToolDirection = OptionalParameters.bOppositeToolDirection or false local sDepth = OptionalParameters.sDepth or 0 + local nToolIndex = OptionalParameters.nToolIndex -- lunghezze e punti caratteristici della lavorazione e del lato lavorato Cutting.dLengthToMachine = EdgeToMachine.dLength @@ -123,14 +124,18 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- -- ricerca utensile - local ToolSearchParameters = {} - ToolSearchParameters.dElevation = EdgeToMachine.dElevation - ToolSearchParameters.vtToolDirection = Cutting.vtToolDirection - ToolSearchParameters.bAllowTopHead = true - ToolSearchParameters.bAllowBottomHead = false - ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade - local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) - Cutting.nToolIndex = ToolInfo.nToolIndex + if nToolIndex then + Cutting.nToolIndex = nToolIndex + else + local ToolSearchParameters = {} + ToolSearchParameters.dElevation = dDepthToMachine + ToolSearchParameters.vtToolDirection = Cutting.vtToolDirection + ToolSearchParameters.bAllowTopHead = true + ToolSearchParameters.bAllowBottomHead = false + ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade + local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) + Cutting.nToolIndex = ToolInfo.nToolIndex + end Cutting.nType = MCH_OY.MILLING if not TOOLS[Cutting.nToolIndex].sName then Cutting.sMessage = 'Blade not found' From 084b6758a3ba23efc4edb6e385ddd6715e3e4ab7 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 28 Jan 2025 10:54:16 +0100 Subject: [PATCH 21/21] - SLOTBYBLADE rinominata FACEBYBLADE; vecchia FACEBYBLADE eliminata - SLOTBYCHAINSAW rinominata FACEBYCHAINSAW - in SPLITCUT modifiche alle chiamate di FACEBYBLADE per contemplare la nuova funzione - in STR0005 - codolo l'utensile non viene passato ma viene lasciato scegliere alla FACEBYBLADE --- Strategies/Standard/HEADCUT/HEADCUT.lua | 51 ++- Strategies/Standard/STR0003/STR0003.lua | 60 ++-- Strategies/Standard/STR0004/STR0004.lua | 22 +- Strategies/Standard/STR0005/STR0005.lua | 59 ++-- StrategyLibs/FACEBYBLADE.lua | 309 ++++++++++++++---- ...{SLOTBYCHAINSAW.lua => FACEBYCHAINSAW.lua} | 8 +- StrategyLibs/SLOTBYBLADE.lua | 295 ----------------- StrategyLibs/SPLITCUT.lua | 38 +-- 8 files changed, 352 insertions(+), 490 deletions(-) rename StrategyLibs/{SLOTBYCHAINSAW.lua => FACEBYCHAINSAW.lua} (98%) delete mode 100644 StrategyLibs/SLOTBYBLADE.lua diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index adbd9d3..cc79320 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -16,7 +16,6 @@ local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base local FaceByBlade = require('FACEBYBLADE') -local SlotByBlade = require('SLOTBYBLADE') -- Tabella per definizione modulo local HEADCUT = {} @@ -252,7 +251,7 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) local Splitting = {} local AuxiliaryData = {} - Strategy.sSplitStrategy = GetSplitStrategy( Proc, Part) + Strategy.SplitStrategy = GetSplitStrategy( Proc, Part) if bAddMachining then -- inserimento smussi su spigoli del taglio if Strategy.Parameters.bMakeChamfer then @@ -262,27 +261,27 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) local OptionalParameters = {} -- applico le lavorazioni ---------------------------------------------------------------------------------- - if Strategy.sSplitStrategy.sTypeMachining == 'BladeSideSingle' then + if Strategy.SplitStrategy.sTypeMachining == 'BladeSideSingle' then OptionalParameters = {} - OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex + OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex -- TODO gestire lavorazione a cubetti local EdgeToMachine = GetEdgeToMachine( Proc, -Y_AX()) - Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- - elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeSideDouble' then + elseif Strategy.SplitStrategy.sTypeMachining == 'BladeSideDouble' then -- Taglio lato frontale OptionalParameters = {} - OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex + OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex OptionalParameters.dDepthToMachine = Part.dWidth / 2 + BeamData.CUT_EXTRA_MIN -- TODO gestire lavorazione a cubetti local EdgeToMachine = GetEdgeToMachine( Proc, -Y_AX()) - Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) @@ -290,39 +289,39 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) OptionalParameters = {} Splitting = {} AuxiliaryData = {} - OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex + OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex OptionalParameters.dDepthToMachine = Part.dWidth / 2 + BeamData.CUT_EXTRA_MIN -- TODO gestire lavorazione a cubetti EdgeToMachine = GetEdgeToMachine( Proc, Y_AX()) - Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- - elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeHorizontalSingle' then + elseif Strategy.SplitStrategy.sTypeMachining == 'BladeHorizontalSingle' then OptionalParameters = {} - OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex + OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex OptionalParameters.dDepthToMachine = Part.dHeight + BeamData.CUT_EXTRA -- TODO gestire lavorazione a cubetti local EdgeToMachine = GetEdgeToMachine( Proc, Z_AX()) - Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- - elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeHorizontalDouble' then + elseif Strategy.SplitStrategy.sTypeMachining == 'BladeHorizontalDouble' then -- Taglio lato frontale OptionalParameters = {} - OptionalParameters.nToolIndex = Strategy.sSplitStrategy[1].ToolInfo.nToolIndex - local dExtraMaxMat = ( Strategy.sSplitStrategy[1].ToolInfo.dMaxMatBladeFromTop + Strategy.sSplitStrategy[2].ToolInfo.dMaxMatBladeFromDown - Part.dHeight - BeamData.CUT_EXTRA) / 2 - OptionalParameters.dDepthToMachine = Strategy.sSplitStrategy[1].ToolInfo.dMaxMatBladeFromTop - dExtraMaxMat + OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex + local dExtraMaxMat = ( Strategy.SplitStrategy[1].ToolInfo.dMaxMatBladeFromTop + Strategy.SplitStrategy[2].ToolInfo.dMaxMatBladeFromDown - Part.dHeight - BeamData.CUT_EXTRA_MIN) / 2 + OptionalParameters.dDepthToMachine = Strategy.SplitStrategy[1].ToolInfo.dMaxMatBladeFromTop - dExtraMaxMat -- TODO gestire lavorazione a cubetti local EdgeToMachine = GetEdgeToMachine( Proc, Z_AX()) - Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) @@ -330,29 +329,29 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) OptionalParameters = {} Splitting = {} AuxiliaryData = {} - OptionalParameters.nToolIndex = Strategy.sSplitStrategy[2].ToolInfo.nToolIndex - OptionalParameters.dDepthToMachine = Strategy.sSplitStrategy[2].ToolInfo.dMaxMatBladeFromDown - dExtraMaxMat + OptionalParameters.nToolIndex = Strategy.SplitStrategy[2].ToolInfo.nToolIndex + OptionalParameters.dDepthToMachine = Strategy.SplitStrategy[2].ToolInfo.dMaxMatBladeFromDown - dExtraMaxMat -- TODO gestire lavorazione a cubetti EdgeToMachine = GetEdgeToMachine( Proc, -Z_AX()) - Splitting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) + Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- - elseif Strategy.sSplitStrategy.sTypeMachining == 'ChainSawHorizontal' then + elseif Strategy.SplitStrategy.sTypeMachining == 'ChainSawHorizontal' then ; -- TODO ---------------------------------------------------------------------------------- - elseif Strategy.sSplitStrategy.sTypeMachining == 'ChainSawSideSingle' then + elseif Strategy.SplitStrategy.sTypeMachining == 'ChainSawSideSingle' then ; -- TODO ---------------------------------------------------------------------------------- - elseif Strategy.sSplitStrategy.sTypeMachining == 'ChainSawSideDouble' then + elseif Strategy.SplitStrategy.sTypeMachining == 'ChainSawSideDouble' then ; -- TODO ---------------------------------------------------------------------------------- - elseif Strategy.sSplitStrategy.sTypeMachining == 'ChainSawPlusBlade' then + elseif Strategy.SplitStrategy.sTypeMachining == 'ChainSawPlusBlade' then ; -- TODO ---------------------------------------------------------------------------------- - elseif Strategy.sSplitStrategy.sTypeMachining == 'Mill' then + elseif Strategy.SplitStrategy.sTypeMachining == 'Mill' then ; -- TODO ---------------------------------------------------------------------------------- end diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index af49780..1265c62 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -19,8 +19,8 @@ local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base -local SlotByBlade = require( 'SLOTBYBLADE') -local SlotByChainSaw = require( 'SLOTBYCHAINSAW') +local FaceByBlade = require( 'FACEBYBLADE') +local FaceByChainsaw = require( 'FACEBYCHAINSAW') -- Tabella per definizione modulo local STR0003 = {} @@ -297,15 +297,15 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) local OptionalParameters = { bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} if Proc.Topology.sFamily == 'Tunnel' then OptionalParameters.bOppositeToolDirection = true - Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Cutting = FaceByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) else - Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Cutting = FaceByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) end Blade.AddResult( Cutting) -- lato opposto del tunnel if Proc.Topology.sFamily == 'Tunnel' then OptionalParameters.bOppositeToolDirection = true - Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) + Cutting = FaceByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Blade.AddResult( Cutting) else -- se la lama non è arrivata sul fondo e c'è almeno un lato aperto va lavorato @@ -313,13 +313,13 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- eventuale lavorazione di lama - lato della tasca da cui inizia la lavorazione if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then OptionalParameters.bOppositeToolDirection = true - Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Cutting = FaceByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Blade.AddResult( Cutting) end -- eventuale lavorazione di lama - lato della tasca in cui finisce la lavorazione if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then OptionalParameters.bOppositeToolDirection = true - Cutting = SlotByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Cutting = FaceByBlade.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Blade.AddResult( Cutting) end -- la lama è arrivata sul fondo e tasca passante, non servono ulteriori lavorazioni @@ -383,18 +383,18 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if not Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) end if not Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Bottom[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) end -- si lavora tutto il fondo else local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) end -- ancora materiale residuo - se possibile si lavora dal lato @@ -403,10 +403,10 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if ( #Blade.Result.Side > 0) and Blade.Result.Side[1].dResidualDepth < 10 * GEO.EPS_SMALL then if ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif ( Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[1].dBladeMarkLength - 10 * GEO.EPS_SMALL) then local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end -- si lavora tutto il lato else @@ -418,10 +418,10 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then local OptionalParameters = { dMaxElev = dBladeResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end end Chainsaw.AddResult( Mortising) @@ -430,7 +430,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if Blade.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL then -- si lavora tutto il fondo local OptionalParameters = { dMaxElev = Blade.Result.Bottom[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavorano i lati if Chainsaw.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL then @@ -439,16 +439,16 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) ( Blade.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2].dLength > 3 * Blade.Result.Side[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then local OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Side[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Side[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può eliminare la lavorazione del fondo if Chainsaw.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL then @@ -458,17 +458,17 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- si lavora tutto il lato else local OptionalParameters = { dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Side[1].bIsApplicable = false local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Side[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo if Chainsaw.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL then @@ -484,43 +484,43 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) ( Blade.Result.Opposite[2].dResidualDepth < 10 * GEO.EPS_SMALL and Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2].dLength > 3 * Blade.Result.Opposite[2].dBladeMarkLength - 10 * GEO.EPS_SMALL) then local OptionalParameters = { sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} OptionalParameters = { sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL or Chainsaw.Result.Opposite[2].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false Chainsaw.Result.Opposite[2].bIsApplicable = false local OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[1].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'Start', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} OptionalParameters = { bStopAtHalfElevation = true, sSideToMachine = 'End', dLengthToMachine = Blade.Result.Opposite[2].dBladeMarkLength, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end else local OptionalParameters = { dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false local OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[1].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} OptionalParameters = { bStopAtHalfElevation = true, dMaxElev = Blade.Result.Opposite[2].dResidualDepth + BeamData.CUT_EXTRA, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end end diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua index 7691488..923ba9f 100644 --- a/Strategies/Standard/STR0004/STR0004.lua +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -19,7 +19,7 @@ local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base -local SlotByChainSaw = require( 'SLOTBYCHAINSAW') +local FaceByChainsaw = require( 'FACEBYCHAINSAW') -- Tabella per definizione modulo local STR0004 = {} @@ -185,38 +185,38 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} if Proc.Topology.sName == 'Groove-4-Blind' or Proc.Topology.sName == 'Pocket-5-Blind' then -- si lavora tutto il fondo - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) -- materiale residuo - se possibile si lavora dal lato if ( Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].dResidualDepth > 10 * GEO.EPS_SMALL or not Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].bIsApplicable) and #Proc.MainFaces.SideFaces == 1 then if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsStartOpen then OptionalParameters.bOppositeToolDirection = true - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) elseif Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.bIsEndOpen then OptionalParameters.bOppositeToolDirection = true - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) end Chainsaw.AddResult( Mortising) end elseif Proc.Topology.sName == 'Groove-3-Through' then -- si lavora tutto il fondo local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge, OptionalParameters) Chainsaw.AddResult( Mortising) -- materiale residuo - si lavorano i lati if ( Chainsaw.Result.Bottom[1].dResidualDepth > 10 * GEO.EPS_SMALL or not Chainsaw.Result.Bottom[#Chainsaw.Result.Bottom].bIsApplicable) then local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) -- ancora materiale residuo - si lavora da entrambi i lati if Chainsaw.Result.Side[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Side[1].bIsApplicable = false local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) -- lavorando dai due lati non c'è materiale residuo - si può disabilitare la lavorazione del fondo if Chainsaw.Result.Side[2].dResidualDepth < 10 * GEO.EPS_SMALL then @@ -226,16 +226,16 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) end elseif Proc.Topology.sName == 'Tunnel-4-Through' then local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - Mortising = SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + Mortising = FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) if Chainsaw.Result.Opposite[1].dResidualDepth > 10 * GEO.EPS_SMALL then Chainsaw.Result.Opposite[1].bIsApplicable = false local OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) + FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1], OptionalParameters) Chainsaw.AddResult( Mortising) OptionalParameters = {} OptionalParameters = { bStopAtHalfElevation = true, dExtendAfterTail = dExtendAfterTail, dPocketHeight = dPocketHeight, bOppositeToolDirection = true, bIsSplitFeature = bIsSplitFeature} - SlotByChainSaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) + FaceByChainsaw.Make( Proc, Part, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2], OptionalParameters) Chainsaw.AddResult( Mortising) end end diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 7dd786a..311bee6 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -10,7 +10,7 @@ local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base local BladeToWaste = require( 'BLADETOWASTE') -local SlotByBlade = require( 'SLOTBYBLADE') +local FaceByBlade = require( 'FACEBYBLADE') -- Tabella per definizione modulo local STR0005 = {} @@ -125,7 +125,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) local bLeaveWasteAttached = Strategy.Parameters.sCuttingStrategy == 'LEAVE_WASTE_ATTACHED' local bFeatureHindersClamping = FeatureLib.IsMachiningLong( max( dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN}) local Cutting = {} - local MRRParametersBlade = {} + local dMRRBlade = 0 if bFeatureHindersClamping or bLeaveWasteAttached then -- TODO valutare se estrapolare in funzione a sè stante in StrategyLibs @@ -133,6 +133,9 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) -- attenzione perchè se l'inclinazione della faccia la fa finire oltre lo spigolo questo riduce il massimo (come calcolare????) -- il FindBlade dovrà restituire di utilizzare sempre la lama sopra se l'angolo lo permette, ma avendo un'altezza massima (da macchina) oltre cui il DownUp non sarà fattibile (evita collisioni tra asse e pezzo) + local Cutting1 = {} + local Cutting2 = {} + -- si trovano i lati da lavorare local EdgesSorted = {} for i = 1, #Proc.Faces[1].Edges do @@ -142,30 +145,6 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) local dDepthToMachine = EdgesSorted[1].dElevation / 2 - Strategy.Parameters.dStripWidth / 2 - -- ricerca utensile - local ToolSearchParameters = {} - ToolSearchParameters.dElevation = dDepthToMachine - ToolSearchParameters.vtToolDirection = EdgesSorted[1].vtN - ToolSearchParameters.bAllowTopHead = true - ToolSearchParameters.bAllowBottomHead = true - ToolSearchParameters.bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade - local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) - Cutting.nToolIndex = ToolInfo.nToolIndex - Cutting.nType = MCH_OY.MILLING - if not TOOLS[Cutting.nToolIndex].sName then - Cutting.sMessage = 'Blade not found' - Cutting.bIsApplicable = false - EgtOutLog( Cutting.sMessage) - return Cutting, EdgesSorted[1].dElevation - end - - -- parametri per il calcolo della velocità di asportazione - MRRParametersBlade = { - dStep = min( TOOLS[Cutting.nToolIndex].dStep, EdgesSorted[1].dElevation), - dSideStep = TOOLS[Cutting.nToolIndex].dThickness, - dFeed = TOOLS[Cutting.nToolIndex].Feeds.dFeed - } - -- eventuali punti di spezzatura local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) local bIsSplitFeature = false @@ -174,12 +153,12 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) end -- primo lato - local OptionalParameters = { dDepthToMachine = dDepthToMachine, nToolIndex = Cutting.nToolIndex, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail} - Cutting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[1], OptionalParameters) - Blade.AddResult( Cutting) + local OptionalParameters = { dDepthToMachine = dDepthToMachine, bIsSplitFeature = bIsSplitFeature, dExtendAfterTail = dExtendAfterTail} + Cutting1 = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[1], OptionalParameters) + Blade.AddResult( Cutting1) -- secondo lato - Cutting = SlotByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[2], OptionalParameters) - Blade.AddResult( Cutting) + Cutting2 = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgesSorted[2], OptionalParameters) + Blade.AddResult( Cutting2) -- lavorazioni raggruppate in unica lista Blade.Result.Sorted = {} @@ -196,6 +175,22 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) table.sort( Blade.Result.Sorted, SortMachiningsBySegment) + -- parametri per il calcolo della velocità di asportazione + MRRParameters1 = { + dStep = TOOLS[Cutting1.nToolIndex].dThickness, + dSideStep = min( TOOLS[Cutting1.nToolIndex].dSideStep, dDepthToMachine), + dFeed = TOOLS[Cutting1.nToolIndex].Feeds.dFeed} + + MRRParameters2 = { + dStep = TOOLS[Cutting2.nToolIndex].dThickness, + dSideStep = min( TOOLS[Cutting2.nToolIndex].dSideStep, dDepthToMachine), + dFeed = TOOLS[Cutting2.nToolIndex].Feeds.dFeed} + + local dMRRBlade1 = MachiningLib.GetToolMRR( MRRParameters1) + local dMRRBlade2 = MachiningLib.GetToolMRR( MRRParameters2) + dMRRBlade = ( dMRRBlade1 + dMRRBlade2) / 2 + + Cutting = Cutting2 -- se la lavorazione con codolo fallisce o non è possibile si proseguirà a quella con cubetti end @@ -219,6 +214,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Blade.Result.Sorted[i].sMessage end end + -- TODO calcolo migliore area lavorata; se ho il codolo ha senso l'incompleta? se incompleta con codolo faccio i cubetti?? if nIsApplicableCount > 0 then if Cutting.dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then Strategy.Result.sStatus = 'Completed' @@ -232,7 +228,6 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) end Strategy.Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dFinalCompletionPercentage) Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Blade') - local dMRRBlade = MachiningLib.GetToolMRR( MRRParametersBlade) Strategy.Result.dMRR = dMRRBlade return bAreAllMachiningsAdded, Strategy.Result diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index d1c4e15..3c91c15 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -1,7 +1,7 @@ -- Strategia: FACEBYBLADE -- Descrizione --- Strategia di base per la lavorazione di una faccia con lama --- Feature: tutte +-- Strategia di base per la lavorazione delle slot o tasche con lama +-- Feature: tipo lapjoint -- carico librerie local BeamLib = require( 'BeamLib') @@ -11,9 +11,18 @@ local MachiningLib = require( 'MachiningLib') -- Tabella per definizione modulo local FACEBYBLADE = {} - ------------------------------------------------------------------------------------------------------------- -local function CalculateLeadInOut( EdgeToMachine) + +local function CalculateLeadInOut( Machining, EdgeToMachine) + -- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom) + + -- si determina l'eventuale riduzione da applicare in caso di inizio o fine chiusi + local dAddLengthToReduce = sqrt( Machining.dDepthToMachine * TOOLS[Machining.nToolIndex].dDiameter - Machining.dDepthToMachine * Machining.dDepthToMachine) + + if Machining.bInvert then + Machining.bIsStartClosed, Machining.bIsEndClosed = Machining.bIsEndClosed, Machining.bIsStartClosed + end + local LeadIn = {} local LeadOut = {} LeadIn.dStartAddLength = 0 @@ -22,93 +31,271 @@ local function CalculateLeadInOut( EdgeToMachine) LeadOut.nType = MCH_MILL_LI.LINEAR LeadIn.dTangentDistance = 0 LeadOut.dTangentDistance = 0 - -- elevazione sempre in negativo - LeadIn.dPerpDistance = BeamData.CUT_SIC + EdgeToMachine.dElevation - LeadOut.dPerpDistance = BeamData.CUT_SIC + EdgeToMachine.dElevation + if AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then + LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset + LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset + else + LeadIn.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset + LeadOut.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset + end LeadIn.dElevation = 0 LeadOut.dElevation = 0 LeadIn.dCompLength = 0 LeadOut.dCompLength = 0 - LeadIn.dStartAddLength = BeamData.CUT_EXTRA - LeadOut.dEndAddLength = BeamData.CUT_EXTRA + if Machining.bIsStartClosed and Machining.bIsEndClosed then + LeadIn.dStartAddLength = -dAddLengthToReduce + LeadOut.dEndAddLength = -dAddLengthToReduce + elseif Machining.bIsStartClosed then + LeadIn.dStartAddLength = -dAddLengthToReduce + -- eventuale correzione per accorciamento maggiore di larghezza tasca + LeadOut.dEndAddLength = max( -LeadIn.dStartAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) + elseif Machining.bIsEndClosed then + LeadOut.dEndAddLength = -dAddLengthToReduce + -- eventuale correzione per accorciamento maggiore di larghezza tasca + LeadIn.dStartAddLength = max( -LeadOut.dEndAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) + else + LeadIn.dStartAddLength = BeamData.CUT_EXTRA + LeadOut.dEndAddLength = BeamData.CUT_EXTRA + end return LeadIn, LeadOut end -------------------------------------------------------------------------------------------------------------- --- TODO da sistemare + local function GetSCC( vtMachiningDirection) + -- TODO implementare SCC come per FacesBySaw local nSCC = MCH_SCC.NONE - - if vtMachiningDirection:getZ() < -0.9 then - nSCC = MCH_SCC.ADIR_ZM - elseif vtMachiningDirection:getZ() > 0.9 then + if AreSameVectorApprox( vtMachiningDirection, Z_AX()) then nSCC = MCH_SCC.ADIR_ZP - elseif vtMachiningDirection:getY() < -0.707 then - nSCC = MCH_SCC.ADIR_YM - elseif vtMachiningDirection:getY() > 0.707 then + elseif AreOppositeVectorApprox( vtMachiningDirection, Z_AX()) then + nSCC = MCH_SCC.ADIR_ZM + elseif AreSameVectorApprox( vtMachiningDirection, Y_AX()) then nSCC = MCH_SCC.ADIR_YP - elseif vtMachiningDirection:getX() < -0.707 then - nSCC = MCH_SCC.ADIR_XM - elseif vtMachiningDirection:getX() > 0.707 then + elseif AreOppositeVectorApprox( vtMachiningDirection, Y_AX()) then + nSCC = MCH_SCC.ADIR_YM + elseif AreSameVectorApprox( vtMachiningDirection, X_AX()) then nSCC = MCH_SCC.ADIR_XP + elseif AreOppositeVectorApprox( vtMachiningDirection, X_AX()) then + nSCC = MCH_SCC.ADIR_XM end return nSCC end -------------------------------------------------------------------------------------------------------------- --- TODO da sistemare + +-- TODO calcolo area lavorata per completamento function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalParameters) local Cutting = {} + Cutting.bIsApplicable = true + Cutting.dDepthToMachine = 0 + Cutting.sMessage = '' + Cutting.idProc = Proc.id + Cutting.dResidualDepth = EdgeToMachine.dElevation + Cutting.dBladeMarkLength = 0 + Cutting.sEdgeType = EdgeToMachine.sType + Cutting.nFeatureSegment = 1 - local vtMachiningDirection = EdgeToMachine.vtN - local vtN = Proc.Faces[FaceToMachine.id+1].vtN - Cutting.sDepth = OptionalParameters.sDepth or 0 - Cutting.dLongitudinalOffset = OptionalParameters.dLongitudinalOffset or 0 - Cutting.dRadialOffset = OptionalParameters.dRadialOffset or 0 + -- parametri opzionali + if not OptionalParameters then + OptionalParameters = {} + end + local bForceLongcutBlade = OptionalParameters.bForceLongcutBlade or false + local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 + local dPocketHeight = OptionalParameters.dPocketHeight or 0 + local dDepthToMachine = min( OptionalParameters.dDepthToMachine or EdgeToMachine.dElevation, EdgeToMachine.dElevation) + local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false + local bOppositeToolDirection = OptionalParameters.bOppositeToolDirection or false + local sDepth = OptionalParameters.sDepth or 0 + local nToolIndex = OptionalParameters.nToolIndex + local dLongitudinalOffset = OptionalParameters.dLongitudinalOffset or 0 + if OptionalParameters.dPocketHeight then + dLongitudinalOffset = 0 + end + local sUserNotes = OptionalParameters.sUserNotes or '' - Cutting.nType = MCH_MY.MILLING - Cutting.nToolIndex = OptionalParameters.nToolIndex - Cutting.Geometry = {{ Proc.id, FaceToMachine.id}} - Cutting.id = Proc.id - Cutting.vtToolDirection = vtMachiningDirection - - -- TODO se l'utensile non arriva dai parametri opzionali va cercato!! - - -- ===== calcolo LeadIn/out ===== - if OptionalParameters.LeadIn and OptionalParameters.LeadOut then - Cutting.LeadIn, Cutting.LeadOut = OptionalParameters.LeadIn, OptionalParameters.LeadOut + -- lunghezze e punti caratteristici della lavorazione e del lato lavorato + Cutting.dLengthToMachine = EdgeToMachine.dLength + Cutting.dEdgeLength = EdgeToMachine.dLength + if bOppositeToolDirection then + Cutting.vtToolDirection = -EdgeToMachine.vtN else - Cutting.LeadIn, Cutting.LeadOut = CalculateLeadInOut( EdgeToMachine) + Cutting.vtToolDirection = EdgeToMachine.vtN + end + Cutting.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN + -- TODO conviene spostare questi calcoli nel FaceData? + Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -Cutting.vtToolDirection, GDB_ID.ROOT) + local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2) + Cutting.dLengthOnX = b3BoxEdge:getDimX() + -- + + -- ricerca utensile + if nToolIndex then + Cutting.nToolIndex = nToolIndex + else + local ToolSearchParameters = {} + ToolSearchParameters.dElevation = dDepthToMachine + ToolSearchParameters.vtToolDirection = Cutting.vtToolDirection + ToolSearchParameters.bAllowTopHead = true + -- TODO bisognerà implementare anche la lama da sotto + ToolSearchParameters.bAllowBottomHead = false + ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade + local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) + Cutting.nToolIndex = ToolInfo.nToolIndex + end + Cutting.nType = MCH_OY.MILLING + if not TOOLS[Cutting.nToolIndex].sName then + Cutting.sMessage = 'Blade not found' + Cutting.bIsApplicable = false + EgtOutLog( Cutting.sMessage) + return Cutting, EdgeToMachine.dElevation end - -- ===== scelta soluzione braccio C del motore ===== - Cutting.nSCC = GetSCC( vtMachiningDirection) - - -- ===== parametri da settare in UserNotes ===== - Cutting.nFaceuse = OptionalParameters.nFaceuse - Cutting.sUserNotes = EgtSetValInNotes( Cutting.sUserNotes, 'VtFaceUse', vtMachiningDirection) - if OptionalParameters.sUserNotes then - Cutting.sUserNotes = Cutting.sUserNotes .. OptionalParameters.sUserNotes + -- verifica dimensioni tasca compatibili + -- se tasca meno spessa della lama la strategia non è applicabile + if OptionalParameters.dPocketHeight and ( TOOLS[Cutting.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL) then + Cutting.sMessage = 'Pocket too narrow for blade thickness' + Cutting.bIsApplicable = false + EgtOutLog( Cutting.sMessage) + return Cutting, EdgeToMachine.dElevation end - - -- ===== scelta senso di lavorazione ===== - local bIsSawCCW = TOOLS[Cutting.nToolIndex].bIsCCW - local bInvert - -- se la lama ruota in senso antiorario inverto la direzione di lavorazione, per avere rotazione lama opposta a avanzamento - if bInvert == nil then - bInvert = ( not bIsSawCCW) - if bIsSawCCW then - bInvert = (( Cutting.nFaceuse == MCH_MILL_FU.ORTHO_FRONT and vtN:getX() < 0) or ( Cutting.nFaceuse == MCH_MILL_FU.ORTHO_BACK and vtN:getX() > 0)) - else - bInvert = (( Cutting.nFaceuse == MCH_MILL_FU.ORTHO_FRONT and vtN:getX() > 0) or ( Cutting.nFaceuse == MCH_MILL_FU.ORTHO_BACK and vtN:getX() < 0)) + if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then + -- se tasca più stretta della lama la strategia non è applicabile + 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 + + -- parametri della lavorazione + -- profondità (parametro DEPTH) + Cutting.sDepth = sDepth + -- inizio e fine aperti o chiusi + Cutting.bIsStartClosed = not EdgeToMachine.bIsStartOpen + Cutting.bIsEndClosed = not EdgeToMachine.bIsEndOpen + -- lato di lavoro e inversioni + if TOOLS[Cutting.nToolIndex].bIsCCW then + Cutting.nWorkside = MCH_MILL_WS.RIGHT + Cutting.bInvert = true + else + Cutting.nWorkside = MCH_MILL_WS.LEFT + Cutting.bInvert = false + end + if bOppositeToolDirection then + Cutting.bInvert = not Cutting.bInvert + end + -- TODO gestire lama da sotto e lama downUp + if FaceToMachine.vtN:getZ() < - 10 * GEO.EPS_SMALL then + Cutting.bToolInvert = true + Cutting.bInvert = not Cutting.bInvert + else + Cutting.bToolInvert = false + end + -- profondità da lavorare e offset radiale + if TOOLS[Cutting.nToolIndex].dMaxDepth > dDepthToMachine - 10 * GEO.EPS_SMALL then + -- TODO la depth dovrebbe essere quella del machining + Cutting.dDepthToMachine = dDepthToMachine + Cutting.dResidualDepth = 0 + if bOppositeToolDirection then + Cutting.dRadialOffset = -dDepthToMachine + else + Cutting.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine + end + else + Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].dMaxDepth - 1 + Cutting.dResidualDepth = EdgeToMachine.dElevation - Cutting.dDepthToMachine + if bOppositeToolDirection then + Cutting.dRadialOffset = -Cutting.dDepthToMachine + else + Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine + end + end + -- completamento + Cutting.dCompletionPercentage = 100 - Cutting.dResidualDepth / Cutting.dDepthToMachine + -- step verticale e offset longitudinale + Cutting.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, TOOLS[Cutting.nToolIndex].dThickness) + Cutting.Steps.nStepType = MCH_MILL_ST.ONEWAY + Cutting.dMaxElev = Cutting.Steps.dStep * Cutting.Steps.nCount - 10 * GEO.EPS_SMALL + if Cutting.bToolInvert and Cutting.Steps.nCount > 1 then + Cutting.dLongitudinalOffset = - dPocketHeight + else + Cutting.dLongitudinalOffset = dLongitudinalOffset + end + -- distanza di sicurezza + Cutting.dStartSafetyLength = 10 + -- overlap + Cutting.dOverlap = 0 + -- faceuse + if bOppositeToolDirection then + Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( -Cutting.vtToolDirection) + else + Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( Cutting.vtToolDirection) + end + -- SCC + Cutting.nSCC = GetSCC( Cutting.vtToolDirection) + -- asse bloccato + Cutting.sBlockedAxis = BeamLib.GetBlockedAxis( Cutting.nToolIndex, 'perpendicular', Part.b3Raw, FaceToMachine.vtN, EgtIf( FaceToMachine.vtN:getX() > 0, X_AX(), -X_AX())) + -- approccio e retrazione + Cutting.LeadIn, Cutting.LeadOut = CalculateLeadInOut( Cutting, EdgeToMachine) + -- eventuale step orizzontale + Cutting.HorizontalSteps = {} + if TOOLS[Cutting.nToolIndex].dSideStep then + Cutting.HorizontalSteps = MachiningLib.GetMachiningSteps( Cutting.dDepthToMachine, TOOLS[Cutting.nToolIndex].dSideStep) + else + Cutting.HorizontalSteps.nCount = 1 + Cutting.HorizontalSteps.dStep = 0 + end + -- lunghezza impronta lama + if Cutting.bIsStartClosed and Cutting.bIsEndClosed then + Cutting.dBladeMarkLength = abs( min( Cutting.LeadIn.dStartAddLength, Cutting.LeadOut.dEndAddLength)) + elseif Cutting.bIsStartClosed then + Cutting.dBladeMarkLength = abs( Cutting.LeadIn.dStartAddLength) + elseif Cutting.bIsEndClosed then + Cutting.dBladeMarkLength = abs( Cutting.LeadOut.dEndAddLength) + end + -- geometria + Cutting.Geometry = {{Cutting.idProc, FaceToMachine.id}} + -- note utente + Cutting.sUserNotes = sUserNotes + -- nome operazione + Cutting.sOperationName = 'Cut_' .. ( EgtGetName( Cutting.idProc) or tostring( Cutting.idProc)) .. '_' .. tostring( FaceToMachine.id + 1) + + -- se lavorazione aperta sulla coda, eventuali aggiustamenti + -- TODO valutare se fare funzione a parte + if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( Cutting.vtToolDirection:getX() < 0.707)) then + local dLengthOnX = Cutting.dLengthOnX + -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione + if bIsSplitFeature then + dLengthOnX = 0 + end + local bStartLeft = MachiningLib.StartsLeftSide( Cutting) + local dAddLengthLeftSide = Cutting.LeadOut.dEndAddLength + local dAddLengthToReduce = sqrt( Cutting.dDepthToMachine * TOOLS[Cutting.nToolIndex].dDiameter - Cutting.dDepthToMachine * Cutting.dDepthToMachine) + if bStartLeft then + dAddLengthLeftSide = Cutting.LeadIn.dStartAddLength + end + if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtN, Y_AX()) then + if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then + Cutting.sStage = 'AfterTail' + else + Cutting.bIsApplicable = false + end + elseif dAddLengthLeftSide + dAddLengthToReduce > dExtendAfterTail then + if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then + Cutting.sStage = 'AfterTail' + else + if bStartLeft then + Cutting.LeadIn.dStartAddLength = - dAddLengthToReduce + dExtendAfterTail + else + Cutting.LeadOut.dEndAddLength = - dAddLengthToReduce + dExtendAfterTail + end + end end end - Cutting.bInvert = bInvert - Cutting.nWorkside = EgtIf( bInvert, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) return Cutting + end ------------------------------------------------------------------------------------------------------------- diff --git a/StrategyLibs/SLOTBYCHAINSAW.lua b/StrategyLibs/FACEBYCHAINSAW.lua similarity index 98% rename from StrategyLibs/SLOTBYCHAINSAW.lua rename to StrategyLibs/FACEBYCHAINSAW.lua index fcd3dc3..facf6f8 100644 --- a/StrategyLibs/SLOTBYCHAINSAW.lua +++ b/StrategyLibs/FACEBYCHAINSAW.lua @@ -1,4 +1,4 @@ --- Strategia: SLOTBYCHAINSAW +-- Strategia: FACEBYCHAINSAW -- Descrizione -- Strategia di base per la lavorazione delle slot o tasche con sega a catena -- Feature: tipo lapjoint @@ -9,7 +9,7 @@ local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') -- Tabella per definizione modulo -local SLOTBYCHAINSAW = {} +local FACEBYCHAINSAW = {} ------------------------------------------------------------------------------------------------------------- @@ -48,7 +48,7 @@ end -- TODO calcolo area lavorata per completamento -function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalParameters) +function FACEBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalParameters) local Mortising = {} Mortising.bIsApplicable = true Mortising.dDepthToMachine = 0 @@ -258,4 +258,4 @@ end ------------------------------------------------------------------------------------------------------------- - return SLOTBYCHAINSAW \ No newline at end of file + return FACEBYCHAINSAW \ No newline at end of file diff --git a/StrategyLibs/SLOTBYBLADE.lua b/StrategyLibs/SLOTBYBLADE.lua deleted file mode 100644 index 7df816a..0000000 --- a/StrategyLibs/SLOTBYBLADE.lua +++ /dev/null @@ -1,295 +0,0 @@ --- Strategia: SLOTBYBLADE --- Descrizione --- Strategia di base per la lavorazione delle slot o tasche con lama --- Feature: tipo lapjoint - --- carico librerie -local BeamLib = require( 'BeamLib') -local BeamData = require( 'BeamData') -local MachiningLib = require( 'MachiningLib') - --- Tabella per definizione modulo -local SLOTBYBLADE = {} - -------------------------------------------------------------------------------------------------------------- - -local function CalculateLeadInOut( Machining, EdgeToMachine) - -- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom) - - -- si determina l'eventuale riduzione da applicare in caso di inizio o fine chiusi - local dAddLengthToReduce = sqrt( Machining.dDepthToMachine * TOOLS[Machining.nToolIndex].dDiameter - Machining.dDepthToMachine * Machining.dDepthToMachine) - - if Machining.bInvert then - Machining.bIsStartClosed, Machining.bIsEndClosed = Machining.bIsEndClosed, Machining.bIsStartClosed - end - - local LeadIn = {} - local LeadOut = {} - LeadIn.dStartAddLength = 0 - LeadOut.dEndAddLength = 0 - LeadIn.nType = MCH_MILL_LI.LINEAR - LeadOut.nType = MCH_MILL_LI.LINEAR - LeadIn.dTangentDistance = 0 - LeadOut.dTangentDistance = 0 - if AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then - LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset - LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - Machining.dRadialOffset - else - LeadIn.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset - LeadOut.dPerpDistance = BeamData.CUT_SIC - Machining.dRadialOffset - end - LeadIn.dElevation = 0 - LeadOut.dElevation = 0 - LeadIn.dCompLength = 0 - LeadOut.dCompLength = 0 - if Machining.bIsStartClosed and Machining.bIsEndClosed then - LeadIn.dStartAddLength = -dAddLengthToReduce - LeadOut.dEndAddLength = -dAddLengthToReduce - elseif Machining.bIsStartClosed then - LeadIn.dStartAddLength = -dAddLengthToReduce - -- eventuale correzione per accorciamento maggiore di larghezza tasca - LeadOut.dEndAddLength = max( -LeadIn.dStartAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) - elseif Machining.bIsEndClosed then - LeadOut.dEndAddLength = -dAddLengthToReduce - -- eventuale correzione per accorciamento maggiore di larghezza tasca - LeadIn.dStartAddLength = max( -LeadOut.dEndAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) - else - LeadIn.dStartAddLength = BeamData.CUT_EXTRA - LeadOut.dEndAddLength = BeamData.CUT_EXTRA - end - - return LeadIn, LeadOut -end - - -local function GetSCC( vtMachiningDirection) - -- TODO implementare SCC come per FacesBySaw - local nSCC = MCH_SCC.NONE - if AreSameVectorApprox( vtMachiningDirection, Z_AX()) then - nSCC = MCH_SCC.ADIR_ZP - elseif AreOppositeVectorApprox( vtMachiningDirection, Z_AX()) then - nSCC = MCH_SCC.ADIR_ZM - elseif AreSameVectorApprox( vtMachiningDirection, Y_AX()) then - nSCC = MCH_SCC.ADIR_YP - elseif AreOppositeVectorApprox( vtMachiningDirection, Y_AX()) then - nSCC = MCH_SCC.ADIR_YM - elseif AreSameVectorApprox( vtMachiningDirection, X_AX()) then - nSCC = MCH_SCC.ADIR_XP - elseif AreOppositeVectorApprox( vtMachiningDirection, X_AX()) then - nSCC = MCH_SCC.ADIR_XM - end - - return nSCC -end - - --- TODO calcolo area lavorata per completamento -function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalParameters) - local Cutting = {} - Cutting.bIsApplicable = true - Cutting.dDepthToMachine = 0 - Cutting.sMessage = '' - Cutting.idProc = Proc.id - Cutting.dResidualDepth = EdgeToMachine.dElevation - Cutting.dBladeMarkLength = 0 - Cutting.sEdgeType = EdgeToMachine.sType - Cutting.nFeatureSegment = 1 - - -- parametri opzionali - if not OptionalParameters then - OptionalParameters = {} - end - local bForceLongcutBlade = OptionalParameters.bForceLongcutBlade or false - local dExtendAfterTail = OptionalParameters.dExtendAfterTail or 10000 - local dPocketHeight = OptionalParameters.dPocketHeight or 0 - local dDepthToMachine = min( OptionalParameters.dDepthToMachine or EdgeToMachine.dElevation, EdgeToMachine.dElevation) - local bIsSplitFeature = OptionalParameters.bIsSplitFeature or false - local bOppositeToolDirection = OptionalParameters.bOppositeToolDirection or false - local sDepth = OptionalParameters.sDepth or 0 - local nToolIndex = OptionalParameters.nToolIndex - - -- lunghezze e punti caratteristici della lavorazione e del lato lavorato - Cutting.dLengthToMachine = EdgeToMachine.dLength - Cutting.dEdgeLength = EdgeToMachine.dLength - if bOppositeToolDirection then - Cutting.vtToolDirection = -EdgeToMachine.vtN - else - Cutting.vtToolDirection = EdgeToMachine.vtN - end - Cutting.vtEdgeDirection = EdgeToMachine.vtN ^ FaceToMachine.vtN - -- TODO conviene spostare questi calcoli nel FaceData? - Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -Cutting.vtToolDirection, GDB_ID.ROOT) - local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2) - Cutting.dLengthOnX = b3BoxEdge:getDimX() - -- - - -- ricerca utensile - if nToolIndex then - Cutting.nToolIndex = nToolIndex - else - local ToolSearchParameters = {} - ToolSearchParameters.dElevation = dDepthToMachine - ToolSearchParameters.vtToolDirection = Cutting.vtToolDirection - ToolSearchParameters.bAllowTopHead = true - ToolSearchParameters.bAllowBottomHead = false - ToolSearchParameters.bForceLongcutBlade = bForceLongcutBlade - local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) - Cutting.nToolIndex = ToolInfo.nToolIndex - end - Cutting.nType = MCH_OY.MILLING - if not TOOLS[Cutting.nToolIndex].sName then - Cutting.sMessage = 'Blade not found' - Cutting.bIsApplicable = false - EgtOutLog( Cutting.sMessage) - return Cutting, EdgeToMachine.dElevation - end - - -- verifica dimensioni tasca compatibili - -- se tasca meno spessa della lama la strategia non è applicabile - if OptionalParameters.dPocketHeight and ( TOOLS[Cutting.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL) then - Cutting.sMessage = 'Pocket too narrow for blade thickness' - Cutting.bIsApplicable = false - EgtOutLog( Cutting.sMessage) - return Cutting, EdgeToMachine.dElevation - end - if Proc.MainFaces and #( Proc.MainFaces.SideFaces) > 1 then - -- se tasca più stretta della lama la strategia non è applicabile - 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 - - -- parametri della lavorazione - -- profondità (parametro DEPTH) - Cutting.sDepth = sDepth - -- inizio e fine aperti o chiusi - Cutting.bIsStartClosed = not EdgeToMachine.bIsStartOpen - Cutting.bIsEndClosed = not EdgeToMachine.bIsEndOpen - -- lato di lavoro e inversioni - if TOOLS[Cutting.nToolIndex].bIsCCW then - Cutting.nWorkside = MCH_MILL_WS.RIGHT - Cutting.bInvert = true - else - Cutting.nWorkside = MCH_MILL_WS.LEFT - Cutting.bInvert = false - end - if bOppositeToolDirection then - Cutting.bInvert = not Cutting.bInvert - end - -- TODO gestire lama da sotto e lama downUp - if FaceToMachine.vtN:getZ() < - 10 * GEO.EPS_SMALL then - Cutting.bToolInvert = true - Cutting.bInvert = not Cutting.bInvert - else - Cutting.bToolInvert = false - end - -- profondità da lavorare e offset radiale - if TOOLS[Cutting.nToolIndex].dMaxDepth > dDepthToMachine - 10 * GEO.EPS_SMALL then - -- TODO la depth dovrebbe essere quella del machining - Cutting.dDepthToMachine = dDepthToMachine - Cutting.dResidualDepth = 0 - if bOppositeToolDirection then - Cutting.dRadialOffset = -dDepthToMachine - else - Cutting.dRadialOffset = EdgeToMachine.dElevation - dDepthToMachine - end - else - Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].dMaxDepth - 1 - Cutting.dResidualDepth = EdgeToMachine.dElevation - Cutting.dDepthToMachine - if bOppositeToolDirection then - Cutting.dRadialOffset = -Cutting.dDepthToMachine - else - Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine - end - end - -- completamento - Cutting.dCompletionPercentage = 100 - Cutting.dResidualDepth / Cutting.dDepthToMachine - -- step verticale e offset longitudinale - Cutting.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, TOOLS[Cutting.nToolIndex].dThickness) - Cutting.Steps.nStepType = MCH_MILL_ST.ONEWAY - Cutting.dMaxElev = Cutting.Steps.dStep * Cutting.Steps.nCount - 10 * GEO.EPS_SMALL - if Cutting.bToolInvert and Cutting.Steps.nCount > 1 then - Cutting.dLongitudinalOffset = - dPocketHeight - else - Cutting.dLongitudinalOffset = 0 - end - -- distanza di sicurezza - Cutting.dStartSafetyLength = 10 - -- overlap - Cutting.dOverlap = 0 - -- faceuse - if bOppositeToolDirection then - Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( -Cutting.vtToolDirection) - else - Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( Cutting.vtToolDirection) - end - -- SCC - Cutting.nSCC = GetSCC( Cutting.vtToolDirection) - -- asse bloccato - Cutting.sBlockedAxis = BeamLib.GetBlockedAxis( Cutting.nToolIndex, 'perpendicular', Part.b3Raw, FaceToMachine.vtN, EgtIf( FaceToMachine.vtN:getX() > 0, X_AX(), -X_AX())) - -- approccio e retrazione - Cutting.LeadIn, Cutting.LeadOut = CalculateLeadInOut( Cutting, EdgeToMachine) - -- eventuale step orizzontale - Cutting.HorizontalSteps = {} - if TOOLS[Cutting.nToolIndex].dSideStep then - Cutting.HorizontalSteps = MachiningLib.GetMachiningSteps( Cutting.dDepthToMachine, TOOLS[Cutting.nToolIndex].dSideStep) - else - Cutting.HorizontalSteps.nCount = 1 - Cutting.HorizontalSteps.dStep = 0 - end - -- lunghezza impronta lama - if Cutting.bIsStartClosed and Cutting.bIsEndClosed then - Cutting.dBladeMarkLength = abs( min( Cutting.LeadIn.dStartAddLength, Cutting.LeadOut.dEndAddLength)) - elseif Cutting.bIsStartClosed then - Cutting.dBladeMarkLength = abs( Cutting.LeadIn.dStartAddLength) - elseif Cutting.bIsEndClosed then - Cutting.dBladeMarkLength = abs( Cutting.LeadOut.dEndAddLength) - end - -- geometria - Cutting.Geometry = {{Cutting.idProc, FaceToMachine.id}} - -- nome operazione - Cutting.sOperationName = 'Cut_' .. ( EgtGetName( Cutting.idProc) or tostring( Cutting.idProc)) .. '_' .. tostring( FaceToMachine.id + 1) - - -- se lavorazione aperta sulla coda, eventuali aggiustamenti - -- TODO valutare se fare funzione a parte - if Proc.AffectedFaces.bLeft and ( EdgeToMachine.sType == 'Bottom' or ( Cutting.vtToolDirection:getX() < 0.707)) then - local dLengthOnX = Cutting.dLengthOnX - -- se feature splittata non si considera la lunghezza della feature per il check spostamento dopo separazione - if bIsSplitFeature then - dLengthOnX = 0 - end - local bStartLeft = MachiningLib.StartsLeftSide( Cutting) - local dAddLengthLeftSide = Cutting.LeadOut.dEndAddLength - local dAddLengthToReduce = sqrt( Cutting.dDepthToMachine * TOOLS[Cutting.nToolIndex].dDiameter - Cutting.dDepthToMachine * Cutting.dDepthToMachine) - if bStartLeft then - dAddLengthLeftSide = Cutting.LeadIn.dStartAddLength - end - if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtN, Y_AX()) then - if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then - Cutting.sStage = 'AfterTail' - else - Cutting.bIsApplicable = false - end - elseif dAddLengthLeftSide + dAddLengthToReduce > dExtendAfterTail then - if MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) then - Cutting.sStage = 'AfterTail' - else - if bStartLeft then - Cutting.LeadIn.dStartAddLength = - dAddLengthToReduce + dExtendAfterTail - else - Cutting.LeadOut.dEndAddLength = - dAddLengthToReduce + dExtendAfterTail - end - end - end - end - - return Cutting - -end - -------------------------------------------------------------------------------------------------------------- - - return SLOTBYBLADE \ No newline at end of file diff --git a/StrategyLibs/SPLITCUT.lua b/StrategyLibs/SPLITCUT.lua index 833f7b5..2116432 100644 --- a/StrategyLibs/SPLITCUT.lua +++ b/StrategyLibs/SPLITCUT.lua @@ -227,16 +227,12 @@ function SPLITCUT.Execute( Proc, Part, Strategy) Machining.AuxiliaryData = {} local OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_BACK - OptionalParameters.sDepth = 0 OptionalParameters.dLongitudinalOffset = Strategy.dOffset or 0 OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Split;', 'Cut;') Machining.AuxiliaryData.bIsSplitOrCut = true local EdgeToMachine = SPLITCUT.GetEdgeToMachine( Proc, -Y_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = SPLITCUT.CalculateLeadInOut( EdgeToMachine) Machining.Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) table.insert( Machinings, Machining) @@ -248,15 +244,11 @@ function SPLITCUT.Execute( Proc, Part, Strategy) local OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex -- Taglio lato frontale - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_BACK - OptionalParameters.sDepth = 0 OptionalParameters.dLongitudinalOffset = Strategy.dOffset or 0 - OptionalParameters.dRadialOffset = ( Part.dWidth - BeamData.CUT_EXTRA) / 2 + OptionalParameters.dDepthToMachine = Part.dWidth / 2 + BeamData.CUT_EXTRA_MIN OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Presplit;', 'Precut;') local EdgeToMachine = SPLITCUT.GetEdgeToMachine( Proc, -Y_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = SPLITCUT.CalculateLeadInOut( EdgeToMachine) Machining.Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) table.insert( Machinings, Machining) @@ -266,17 +258,13 @@ function SPLITCUT.Execute( Proc, Part, Strategy) Machining.AuxiliaryData = {} OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_FRONT - OptionalParameters.sDepth = 0 OptionalParameters.dLongitudinalOffset = Strategy.dOffset or 0 - OptionalParameters.dRadialOffset = ( Part.dWidth - BeamData.CUT_EXTRA) / 2 + OptionalParameters.dDepthToMachine = Part.dWidth / 2 + BeamData.CUT_EXTRA_MIN OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Split;', 'Cut;') Machining.AuxiliaryData.bIsSplitOrCut = true EdgeToMachine = SPLITCUT.GetEdgeToMachine( Proc, Y_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = SPLITCUT.CalculateLeadInOut( EdgeToMachine) Machining.Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) table.insert( Machinings, Machining) ---------------------------------------------------------------------------------- @@ -286,38 +274,30 @@ function SPLITCUT.Execute( Proc, Part, Strategy) Machining.AuxiliaryData = {} local OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_DOWN - OptionalParameters.sDepth = 0 OptionalParameters.dLongitudinalOffset = Strategy.dOffset or 0 - OptionalParameters.dRadialOffset = -BeamData.CUT_EXTRA + OptionalParameters.dDepthToMachine = Part.dHeight + BeamData.CUT_EXTRA OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Split;', 'Cut;') Machining.AuxiliaryData.bIsSplitOrCut = true local EdgeToMachine = SPLITCUT.GetEdgeToMachine( Proc, Z_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = SPLITCUT.CalculateLeadInOut( EdgeToMachine) Machining.Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) table.insert( Machinings, Machining) ---------------------------------------------------------------------------------- elseif Strategy.SplitStrategy.sTypeMachining == 'BladeHorizontalDouble' then + -- Taglio lato frontale local Machining = {} Machining.Splitting = {} Machining.AuxiliaryData = {} local OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.SplitStrategy[1].ToolInfo.nToolIndex - -- Taglio lato frontale - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_DOWN - OptionalParameters.sDepth = 0 OptionalParameters.dLongitudinalOffset = Strategy.dOffset or 0 - local dExtraMaxMat = ( Strategy.SplitStrategy[1].ToolInfo.dMaxMatBladeFromTop + Strategy.SplitStrategy[2].ToolInfo.dMaxMatBladeFromDown - Part.dHeight - BeamData.CUT_EXTRA) / 2 - OptionalParameters.dRadialOffset = Part.dHeight - Strategy.SplitStrategy[1].ToolInfo.dMaxMatBladeFromTop + dExtraMaxMat + local dExtraMaxMat = ( Strategy.SplitStrategy[1].ToolInfo.dMaxMatBladeFromTop + Strategy.SplitStrategy[2].ToolInfo.dMaxMatBladeFromDown - Part.dHeight - BeamData.CUT_EXTRA_MIN) / 2 + OptionalParameters.dDepthToMachine = Strategy.SplitStrategy[1].ToolInfo.dMaxMatBladeFromTop - dExtraMaxMat OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Presplit;', 'Precut;') local EdgeToMachine = SPLITCUT.GetEdgeToMachine( Proc, Z_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = SPLITCUT.CalculateLeadInOut( EdgeToMachine) Machining.Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) table.insert( Machinings, Machining) @@ -327,17 +307,13 @@ function SPLITCUT.Execute( Proc, Part, Strategy) Machining.AuxiliaryData = {} OptionalParameters = {} OptionalParameters.nToolIndex = Strategy.SplitStrategy[2].ToolInfo.nToolIndex - OptionalParameters.nFaceuse = MCH_MILL_FU.ORTHO_TOP - OptionalParameters.sDepth = 0 OptionalParameters.dLongitudinalOffset = Strategy.dOffset or 0 - OptionalParameters.dRadialOffset = Part.dHeight - Strategy.SplitStrategy[2].ToolInfo.dMaxMatBladeFromDown + dExtraMaxMat + OptionalParameters.dDepthToMachine = Strategy.SplitStrategy[2].ToolInfo.dMaxMatBladeFromDown - dExtraMaxMat OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Split;', 'Cut;') Machining.AuxiliaryData.bIsSplitOrCut = true EdgeToMachine = SPLITCUT.GetEdgeToMachine( Proc, -Z_AX()) - -- approccio e retrazione - OptionalParameters.LeadIn, OptionalParameters.LeadOut = SPLITCUT.CalculateLeadInOut( EdgeToMachine) Machining.Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParameters) table.insert( Machinings, Machining) ----------------------------------------------------------------------------------